|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590 |
- // Version: 1.0.0 - March 24, 2021 22:27:48
- 'use strict';
-
- var path$1 = require('path');
- var moment = require('moment');
- var crossfilterreq = require('crossfilter2');
- var crypto = require('crypto');
- var childProcess = require('child_process');
- var fs$1 = require('fs');
- var readline = require('readline');
- var os = require('os');
- var tty = require('tty');
- var require$$0 = require('util');
- var require$$0$1 = require('events');
- var assert = require('assert');
-
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
-
- var path__default = /*#__PURE__*/_interopDefaultLegacy(path$1);
- var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
- var crossfilterreq__default = /*#__PURE__*/_interopDefaultLegacy(crossfilterreq);
- var crypto__default = /*#__PURE__*/_interopDefaultLegacy(crypto);
- var childProcess__default = /*#__PURE__*/_interopDefaultLegacy(childProcess);
- var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs$1);
- var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);
- var os__default = /*#__PURE__*/_interopDefaultLegacy(os);
- var tty__default = /*#__PURE__*/_interopDefaultLegacy(tty);
- var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
- var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
- var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert);
-
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
-
- function createCommonjsModule(fn, basedir, module) {
- return module = {
- path: basedir,
- exports: {},
- require: function (path, base) {
- return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
- }
- }, fn(module, module.exports), module.exports;
- }
-
- function commonjsRegister (path, loader) {
- DYNAMIC_REQUIRE_LOADERS[path] = loader;
- }
-
- const DYNAMIC_REQUIRE_LOADERS = Object.create(null);
- const DYNAMIC_REQUIRE_CACHE = Object.create(null);
- const DEFAULT_PARENT_MODULE = {
- id: '<' + 'rollup>', exports: {}, parent: undefined, filename: null, loaded: false, children: [], paths: []
- };
- const CHECKED_EXTENSIONS = ['', '.js', '.json'];
-
- function normalize (path) {
- path = path.replace(/\\/g, '/');
- const parts = path.split('/');
- const slashed = parts[0] === '';
- for (let i = 1; i < parts.length; i++) {
- if (parts[i] === '.' || parts[i] === '') {
- parts.splice(i--, 1);
- }
- }
- for (let i = 1; i < parts.length; i++) {
- if (parts[i] !== '..') continue;
- if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') {
- parts.splice(--i, 2);
- i--;
- }
- }
- path = parts.join('/');
- if (slashed && path[0] !== '/')
- path = '/' + path;
- else if (path.length === 0)
- path = '.';
- return path;
- }
-
- function join () {
- if (arguments.length === 0)
- return '.';
- let joined;
- for (let i = 0; i < arguments.length; ++i) {
- let arg = arguments[i];
- if (arg.length > 0) {
- if (joined === undefined)
- joined = arg;
- else
- joined += '/' + arg;
- }
- }
- if (joined === undefined)
- return '.';
-
- return joined;
- }
-
- function isPossibleNodeModulesPath (modulePath) {
- let c0 = modulePath[0];
- if (c0 === '/' || c0 === '\\') return false;
- let c1 = modulePath[1], c2 = modulePath[2];
- if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\')) ||
- (c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\'))) return false;
- if (c1 === ':' && (c2 === '/' || c2 === '\\'))
- return false;
- return true;
- }
-
- function dirname (path) {
- if (path.length === 0)
- return '.';
-
- let i = path.length - 1;
- while (i > 0) {
- const c = path.charCodeAt(i);
- if ((c === 47 || c === 92) && i !== path.length - 1)
- break;
- i--;
- }
-
- if (i > 0)
- return path.substr(0, i);
-
- if (path.chartCodeAt(0) === 47 || path.chartCodeAt(0) === 92)
- return path.charAt(0);
-
- return '.';
- }
-
- function commonjsResolveImpl (path, originalModuleDir, testCache) {
- const shouldTryNodeModules = isPossibleNodeModulesPath(path);
- path = normalize(path);
- let relPath;
- if (path[0] === '/') {
- originalModuleDir = '/';
- }
- while (true) {
- if (!shouldTryNodeModules) {
- relPath = originalModuleDir ? normalize(originalModuleDir + '/' + path) : path;
- } else if (originalModuleDir) {
- relPath = normalize(originalModuleDir + '/node_modules/' + path);
- } else {
- relPath = normalize(join('node_modules', path));
- }
-
- if (relPath.endsWith('/..')) {
- break; // Travelled too far up, avoid infinite loop
- }
-
- for (let extensionIndex = 0; extensionIndex < CHECKED_EXTENSIONS.length; extensionIndex++) {
- const resolvedPath = relPath + CHECKED_EXTENSIONS[extensionIndex];
- if (DYNAMIC_REQUIRE_CACHE[resolvedPath]) {
- return resolvedPath;
- } if (DYNAMIC_REQUIRE_LOADERS[resolvedPath]) {
- return resolvedPath;
- } }
- if (!shouldTryNodeModules) break;
- const nextDir = normalize(originalModuleDir + '/..');
- if (nextDir === originalModuleDir) break;
- originalModuleDir = nextDir;
- }
- return null;
- }
-
- function commonjsResolve (path, originalModuleDir) {
- const resolvedPath = commonjsResolveImpl(path, originalModuleDir);
- if (resolvedPath !== null) {
- return resolvedPath;
- }
- return require.resolve(path);
- }
-
- function commonjsRequire (path, originalModuleDir) {
- const resolvedPath = commonjsResolveImpl(path, originalModuleDir);
- if (resolvedPath !== null) {
- let cachedModule = DYNAMIC_REQUIRE_CACHE[resolvedPath];
- if (cachedModule) return cachedModule.exports;
- const loader = DYNAMIC_REQUIRE_LOADERS[resolvedPath];
- if (loader) {
- DYNAMIC_REQUIRE_CACHE[resolvedPath] = cachedModule = {
- id: resolvedPath,
- filename: resolvedPath,
- path: dirname(resolvedPath),
- exports: {},
- parent: DEFAULT_PARENT_MODULE,
- loaded: false,
- children: [],
- paths: [],
- require: function (path, base) {
- return commonjsRequire(path, (base === undefined || base === null) ? cachedModule.path : base);
- }
- };
- try {
- loader.call(commonjsGlobal, cachedModule, cachedModule.exports);
- } catch (error) {
- delete DYNAMIC_REQUIRE_CACHE[resolvedPath];
- throw error;
- }
- cachedModule.loaded = true;
- return cachedModule.exports;
- } }
- return require(path);
- }
-
- commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;
- commonjsRequire.resolve = commonjsResolve;
-
- /**
- * This method returns the first argument it receives.
- *
- * @static
- * @since 0.1.0
- * @memberOf _
- * @category Util
- * @param {*} value Any value.
- * @returns {*} Returns `value`.
- * @example
- *
- * var object = { 'a': 1 };
- *
- * console.log(_.identity(object) === object);
- * // => true
- */
- function identity(value) {
- return value;
- }
-
- var identity_1 = identity;
-
- /** Detect free variable `global` from Node.js. */
-
- var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
-
- var _freeGlobal = freeGlobal;
-
- /** Detect free variable `self`. */
- var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
-
- /** Used as a reference to the global object. */
- var root = _freeGlobal || freeSelf || Function('return this')();
-
- var _root = root;
-
- /** Built-in value references. */
- var Symbol$1 = _root.Symbol;
-
- var _Symbol = Symbol$1;
-
- /** Used for built-in method references. */
- var objectProto$h = Object.prototype;
-
- /** Used to check objects for own properties. */
- var hasOwnProperty$e = objectProto$h.hasOwnProperty;
-
- /**
- * Used to resolve the
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
- * of values.
- */
- var nativeObjectToString$1 = objectProto$h.toString;
-
- /** Built-in value references. */
- var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined;
-
- /**
- * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
- *
- * @private
- * @param {*} value The value to query.
- * @returns {string} Returns the raw `toStringTag`.
- */
- function getRawTag(value) {
- var isOwn = hasOwnProperty$e.call(value, symToStringTag$1),
- tag = value[symToStringTag$1];
-
- try {
- value[symToStringTag$1] = undefined;
- var unmasked = true;
- } catch (e) {}
-
- var result = nativeObjectToString$1.call(value);
- if (unmasked) {
- if (isOwn) {
- value[symToStringTag$1] = tag;
- } else {
- delete value[symToStringTag$1];
- }
- }
- return result;
- }
-
- var _getRawTag = getRawTag;
-
- /** Used for built-in method references. */
- var objectProto$g = Object.prototype;
-
- /**
- * Used to resolve the
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
- * of values.
- */
- var nativeObjectToString = objectProto$g.toString;
-
- /**
- * Converts `value` to a string using `Object.prototype.toString`.
- *
- * @private
- * @param {*} value The value to convert.
- * @returns {string} Returns the converted string.
- */
- function objectToString(value) {
- return nativeObjectToString.call(value);
- }
-
- var _objectToString = objectToString;
-
- /** `Object#toString` result references. */
- var nullTag = '[object Null]',
- undefinedTag = '[object Undefined]';
-
- /** Built-in value references. */
- var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined;
-
- /**
- * The base implementation of `getTag` without fallbacks for buggy environments.
- *
- * @private
- * @param {*} value The value to query.
- * @returns {string} Returns the `toStringTag`.
- */
- function baseGetTag(value) {
- if (value == null) {
- return value === undefined ? undefinedTag : nullTag;
- }
- return (symToStringTag && symToStringTag in Object(value))
- ? _getRawTag(value)
- : _objectToString(value);
- }
-
- var _baseGetTag = baseGetTag;
-
- /**
- * Checks if `value` is the
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
- * @example
- *
- * _.isObject({});
- * // => true
- *
- * _.isObject([1, 2, 3]);
- * // => true
- *
- * _.isObject(_.noop);
- * // => true
- *
- * _.isObject(null);
- * // => false
- */
- function isObject$1(value) {
- var type = typeof value;
- return value != null && (type == 'object' || type == 'function');
- }
-
- var isObject_1 = isObject$1;
-
- /** `Object#toString` result references. */
- var asyncTag = '[object AsyncFunction]',
- funcTag$2 = '[object Function]',
- genTag$1 = '[object GeneratorFunction]',
- proxyTag = '[object Proxy]';
-
- /**
- * Checks if `value` is classified as a `Function` object.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a function, else `false`.
- * @example
- *
- * _.isFunction(_);
- * // => true
- *
- * _.isFunction(/abc/);
- * // => false
- */
- function isFunction(value) {
- if (!isObject_1(value)) {
- return false;
- }
- // The use of `Object#toString` avoids issues with the `typeof` operator
- // in Safari 9 which returns 'object' for typed arrays and other constructors.
- var tag = _baseGetTag(value);
- return tag == funcTag$2 || tag == genTag$1 || tag == asyncTag || tag == proxyTag;
- }
-
- var isFunction_1 = isFunction;
-
- /** Used to detect overreaching core-js shims. */
- var coreJsData = _root['__core-js_shared__'];
-
- var _coreJsData = coreJsData;
-
- /** Used to detect methods masquerading as native. */
- var maskSrcKey = (function() {
- var uid = /[^.]+$/.exec(_coreJsData && _coreJsData.keys && _coreJsData.keys.IE_PROTO || '');
- return uid ? ('Symbol(src)_1.' + uid) : '';
- }());
-
- /**
- * Checks if `func` has its source masked.
- *
- * @private
- * @param {Function} func The function to check.
- * @returns {boolean} Returns `true` if `func` is masked, else `false`.
- */
- function isMasked(func) {
- return !!maskSrcKey && (maskSrcKey in func);
- }
-
- var _isMasked = isMasked;
-
- /** Used for built-in method references. */
- var funcProto$2 = Function.prototype;
-
- /** Used to resolve the decompiled source of functions. */
- var funcToString$2 = funcProto$2.toString;
-
- /**
- * Converts `func` to its source code.
- *
- * @private
- * @param {Function} func The function to convert.
- * @returns {string} Returns the source code.
- */
- function toSource(func) {
- if (func != null) {
- try {
- return funcToString$2.call(func);
- } catch (e) {}
- try {
- return (func + '');
- } catch (e) {}
- }
- return '';
- }
-
- var _toSource = toSource;
-
- /**
- * Used to match `RegExp`
- * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
- */
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
-
- /** Used to detect host constructors (Safari). */
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
-
- /** Used for built-in method references. */
- var funcProto$1 = Function.prototype,
- objectProto$f = Object.prototype;
-
- /** Used to resolve the decompiled source of functions. */
- var funcToString$1 = funcProto$1.toString;
-
- /** Used to check objects for own properties. */
- var hasOwnProperty$d = objectProto$f.hasOwnProperty;
-
- /** Used to detect if a method is native. */
- var reIsNative = RegExp('^' +
- funcToString$1.call(hasOwnProperty$d).replace(reRegExpChar, '\\$&')
- .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
- );
-
- /**
- * The base implementation of `_.isNative` without bad shim checks.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a native function,
- * else `false`.
- */
- function baseIsNative(value) {
- if (!isObject_1(value) || _isMasked(value)) {
- return false;
- }
- var pattern = isFunction_1(value) ? reIsNative : reIsHostCtor;
- return pattern.test(_toSource(value));
- }
-
- var _baseIsNative = baseIsNative;
-
- /**
- * Gets the value at `key` of `object`.
- *
- * @private
- * @param {Object} [object] The object to query.
- * @param {string} key The key of the property to get.
- * @returns {*} Returns the property value.
- */
- function getValue(object, key) {
- return object == null ? undefined : object[key];
- }
-
- var _getValue = getValue;
-
- /**
- * Gets the native function at `key` of `object`.
- *
- * @private
- * @param {Object} object The object to query.
- * @param {string} key The key of the method to get.
- * @returns {*} Returns the function if it's native, else `undefined`.
- */
- function getNative(object, key) {
- var value = _getValue(object, key);
- return _baseIsNative(value) ? value : undefined;
- }
-
- var _getNative = getNative;
-
- /* Built-in method references that are verified to be native. */
- var WeakMap$1 = _getNative(_root, 'WeakMap');
-
- var _WeakMap = WeakMap$1;
-
- /** Used to store function metadata. */
- var metaMap = _WeakMap && new _WeakMap;
-
- var _metaMap = metaMap;
-
- /**
- * The base implementation of `setData` without support for hot loop shorting.
- *
- * @private
- * @param {Function} func The function to associate metadata with.
- * @param {*} data The metadata.
- * @returns {Function} Returns `func`.
- */
- var baseSetData = !_metaMap ? identity_1 : function(func, data) {
- _metaMap.set(func, data);
- return func;
- };
-
- var _baseSetData = baseSetData;
-
- /** Built-in value references. */
- var objectCreate = Object.create;
-
- /**
- * The base implementation of `_.create` without support for assigning
- * properties to the created object.
- *
- * @private
- * @param {Object} proto The object to inherit from.
- * @returns {Object} Returns the new object.
- */
- var baseCreate = (function() {
- function object() {}
- return function(proto) {
- if (!isObject_1(proto)) {
- return {};
- }
- if (objectCreate) {
- return objectCreate(proto);
- }
- object.prototype = proto;
- var result = new object;
- object.prototype = undefined;
- return result;
- };
- }());
-
- var _baseCreate = baseCreate;
-
- /**
- * Creates a function that produces an instance of `Ctor` regardless of
- * whether it was invoked as part of a `new` expression or by `call` or `apply`.
- *
- * @private
- * @param {Function} Ctor The constructor to wrap.
- * @returns {Function} Returns the new wrapped function.
- */
- function createCtor(Ctor) {
- return function() {
- // Use a `switch` statement to work with class constructors. See
- // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
- // for more details.
- var args = arguments;
- switch (args.length) {
- case 0: return new Ctor;
- case 1: return new Ctor(args[0]);
- case 2: return new Ctor(args[0], args[1]);
- case 3: return new Ctor(args[0], args[1], args[2]);
- case 4: return new Ctor(args[0], args[1], args[2], args[3]);
- case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
- case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
- case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
- }
- var thisBinding = _baseCreate(Ctor.prototype),
- result = Ctor.apply(thisBinding, args);
-
- // Mimic the constructor's `return` behavior.
- // See https://es5.github.io/#x13.2.2 for more details.
- return isObject_1(result) ? result : thisBinding;
- };
- }
-
- var _createCtor = createCtor;
-
- /** Used to compose bitmasks for function metadata. */
- var WRAP_BIND_FLAG$6 = 1;
-
- /**
- * Creates a function that wraps `func` to invoke it with the optional `this`
- * binding of `thisArg`.
- *
- * @private
- * @param {Function} func The function to wrap.
- * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
- * @param {*} [thisArg] The `this` binding of `func`.
- * @returns {Function} Returns the new wrapped function.
- */
- function createBind(func, bitmask, thisArg) {
- var isBind = bitmask & WRAP_BIND_FLAG$6,
- Ctor = _createCtor(func);
-
- function wrapper() {
- var fn = (this && this !== _root && this instanceof wrapper) ? Ctor : func;
- return fn.apply(isBind ? thisArg : this, arguments);
- }
- return wrapper;
- }
-
- var _createBind = createBind;
-
- /**
- * A faster alternative to `Function#apply`, this function invokes `func`
- * with the `this` binding of `thisArg` and the arguments of `args`.
- *
- * @private
- * @param {Function} func The function to invoke.
- * @param {*} thisArg The `this` binding of `func`.
- * @param {Array} args The arguments to invoke `func` with.
- * @returns {*} Returns the result of `func`.
- */
- function apply(func, thisArg, args) {
- switch (args.length) {
- case 0: return func.call(thisArg);
- case 1: return func.call(thisArg, args[0]);
- case 2: return func.call(thisArg, args[0], args[1]);
- case 3: return func.call(thisArg, args[0], args[1], args[2]);
- }
- return func.apply(thisArg, args);
- }
-
- var _apply = apply;
-
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeMax$3 = Math.max;
-
- /**
- * Creates an array that is the composition of partially applied arguments,
- * placeholders, and provided arguments into a single array of arguments.
- *
- * @private
- * @param {Array} args The provided arguments.
- * @param {Array} partials The arguments to prepend to those provided.
- * @param {Array} holders The `partials` placeholder indexes.
- * @params {boolean} [isCurried] Specify composing for a curried function.
- * @returns {Array} Returns the new array of composed arguments.
- */
- function composeArgs(args, partials, holders, isCurried) {
- var argsIndex = -1,
- argsLength = args.length,
- holdersLength = holders.length,
- leftIndex = -1,
- leftLength = partials.length,
- rangeLength = nativeMax$3(argsLength - holdersLength, 0),
- result = Array(leftLength + rangeLength),
- isUncurried = !isCurried;
-
- while (++leftIndex < leftLength) {
- result[leftIndex] = partials[leftIndex];
- }
- while (++argsIndex < holdersLength) {
- if (isUncurried || argsIndex < argsLength) {
- result[holders[argsIndex]] = args[argsIndex];
- }
- }
- while (rangeLength--) {
- result[leftIndex++] = args[argsIndex++];
- }
- return result;
- }
-
- var _composeArgs = composeArgs;
-
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeMax$2 = Math.max;
-
- /**
- * This function is like `composeArgs` except that the arguments composition
- * is tailored for `_.partialRight`.
- *
- * @private
- * @param {Array} args The provided arguments.
- * @param {Array} partials The arguments to append to those provided.
- * @param {Array} holders The `partials` placeholder indexes.
- * @params {boolean} [isCurried] Specify composing for a curried function.
- * @returns {Array} Returns the new array of composed arguments.
- */
- function composeArgsRight(args, partials, holders, isCurried) {
- var argsIndex = -1,
- argsLength = args.length,
- holdersIndex = -1,
- holdersLength = holders.length,
- rightIndex = -1,
- rightLength = partials.length,
- rangeLength = nativeMax$2(argsLength - holdersLength, 0),
- result = Array(rangeLength + rightLength),
- isUncurried = !isCurried;
-
- while (++argsIndex < rangeLength) {
- result[argsIndex] = args[argsIndex];
- }
- var offset = argsIndex;
- while (++rightIndex < rightLength) {
- result[offset + rightIndex] = partials[rightIndex];
- }
- while (++holdersIndex < holdersLength) {
- if (isUncurried || argsIndex < argsLength) {
- result[offset + holders[holdersIndex]] = args[argsIndex++];
- }
- }
- return result;
- }
-
- var _composeArgsRight = composeArgsRight;
-
- /**
- * Gets the number of `placeholder` occurrences in `array`.
- *
- * @private
- * @param {Array} array The array to inspect.
- * @param {*} placeholder The placeholder to search for.
- * @returns {number} Returns the placeholder count.
- */
- function countHolders(array, placeholder) {
- var length = array.length,
- result = 0;
-
- while (length--) {
- if (array[length] === placeholder) {
- ++result;
- }
- }
- return result;
- }
-
- var _countHolders = countHolders;
-
- /**
- * The function whose prototype chain sequence wrappers inherit from.
- *
- * @private
- */
- function baseLodash() {
- // No operation performed.
- }
-
- var _baseLodash = baseLodash;
-
- /** Used as references for the maximum length and index of an array. */
- var MAX_ARRAY_LENGTH = 4294967295;
-
- /**
- * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
- *
- * @private
- * @constructor
- * @param {*} value The value to wrap.
- */
- function LazyWrapper(value) {
- this.__wrapped__ = value;
- this.__actions__ = [];
- this.__dir__ = 1;
- this.__filtered__ = false;
- this.__iteratees__ = [];
- this.__takeCount__ = MAX_ARRAY_LENGTH;
- this.__views__ = [];
- }
-
- // Ensure `LazyWrapper` is an instance of `baseLodash`.
- LazyWrapper.prototype = _baseCreate(_baseLodash.prototype);
- LazyWrapper.prototype.constructor = LazyWrapper;
-
- var _LazyWrapper = LazyWrapper;
-
- /**
- * This method returns `undefined`.
- *
- * @static
- * @memberOf _
- * @since 2.3.0
- * @category Util
- * @example
- *
- * _.times(2, _.noop);
- * // => [undefined, undefined]
- */
- function noop() {
- // No operation performed.
- }
-
- var noop_1 = noop;
-
- /**
- * Gets metadata for `func`.
- *
- * @private
- * @param {Function} func The function to query.
- * @returns {*} Returns the metadata for `func`.
- */
- var getData = !_metaMap ? noop_1 : function(func) {
- return _metaMap.get(func);
- };
-
- var _getData = getData;
-
- /** Used to lookup unminified function names. */
- var realNames = {};
-
- var _realNames = realNames;
-
- /** Used for built-in method references. */
- var objectProto$e = Object.prototype;
-
- /** Used to check objects for own properties. */
- var hasOwnProperty$c = objectProto$e.hasOwnProperty;
-
- /**
- * Gets the name of `func`.
- *
- * @private
- * @param {Function} func The function to query.
- * @returns {string} Returns the function name.
- */
- function getFuncName(func) {
- var result = (func.name + ''),
- array = _realNames[result],
- length = hasOwnProperty$c.call(_realNames, result) ? array.length : 0;
-
- while (length--) {
- var data = array[length],
- otherFunc = data.func;
- if (otherFunc == null || otherFunc == func) {
- return data.name;
- }
- }
- return result;
- }
-
- var _getFuncName = getFuncName;
-
- /**
- * The base constructor for creating `lodash` wrapper objects.
- *
- * @private
- * @param {*} value The value to wrap.
- * @param {boolean} [chainAll] Enable explicit method chain sequences.
- */
- function LodashWrapper(value, chainAll) {
- this.__wrapped__ = value;
- this.__actions__ = [];
- this.__chain__ = !!chainAll;
- this.__index__ = 0;
- this.__values__ = undefined;
- }
-
- LodashWrapper.prototype = _baseCreate(_baseLodash.prototype);
- LodashWrapper.prototype.constructor = LodashWrapper;
-
- var _LodashWrapper = LodashWrapper;
-
- /**
- * Checks if `value` is classified as an `Array` object.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is an array, else `false`.
- * @example
- *
- * _.isArray([1, 2, 3]);
- * // => true
- *
- * _.isArray(document.body.children);
- * // => false
- *
- * _.isArray('abc');
- * // => false
- *
- * _.isArray(_.noop);
- * // => false
- */
- var isArray$3 = Array.isArray;
-
- var isArray_1 = isArray$3;
-
- /**
- * Checks if `value` is object-like. A value is object-like if it's not `null`
- * and has a `typeof` result of "object".
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
- * @example
- *
- * _.isObjectLike({});
- * // => true
- *
- * _.isObjectLike([1, 2, 3]);
- * // => true
- *
- * _.isObjectLike(_.noop);
- * // => false
- *
- * _.isObjectLike(null);
- * // => false
- */
- function isObjectLike(value) {
- return value != null && typeof value == 'object';
- }
-
- var isObjectLike_1 = isObjectLike;
-
- /**
- * Copies the values of `source` to `array`.
- *
- * @private
- * @param {Array} source The array to copy values from.
- * @param {Array} [array=[]] The array to copy values to.
- * @returns {Array} Returns `array`.
- */
- function copyArray(source, array) {
- var index = -1,
- length = source.length;
-
- array || (array = Array(length));
- while (++index < length) {
- array[index] = source[index];
- }
- return array;
- }
-
- var _copyArray = copyArray;
-
- /**
- * Creates a clone of `wrapper`.
- *
- * @private
- * @param {Object} wrapper The wrapper to clone.
- * @returns {Object} Returns the cloned wrapper.
- */
- function wrapperClone(wrapper) {
- if (wrapper instanceof _LazyWrapper) {
- return wrapper.clone();
- }
- var result = new _LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
- result.__actions__ = _copyArray(wrapper.__actions__);
- result.__index__ = wrapper.__index__;
- result.__values__ = wrapper.__values__;
- return result;
- }
-
- var _wrapperClone = wrapperClone;
-
- /** Used for built-in method references. */
- var objectProto$d = Object.prototype;
-
- /** Used to check objects for own properties. */
- var hasOwnProperty$b = objectProto$d.hasOwnProperty;
-
- /**
- * Creates a `lodash` object which wraps `value` to enable implicit method
- * chain sequences. Methods that operate on and return arrays, collections,
- * and functions can be chained together. Methods that retrieve a single value
- * or may return a primitive value will automatically end the chain sequence
- * and return the unwrapped value. Otherwise, the value must be unwrapped
- * with `_#value`.
- *
- * Explicit chain sequences, which must be unwrapped with `_#value`, may be
- * enabled using `_.chain`.
- *
- * The execution of chained methods is lazy, that is, it's deferred until
- * `_#value` is implicitly or explicitly called.
- *
- * Lazy evaluation allows several methods to support shortcut fusion.
- * Shortcut fusion is an optimization to merge iteratee calls; this avoids
- * the creation of intermediate arrays and can greatly reduce the number of
- * iteratee executions. Sections of a chain sequence qualify for shortcut
- * fusion if the section is applied to an array and iteratees accept only
- * one argument. The heuristic for whether a section qualifies for shortcut
- * fusion is subject to change.
- *
- * Chaining is supported in custom builds as long as the `_#value` method is
- * directly or indirectly included in the build.
- *
- * In addition to lodash methods, wrappers have `Array` and `String` methods.
- *
- * The wrapper `Array` methods are:
- * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
- *
- * The wrapper `String` methods are:
- * `replace` and `split`
- *
- * The wrapper methods that support shortcut fusion are:
- * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
- * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
- * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
- *
- * The chainable wrapper methods are:
- * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
- * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
- * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
- * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
- * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
- * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
- * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
- * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
- * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
- * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
- * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
- * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
- * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
- * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
- * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
- * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
- * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
- * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
- * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
- * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
- * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
- * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
- * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
- * `zipObject`, `zipObjectDeep`, and `zipWith`
- *
- * The wrapper methods that are **not** chainable by default are:
- * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
- * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
- * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
- * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
- * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
- * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
- * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
- * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
- * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
- * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
- * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
- * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
- * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
- * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
- * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
- * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
- * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
- * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
- * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
- * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
- * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
- * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
- * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
- * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
- * `upperFirst`, `value`, and `words`
- *
- * @name _
- * @constructor
- * @category Seq
- * @param {*} value The value to wrap in a `lodash` instance.
- * @returns {Object} Returns the new `lodash` wrapper instance.
- * @example
- *
- * function square(n) {
- * return n * n;
- * }
- *
- * var wrapped = _([1, 2, 3]);
- *
- * // Returns an unwrapped value.
- * wrapped.reduce(_.add);
- * // => 6
- *
- * // Returns a wrapped value.
- * var squares = wrapped.map(square);
- *
- * _.isArray(squares);
- * // => false
- *
- * _.isArray(squares.value());
- * // => true
- */
- function lodash(value) {
- if (isObjectLike_1(value) && !isArray_1(value) && !(value instanceof _LazyWrapper)) {
- if (value instanceof _LodashWrapper) {
- return value;
- }
- if (hasOwnProperty$b.call(value, '__wrapped__')) {
- return _wrapperClone(value);
- }
- }
- return new _LodashWrapper(value);
- }
-
- // Ensure wrappers are instances of `baseLodash`.
- lodash.prototype = _baseLodash.prototype;
- lodash.prototype.constructor = lodash;
-
- var wrapperLodash = lodash;
-
- /**
- * Checks if `func` has a lazy counterpart.
- *
- * @private
- * @param {Function} func The function to check.
- * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
- * else `false`.
- */
- function isLaziable(func) {
- var funcName = _getFuncName(func),
- other = wrapperLodash[funcName];
-
- if (typeof other != 'function' || !(funcName in _LazyWrapper.prototype)) {
- return false;
- }
- if (func === other) {
- return true;
- }
- var data = _getData(other);
- return !!data && func === data[0];
- }
-
- var _isLaziable = isLaziable;
-
- /** Used to detect hot functions by number of calls within a span of milliseconds. */
- var HOT_COUNT = 800,
- HOT_SPAN = 16;
-
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeNow = Date.now;
-
- /**
- * Creates a function that'll short out and invoke `identity` instead
- * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
- * milliseconds.
- *
- * @private
- * @param {Function} func The function to restrict.
- * @returns {Function} Returns the new shortable function.
- */
- function shortOut(func) {
- var count = 0,
- lastCalled = 0;
-
- return function() {
- var stamp = nativeNow(),
- remaining = HOT_SPAN - (stamp - lastCalled);
-
- lastCalled = stamp;
- if (remaining > 0) {
- if (++count >= HOT_COUNT) {
- return arguments[0];
- }
- } else {
- count = 0;
- }
- return func.apply(undefined, arguments);
- };
- }
-
- var _shortOut = shortOut;
-
- /**
- * Sets metadata for `func`.
- *
- * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
- * period of time, it will trip its breaker and transition to an identity
- * function to avoid garbage collection pauses in V8. See
- * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
- * for more details.
- *
- * @private
- * @param {Function} func The function to associate metadata with.
- * @param {*} data The metadata.
- * @returns {Function} Returns `func`.
- */
- var setData = _shortOut(_baseSetData);
-
- var _setData = setData;
-
- /** Used to match wrap detail comments. */
- var reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
- reSplitDetails = /,? & /;
-
- /**
- * Extracts wrapper details from the `source` body comment.
- *
- * @private
- * @param {string} source The source to inspect.
- * @returns {Array} Returns the wrapper details.
- */
- function getWrapDetails(source) {
- var match = source.match(reWrapDetails);
- return match ? match[1].split(reSplitDetails) : [];
- }
-
- var _getWrapDetails = getWrapDetails;
-
- /** Used to match wrap detail comments. */
- var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/;
-
- /**
- * Inserts wrapper `details` in a comment at the top of the `source` body.
- *
- * @private
- * @param {string} source The source to modify.
- * @returns {Array} details The details to insert.
- * @returns {string} Returns the modified source.
- */
- function insertWrapDetails(source, details) {
- var length = details.length;
- if (!length) {
- return source;
- }
- var lastIndex = length - 1;
- details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
- details = details.join(length > 2 ? ', ' : ' ');
- return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
- }
-
- var _insertWrapDetails = insertWrapDetails;
-
- /**
- * Creates a function that returns `value`.
- *
- * @static
- * @memberOf _
- * @since 2.4.0
- * @category Util
- * @param {*} value The value to return from the new function.
- * @returns {Function} Returns the new constant function.
- * @example
- *
- * var objects = _.times(2, _.constant({ 'a': 1 }));
- *
- * console.log(objects);
- * // => [{ 'a': 1 }, { 'a': 1 }]
- *
- * console.log(objects[0] === objects[1]);
- * // => true
- */
- function constant(value) {
- return function() {
- return value;
- };
- }
-
- var constant_1 = constant;
-
- var defineProperty = (function() {
- try {
- var func = _getNative(Object, 'defineProperty');
- func({}, '', {});
- return func;
- } catch (e) {}
- }());
-
- var _defineProperty = defineProperty;
-
- /**
- * The base implementation of `setToString` without support for hot loop shorting.
- *
- * @private
- * @param {Function} func The function to modify.
- * @param {Function} string The `toString` result.
- * @returns {Function} Returns `func`.
- */
- var baseSetToString = !_defineProperty ? identity_1 : function(func, string) {
- return _defineProperty(func, 'toString', {
- 'configurable': true,
- 'enumerable': false,
- 'value': constant_1(string),
- 'writable': true
- });
- };
-
- var _baseSetToString = baseSetToString;
-
- /**
- * Sets the `toString` method of `func` to return `string`.
- *
- * @private
- * @param {Function} func The function to modify.
- * @param {Function} string The `toString` result.
- * @returns {Function} Returns `func`.
- */
- var setToString = _shortOut(_baseSetToString);
-
- var _setToString = setToString;
-
- /**
- * A specialized version of `_.forEach` for arrays without support for
- * iteratee shorthands.
- *
- * @private
- * @param {Array} [array] The array to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Array} Returns `array`.
- */
- function arrayEach(array, iteratee) {
- var index = -1,
- length = array == null ? 0 : array.length;
-
- while (++index < length) {
- if (iteratee(array[index], index, array) === false) {
- break;
- }
- }
- return array;
- }
-
- var _arrayEach = arrayEach;
-
- /**
- * The base implementation of `_.findIndex` and `_.findLastIndex` without
- * support for iteratee shorthands.
- *
- * @private
- * @param {Array} array The array to inspect.
- * @param {Function} predicate The function invoked per iteration.
- * @param {number} fromIndex The index to search from.
- * @param {boolean} [fromRight] Specify iterating from right to left.
- * @returns {number} Returns the index of the matched value, else `-1`.
- */
- function baseFindIndex(array, predicate, fromIndex, fromRight) {
- var length = array.length,
- index = fromIndex + (fromRight ? 1 : -1);
-
- while ((fromRight ? index-- : ++index < length)) {
- if (predicate(array[index], index, array)) {
- return index;
- }
- }
- return -1;
- }
-
- var _baseFindIndex = baseFindIndex;
-
- /**
- * The base implementation of `_.isNaN` without support for number objects.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
- */
- function baseIsNaN(value) {
- return value !== value;
- }
-
- var _baseIsNaN = baseIsNaN;
-
- /**
- * A specialized version of `_.indexOf` which performs strict equality
- * comparisons of values, i.e. `===`.
- *
- * @private
- * @param {Array} array The array to inspect.
- * @param {*} value The value to search for.
- * @param {number} fromIndex The index to search from.
- * @returns {number} Returns the index of the matched value, else `-1`.
- */
- function strictIndexOf(array, value, fromIndex) {
- var index = fromIndex - 1,
- length = array.length;
-
- while (++index < length) {
- if (array[index] === value) {
- return index;
- }
- }
- return -1;
- }
-
- var _strictIndexOf = strictIndexOf;
-
- /**
- * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
- *
- * @private
- * @param {Array} array The array to inspect.
- * @param {*} value The value to search for.
- * @param {number} fromIndex The index to search from.
- * @returns {number} Returns the index of the matched value, else `-1`.
- */
- function baseIndexOf(array, value, fromIndex) {
- return value === value
- ? _strictIndexOf(array, value, fromIndex)
- : _baseFindIndex(array, _baseIsNaN, fromIndex);
- }
-
- var _baseIndexOf = baseIndexOf;
-
- /**
- * A specialized version of `_.includes` for arrays without support for
- * specifying an index to search from.
- *
- * @private
- * @param {Array} [array] The array to inspect.
- * @param {*} target The value to search for.
- * @returns {boolean} Returns `true` if `target` is found, else `false`.
- */
- function arrayIncludes(array, value) {
- var length = array == null ? 0 : array.length;
- return !!length && _baseIndexOf(array, value, 0) > -1;
- }
-
- var _arrayIncludes = arrayIncludes;
-
- /** Used to compose bitmasks for function metadata. */
- var WRAP_BIND_FLAG$5 = 1,
- WRAP_BIND_KEY_FLAG$4 = 2,
- WRAP_CURRY_FLAG$4 = 8,
- WRAP_CURRY_RIGHT_FLAG$2 = 16,
- WRAP_PARTIAL_FLAG$2 = 32,
- WRAP_PARTIAL_RIGHT_FLAG$2 = 64,
- WRAP_ARY_FLAG$3 = 128,
- WRAP_REARG_FLAG$2 = 256,
- WRAP_FLIP_FLAG$1 = 512;
-
- /** Used to associate wrap methods with their bit flags. */
- var wrapFlags = [
- ['ary', WRAP_ARY_FLAG$3],
- ['bind', WRAP_BIND_FLAG$5],
- ['bindKey', WRAP_BIND_KEY_FLAG$4],
- ['curry', WRAP_CURRY_FLAG$4],
- ['curryRight', WRAP_CURRY_RIGHT_FLAG$2],
- ['flip', WRAP_FLIP_FLAG$1],
- ['partial', WRAP_PARTIAL_FLAG$2],
- ['partialRight', WRAP_PARTIAL_RIGHT_FLAG$2],
- ['rearg', WRAP_REARG_FLAG$2]
- ];
-
- /**
- * Updates wrapper `details` based on `bitmask` flags.
- *
- * @private
- * @returns {Array} details The details to modify.
- * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
- * @returns {Array} Returns `details`.
- */
- function updateWrapDetails(details, bitmask) {
- _arrayEach(wrapFlags, function(pair) {
- var value = '_.' + pair[0];
- if ((bitmask & pair[1]) && !_arrayIncludes(details, value)) {
- details.push(value);
- }
- });
- return details.sort();
- }
-
- var _updateWrapDetails = updateWrapDetails;
-
- /**
- * Sets the `toString` method of `wrapper` to mimic the source of `reference`
- * with wrapper details in a comment at the top of the source body.
- *
- * @private
- * @param {Function} wrapper The function to modify.
- * @param {Function} reference The reference function.
- * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
- * @returns {Function} Returns `wrapper`.
- */
- function setWrapToString(wrapper, reference, bitmask) {
- var source = (reference + '');
- return _setToString(wrapper, _insertWrapDetails(source, _updateWrapDetails(_getWrapDetails(source), bitmask)));
- }
-
- var _setWrapToString = setWrapToString;
-
- /** Used to compose bitmasks for function metadata. */
- var WRAP_BIND_FLAG$4 = 1,
- WRAP_BIND_KEY_FLAG$3 = 2,
- WRAP_CURRY_BOUND_FLAG$1 = 4,
- WRAP_CURRY_FLAG$3 = 8,
- WRAP_PARTIAL_FLAG$1 = 32,
- WRAP_PARTIAL_RIGHT_FLAG$1 = 64;
-
- /**
- * Creates a function that wraps `func` to continue currying.
- *
- * @private
- * @param {Function} func The function to wrap.
- * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
- * @param {Function} wrapFunc The function to create the `func` wrapper.
- * @param {*} placeholder The placeholder value.
- * @param {*} [thisArg] The `this` binding of `func`.
- * @param {Array} [partials] The arguments to prepend to those provided to
- * the new function.
- * @param {Array} [holders] The `partials` placeholder indexes.
- * @param {Array} [argPos] The argument positions of the new function.
- * @param {number} [ary] The arity cap of `func`.
- * @param {number} [arity] The arity of `func`.
- * @returns {Function} Returns the new wrapped function.
- */
- function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
- var isCurry = bitmask & WRAP_CURRY_FLAG$3,
- newHolders = isCurry ? holders : undefined,
- newHoldersRight = isCurry ? undefined : holders,
- newPartials = isCurry ? partials : undefined,
- newPartialsRight = isCurry ? undefined : partials;
-
- bitmask |= (isCurry ? WRAP_PARTIAL_FLAG$1 : WRAP_PARTIAL_RIGHT_FLAG$1);
- bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG$1 : WRAP_PARTIAL_FLAG$1);
-
- if (!(bitmask & WRAP_CURRY_BOUND_FLAG$1)) {
- bitmask &= ~(WRAP_BIND_FLAG$4 | WRAP_BIND_KEY_FLAG$3);
- }
- var newData = [
- func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
- newHoldersRight, argPos, ary, arity
- ];
-
- var result = wrapFunc.apply(undefined, newData);
- if (_isLaziable(func)) {
- _setData(result, newData);
- }
- result.placeholder = placeholder;
- return _setWrapToString(result, func, bitmask);
- }
-
- var _createRecurry = createRecurry;
-
- /**
- * Gets the argument placeholder value for `func`.
- *
- * @private
- * @param {Function} func The function to inspect.
- * @returns {*} Returns the placeholder value.
- */
- function getHolder(func) {
- var object = func;
- return object.placeholder;
- }
-
- var _getHolder = getHolder;
-
- /** Used as references for various `Number` constants. */
- var MAX_SAFE_INTEGER$1 = 9007199254740991;
-
- /** Used to detect unsigned integer values. */
- var reIsUint = /^(?:0|[1-9]\d*)$/;
-
- /**
- * Checks if `value` is a valid array-like index.
- *
- * @private
- * @param {*} value The value to check.
- * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
- * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
- */
- function isIndex(value, length) {
- var type = typeof value;
- length = length == null ? MAX_SAFE_INTEGER$1 : length;
-
- return !!length &&
- (type == 'number' ||
- (type != 'symbol' && reIsUint.test(value))) &&
- (value > -1 && value % 1 == 0 && value < length);
- }
-
- var _isIndex = isIndex;
-
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeMin$1 = Math.min;
-
- /**
- * Reorder `array` according to the specified indexes where the element at
- * the first index is assigned as the first element, the element at
- * the second index is assigned as the second element, and so on.
- *
- * @private
- * @param {Array} array The array to reorder.
- * @param {Array} indexes The arranged array indexes.
- * @returns {Array} Returns `array`.
- */
- function reorder(array, indexes) {
- var arrLength = array.length,
- length = nativeMin$1(indexes.length, arrLength),
- oldArray = _copyArray(array);
-
- while (length--) {
- var index = indexes[length];
- array[length] = _isIndex(index, arrLength) ? oldArray[index] : undefined;
- }
- return array;
- }
-
- var _reorder = reorder;
-
- /** Used as the internal argument placeholder. */
- var PLACEHOLDER$1 = '__lodash_placeholder__';
-
- /**
- * Replaces all `placeholder` elements in `array` with an internal placeholder
- * and returns an array of their indexes.
- *
- * @private
- * @param {Array} array The array to modify.
- * @param {*} placeholder The placeholder to replace.
- * @returns {Array} Returns the new array of placeholder indexes.
- */
- function replaceHolders(array, placeholder) {
- var index = -1,
- length = array.length,
- resIndex = 0,
- result = [];
-
- while (++index < length) {
- var value = array[index];
- if (value === placeholder || value === PLACEHOLDER$1) {
- array[index] = PLACEHOLDER$1;
- result[resIndex++] = index;
- }
- }
- return result;
- }
-
- var _replaceHolders = replaceHolders;
-
- /** Used to compose bitmasks for function metadata. */
- var WRAP_BIND_FLAG$3 = 1,
- WRAP_BIND_KEY_FLAG$2 = 2,
- WRAP_CURRY_FLAG$2 = 8,
- WRAP_CURRY_RIGHT_FLAG$1 = 16,
- WRAP_ARY_FLAG$2 = 128,
- WRAP_FLIP_FLAG = 512;
-
- /**
- * Creates a function that wraps `func` to invoke it with optional `this`
- * binding of `thisArg`, partial application, and currying.
- *
- * @private
- * @param {Function|string} func The function or method name to wrap.
- * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
- * @param {*} [thisArg] The `this` binding of `func`.
- * @param {Array} [partials] The arguments to prepend to those provided to
- * the new function.
- * @param {Array} [holders] The `partials` placeholder indexes.
- * @param {Array} [partialsRight] The arguments to append to those provided
- * to the new function.
- * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
- * @param {Array} [argPos] The argument positions of the new function.
- * @param {number} [ary] The arity cap of `func`.
- * @param {number} [arity] The arity of `func`.
- * @returns {Function} Returns the new wrapped function.
- */
- function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
- var isAry = bitmask & WRAP_ARY_FLAG$2,
- isBind = bitmask & WRAP_BIND_FLAG$3,
- isBindKey = bitmask & WRAP_BIND_KEY_FLAG$2,
- isCurried = bitmask & (WRAP_CURRY_FLAG$2 | WRAP_CURRY_RIGHT_FLAG$1),
- isFlip = bitmask & WRAP_FLIP_FLAG,
- Ctor = isBindKey ? undefined : _createCtor(func);
-
- function wrapper() {
- var length = arguments.length,
- args = Array(length),
- index = length;
-
- while (index--) {
- args[index] = arguments[index];
- }
- if (isCurried) {
- var placeholder = _getHolder(wrapper),
- holdersCount = _countHolders(args, placeholder);
- }
- if (partials) {
- args = _composeArgs(args, partials, holders, isCurried);
- }
- if (partialsRight) {
- args = _composeArgsRight(args, partialsRight, holdersRight, isCurried);
- }
- length -= holdersCount;
- if (isCurried && length < arity) {
- var newHolders = _replaceHolders(args, placeholder);
- return _createRecurry(
- func, bitmask, createHybrid, wrapper.placeholder, thisArg,
- args, newHolders, argPos, ary, arity - length
- );
- }
- var thisBinding = isBind ? thisArg : this,
- fn = isBindKey ? thisBinding[func] : func;
-
- length = args.length;
- if (argPos) {
- args = _reorder(args, argPos);
- } else if (isFlip && length > 1) {
- args.reverse();
- }
- if (isAry && ary < length) {
- args.length = ary;
- }
- if (this && this !== _root && this instanceof wrapper) {
- fn = Ctor || _createCtor(fn);
- }
- return fn.apply(thisBinding, args);
- }
- return wrapper;
- }
-
- var _createHybrid = createHybrid;
-
- /**
- * Creates a function that wraps `func` to enable currying.
- *
- * @private
- * @param {Function} func The function to wrap.
- * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
- * @param {number} arity The arity of `func`.
- * @returns {Function} Returns the new wrapped function.
- */
- function createCurry(func, bitmask, arity) {
- var Ctor = _createCtor(func);
-
- function wrapper() {
- var length = arguments.length,
- args = Array(length),
- index = length,
- placeholder = _getHolder(wrapper);
-
- while (index--) {
- args[index] = arguments[index];
- }
- var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
- ? []
- : _replaceHolders(args, placeholder);
-
- length -= holders.length;
- if (length < arity) {
- return _createRecurry(
- func, bitmask, _createHybrid, wrapper.placeholder, undefined,
- args, holders, undefined, undefined, arity - length);
- }
- var fn = (this && this !== _root && this instanceof wrapper) ? Ctor : func;
- return _apply(fn, this, args);
- }
- return wrapper;
- }
-
- var _createCurry = createCurry;
-
- /** Used to compose bitmasks for function metadata. */
- var WRAP_BIND_FLAG$2 = 1;
-
- /**
- * Creates a function that wraps `func` to invoke it with the `this` binding
- * of `thisArg` and `partials` prepended to the arguments it receives.
- *
- * @private
- * @param {Function} func The function to wrap.
- * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
- * @param {*} thisArg The `this` binding of `func`.
- * @param {Array} partials The arguments to prepend to those provided to
- * the new function.
- * @returns {Function} Returns the new wrapped function.
- */
- function createPartial(func, bitmask, thisArg, partials) {
- var isBind = bitmask & WRAP_BIND_FLAG$2,
- Ctor = _createCtor(func);
-
- function wrapper() {
- var argsIndex = -1,
- argsLength = arguments.length,
- leftIndex = -1,
- leftLength = partials.length,
- args = Array(leftLength + argsLength),
- fn = (this && this !== _root && this instanceof wrapper) ? Ctor : func;
-
- while (++leftIndex < leftLength) {
- args[leftIndex] = partials[leftIndex];
- }
- while (argsLength--) {
- args[leftIndex++] = arguments[++argsIndex];
- }
- return _apply(fn, isBind ? thisArg : this, args);
- }
- return wrapper;
- }
-
- var _createPartial = createPartial;
-
- /** Used as the internal argument placeholder. */
- var PLACEHOLDER = '__lodash_placeholder__';
-
- /** Used to compose bitmasks for function metadata. */
- var WRAP_BIND_FLAG$1 = 1,
- WRAP_BIND_KEY_FLAG$1 = 2,
- WRAP_CURRY_BOUND_FLAG = 4,
- WRAP_CURRY_FLAG$1 = 8,
- WRAP_ARY_FLAG$1 = 128,
- WRAP_REARG_FLAG$1 = 256;
-
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeMin = Math.min;
-
- /**
- * Merges the function metadata of `source` into `data`.
- *
- * Merging metadata reduces the number of wrappers used to invoke a function.
- * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
- * may be applied regardless of execution order. Methods like `_.ary` and
- * `_.rearg` modify function arguments, making the order in which they are
- * executed important, preventing the merging of metadata. However, we make
- * an exception for a safe combined case where curried functions have `_.ary`
- * and or `_.rearg` applied.
- *
- * @private
- * @param {Array} data The destination metadata.
- * @param {Array} source The source metadata.
- * @returns {Array} Returns `data`.
- */
- function mergeData(data, source) {
- var bitmask = data[1],
- srcBitmask = source[1],
- newBitmask = bitmask | srcBitmask,
- isCommon = newBitmask < (WRAP_BIND_FLAG$1 | WRAP_BIND_KEY_FLAG$1 | WRAP_ARY_FLAG$1);
-
- var isCombo =
- ((srcBitmask == WRAP_ARY_FLAG$1) && (bitmask == WRAP_CURRY_FLAG$1)) ||
- ((srcBitmask == WRAP_ARY_FLAG$1) && (bitmask == WRAP_REARG_FLAG$1) && (data[7].length <= source[8])) ||
- ((srcBitmask == (WRAP_ARY_FLAG$1 | WRAP_REARG_FLAG$1)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG$1));
-
- // Exit early if metadata can't be merged.
- if (!(isCommon || isCombo)) {
- return data;
- }
- // Use source `thisArg` if available.
- if (srcBitmask & WRAP_BIND_FLAG$1) {
- data[2] = source[2];
- // Set when currying a bound function.
- newBitmask |= bitmask & WRAP_BIND_FLAG$1 ? 0 : WRAP_CURRY_BOUND_FLAG;
- }
- // Compose partial arguments.
- var value = source[3];
- if (value) {
- var partials = data[3];
- data[3] = partials ? _composeArgs(partials, value, source[4]) : value;
- data[4] = partials ? _replaceHolders(data[3], PLACEHOLDER) : source[4];
- }
- // Compose partial right arguments.
- value = source[5];
- if (value) {
- partials = data[5];
- data[5] = partials ? _composeArgsRight(partials, value, source[6]) : value;
- data[6] = partials ? _replaceHolders(data[5], PLACEHOLDER) : source[6];
- }
- // Use source `argPos` if available.
- value = source[7];
- if (value) {
- data[7] = value;
- }
- // Use source `ary` if it's smaller.
- if (srcBitmask & WRAP_ARY_FLAG$1) {
- data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
- }
- // Use source `arity` if one is not provided.
- if (data[9] == null) {
- data[9] = source[9];
- }
- // Use source `func` and merge bitmasks.
- data[0] = source[0];
- data[1] = newBitmask;
-
- return data;
- }
-
- var _mergeData = mergeData;
-
- /** Used to match a single whitespace character. */
- var reWhitespace = /\s/;
-
- /**
- * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
- * character of `string`.
- *
- * @private
- * @param {string} string The string to inspect.
- * @returns {number} Returns the index of the last non-whitespace character.
- */
- function trimmedEndIndex(string) {
- var index = string.length;
-
- while (index-- && reWhitespace.test(string.charAt(index))) {}
- return index;
- }
-
- var _trimmedEndIndex = trimmedEndIndex;
-
- /** Used to match leading whitespace. */
- var reTrimStart = /^\s+/;
-
- /**
- * The base implementation of `_.trim`.
- *
- * @private
- * @param {string} string The string to trim.
- * @returns {string} Returns the trimmed string.
- */
- function baseTrim(string) {
- return string
- ? string.slice(0, _trimmedEndIndex(string) + 1).replace(reTrimStart, '')
- : string;
- }
-
- var _baseTrim = baseTrim;
-
- /** `Object#toString` result references. */
- var symbolTag$3 = '[object Symbol]';
-
- /**
- * Checks if `value` is classified as a `Symbol` primitive or object.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
- * @example
- *
- * _.isSymbol(Symbol.iterator);
- * // => true
- *
- * _.isSymbol('abc');
- * // => false
- */
- function isSymbol(value) {
- return typeof value == 'symbol' ||
- (isObjectLike_1(value) && _baseGetTag(value) == symbolTag$3);
- }
-
- var isSymbol_1 = isSymbol;
-
- /** Used as references for various `Number` constants. */
- var NAN = 0 / 0;
-
- /** Used to detect bad signed hexadecimal string values. */
- var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
-
- /** Used to detect binary string values. */
- var reIsBinary = /^0b[01]+$/i;
-
- /** Used to detect octal string values. */
- var reIsOctal = /^0o[0-7]+$/i;
-
- /** Built-in method references without a dependency on `root`. */
- var freeParseInt = parseInt;
-
- /**
- * Converts `value` to a number.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to process.
- * @returns {number} Returns the number.
- * @example
- *
- * _.toNumber(3.2);
- * // => 3.2
- *
- * _.toNumber(Number.MIN_VALUE);
- * // => 5e-324
- *
- * _.toNumber(Infinity);
- * // => Infinity
- *
- * _.toNumber('3.2');
- * // => 3.2
- */
- function toNumber(value) {
- if (typeof value == 'number') {
- return value;
- }
- if (isSymbol_1(value)) {
- return NAN;
- }
- if (isObject_1(value)) {
- var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
- value = isObject_1(other) ? (other + '') : other;
- }
- if (typeof value != 'string') {
- return value === 0 ? value : +value;
- }
- value = _baseTrim(value);
- var isBinary = reIsBinary.test(value);
- return (isBinary || reIsOctal.test(value))
- ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
- : (reIsBadHex.test(value) ? NAN : +value);
- }
-
- var toNumber_1 = toNumber;
-
- /** Used as references for various `Number` constants. */
- var INFINITY$2 = 1 / 0,
- MAX_INTEGER = 1.7976931348623157e+308;
-
- /**
- * Converts `value` to a finite number.
- *
- * @static
- * @memberOf _
- * @since 4.12.0
- * @category Lang
- * @param {*} value The value to convert.
- * @returns {number} Returns the converted number.
- * @example
- *
- * _.toFinite(3.2);
- * // => 3.2
- *
- * _.toFinite(Number.MIN_VALUE);
- * // => 5e-324
- *
- * _.toFinite(Infinity);
- * // => 1.7976931348623157e+308
- *
- * _.toFinite('3.2');
- * // => 3.2
- */
- function toFinite(value) {
- if (!value) {
- return value === 0 ? value : 0;
- }
- value = toNumber_1(value);
- if (value === INFINITY$2 || value === -INFINITY$2) {
- var sign = (value < 0 ? -1 : 1);
- return sign * MAX_INTEGER;
- }
- return value === value ? value : 0;
- }
-
- var toFinite_1 = toFinite;
-
- /**
- * Converts `value` to an integer.
- *
- * **Note:** This method is loosely based on
- * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to convert.
- * @returns {number} Returns the converted integer.
- * @example
- *
- * _.toInteger(3.2);
- * // => 3
- *
- * _.toInteger(Number.MIN_VALUE);
- * // => 0
- *
- * _.toInteger(Infinity);
- * // => 1.7976931348623157e+308
- *
- * _.toInteger('3.2');
- * // => 3
- */
- function toInteger(value) {
- var result = toFinite_1(value),
- remainder = result % 1;
-
- return result === result ? (remainder ? result - remainder : result) : 0;
- }
-
- var toInteger_1 = toInteger;
-
- /** Error message constants. */
- var FUNC_ERROR_TEXT$1 = 'Expected a function';
-
- /** Used to compose bitmasks for function metadata. */
- var WRAP_BIND_FLAG = 1,
- WRAP_BIND_KEY_FLAG = 2,
- WRAP_CURRY_FLAG = 8,
- WRAP_CURRY_RIGHT_FLAG = 16,
- WRAP_PARTIAL_FLAG = 32,
- WRAP_PARTIAL_RIGHT_FLAG = 64;
-
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeMax$1 = Math.max;
-
- /**
- * Creates a function that either curries or invokes `func` with optional
- * `this` binding and partially applied arguments.
- *
- * @private
- * @param {Function|string} func The function or method name to wrap.
- * @param {number} bitmask The bitmask flags.
- * 1 - `_.bind`
- * 2 - `_.bindKey`
- * 4 - `_.curry` or `_.curryRight` of a bound function
- * 8 - `_.curry`
- * 16 - `_.curryRight`
- * 32 - `_.partial`
- * 64 - `_.partialRight`
- * 128 - `_.rearg`
- * 256 - `_.ary`
- * 512 - `_.flip`
- * @param {*} [thisArg] The `this` binding of `func`.
- * @param {Array} [partials] The arguments to be partially applied.
- * @param {Array} [holders] The `partials` placeholder indexes.
- * @param {Array} [argPos] The argument positions of the new function.
- * @param {number} [ary] The arity cap of `func`.
- * @param {number} [arity] The arity of `func`.
- * @returns {Function} Returns the new wrapped function.
- */
- function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
- var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
- if (!isBindKey && typeof func != 'function') {
- throw new TypeError(FUNC_ERROR_TEXT$1);
- }
- var length = partials ? partials.length : 0;
- if (!length) {
- bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
- partials = holders = undefined;
- }
- ary = ary === undefined ? ary : nativeMax$1(toInteger_1(ary), 0);
- arity = arity === undefined ? arity : toInteger_1(arity);
- length -= holders ? holders.length : 0;
-
- if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
- var partialsRight = partials,
- holdersRight = holders;
-
- partials = holders = undefined;
- }
- var data = isBindKey ? undefined : _getData(func);
-
- var newData = [
- func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
- argPos, ary, arity
- ];
-
- if (data) {
- _mergeData(newData, data);
- }
- func = newData[0];
- bitmask = newData[1];
- thisArg = newData[2];
- partials = newData[3];
- holders = newData[4];
- arity = newData[9] = newData[9] === undefined
- ? (isBindKey ? 0 : func.length)
- : nativeMax$1(newData[9] - length, 0);
-
- if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
- bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
- }
- if (!bitmask || bitmask == WRAP_BIND_FLAG) {
- var result = _createBind(func, bitmask, thisArg);
- } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
- result = _createCurry(func, bitmask, arity);
- } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
- result = _createPartial(func, bitmask, thisArg, partials);
- } else {
- result = _createHybrid.apply(undefined, newData);
- }
- var setter = data ? _baseSetData : _setData;
- return _setWrapToString(setter(result, newData), func, bitmask);
- }
-
- var _createWrap = createWrap;
-
- commonjsRegister("/$$rollup_base$$/node_modules/lodash/curry.js", function (module, exports) {
- var createWrap = _createWrap;
-
- /** Used to compose bitmasks for function metadata. */
- var WRAP_CURRY_FLAG = 8;
-
- /**
- * Creates a function that accepts arguments of `func` and either invokes
- * `func` returning its result, if at least `arity` number of arguments have
- * been provided, or returns a function that accepts the remaining `func`
- * arguments, and so on. The arity of `func` may be specified if `func.length`
- * is not sufficient.
- *
- * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
- * may be used as a placeholder for provided arguments.
- *
- * **Note:** This method doesn't set the "length" property of curried functions.
- *
- * @static
- * @memberOf _
- * @since 2.0.0
- * @category Function
- * @param {Function} func The function to curry.
- * @param {number} [arity=func.length] The arity of `func`.
- * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
- * @returns {Function} Returns the new curried function.
- * @example
- *
- * var abc = function(a, b, c) {
- * return [a, b, c];
- * };
- *
- * var curried = _.curry(abc);
- *
- * curried(1)(2)(3);
- * // => [1, 2, 3]
- *
- * curried(1, 2)(3);
- * // => [1, 2, 3]
- *
- * curried(1, 2, 3);
- * // => [1, 2, 3]
- *
- * // Curried with placeholders.
- * curried(1)(_, 3)(2);
- * // => [1, 2, 3]
- */
- function curry(func, arity, guard) {
- arity = guard ? undefined : arity;
- var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
- result.placeholder = curry.placeholder;
- return result;
- }
-
- // Assign default placeholders.
- curry.placeholder = {};
-
- module.exports = curry;
-
- });
-
- commonjsRegister("/$$rollup_base$$/node_modules/lodash/curryRight.js", function (module, exports) {
- var createWrap = _createWrap;
-
- /** Used to compose bitmasks for function metadata. */
- var WRAP_CURRY_RIGHT_FLAG = 16;
-
- /**
- * This method is like `_.curry` except that arguments are applied to `func`
- * in the manner of `_.partialRight` instead of `_.partial`.
- *
- * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
- * builds, may be used as a placeholder for provided arguments.
- *
- * **Note:** This method doesn't set the "length" property of curried functions.
- *
- * @static
- * @memberOf _
- * @since 3.0.0
- * @category Function
- * @param {Function} func The function to curry.
- * @param {number} [arity=func.length] The arity of `func`.
- * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
- * @returns {Function} Returns the new curried function.
- * @example
- *
- * var abc = function(a, b, c) {
- * return [a, b, c];
- * };
- *
- * var curried = _.curryRight(abc);
- *
- * curried(3)(2)(1);
- * // => [1, 2, 3]
- *
- * curried(2, 3)(1);
- * // => [1, 2, 3]
- *
- * curried(1, 2, 3);
- * // => [1, 2, 3]
- *
- * // Curried with placeholders.
- * curried(3)(1, _)(2);
- * // => [1, 2, 3]
- */
- function curryRight(func, arity, guard) {
- arity = guard ? undefined : arity;
- var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
- result.placeholder = curryRight.placeholder;
- return result;
- }
-
- // Assign default placeholders.
- curryRight.placeholder = {};
-
- module.exports = curryRight;
-
- });
-
- /** Used to map aliases to their real names. */
-
- var _mapping = createCommonjsModule(function (module, exports) {
- exports.aliasToReal = {
-
- // Lodash aliases.
- 'each': 'forEach',
- 'eachRight': 'forEachRight',
- 'entries': 'toPairs',
- 'entriesIn': 'toPairsIn',
- 'extend': 'assignIn',
- 'extendAll': 'assignInAll',
- 'extendAllWith': 'assignInAllWith',
- 'extendWith': 'assignInWith',
- 'first': 'head',
-
- // Methods that are curried variants of others.
- 'conforms': 'conformsTo',
- 'matches': 'isMatch',
- 'property': 'get',
-
- // Ramda aliases.
- '__': 'placeholder',
- 'F': 'stubFalse',
- 'T': 'stubTrue',
- 'all': 'every',
- 'allPass': 'overEvery',
- 'always': 'constant',
- 'any': 'some',
- 'anyPass': 'overSome',
- 'apply': 'spread',
- 'assoc': 'set',
- 'assocPath': 'set',
- 'complement': 'negate',
- 'compose': 'flowRight',
- 'contains': 'includes',
- 'dissoc': 'unset',
- 'dissocPath': 'unset',
- 'dropLast': 'dropRight',
- 'dropLastWhile': 'dropRightWhile',
- 'equals': 'isEqual',
- 'identical': 'eq',
- 'indexBy': 'keyBy',
- 'init': 'initial',
- 'invertObj': 'invert',
- 'juxt': 'over',
- 'omitAll': 'omit',
- 'nAry': 'ary',
- 'path': 'get',
- 'pathEq': 'matchesProperty',
- 'pathOr': 'getOr',
- 'paths': 'at',
- 'pickAll': 'pick',
- 'pipe': 'flow',
- 'pluck': 'map',
- 'prop': 'get',
- 'propEq': 'matchesProperty',
- 'propOr': 'getOr',
- 'props': 'at',
- 'symmetricDifference': 'xor',
- 'symmetricDifferenceBy': 'xorBy',
- 'symmetricDifferenceWith': 'xorWith',
- 'takeLast': 'takeRight',
- 'takeLastWhile': 'takeRightWhile',
- 'unapply': 'rest',
- 'unnest': 'flatten',
- 'useWith': 'overArgs',
- 'where': 'conformsTo',
- 'whereEq': 'isMatch',
- 'zipObj': 'zipObject'
- };
-
- /** Used to map ary to method names. */
- exports.aryMethod = {
- '1': [
- 'assignAll', 'assignInAll', 'attempt', 'castArray', 'ceil', 'create',
- 'curry', 'curryRight', 'defaultsAll', 'defaultsDeepAll', 'floor', 'flow',
- 'flowRight', 'fromPairs', 'invert', 'iteratee', 'memoize', 'method', 'mergeAll',
- 'methodOf', 'mixin', 'nthArg', 'over', 'overEvery', 'overSome','rest', 'reverse',
- 'round', 'runInContext', 'spread', 'template', 'trim', 'trimEnd', 'trimStart',
- 'uniqueId', 'words', 'zipAll'
- ],
- '2': [
- 'add', 'after', 'ary', 'assign', 'assignAllWith', 'assignIn', 'assignInAllWith',
- 'at', 'before', 'bind', 'bindAll', 'bindKey', 'chunk', 'cloneDeepWith',
- 'cloneWith', 'concat', 'conformsTo', 'countBy', 'curryN', 'curryRightN',
- 'debounce', 'defaults', 'defaultsDeep', 'defaultTo', 'delay', 'difference',
- 'divide', 'drop', 'dropRight', 'dropRightWhile', 'dropWhile', 'endsWith', 'eq',
- 'every', 'filter', 'find', 'findIndex', 'findKey', 'findLast', 'findLastIndex',
- 'findLastKey', 'flatMap', 'flatMapDeep', 'flattenDepth', 'forEach',
- 'forEachRight', 'forIn', 'forInRight', 'forOwn', 'forOwnRight', 'get',
- 'groupBy', 'gt', 'gte', 'has', 'hasIn', 'includes', 'indexOf', 'intersection',
- 'invertBy', 'invoke', 'invokeMap', 'isEqual', 'isMatch', 'join', 'keyBy',
- 'lastIndexOf', 'lt', 'lte', 'map', 'mapKeys', 'mapValues', 'matchesProperty',
- 'maxBy', 'meanBy', 'merge', 'mergeAllWith', 'minBy', 'multiply', 'nth', 'omit',
- 'omitBy', 'overArgs', 'pad', 'padEnd', 'padStart', 'parseInt', 'partial',
- 'partialRight', 'partition', 'pick', 'pickBy', 'propertyOf', 'pull', 'pullAll',
- 'pullAt', 'random', 'range', 'rangeRight', 'rearg', 'reject', 'remove',
- 'repeat', 'restFrom', 'result', 'sampleSize', 'some', 'sortBy', 'sortedIndex',
- 'sortedIndexOf', 'sortedLastIndex', 'sortedLastIndexOf', 'sortedUniqBy',
- 'split', 'spreadFrom', 'startsWith', 'subtract', 'sumBy', 'take', 'takeRight',
- 'takeRightWhile', 'takeWhile', 'tap', 'throttle', 'thru', 'times', 'trimChars',
- 'trimCharsEnd', 'trimCharsStart', 'truncate', 'union', 'uniqBy', 'uniqWith',
- 'unset', 'unzipWith', 'without', 'wrap', 'xor', 'zip', 'zipObject',
- 'zipObjectDeep'
- ],
- '3': [
- 'assignInWith', 'assignWith', 'clamp', 'differenceBy', 'differenceWith',
- 'findFrom', 'findIndexFrom', 'findLastFrom', 'findLastIndexFrom', 'getOr',
- 'includesFrom', 'indexOfFrom', 'inRange', 'intersectionBy', 'intersectionWith',
- 'invokeArgs', 'invokeArgsMap', 'isEqualWith', 'isMatchWith', 'flatMapDepth',
- 'lastIndexOfFrom', 'mergeWith', 'orderBy', 'padChars', 'padCharsEnd',
- 'padCharsStart', 'pullAllBy', 'pullAllWith', 'rangeStep', 'rangeStepRight',
- 'reduce', 'reduceRight', 'replace', 'set', 'slice', 'sortedIndexBy',
- 'sortedLastIndexBy', 'transform', 'unionBy', 'unionWith', 'update', 'xorBy',
- 'xorWith', 'zipWith'
- ],
- '4': [
- 'fill', 'setWith', 'updateWith'
- ]
- };
-
- /** Used to map ary to rearg configs. */
- exports.aryRearg = {
- '2': [1, 0],
- '3': [2, 0, 1],
- '4': [3, 2, 0, 1]
- };
-
- /** Used to map method names to their iteratee ary. */
- exports.iterateeAry = {
- 'dropRightWhile': 1,
- 'dropWhile': 1,
- 'every': 1,
- 'filter': 1,
- 'find': 1,
- 'findFrom': 1,
- 'findIndex': 1,
- 'findIndexFrom': 1,
- 'findKey': 1,
- 'findLast': 1,
- 'findLastFrom': 1,
- 'findLastIndex': 1,
- 'findLastIndexFrom': 1,
- 'findLastKey': 1,
- 'flatMap': 1,
- 'flatMapDeep': 1,
- 'flatMapDepth': 1,
- 'forEach': 1,
- 'forEachRight': 1,
- 'forIn': 1,
- 'forInRight': 1,
- 'forOwn': 1,
- 'forOwnRight': 1,
- 'map': 1,
- 'mapKeys': 1,
- 'mapValues': 1,
- 'partition': 1,
- 'reduce': 2,
- 'reduceRight': 2,
- 'reject': 1,
- 'remove': 1,
- 'some': 1,
- 'takeRightWhile': 1,
- 'takeWhile': 1,
- 'times': 1,
- 'transform': 2
- };
-
- /** Used to map method names to iteratee rearg configs. */
- exports.iterateeRearg = {
- 'mapKeys': [1],
- 'reduceRight': [1, 0]
- };
-
- /** Used to map method names to rearg configs. */
- exports.methodRearg = {
- 'assignInAllWith': [1, 0],
- 'assignInWith': [1, 2, 0],
- 'assignAllWith': [1, 0],
- 'assignWith': [1, 2, 0],
- 'differenceBy': [1, 2, 0],
- 'differenceWith': [1, 2, 0],
- 'getOr': [2, 1, 0],
- 'intersectionBy': [1, 2, 0],
- 'intersectionWith': [1, 2, 0],
- 'isEqualWith': [1, 2, 0],
- 'isMatchWith': [2, 1, 0],
- 'mergeAllWith': [1, 0],
- 'mergeWith': [1, 2, 0],
- 'padChars': [2, 1, 0],
- 'padCharsEnd': [2, 1, 0],
- 'padCharsStart': [2, 1, 0],
- 'pullAllBy': [2, 1, 0],
- 'pullAllWith': [2, 1, 0],
- 'rangeStep': [1, 2, 0],
- 'rangeStepRight': [1, 2, 0],
- 'setWith': [3, 1, 2, 0],
- 'sortedIndexBy': [2, 1, 0],
- 'sortedLastIndexBy': [2, 1, 0],
- 'unionBy': [1, 2, 0],
- 'unionWith': [1, 2, 0],
- 'updateWith': [3, 1, 2, 0],
- 'xorBy': [1, 2, 0],
- 'xorWith': [1, 2, 0],
- 'zipWith': [1, 2, 0]
- };
-
- /** Used to map method names to spread configs. */
- exports.methodSpread = {
- 'assignAll': { 'start': 0 },
- 'assignAllWith': { 'start': 0 },
- 'assignInAll': { 'start': 0 },
- 'assignInAllWith': { 'start': 0 },
- 'defaultsAll': { 'start': 0 },
- 'defaultsDeepAll': { 'start': 0 },
- 'invokeArgs': { 'start': 2 },
- 'invokeArgsMap': { 'start': 2 },
- 'mergeAll': { 'start': 0 },
- 'mergeAllWith': { 'start': 0 },
- 'partial': { 'start': 1 },
- 'partialRight': { 'start': 1 },
- 'without': { 'start': 1 },
- 'zipAll': { 'start': 0 }
- };
-
- /** Used to identify methods which mutate arrays or objects. */
- exports.mutate = {
- 'array': {
- 'fill': true,
- 'pull': true,
- 'pullAll': true,
- 'pullAllBy': true,
- 'pullAllWith': true,
- 'pullAt': true,
- 'remove': true,
- 'reverse': true
- },
- 'object': {
- 'assign': true,
- 'assignAll': true,
- 'assignAllWith': true,
- 'assignIn': true,
- 'assignInAll': true,
- 'assignInAllWith': true,
- 'assignInWith': true,
- 'assignWith': true,
- 'defaults': true,
- 'defaultsAll': true,
- 'defaultsDeep': true,
- 'defaultsDeepAll': true,
- 'merge': true,
- 'mergeAll': true,
- 'mergeAllWith': true,
- 'mergeWith': true,
- },
- 'set': {
- 'set': true,
- 'setWith': true,
- 'unset': true,
- 'update': true,
- 'updateWith': true
- }
- };
-
- /** Used to map real names to their aliases. */
- exports.realToAlias = (function() {
- var hasOwnProperty = Object.prototype.hasOwnProperty,
- object = exports.aliasToReal,
- result = {};
-
- for (var key in object) {
- var value = object[key];
- if (hasOwnProperty.call(result, value)) {
- result[value].push(key);
- } else {
- result[value] = [key];
- }
- }
- return result;
- }());
-
- /** Used to map method names to other names. */
- exports.remap = {
- 'assignAll': 'assign',
- 'assignAllWith': 'assignWith',
- 'assignInAll': 'assignIn',
- 'assignInAllWith': 'assignInWith',
- 'curryN': 'curry',
- 'curryRightN': 'curryRight',
- 'defaultsAll': 'defaults',
- 'defaultsDeepAll': 'defaultsDeep',
- 'findFrom': 'find',
- 'findIndexFrom': 'findIndex',
- 'findLastFrom': 'findLast',
- 'findLastIndexFrom': 'findLastIndex',
- 'getOr': 'get',
- 'includesFrom': 'includes',
- 'indexOfFrom': 'indexOf',
- 'invokeArgs': 'invoke',
- 'invokeArgsMap': 'invokeMap',
- 'lastIndexOfFrom': 'lastIndexOf',
- 'mergeAll': 'merge',
- 'mergeAllWith': 'mergeWith',
- 'padChars': 'pad',
- 'padCharsEnd': 'padEnd',
- 'padCharsStart': 'padStart',
- 'propertyOf': 'get',
- 'rangeStep': 'range',
- 'rangeStepRight': 'rangeRight',
- 'restFrom': 'rest',
- 'spreadFrom': 'spread',
- 'trimChars': 'trim',
- 'trimCharsEnd': 'trimEnd',
- 'trimCharsStart': 'trimStart',
- 'zipAll': 'zip'
- };
-
- /** Used to track methods that skip fixing their arity. */
- exports.skipFixed = {
- 'castArray': true,
- 'flow': true,
- 'flowRight': true,
- 'iteratee': true,
- 'mixin': true,
- 'rearg': true,
- 'runInContext': true
- };
-
- /** Used to track methods that skip rearranging arguments. */
- exports.skipRearg = {
- 'add': true,
- 'assign': true,
- 'assignIn': true,
- 'bind': true,
- 'bindKey': true,
- 'concat': true,
- 'difference': true,
- 'divide': true,
- 'eq': true,
- 'gt': true,
- 'gte': true,
- 'isEqual': true,
- 'lt': true,
- 'lte': true,
- 'matchesProperty': true,
- 'merge': true,
- 'multiply': true,
- 'overArgs': true,
- 'partial': true,
- 'partialRight': true,
- 'propertyOf': true,
- 'random': true,
- 'range': true,
- 'rangeRight': true,
- 'subtract': true,
- 'zip': true,
- 'zipObject': true,
- 'zipObjectDeep': true
- };
- }, "/$$rollup_base$$/node_modules/lodash/fp");
-
- /**
- * The default argument placeholder value for methods.
- *
- * @type {Object}
- */
- var placeholder = {};
-
- /** Built-in value reference. */
- var push = Array.prototype.push;
-
- /**
- * Creates a function, with an arity of `n`, that invokes `func` with the
- * arguments it receives.
- *
- * @private
- * @param {Function} func The function to wrap.
- * @param {number} n The arity of the new function.
- * @returns {Function} Returns the new function.
- */
- function baseArity(func, n) {
- return n == 2
- ? function(a, b) { return func.apply(undefined, arguments); }
- : function(a) { return func.apply(undefined, arguments); };
- }
-
- /**
- * Creates a function that invokes `func`, with up to `n` arguments, ignoring
- * any additional arguments.
- *
- * @private
- * @param {Function} func The function to cap arguments for.
- * @param {number} n The arity cap.
- * @returns {Function} Returns the new function.
- */
- function baseAry(func, n) {
- return n == 2
- ? function(a, b) { return func(a, b); }
- : function(a) { return func(a); };
- }
-
- /**
- * Creates a clone of `array`.
- *
- * @private
- * @param {Array} array The array to clone.
- * @returns {Array} Returns the cloned array.
- */
- function cloneArray(array) {
- var length = array ? array.length : 0,
- result = Array(length);
-
- while (length--) {
- result[length] = array[length];
- }
- return result;
- }
-
- /**
- * Creates a function that clones a given object using the assignment `func`.
- *
- * @private
- * @param {Function} func The assignment function.
- * @returns {Function} Returns the new cloner function.
- */
- function createCloner(func) {
- return function(object) {
- return func({}, object);
- };
- }
-
- /**
- * A specialized version of `_.spread` which flattens the spread array into
- * the arguments of the invoked `func`.
- *
- * @private
- * @param {Function} func The function to spread arguments over.
- * @param {number} start The start position of the spread.
- * @returns {Function} Returns the new function.
- */
- function flatSpread(func, start) {
- return function() {
- var length = arguments.length,
- lastIndex = length - 1,
- args = Array(length);
-
- while (length--) {
- args[length] = arguments[length];
- }
- var array = args[start],
- otherArgs = args.slice(0, start);
-
- if (array) {
- push.apply(otherArgs, array);
- }
- if (start != lastIndex) {
- push.apply(otherArgs, args.slice(start + 1));
- }
- return func.apply(this, otherArgs);
- };
- }
-
- /**
- * Creates a function that wraps `func` and uses `cloner` to clone the first
- * argument it receives.
- *
- * @private
- * @param {Function} func The function to wrap.
- * @param {Function} cloner The function to clone arguments.
- * @returns {Function} Returns the new immutable function.
- */
- function wrapImmutable(func, cloner) {
- return function() {
- var length = arguments.length;
- if (!length) {
- return;
- }
- var args = Array(length);
- while (length--) {
- args[length] = arguments[length];
- }
- var result = args[0] = cloner.apply(undefined, args);
- func.apply(undefined, args);
- return result;
- };
- }
-
- /**
- * The base implementation of `convert` which accepts a `util` object of methods
- * required to perform conversions.
- *
- * @param {Object} util The util object.
- * @param {string} name The name of the function to convert.
- * @param {Function} func The function to convert.
- * @param {Object} [options] The options object.
- * @param {boolean} [options.cap=true] Specify capping iteratee arguments.
- * @param {boolean} [options.curry=true] Specify currying.
- * @param {boolean} [options.fixed=true] Specify fixed arity.
- * @param {boolean} [options.immutable=true] Specify immutable operations.
- * @param {boolean} [options.rearg=true] Specify rearranging arguments.
- * @returns {Function|Object} Returns the converted function or object.
- */
- function baseConvert(util, name, func, options) {
- var isLib = typeof name == 'function',
- isObj = name === Object(name);
-
- if (isObj) {
- options = func;
- func = name;
- name = undefined;
- }
- if (func == null) {
- throw new TypeError;
- }
- options || (options = {});
-
- var config = {
- 'cap': 'cap' in options ? options.cap : true,
- 'curry': 'curry' in options ? options.curry : true,
- 'fixed': 'fixed' in options ? options.fixed : true,
- 'immutable': 'immutable' in options ? options.immutable : true,
- 'rearg': 'rearg' in options ? options.rearg : true
- };
-
- var defaultHolder = isLib ? func : placeholder,
- forceCurry = ('curry' in options) && options.curry,
- forceFixed = ('fixed' in options) && options.fixed,
- forceRearg = ('rearg' in options) && options.rearg,
- pristine = isLib ? func.runInContext() : undefined;
-
- var helpers = isLib ? func : {
- 'ary': util.ary,
- 'assign': util.assign,
- 'clone': util.clone,
- 'curry': util.curry,
- 'forEach': util.forEach,
- 'isArray': util.isArray,
- 'isError': util.isError,
- 'isFunction': util.isFunction,
- 'isWeakMap': util.isWeakMap,
- 'iteratee': util.iteratee,
- 'keys': util.keys,
- 'rearg': util.rearg,
- 'toInteger': util.toInteger,
- 'toPath': util.toPath
- };
-
- var ary = helpers.ary,
- assign = helpers.assign,
- clone = helpers.clone,
- curry = helpers.curry,
- each = helpers.forEach,
- isArray = helpers.isArray,
- isError = helpers.isError,
- isFunction = helpers.isFunction,
- isWeakMap = helpers.isWeakMap,
- keys = helpers.keys,
- rearg = helpers.rearg,
- toInteger = helpers.toInteger,
- toPath = helpers.toPath;
-
- var aryMethodKeys = keys(_mapping.aryMethod);
-
- var wrappers = {
- 'castArray': function(castArray) {
- return function() {
- var value = arguments[0];
- return isArray(value)
- ? castArray(cloneArray(value))
- : castArray.apply(undefined, arguments);
- };
- },
- 'iteratee': function(iteratee) {
- return function() {
- var func = arguments[0],
- arity = arguments[1],
- result = iteratee(func, arity),
- length = result.length;
-
- if (config.cap && typeof arity == 'number') {
- arity = arity > 2 ? (arity - 2) : 1;
- return (length && length <= arity) ? result : baseAry(result, arity);
- }
- return result;
- };
- },
- 'mixin': function(mixin) {
- return function(source) {
- var func = this;
- if (!isFunction(func)) {
- return mixin(func, Object(source));
- }
- var pairs = [];
- each(keys(source), function(key) {
- if (isFunction(source[key])) {
- pairs.push([key, func.prototype[key]]);
- }
- });
-
- mixin(func, Object(source));
-
- each(pairs, function(pair) {
- var value = pair[1];
- if (isFunction(value)) {
- func.prototype[pair[0]] = value;
- } else {
- delete func.prototype[pair[0]];
- }
- });
- return func;
- };
- },
- 'nthArg': function(nthArg) {
- return function(n) {
- var arity = n < 0 ? 1 : (toInteger(n) + 1);
- return curry(nthArg(n), arity);
- };
- },
- 'rearg': function(rearg) {
- return function(func, indexes) {
- var arity = indexes ? indexes.length : 0;
- return curry(rearg(func, indexes), arity);
- };
- },
- 'runInContext': function(runInContext) {
- return function(context) {
- return baseConvert(util, runInContext(context), options);
- };
- }
- };
-
- /*--------------------------------------------------------------------------*/
-
- /**
- * Casts `func` to a function with an arity capped iteratee if needed.
- *
- * @private
- * @param {string} name The name of the function to inspect.
- * @param {Function} func The function to inspect.
- * @returns {Function} Returns the cast function.
- */
- function castCap(name, func) {
- if (config.cap) {
- var indexes = _mapping.iterateeRearg[name];
- if (indexes) {
- return iterateeRearg(func, indexes);
- }
- var n = !isLib && _mapping.iterateeAry[name];
- if (n) {
- return iterateeAry(func, n);
- }
- }
- return func;
- }
-
- /**
- * Casts `func` to a curried function if needed.
- *
- * @private
- * @param {string} name The name of the function to inspect.
- * @param {Function} func The function to inspect.
- * @param {number} n The arity of `func`.
- * @returns {Function} Returns the cast function.
- */
- function castCurry(name, func, n) {
- return (forceCurry || (config.curry && n > 1))
- ? curry(func, n)
- : func;
- }
-
- /**
- * Casts `func` to a fixed arity function if needed.
- *
- * @private
- * @param {string} name The name of the function to inspect.
- * @param {Function} func The function to inspect.
- * @param {number} n The arity cap.
- * @returns {Function} Returns the cast function.
- */
- function castFixed(name, func, n) {
- if (config.fixed && (forceFixed || !_mapping.skipFixed[name])) {
- var data = _mapping.methodSpread[name],
- start = data && data.start;
-
- return start === undefined ? ary(func, n) : flatSpread(func, start);
- }
- return func;
- }
-
- /**
- * Casts `func` to an rearged function if needed.
- *
- * @private
- * @param {string} name The name of the function to inspect.
- * @param {Function} func The function to inspect.
- * @param {number} n The arity of `func`.
- * @returns {Function} Returns the cast function.
- */
- function castRearg(name, func, n) {
- return (config.rearg && n > 1 && (forceRearg || !_mapping.skipRearg[name]))
- ? rearg(func, _mapping.methodRearg[name] || _mapping.aryRearg[n])
- : func;
- }
-
- /**
- * Creates a clone of `object` by `path`.
- *
- * @private
- * @param {Object} object The object to clone.
- * @param {Array|string} path The path to clone by.
- * @returns {Object} Returns the cloned object.
- */
- function cloneByPath(object, path) {
- path = toPath(path);
-
- var index = -1,
- length = path.length,
- lastIndex = length - 1,
- result = clone(Object(object)),
- nested = result;
-
- while (nested != null && ++index < length) {
- var key = path[index],
- value = nested[key];
-
- if (value != null &&
- !(isFunction(value) || isError(value) || isWeakMap(value))) {
- nested[key] = clone(index == lastIndex ? value : Object(value));
- }
- nested = nested[key];
- }
- return result;
- }
-
- /**
- * Converts `lodash` to an immutable auto-curried iteratee-first data-last
- * version with conversion `options` applied.
- *
- * @param {Object} [options] The options object. See `baseConvert` for more details.
- * @returns {Function} Returns the converted `lodash`.
- */
- function convertLib(options) {
- return _.runInContext.convert(options)(undefined);
- }
-
- /**
- * Create a converter function for `func` of `name`.
- *
- * @param {string} name The name of the function to convert.
- * @param {Function} func The function to convert.
- * @returns {Function} Returns the new converter function.
- */
- function createConverter(name, func) {
- var realName = _mapping.aliasToReal[name] || name,
- methodName = _mapping.remap[realName] || realName,
- oldOptions = options;
-
- return function(options) {
- var newUtil = isLib ? pristine : helpers,
- newFunc = isLib ? pristine[methodName] : func,
- newOptions = assign(assign({}, oldOptions), options);
-
- return baseConvert(newUtil, realName, newFunc, newOptions);
- };
- }
-
- /**
- * Creates a function that wraps `func` to invoke its iteratee, with up to `n`
- * arguments, ignoring any additional arguments.
- *
- * @private
- * @param {Function} func The function to cap iteratee arguments for.
- * @param {number} n The arity cap.
- * @returns {Function} Returns the new function.
- */
- function iterateeAry(func, n) {
- return overArg(func, function(func) {
- return typeof func == 'function' ? baseAry(func, n) : func;
- });
- }
-
- /**
- * Creates a function that wraps `func` to invoke its iteratee with arguments
- * arranged according to the specified `indexes` where the argument value at
- * the first index is provided as the first argument, the argument value at
- * the second index is provided as the second argument, and so on.
- *
- * @private
- * @param {Function} func The function to rearrange iteratee arguments for.
- * @param {number[]} indexes The arranged argument indexes.
- * @returns {Function} Returns the new function.
- */
- function iterateeRearg(func, indexes) {
- return overArg(func, function(func) {
- var n = indexes.length;
- return baseArity(rearg(baseAry(func, n), indexes), n);
- });
- }
-
- /**
- * Creates a function that invokes `func` with its first argument transformed.
- *
- * @private
- * @param {Function} func The function to wrap.
- * @param {Function} transform The argument transform.
- * @returns {Function} Returns the new function.
- */
- function overArg(func, transform) {
- return function() {
- var length = arguments.length;
- if (!length) {
- return func();
- }
- var args = Array(length);
- while (length--) {
- args[length] = arguments[length];
- }
- var index = config.rearg ? 0 : (length - 1);
- args[index] = transform(args[index]);
- return func.apply(undefined, args);
- };
- }
-
- /**
- * Creates a function that wraps `func` and applys the conversions
- * rules by `name`.
- *
- * @private
- * @param {string} name The name of the function to wrap.
- * @param {Function} func The function to wrap.
- * @returns {Function} Returns the converted function.
- */
- function wrap(name, func, placeholder) {
- var result,
- realName = _mapping.aliasToReal[name] || name,
- wrapped = func,
- wrapper = wrappers[realName];
-
- if (wrapper) {
- wrapped = wrapper(func);
- }
- else if (config.immutable) {
- if (_mapping.mutate.array[realName]) {
- wrapped = wrapImmutable(func, cloneArray);
- }
- else if (_mapping.mutate.object[realName]) {
- wrapped = wrapImmutable(func, createCloner(func));
- }
- else if (_mapping.mutate.set[realName]) {
- wrapped = wrapImmutable(func, cloneByPath);
- }
- }
- each(aryMethodKeys, function(aryKey) {
- each(_mapping.aryMethod[aryKey], function(otherName) {
- if (realName == otherName) {
- var data = _mapping.methodSpread[realName],
- afterRearg = data && data.afterRearg;
-
- result = afterRearg
- ? castFixed(realName, castRearg(realName, wrapped, aryKey), aryKey)
- : castRearg(realName, castFixed(realName, wrapped, aryKey), aryKey);
-
- result = castCap(realName, result);
- result = castCurry(realName, result, aryKey);
- return false;
- }
- });
- return !result;
- });
-
- result || (result = wrapped);
- if (result == func) {
- result = forceCurry ? curry(result, 1) : function() {
- return func.apply(this, arguments);
- };
- }
- result.convert = createConverter(realName, func);
- result.placeholder = func.placeholder = placeholder;
-
- return result;
- }
-
- /*--------------------------------------------------------------------------*/
-
- if (!isObj) {
- return wrap(name, func, defaultHolder);
- }
- var _ = func;
-
- // Convert methods by ary cap.
- var pairs = [];
- each(aryMethodKeys, function(aryKey) {
- each(_mapping.aryMethod[aryKey], function(key) {
- var func = _[_mapping.remap[key] || key];
- if (func) {
- pairs.push([key, wrap(key, func, _)]);
- }
- });
- });
-
- // Convert remaining methods.
- each(keys(_), function(key) {
- var func = _[key];
- if (typeof func == 'function') {
- var length = pairs.length;
- while (length--) {
- if (pairs[length][0] == key) {
- return;
- }
- }
- func.convert = createConverter(key, func);
- pairs.push([key, func]);
- }
- });
-
- // Assign to `_` leaving `_.prototype` unchanged to allow chaining.
- each(pairs, function(pair) {
- _[pair[0]] = pair[1];
- });
-
- _.convert = convertLib;
- _.placeholder = _;
-
- // Assign aliases.
- each(keys(_), function(key) {
- each(_mapping.realToAlias[key] || [], function(alias) {
- _[alias] = _[key];
- });
- });
-
- return _;
- }
-
- var _baseConvert = baseConvert;
-
- /** Used to compose bitmasks for function metadata. */
- var WRAP_ARY_FLAG = 128;
-
- /**
- * Creates a function that invokes `func`, with up to `n` arguments,
- * ignoring any additional arguments.
- *
- * @static
- * @memberOf _
- * @since 3.0.0
- * @category Function
- * @param {Function} func The function to cap arguments for.
- * @param {number} [n=func.length] The arity cap.
- * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
- * @returns {Function} Returns the new capped function.
- * @example
- *
- * _.map(['6', '8', '10'], _.ary(parseInt, 1));
- * // => [6, 8, 10]
- */
- function ary(func, n, guard) {
- n = guard ? undefined : n;
- n = (func && n == null) ? func.length : n;
- return _createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
- }
-
- var ary_1 = ary;
-
- /**
- * The base implementation of `assignValue` and `assignMergeValue` without
- * value checks.
- *
- * @private
- * @param {Object} object The object to modify.
- * @param {string} key The key of the property to assign.
- * @param {*} value The value to assign.
- */
- function baseAssignValue(object, key, value) {
- if (key == '__proto__' && _defineProperty) {
- _defineProperty(object, key, {
- 'configurable': true,
- 'enumerable': true,
- 'value': value,
- 'writable': true
- });
- } else {
- object[key] = value;
- }
- }
-
- var _baseAssignValue = baseAssignValue;
-
- /**
- * Performs a
- * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
- * comparison between two values to determine if they are equivalent.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to compare.
- * @param {*} other The other value to compare.
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
- * @example
- *
- * var object = { 'a': 1 };
- * var other = { 'a': 1 };
- *
- * _.eq(object, object);
- * // => true
- *
- * _.eq(object, other);
- * // => false
- *
- * _.eq('a', 'a');
- * // => true
- *
- * _.eq('a', Object('a'));
- * // => false
- *
- * _.eq(NaN, NaN);
- * // => true
- */
- function eq(value, other) {
- return value === other || (value !== value && other !== other);
- }
-
- var eq_1 = eq;
-
- /** Used for built-in method references. */
- var objectProto$c = Object.prototype;
-
- /** Used to check objects for own properties. */
- var hasOwnProperty$a = objectProto$c.hasOwnProperty;
-
- /**
- * Assigns `value` to `key` of `object` if the existing value is not equivalent
- * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
- * for equality comparisons.
- *
- * @private
- * @param {Object} object The object to modify.
- * @param {string} key The key of the property to assign.
- * @param {*} value The value to assign.
- */
- function assignValue(object, key, value) {
- var objValue = object[key];
- if (!(hasOwnProperty$a.call(object, key) && eq_1(objValue, value)) ||
- (value === undefined && !(key in object))) {
- _baseAssignValue(object, key, value);
- }
- }
-
- var _assignValue = assignValue;
-
- /**
- * Copies properties of `source` to `object`.
- *
- * @private
- * @param {Object} source The object to copy properties from.
- * @param {Array} props The property identifiers to copy.
- * @param {Object} [object={}] The object to copy properties to.
- * @param {Function} [customizer] The function to customize copied values.
- * @returns {Object} Returns `object`.
- */
- function copyObject(source, props, object, customizer) {
- var isNew = !object;
- object || (object = {});
-
- var index = -1,
- length = props.length;
-
- while (++index < length) {
- var key = props[index];
-
- var newValue = customizer
- ? customizer(object[key], source[key], key, object, source)
- : undefined;
-
- if (newValue === undefined) {
- newValue = source[key];
- }
- if (isNew) {
- _baseAssignValue(object, key, newValue);
- } else {
- _assignValue(object, key, newValue);
- }
- }
- return object;
- }
-
- var _copyObject = copyObject;
-
- /**
- * The base implementation of `_.times` without support for iteratee shorthands
- * or max array length checks.
- *
- * @private
- * @param {number} n The number of times to invoke `iteratee`.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Array} Returns the array of results.
- */
- function baseTimes(n, iteratee) {
- var index = -1,
- result = Array(n);
-
- while (++index < n) {
- result[index] = iteratee(index);
- }
- return result;
- }
-
- var _baseTimes = baseTimes;
-
- /** `Object#toString` result references. */
- var argsTag$3 = '[object Arguments]';
-
- /**
- * The base implementation of `_.isArguments`.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
- */
- function baseIsArguments(value) {
- return isObjectLike_1(value) && _baseGetTag(value) == argsTag$3;
- }
-
- var _baseIsArguments = baseIsArguments;
-
- /** Used for built-in method references. */
- var objectProto$b = Object.prototype;
-
- /** Used to check objects for own properties. */
- var hasOwnProperty$9 = objectProto$b.hasOwnProperty;
-
- /** Built-in value references. */
- var propertyIsEnumerable$1 = objectProto$b.propertyIsEnumerable;
-
- /**
- * Checks if `value` is likely an `arguments` object.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
- * else `false`.
- * @example
- *
- * _.isArguments(function() { return arguments; }());
- * // => true
- *
- * _.isArguments([1, 2, 3]);
- * // => false
- */
- var isArguments = _baseIsArguments(function() { return arguments; }()) ? _baseIsArguments : function(value) {
- return isObjectLike_1(value) && hasOwnProperty$9.call(value, 'callee') &&
- !propertyIsEnumerable$1.call(value, 'callee');
- };
-
- var isArguments_1 = isArguments;
-
- /**
- * This method returns `false`.
- *
- * @static
- * @memberOf _
- * @since 4.13.0
- * @category Util
- * @returns {boolean} Returns `false`.
- * @example
- *
- * _.times(2, _.stubFalse);
- * // => [false, false]
- */
- function stubFalse() {
- return false;
- }
-
- var stubFalse_1 = stubFalse;
-
- var isBuffer_1 = createCommonjsModule(function (module, exports) {
- /** Detect free variable `exports`. */
- var freeExports = exports && !exports.nodeType && exports;
-
- /** Detect free variable `module`. */
- var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
-
- /** Detect the popular CommonJS extension `module.exports`. */
- var moduleExports = freeModule && freeModule.exports === freeExports;
-
- /** Built-in value references. */
- var Buffer = moduleExports ? _root.Buffer : undefined;
-
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
-
- /**
- * Checks if `value` is a buffer.
- *
- * @static
- * @memberOf _
- * @since 4.3.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
- * @example
- *
- * _.isBuffer(new Buffer(2));
- * // => true
- *
- * _.isBuffer(new Uint8Array(2));
- * // => false
- */
- var isBuffer = nativeIsBuffer || stubFalse_1;
-
- module.exports = isBuffer;
- }, "/$$rollup_base$$/node_modules/lodash");
-
- /** Used as references for various `Number` constants. */
- var MAX_SAFE_INTEGER = 9007199254740991;
-
- /**
- * Checks if `value` is a valid array-like length.
- *
- * **Note:** This method is loosely based on
- * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
- * @example
- *
- * _.isLength(3);
- * // => true
- *
- * _.isLength(Number.MIN_VALUE);
- * // => false
- *
- * _.isLength(Infinity);
- * // => false
- *
- * _.isLength('3');
- * // => false
- */
- function isLength(value) {
- return typeof value == 'number' &&
- value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
- }
-
- var isLength_1 = isLength;
-
- /** `Object#toString` result references. */
- var argsTag$2 = '[object Arguments]',
- arrayTag$2 = '[object Array]',
- boolTag$3 = '[object Boolean]',
- dateTag$3 = '[object Date]',
- errorTag$3 = '[object Error]',
- funcTag$1 = '[object Function]',
- mapTag$5 = '[object Map]',
- numberTag$3 = '[object Number]',
- objectTag$4 = '[object Object]',
- regexpTag$3 = '[object RegExp]',
- setTag$5 = '[object Set]',
- stringTag$3 = '[object String]',
- weakMapTag$3 = '[object WeakMap]';
-
- var arrayBufferTag$3 = '[object ArrayBuffer]',
- dataViewTag$4 = '[object DataView]',
- float32Tag$2 = '[object Float32Array]',
- float64Tag$2 = '[object Float64Array]',
- int8Tag$2 = '[object Int8Array]',
- int16Tag$2 = '[object Int16Array]',
- int32Tag$2 = '[object Int32Array]',
- uint8Tag$2 = '[object Uint8Array]',
- uint8ClampedTag$2 = '[object Uint8ClampedArray]',
- uint16Tag$2 = '[object Uint16Array]',
- uint32Tag$2 = '[object Uint32Array]';
-
- /** Used to identify `toStringTag` values of typed arrays. */
- var typedArrayTags = {};
- typedArrayTags[float32Tag$2] = typedArrayTags[float64Tag$2] =
- typedArrayTags[int8Tag$2] = typedArrayTags[int16Tag$2] =
- typedArrayTags[int32Tag$2] = typedArrayTags[uint8Tag$2] =
- typedArrayTags[uint8ClampedTag$2] = typedArrayTags[uint16Tag$2] =
- typedArrayTags[uint32Tag$2] = true;
- typedArrayTags[argsTag$2] = typedArrayTags[arrayTag$2] =
- typedArrayTags[arrayBufferTag$3] = typedArrayTags[boolTag$3] =
- typedArrayTags[dataViewTag$4] = typedArrayTags[dateTag$3] =
- typedArrayTags[errorTag$3] = typedArrayTags[funcTag$1] =
- typedArrayTags[mapTag$5] = typedArrayTags[numberTag$3] =
- typedArrayTags[objectTag$4] = typedArrayTags[regexpTag$3] =
- typedArrayTags[setTag$5] = typedArrayTags[stringTag$3] =
- typedArrayTags[weakMapTag$3] = false;
-
- /**
- * The base implementation of `_.isTypedArray` without Node.js optimizations.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
- */
- function baseIsTypedArray(value) {
- return isObjectLike_1(value) &&
- isLength_1(value.length) && !!typedArrayTags[_baseGetTag(value)];
- }
-
- var _baseIsTypedArray = baseIsTypedArray;
-
- /**
- * The base implementation of `_.unary` without support for storing metadata.
- *
- * @private
- * @param {Function} func The function to cap arguments for.
- * @returns {Function} Returns the new capped function.
- */
- function baseUnary(func) {
- return function(value) {
- return func(value);
- };
- }
-
- var _baseUnary = baseUnary;
-
- var _nodeUtil = createCommonjsModule(function (module, exports) {
- /** Detect free variable `exports`. */
- var freeExports = exports && !exports.nodeType && exports;
-
- /** Detect free variable `module`. */
- var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
-
- /** Detect the popular CommonJS extension `module.exports`. */
- var moduleExports = freeModule && freeModule.exports === freeExports;
-
- /** Detect free variable `process` from Node.js. */
- var freeProcess = moduleExports && _freeGlobal.process;
-
- /** Used to access faster Node.js helpers. */
- var nodeUtil = (function() {
- try {
- // Use `util.types` for Node.js 10+.
- var types = freeModule && freeModule.require && freeModule.require('util').types;
-
- if (types) {
- return types;
- }
-
- // Legacy `process.binding('util')` for Node.js < 10.
- return freeProcess && freeProcess.binding && freeProcess.binding('util');
- } catch (e) {}
- }());
-
- module.exports = nodeUtil;
- }, "/$$rollup_base$$/node_modules/lodash");
-
- /* Node.js helper references. */
- var nodeIsTypedArray = _nodeUtil && _nodeUtil.isTypedArray;
-
- /**
- * Checks if `value` is classified as a typed array.
- *
- * @static
- * @memberOf _
- * @since 3.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
- * @example
- *
- * _.isTypedArray(new Uint8Array);
- * // => true
- *
- * _.isTypedArray([]);
- * // => false
- */
- var isTypedArray = nodeIsTypedArray ? _baseUnary(nodeIsTypedArray) : _baseIsTypedArray;
-
- var isTypedArray_1 = isTypedArray;
-
- /** Used for built-in method references. */
- var objectProto$a = Object.prototype;
-
- /** Used to check objects for own properties. */
- var hasOwnProperty$8 = objectProto$a.hasOwnProperty;
-
- /**
- * Creates an array of the enumerable property names of the array-like `value`.
- *
- * @private
- * @param {*} value The value to query.
- * @param {boolean} inherited Specify returning inherited property names.
- * @returns {Array} Returns the array of property names.
- */
- function arrayLikeKeys(value, inherited) {
- var isArr = isArray_1(value),
- isArg = !isArr && isArguments_1(value),
- isBuff = !isArr && !isArg && isBuffer_1(value),
- isType = !isArr && !isArg && !isBuff && isTypedArray_1(value),
- skipIndexes = isArr || isArg || isBuff || isType,
- result = skipIndexes ? _baseTimes(value.length, String) : [],
- length = result.length;
-
- for (var key in value) {
- if ((inherited || hasOwnProperty$8.call(value, key)) &&
- !(skipIndexes && (
- // Safari 9 has enumerable `arguments.length` in strict mode.
- key == 'length' ||
- // Node.js 0.10 has enumerable non-index properties on buffers.
- (isBuff && (key == 'offset' || key == 'parent')) ||
- // PhantomJS 2 has enumerable non-index properties on typed arrays.
- (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
- // Skip index properties.
- _isIndex(key, length)
- ))) {
- result.push(key);
- }
- }
- return result;
- }
-
- var _arrayLikeKeys = arrayLikeKeys;
-
- /** Used for built-in method references. */
- var objectProto$9 = Object.prototype;
-
- /**
- * Checks if `value` is likely a prototype object.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
- */
- function isPrototype(value) {
- var Ctor = value && value.constructor,
- proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$9;
-
- return value === proto;
- }
-
- var _isPrototype = isPrototype;
-
- /**
- * Creates a unary function that invokes `func` with its argument transformed.
- *
- * @private
- * @param {Function} func The function to wrap.
- * @param {Function} transform The argument transform.
- * @returns {Function} Returns the new function.
- */
- function overArg(func, transform) {
- return function(arg) {
- return func(transform(arg));
- };
- }
-
- var _overArg = overArg;
-
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeKeys = _overArg(Object.keys, Object);
-
- var _nativeKeys = nativeKeys;
-
- /** Used for built-in method references. */
- var objectProto$8 = Object.prototype;
-
- /** Used to check objects for own properties. */
- var hasOwnProperty$7 = objectProto$8.hasOwnProperty;
-
- /**
- * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property names.
- */
- function baseKeys(object) {
- if (!_isPrototype(object)) {
- return _nativeKeys(object);
- }
- var result = [];
- for (var key in Object(object)) {
- if (hasOwnProperty$7.call(object, key) && key != 'constructor') {
- result.push(key);
- }
- }
- return result;
- }
-
- var _baseKeys = baseKeys;
-
- /**
- * Checks if `value` is array-like. A value is considered array-like if it's
- * not a function and has a `value.length` that's an integer greater than or
- * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
- * @example
- *
- * _.isArrayLike([1, 2, 3]);
- * // => true
- *
- * _.isArrayLike(document.body.children);
- * // => true
- *
- * _.isArrayLike('abc');
- * // => true
- *
- * _.isArrayLike(_.noop);
- * // => false
- */
- function isArrayLike(value) {
- return value != null && isLength_1(value.length) && !isFunction_1(value);
- }
-
- var isArrayLike_1 = isArrayLike;
-
- /**
- * Creates an array of the own enumerable property names of `object`.
- *
- * **Note:** Non-object values are coerced to objects. See the
- * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
- * for more details.
- *
- * @static
- * @since 0.1.0
- * @memberOf _
- * @category Object
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property names.
- * @example
- *
- * function Foo() {
- * this.a = 1;
- * this.b = 2;
- * }
- *
- * Foo.prototype.c = 3;
- *
- * _.keys(new Foo);
- * // => ['a', 'b'] (iteration order is not guaranteed)
- *
- * _.keys('hi');
- * // => ['0', '1']
- */
- function keys(object) {
- return isArrayLike_1(object) ? _arrayLikeKeys(object) : _baseKeys(object);
- }
-
- var keys_1 = keys;
-
- /**
- * The base implementation of `_.assign` without support for multiple sources
- * or `customizer` functions.
- *
- * @private
- * @param {Object} object The destination object.
- * @param {Object} source The source object.
- * @returns {Object} Returns `object`.
- */
- function baseAssign(object, source) {
- return object && _copyObject(source, keys_1(source), object);
- }
-
- var _baseAssign = baseAssign;
-
- /**
- * Removes all key-value entries from the list cache.
- *
- * @private
- * @name clear
- * @memberOf ListCache
- */
- function listCacheClear() {
- this.__data__ = [];
- this.size = 0;
- }
-
- var _listCacheClear = listCacheClear;
-
- /**
- * Gets the index at which the `key` is found in `array` of key-value pairs.
- *
- * @private
- * @param {Array} array The array to inspect.
- * @param {*} key The key to search for.
- * @returns {number} Returns the index of the matched value, else `-1`.
- */
- function assocIndexOf(array, key) {
- var length = array.length;
- while (length--) {
- if (eq_1(array[length][0], key)) {
- return length;
- }
- }
- return -1;
- }
-
- var _assocIndexOf = assocIndexOf;
-
- /** Used for built-in method references. */
- var arrayProto = Array.prototype;
-
- /** Built-in value references. */
- var splice = arrayProto.splice;
-
- /**
- * Removes `key` and its value from the list cache.
- *
- * @private
- * @name delete
- * @memberOf ListCache
- * @param {string} key The key of the value to remove.
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
- */
- function listCacheDelete(key) {
- var data = this.__data__,
- index = _assocIndexOf(data, key);
-
- if (index < 0) {
- return false;
- }
- var lastIndex = data.length - 1;
- if (index == lastIndex) {
- data.pop();
- } else {
- splice.call(data, index, 1);
- }
- --this.size;
- return true;
- }
-
- var _listCacheDelete = listCacheDelete;
-
- /**
- * Gets the list cache value for `key`.
- *
- * @private
- * @name get
- * @memberOf ListCache
- * @param {string} key The key of the value to get.
- * @returns {*} Returns the entry value.
- */
- function listCacheGet(key) {
- var data = this.__data__,
- index = _assocIndexOf(data, key);
-
- return index < 0 ? undefined : data[index][1];
- }
-
- var _listCacheGet = listCacheGet;
-
- /**
- * Checks if a list cache value for `key` exists.
- *
- * @private
- * @name has
- * @memberOf ListCache
- * @param {string} key The key of the entry to check.
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
- */
- function listCacheHas(key) {
- return _assocIndexOf(this.__data__, key) > -1;
- }
-
- var _listCacheHas = listCacheHas;
-
- /**
- * Sets the list cache `key` to `value`.
- *
- * @private
- * @name set
- * @memberOf ListCache
- * @param {string} key The key of the value to set.
- * @param {*} value The value to set.
- * @returns {Object} Returns the list cache instance.
- */
- function listCacheSet(key, value) {
- var data = this.__data__,
- index = _assocIndexOf(data, key);
-
- if (index < 0) {
- ++this.size;
- data.push([key, value]);
- } else {
- data[index][1] = value;
- }
- return this;
- }
-
- var _listCacheSet = listCacheSet;
-
- /**
- * Creates an list cache object.
- *
- * @private
- * @constructor
- * @param {Array} [entries] The key-value pairs to cache.
- */
- function ListCache(entries) {
- var index = -1,
- length = entries == null ? 0 : entries.length;
-
- this.clear();
- while (++index < length) {
- var entry = entries[index];
- this.set(entry[0], entry[1]);
- }
- }
-
- // Add methods to `ListCache`.
- ListCache.prototype.clear = _listCacheClear;
- ListCache.prototype['delete'] = _listCacheDelete;
- ListCache.prototype.get = _listCacheGet;
- ListCache.prototype.has = _listCacheHas;
- ListCache.prototype.set = _listCacheSet;
-
- var _ListCache = ListCache;
-
- /**
- * Removes all key-value entries from the stack.
- *
- * @private
- * @name clear
- * @memberOf Stack
- */
- function stackClear() {
- this.__data__ = new _ListCache;
- this.size = 0;
- }
-
- var _stackClear = stackClear;
-
- /**
- * Removes `key` and its value from the stack.
- *
- * @private
- * @name delete
- * @memberOf Stack
- * @param {string} key The key of the value to remove.
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
- */
- function stackDelete(key) {
- var data = this.__data__,
- result = data['delete'](key);
-
- this.size = data.size;
- return result;
- }
-
- var _stackDelete = stackDelete;
-
- /**
- * Gets the stack value for `key`.
- *
- * @private
- * @name get
- * @memberOf Stack
- * @param {string} key The key of the value to get.
- * @returns {*} Returns the entry value.
- */
- function stackGet(key) {
- return this.__data__.get(key);
- }
-
- var _stackGet = stackGet;
-
- /**
- * Checks if a stack value for `key` exists.
- *
- * @private
- * @name has
- * @memberOf Stack
- * @param {string} key The key of the entry to check.
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
- */
- function stackHas(key) {
- return this.__data__.has(key);
- }
-
- var _stackHas = stackHas;
-
- /* Built-in method references that are verified to be native. */
- var Map$1 = _getNative(_root, 'Map');
-
- var _Map = Map$1;
-
- /* Built-in method references that are verified to be native. */
- var nativeCreate = _getNative(Object, 'create');
-
- var _nativeCreate = nativeCreate;
-
- /**
- * Removes all key-value entries from the hash.
- *
- * @private
- * @name clear
- * @memberOf Hash
- */
- function hashClear() {
- this.__data__ = _nativeCreate ? _nativeCreate(null) : {};
- this.size = 0;
- }
-
- var _hashClear = hashClear;
-
- /**
- * Removes `key` and its value from the hash.
- *
- * @private
- * @name delete
- * @memberOf Hash
- * @param {Object} hash The hash to modify.
- * @param {string} key The key of the value to remove.
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
- */
- function hashDelete(key) {
- var result = this.has(key) && delete this.__data__[key];
- this.size -= result ? 1 : 0;
- return result;
- }
-
- var _hashDelete = hashDelete;
-
- /** Used to stand-in for `undefined` hash values. */
- var HASH_UNDEFINED$2 = '__lodash_hash_undefined__';
-
- /** Used for built-in method references. */
- var objectProto$7 = Object.prototype;
-
- /** Used to check objects for own properties. */
- var hasOwnProperty$6 = objectProto$7.hasOwnProperty;
-
- /**
- * Gets the hash value for `key`.
- *
- * @private
- * @name get
- * @memberOf Hash
- * @param {string} key The key of the value to get.
- * @returns {*} Returns the entry value.
- */
- function hashGet(key) {
- var data = this.__data__;
- if (_nativeCreate) {
- var result = data[key];
- return result === HASH_UNDEFINED$2 ? undefined : result;
- }
- return hasOwnProperty$6.call(data, key) ? data[key] : undefined;
- }
-
- var _hashGet = hashGet;
-
- /** Used for built-in method references. */
- var objectProto$6 = Object.prototype;
-
- /** Used to check objects for own properties. */
- var hasOwnProperty$5 = objectProto$6.hasOwnProperty;
-
- /**
- * Checks if a hash value for `key` exists.
- *
- * @private
- * @name has
- * @memberOf Hash
- * @param {string} key The key of the entry to check.
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
- */
- function hashHas(key) {
- var data = this.__data__;
- return _nativeCreate ? (data[key] !== undefined) : hasOwnProperty$5.call(data, key);
- }
-
- var _hashHas = hashHas;
-
- /** Used to stand-in for `undefined` hash values. */
- var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
-
- /**
- * Sets the hash `key` to `value`.
- *
- * @private
- * @name set
- * @memberOf Hash
- * @param {string} key The key of the value to set.
- * @param {*} value The value to set.
- * @returns {Object} Returns the hash instance.
- */
- function hashSet(key, value) {
- var data = this.__data__;
- this.size += this.has(key) ? 0 : 1;
- data[key] = (_nativeCreate && value === undefined) ? HASH_UNDEFINED$1 : value;
- return this;
- }
-
- var _hashSet = hashSet;
-
- /**
- * Creates a hash object.
- *
- * @private
- * @constructor
- * @param {Array} [entries] The key-value pairs to cache.
- */
- function Hash(entries) {
- var index = -1,
- length = entries == null ? 0 : entries.length;
-
- this.clear();
- while (++index < length) {
- var entry = entries[index];
- this.set(entry[0], entry[1]);
- }
- }
-
- // Add methods to `Hash`.
- Hash.prototype.clear = _hashClear;
- Hash.prototype['delete'] = _hashDelete;
- Hash.prototype.get = _hashGet;
- Hash.prototype.has = _hashHas;
- Hash.prototype.set = _hashSet;
-
- var _Hash = Hash;
-
- /**
- * Removes all key-value entries from the map.
- *
- * @private
- * @name clear
- * @memberOf MapCache
- */
- function mapCacheClear() {
- this.size = 0;
- this.__data__ = {
- 'hash': new _Hash,
- 'map': new (_Map || _ListCache),
- 'string': new _Hash
- };
- }
-
- var _mapCacheClear = mapCacheClear;
-
- /**
- * Checks if `value` is suitable for use as unique object key.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
- */
- function isKeyable(value) {
- var type = typeof value;
- return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
- ? (value !== '__proto__')
- : (value === null);
- }
-
- var _isKeyable = isKeyable;
-
- /**
- * Gets the data for `map`.
- *
- * @private
- * @param {Object} map The map to query.
- * @param {string} key The reference key.
- * @returns {*} Returns the map data.
- */
- function getMapData(map, key) {
- var data = map.__data__;
- return _isKeyable(key)
- ? data[typeof key == 'string' ? 'string' : 'hash']
- : data.map;
- }
-
- var _getMapData = getMapData;
-
- /**
- * Removes `key` and its value from the map.
- *
- * @private
- * @name delete
- * @memberOf MapCache
- * @param {string} key The key of the value to remove.
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
- */
- function mapCacheDelete(key) {
- var result = _getMapData(this, key)['delete'](key);
- this.size -= result ? 1 : 0;
- return result;
- }
-
- var _mapCacheDelete = mapCacheDelete;
-
- /**
- * Gets the map value for `key`.
- *
- * @private
- * @name get
- * @memberOf MapCache
- * @param {string} key The key of the value to get.
- * @returns {*} Returns the entry value.
- */
- function mapCacheGet(key) {
- return _getMapData(this, key).get(key);
- }
-
- var _mapCacheGet = mapCacheGet;
-
- /**
- * Checks if a map value for `key` exists.
- *
- * @private
- * @name has
- * @memberOf MapCache
- * @param {string} key The key of the entry to check.
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
- */
- function mapCacheHas(key) {
- return _getMapData(this, key).has(key);
- }
-
- var _mapCacheHas = mapCacheHas;
-
- /**
- * Sets the map `key` to `value`.
- *
- * @private
- * @name set
- * @memberOf MapCache
- * @param {string} key The key of the value to set.
- * @param {*} value The value to set.
- * @returns {Object} Returns the map cache instance.
- */
- function mapCacheSet(key, value) {
- var data = _getMapData(this, key),
- size = data.size;
-
- data.set(key, value);
- this.size += data.size == size ? 0 : 1;
- return this;
- }
-
- var _mapCacheSet = mapCacheSet;
-
- /**
- * Creates a map cache object to store key-value pairs.
- *
- * @private
- * @constructor
- * @param {Array} [entries] The key-value pairs to cache.
- */
- function MapCache(entries) {
- var index = -1,
- length = entries == null ? 0 : entries.length;
-
- this.clear();
- while (++index < length) {
- var entry = entries[index];
- this.set(entry[0], entry[1]);
- }
- }
-
- // Add methods to `MapCache`.
- MapCache.prototype.clear = _mapCacheClear;
- MapCache.prototype['delete'] = _mapCacheDelete;
- MapCache.prototype.get = _mapCacheGet;
- MapCache.prototype.has = _mapCacheHas;
- MapCache.prototype.set = _mapCacheSet;
-
- var _MapCache = MapCache;
-
- /** Used as the size to enable large array optimizations. */
- var LARGE_ARRAY_SIZE = 200;
-
- /**
- * Sets the stack `key` to `value`.
- *
- * @private
- * @name set
- * @memberOf Stack
- * @param {string} key The key of the value to set.
- * @param {*} value The value to set.
- * @returns {Object} Returns the stack cache instance.
- */
- function stackSet(key, value) {
- var data = this.__data__;
- if (data instanceof _ListCache) {
- var pairs = data.__data__;
- if (!_Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
- pairs.push([key, value]);
- this.size = ++data.size;
- return this;
- }
- data = this.__data__ = new _MapCache(pairs);
- }
- data.set(key, value);
- this.size = data.size;
- return this;
- }
-
- var _stackSet = stackSet;
-
- /**
- * Creates a stack cache object to store key-value pairs.
- *
- * @private
- * @constructor
- * @param {Array} [entries] The key-value pairs to cache.
- */
- function Stack(entries) {
- var data = this.__data__ = new _ListCache(entries);
- this.size = data.size;
- }
-
- // Add methods to `Stack`.
- Stack.prototype.clear = _stackClear;
- Stack.prototype['delete'] = _stackDelete;
- Stack.prototype.get = _stackGet;
- Stack.prototype.has = _stackHas;
- Stack.prototype.set = _stackSet;
-
- var _Stack = Stack;
-
- /**
- * This function is like
- * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
- * except that it includes inherited enumerable properties.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property names.
- */
- function nativeKeysIn(object) {
- var result = [];
- if (object != null) {
- for (var key in Object(object)) {
- result.push(key);
- }
- }
- return result;
- }
-
- var _nativeKeysIn = nativeKeysIn;
-
- /** Used for built-in method references. */
- var objectProto$5 = Object.prototype;
-
- /** Used to check objects for own properties. */
- var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
-
- /**
- * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property names.
- */
- function baseKeysIn(object) {
- if (!isObject_1(object)) {
- return _nativeKeysIn(object);
- }
- var isProto = _isPrototype(object),
- result = [];
-
- for (var key in object) {
- if (!(key == 'constructor' && (isProto || !hasOwnProperty$4.call(object, key)))) {
- result.push(key);
- }
- }
- return result;
- }
-
- var _baseKeysIn = baseKeysIn;
-
- /**
- * Creates an array of the own and inherited enumerable property names of `object`.
- *
- * **Note:** Non-object values are coerced to objects.
- *
- * @static
- * @memberOf _
- * @since 3.0.0
- * @category Object
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property names.
- * @example
- *
- * function Foo() {
- * this.a = 1;
- * this.b = 2;
- * }
- *
- * Foo.prototype.c = 3;
- *
- * _.keysIn(new Foo);
- * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
- */
- function keysIn(object) {
- return isArrayLike_1(object) ? _arrayLikeKeys(object, true) : _baseKeysIn(object);
- }
-
- var keysIn_1 = keysIn;
-
- /**
- * The base implementation of `_.assignIn` without support for multiple sources
- * or `customizer` functions.
- *
- * @private
- * @param {Object} object The destination object.
- * @param {Object} source The source object.
- * @returns {Object} Returns `object`.
- */
- function baseAssignIn(object, source) {
- return object && _copyObject(source, keysIn_1(source), object);
- }
-
- var _baseAssignIn = baseAssignIn;
-
- var _cloneBuffer = createCommonjsModule(function (module, exports) {
- /** Detect free variable `exports`. */
- var freeExports = exports && !exports.nodeType && exports;
-
- /** Detect free variable `module`. */
- var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
-
- /** Detect the popular CommonJS extension `module.exports`. */
- var moduleExports = freeModule && freeModule.exports === freeExports;
-
- /** Built-in value references. */
- var Buffer = moduleExports ? _root.Buffer : undefined,
- allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined;
-
- /**
- * Creates a clone of `buffer`.
- *
- * @private
- * @param {Buffer} buffer The buffer to clone.
- * @param {boolean} [isDeep] Specify a deep clone.
- * @returns {Buffer} Returns the cloned buffer.
- */
- function cloneBuffer(buffer, isDeep) {
- if (isDeep) {
- return buffer.slice();
- }
- var length = buffer.length,
- result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
-
- buffer.copy(result);
- return result;
- }
-
- module.exports = cloneBuffer;
- }, "/$$rollup_base$$/node_modules/lodash");
-
- /**
- * A specialized version of `_.filter` for arrays without support for
- * iteratee shorthands.
- *
- * @private
- * @param {Array} [array] The array to iterate over.
- * @param {Function} predicate The function invoked per iteration.
- * @returns {Array} Returns the new filtered array.
- */
- function arrayFilter(array, predicate) {
- var index = -1,
- length = array == null ? 0 : array.length,
- resIndex = 0,
- result = [];
-
- while (++index < length) {
- var value = array[index];
- if (predicate(value, index, array)) {
- result[resIndex++] = value;
- }
- }
- return result;
- }
-
- var _arrayFilter = arrayFilter;
-
- /**
- * This method returns a new empty array.
- *
- * @static
- * @memberOf _
- * @since 4.13.0
- * @category Util
- * @returns {Array} Returns the new empty array.
- * @example
- *
- * var arrays = _.times(2, _.stubArray);
- *
- * console.log(arrays);
- * // => [[], []]
- *
- * console.log(arrays[0] === arrays[1]);
- * // => false
- */
- function stubArray() {
- return [];
- }
-
- var stubArray_1 = stubArray;
-
- /** Used for built-in method references. */
- var objectProto$4 = Object.prototype;
-
- /** Built-in value references. */
- var propertyIsEnumerable = objectProto$4.propertyIsEnumerable;
-
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeGetSymbols$1 = Object.getOwnPropertySymbols;
-
- /**
- * Creates an array of the own enumerable symbols of `object`.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of symbols.
- */
- var getSymbols = !nativeGetSymbols$1 ? stubArray_1 : function(object) {
- if (object == null) {
- return [];
- }
- object = Object(object);
- return _arrayFilter(nativeGetSymbols$1(object), function(symbol) {
- return propertyIsEnumerable.call(object, symbol);
- });
- };
-
- var _getSymbols = getSymbols;
-
- /**
- * Copies own symbols of `source` to `object`.
- *
- * @private
- * @param {Object} source The object to copy symbols from.
- * @param {Object} [object={}] The object to copy symbols to.
- * @returns {Object} Returns `object`.
- */
- function copySymbols(source, object) {
- return _copyObject(source, _getSymbols(source), object);
- }
-
- var _copySymbols = copySymbols;
-
- /**
- * Appends the elements of `values` to `array`.
- *
- * @private
- * @param {Array} array The array to modify.
- * @param {Array} values The values to append.
- * @returns {Array} Returns `array`.
- */
- function arrayPush(array, values) {
- var index = -1,
- length = values.length,
- offset = array.length;
-
- while (++index < length) {
- array[offset + index] = values[index];
- }
- return array;
- }
-
- var _arrayPush = arrayPush;
-
- /** Built-in value references. */
- var getPrototype = _overArg(Object.getPrototypeOf, Object);
-
- var _getPrototype = getPrototype;
-
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeGetSymbols = Object.getOwnPropertySymbols;
-
- /**
- * Creates an array of the own and inherited enumerable symbols of `object`.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of symbols.
- */
- var getSymbolsIn = !nativeGetSymbols ? stubArray_1 : function(object) {
- var result = [];
- while (object) {
- _arrayPush(result, _getSymbols(object));
- object = _getPrototype(object);
- }
- return result;
- };
-
- var _getSymbolsIn = getSymbolsIn;
-
- /**
- * Copies own and inherited symbols of `source` to `object`.
- *
- * @private
- * @param {Object} source The object to copy symbols from.
- * @param {Object} [object={}] The object to copy symbols to.
- * @returns {Object} Returns `object`.
- */
- function copySymbolsIn(source, object) {
- return _copyObject(source, _getSymbolsIn(source), object);
- }
-
- var _copySymbolsIn = copySymbolsIn;
-
- /**
- * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
- * `keysFunc` and `symbolsFunc` to get the enumerable property names and
- * symbols of `object`.
- *
- * @private
- * @param {Object} object The object to query.
- * @param {Function} keysFunc The function to get the keys of `object`.
- * @param {Function} symbolsFunc The function to get the symbols of `object`.
- * @returns {Array} Returns the array of property names and symbols.
- */
- function baseGetAllKeys(object, keysFunc, symbolsFunc) {
- var result = keysFunc(object);
- return isArray_1(object) ? result : _arrayPush(result, symbolsFunc(object));
- }
-
- var _baseGetAllKeys = baseGetAllKeys;
-
- /**
- * Creates an array of own enumerable property names and symbols of `object`.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property names and symbols.
- */
- function getAllKeys(object) {
- return _baseGetAllKeys(object, keys_1, _getSymbols);
- }
-
- var _getAllKeys = getAllKeys;
-
- /**
- * Creates an array of own and inherited enumerable property names and
- * symbols of `object`.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property names and symbols.
- */
- function getAllKeysIn(object) {
- return _baseGetAllKeys(object, keysIn_1, _getSymbolsIn);
- }
-
- var _getAllKeysIn = getAllKeysIn;
-
- /* Built-in method references that are verified to be native. */
- var DataView = _getNative(_root, 'DataView');
-
- var _DataView = DataView;
-
- /* Built-in method references that are verified to be native. */
- var Promise$1 = _getNative(_root, 'Promise');
-
- var _Promise = Promise$1;
-
- /* Built-in method references that are verified to be native. */
- var Set$1 = _getNative(_root, 'Set');
-
- var _Set = Set$1;
-
- /** `Object#toString` result references. */
- var mapTag$4 = '[object Map]',
- objectTag$3 = '[object Object]',
- promiseTag = '[object Promise]',
- setTag$4 = '[object Set]',
- weakMapTag$2 = '[object WeakMap]';
-
- var dataViewTag$3 = '[object DataView]';
-
- /** Used to detect maps, sets, and weakmaps. */
- var dataViewCtorString = _toSource(_DataView),
- mapCtorString = _toSource(_Map),
- promiseCtorString = _toSource(_Promise),
- setCtorString = _toSource(_Set),
- weakMapCtorString = _toSource(_WeakMap);
-
- /**
- * Gets the `toStringTag` of `value`.
- *
- * @private
- * @param {*} value The value to query.
- * @returns {string} Returns the `toStringTag`.
- */
- var getTag = _baseGetTag;
-
- // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
- if ((_DataView && getTag(new _DataView(new ArrayBuffer(1))) != dataViewTag$3) ||
- (_Map && getTag(new _Map) != mapTag$4) ||
- (_Promise && getTag(_Promise.resolve()) != promiseTag) ||
- (_Set && getTag(new _Set) != setTag$4) ||
- (_WeakMap && getTag(new _WeakMap) != weakMapTag$2)) {
- getTag = function(value) {
- var result = _baseGetTag(value),
- Ctor = result == objectTag$3 ? value.constructor : undefined,
- ctorString = Ctor ? _toSource(Ctor) : '';
-
- if (ctorString) {
- switch (ctorString) {
- case dataViewCtorString: return dataViewTag$3;
- case mapCtorString: return mapTag$4;
- case promiseCtorString: return promiseTag;
- case setCtorString: return setTag$4;
- case weakMapCtorString: return weakMapTag$2;
- }
- }
- return result;
- };
- }
-
- var _getTag = getTag;
-
- /** Used for built-in method references. */
- var objectProto$3 = Object.prototype;
-
- /** Used to check objects for own properties. */
- var hasOwnProperty$3 = objectProto$3.hasOwnProperty;
-
- /**
- * Initializes an array clone.
- *
- * @private
- * @param {Array} array The array to clone.
- * @returns {Array} Returns the initialized clone.
- */
- function initCloneArray(array) {
- var length = array.length,
- result = new array.constructor(length);
-
- // Add properties assigned by `RegExp#exec`.
- if (length && typeof array[0] == 'string' && hasOwnProperty$3.call(array, 'index')) {
- result.index = array.index;
- result.input = array.input;
- }
- return result;
- }
-
- var _initCloneArray = initCloneArray;
-
- /** Built-in value references. */
- var Uint8Array = _root.Uint8Array;
-
- var _Uint8Array = Uint8Array;
-
- /**
- * Creates a clone of `arrayBuffer`.
- *
- * @private
- * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
- * @returns {ArrayBuffer} Returns the cloned array buffer.
- */
- function cloneArrayBuffer(arrayBuffer) {
- var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
- new _Uint8Array(result).set(new _Uint8Array(arrayBuffer));
- return result;
- }
-
- var _cloneArrayBuffer = cloneArrayBuffer;
-
- /**
- * Creates a clone of `dataView`.
- *
- * @private
- * @param {Object} dataView The data view to clone.
- * @param {boolean} [isDeep] Specify a deep clone.
- * @returns {Object} Returns the cloned data view.
- */
- function cloneDataView(dataView, isDeep) {
- var buffer = isDeep ? _cloneArrayBuffer(dataView.buffer) : dataView.buffer;
- return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
- }
-
- var _cloneDataView = cloneDataView;
-
- /** Used to match `RegExp` flags from their coerced string values. */
- var reFlags = /\w*$/;
-
- /**
- * Creates a clone of `regexp`.
- *
- * @private
- * @param {Object} regexp The regexp to clone.
- * @returns {Object} Returns the cloned regexp.
- */
- function cloneRegExp(regexp) {
- var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
- result.lastIndex = regexp.lastIndex;
- return result;
- }
-
- var _cloneRegExp = cloneRegExp;
-
- /** Used to convert symbols to primitives and strings. */
- var symbolProto$2 = _Symbol ? _Symbol.prototype : undefined,
- symbolValueOf$1 = symbolProto$2 ? symbolProto$2.valueOf : undefined;
-
- /**
- * Creates a clone of the `symbol` object.
- *
- * @private
- * @param {Object} symbol The symbol object to clone.
- * @returns {Object} Returns the cloned symbol object.
- */
- function cloneSymbol(symbol) {
- return symbolValueOf$1 ? Object(symbolValueOf$1.call(symbol)) : {};
- }
-
- var _cloneSymbol = cloneSymbol;
-
- /**
- * Creates a clone of `typedArray`.
- *
- * @private
- * @param {Object} typedArray The typed array to clone.
- * @param {boolean} [isDeep] Specify a deep clone.
- * @returns {Object} Returns the cloned typed array.
- */
- function cloneTypedArray(typedArray, isDeep) {
- var buffer = isDeep ? _cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
- return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
- }
-
- var _cloneTypedArray = cloneTypedArray;
-
- /** `Object#toString` result references. */
- var boolTag$2 = '[object Boolean]',
- dateTag$2 = '[object Date]',
- mapTag$3 = '[object Map]',
- numberTag$2 = '[object Number]',
- regexpTag$2 = '[object RegExp]',
- setTag$3 = '[object Set]',
- stringTag$2 = '[object String]',
- symbolTag$2 = '[object Symbol]';
-
- var arrayBufferTag$2 = '[object ArrayBuffer]',
- dataViewTag$2 = '[object DataView]',
- float32Tag$1 = '[object Float32Array]',
- float64Tag$1 = '[object Float64Array]',
- int8Tag$1 = '[object Int8Array]',
- int16Tag$1 = '[object Int16Array]',
- int32Tag$1 = '[object Int32Array]',
- uint8Tag$1 = '[object Uint8Array]',
- uint8ClampedTag$1 = '[object Uint8ClampedArray]',
- uint16Tag$1 = '[object Uint16Array]',
- uint32Tag$1 = '[object Uint32Array]';
-
- /**
- * Initializes an object clone based on its `toStringTag`.
- *
- * **Note:** This function only supports cloning values with tags of
- * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
- *
- * @private
- * @param {Object} object The object to clone.
- * @param {string} tag The `toStringTag` of the object to clone.
- * @param {boolean} [isDeep] Specify a deep clone.
- * @returns {Object} Returns the initialized clone.
- */
- function initCloneByTag(object, tag, isDeep) {
- var Ctor = object.constructor;
- switch (tag) {
- case arrayBufferTag$2:
- return _cloneArrayBuffer(object);
-
- case boolTag$2:
- case dateTag$2:
- return new Ctor(+object);
-
- case dataViewTag$2:
- return _cloneDataView(object, isDeep);
-
- case float32Tag$1: case float64Tag$1:
- case int8Tag$1: case int16Tag$1: case int32Tag$1:
- case uint8Tag$1: case uint8ClampedTag$1: case uint16Tag$1: case uint32Tag$1:
- return _cloneTypedArray(object, isDeep);
-
- case mapTag$3:
- return new Ctor;
-
- case numberTag$2:
- case stringTag$2:
- return new Ctor(object);
-
- case regexpTag$2:
- return _cloneRegExp(object);
-
- case setTag$3:
- return new Ctor;
-
- case symbolTag$2:
- return _cloneSymbol(object);
- }
- }
-
- var _initCloneByTag = initCloneByTag;
-
- /**
- * Initializes an object clone.
- *
- * @private
- * @param {Object} object The object to clone.
- * @returns {Object} Returns the initialized clone.
- */
- function initCloneObject(object) {
- return (typeof object.constructor == 'function' && !_isPrototype(object))
- ? _baseCreate(_getPrototype(object))
- : {};
- }
-
- var _initCloneObject = initCloneObject;
-
- /** `Object#toString` result references. */
- var mapTag$2 = '[object Map]';
-
- /**
- * The base implementation of `_.isMap` without Node.js optimizations.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a map, else `false`.
- */
- function baseIsMap(value) {
- return isObjectLike_1(value) && _getTag(value) == mapTag$2;
- }
-
- var _baseIsMap = baseIsMap;
-
- /* Node.js helper references. */
- var nodeIsMap = _nodeUtil && _nodeUtil.isMap;
-
- /**
- * Checks if `value` is classified as a `Map` object.
- *
- * @static
- * @memberOf _
- * @since 4.3.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a map, else `false`.
- * @example
- *
- * _.isMap(new Map);
- * // => true
- *
- * _.isMap(new WeakMap);
- * // => false
- */
- var isMap = nodeIsMap ? _baseUnary(nodeIsMap) : _baseIsMap;
-
- var isMap_1 = isMap;
-
- /** `Object#toString` result references. */
- var setTag$2 = '[object Set]';
-
- /**
- * The base implementation of `_.isSet` without Node.js optimizations.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a set, else `false`.
- */
- function baseIsSet(value) {
- return isObjectLike_1(value) && _getTag(value) == setTag$2;
- }
-
- var _baseIsSet = baseIsSet;
-
- /* Node.js helper references. */
- var nodeIsSet = _nodeUtil && _nodeUtil.isSet;
-
- /**
- * Checks if `value` is classified as a `Set` object.
- *
- * @static
- * @memberOf _
- * @since 4.3.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a set, else `false`.
- * @example
- *
- * _.isSet(new Set);
- * // => true
- *
- * _.isSet(new WeakSet);
- * // => false
- */
- var isSet = nodeIsSet ? _baseUnary(nodeIsSet) : _baseIsSet;
-
- var isSet_1 = isSet;
-
- /** Used to compose bitmasks for cloning. */
- var CLONE_DEEP_FLAG$1 = 1,
- CLONE_FLAT_FLAG = 2,
- CLONE_SYMBOLS_FLAG$1 = 4;
-
- /** `Object#toString` result references. */
- var argsTag$1 = '[object Arguments]',
- arrayTag$1 = '[object Array]',
- boolTag$1 = '[object Boolean]',
- dateTag$1 = '[object Date]',
- errorTag$2 = '[object Error]',
- funcTag = '[object Function]',
- genTag = '[object GeneratorFunction]',
- mapTag$1 = '[object Map]',
- numberTag$1 = '[object Number]',
- objectTag$2 = '[object Object]',
- regexpTag$1 = '[object RegExp]',
- setTag$1 = '[object Set]',
- stringTag$1 = '[object String]',
- symbolTag$1 = '[object Symbol]',
- weakMapTag$1 = '[object WeakMap]';
-
- var arrayBufferTag$1 = '[object ArrayBuffer]',
- dataViewTag$1 = '[object DataView]',
- float32Tag = '[object Float32Array]',
- float64Tag = '[object Float64Array]',
- int8Tag = '[object Int8Array]',
- int16Tag = '[object Int16Array]',
- int32Tag = '[object Int32Array]',
- uint8Tag = '[object Uint8Array]',
- uint8ClampedTag = '[object Uint8ClampedArray]',
- uint16Tag = '[object Uint16Array]',
- uint32Tag = '[object Uint32Array]';
-
- /** Used to identify `toStringTag` values supported by `_.clone`. */
- var cloneableTags = {};
- cloneableTags[argsTag$1] = cloneableTags[arrayTag$1] =
- cloneableTags[arrayBufferTag$1] = cloneableTags[dataViewTag$1] =
- cloneableTags[boolTag$1] = cloneableTags[dateTag$1] =
- cloneableTags[float32Tag] = cloneableTags[float64Tag] =
- cloneableTags[int8Tag] = cloneableTags[int16Tag] =
- cloneableTags[int32Tag] = cloneableTags[mapTag$1] =
- cloneableTags[numberTag$1] = cloneableTags[objectTag$2] =
- cloneableTags[regexpTag$1] = cloneableTags[setTag$1] =
- cloneableTags[stringTag$1] = cloneableTags[symbolTag$1] =
- cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
- cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
- cloneableTags[errorTag$2] = cloneableTags[funcTag] =
- cloneableTags[weakMapTag$1] = false;
-
- /**
- * The base implementation of `_.clone` and `_.cloneDeep` which tracks
- * traversed objects.
- *
- * @private
- * @param {*} value The value to clone.
- * @param {boolean} bitmask The bitmask flags.
- * 1 - Deep clone
- * 2 - Flatten inherited properties
- * 4 - Clone symbols
- * @param {Function} [customizer] The function to customize cloning.
- * @param {string} [key] The key of `value`.
- * @param {Object} [object] The parent object of `value`.
- * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
- * @returns {*} Returns the cloned value.
- */
- function baseClone(value, bitmask, customizer, key, object, stack) {
- var result,
- isDeep = bitmask & CLONE_DEEP_FLAG$1,
- isFlat = bitmask & CLONE_FLAT_FLAG,
- isFull = bitmask & CLONE_SYMBOLS_FLAG$1;
-
- if (customizer) {
- result = object ? customizer(value, key, object, stack) : customizer(value);
- }
- if (result !== undefined) {
- return result;
- }
- if (!isObject_1(value)) {
- return value;
- }
- var isArr = isArray_1(value);
- if (isArr) {
- result = _initCloneArray(value);
- if (!isDeep) {
- return _copyArray(value, result);
- }
- } else {
- var tag = _getTag(value),
- isFunc = tag == funcTag || tag == genTag;
-
- if (isBuffer_1(value)) {
- return _cloneBuffer(value, isDeep);
- }
- if (tag == objectTag$2 || tag == argsTag$1 || (isFunc && !object)) {
- result = (isFlat || isFunc) ? {} : _initCloneObject(value);
- if (!isDeep) {
- return isFlat
- ? _copySymbolsIn(value, _baseAssignIn(result, value))
- : _copySymbols(value, _baseAssign(result, value));
- }
- } else {
- if (!cloneableTags[tag]) {
- return object ? value : {};
- }
- result = _initCloneByTag(value, tag, isDeep);
- }
- }
- // Check for circular references and return its corresponding clone.
- stack || (stack = new _Stack);
- var stacked = stack.get(value);
- if (stacked) {
- return stacked;
- }
- stack.set(value, result);
-
- if (isSet_1(value)) {
- value.forEach(function(subValue) {
- result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
- });
- } else if (isMap_1(value)) {
- value.forEach(function(subValue, key) {
- result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
- });
- }
-
- var keysFunc = isFull
- ? (isFlat ? _getAllKeysIn : _getAllKeys)
- : (isFlat ? keysIn_1 : keys_1);
-
- var props = isArr ? undefined : keysFunc(value);
- _arrayEach(props || value, function(subValue, key) {
- if (props) {
- key = subValue;
- subValue = value[key];
- }
- // Recursively populate clone (susceptible to call stack limits).
- _assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
- });
- return result;
- }
-
- var _baseClone = baseClone;
-
- /** Used to compose bitmasks for cloning. */
- var CLONE_SYMBOLS_FLAG = 4;
-
- /**
- * Creates a shallow clone of `value`.
- *
- * **Note:** This method is loosely based on the
- * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
- * and supports cloning arrays, array buffers, booleans, date objects, maps,
- * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
- * arrays. The own enumerable properties of `arguments` objects are cloned
- * as plain objects. An empty object is returned for uncloneable values such
- * as error objects, functions, DOM nodes, and WeakMaps.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Lang
- * @param {*} value The value to clone.
- * @returns {*} Returns the cloned value.
- * @see _.cloneDeep
- * @example
- *
- * var objects = [{ 'a': 1 }, { 'b': 2 }];
- *
- * var shallow = _.clone(objects);
- * console.log(shallow[0] === objects[0]);
- * // => true
- */
- function clone(value) {
- return _baseClone(value, CLONE_SYMBOLS_FLAG);
- }
-
- var clone_1 = clone;
-
- /** `Object#toString` result references. */
- var objectTag$1 = '[object Object]';
-
- /** Used for built-in method references. */
- var funcProto = Function.prototype,
- objectProto$2 = Object.prototype;
-
- /** Used to resolve the decompiled source of functions. */
- var funcToString = funcProto.toString;
-
- /** Used to check objects for own properties. */
- var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
-
- /** Used to infer the `Object` constructor. */
- var objectCtorString = funcToString.call(Object);
-
- /**
- * Checks if `value` is a plain object, that is, an object created by the
- * `Object` constructor or one with a `[[Prototype]]` of `null`.
- *
- * @static
- * @memberOf _
- * @since 0.8.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
- * @example
- *
- * function Foo() {
- * this.a = 1;
- * }
- *
- * _.isPlainObject(new Foo);
- * // => false
- *
- * _.isPlainObject([1, 2, 3]);
- * // => false
- *
- * _.isPlainObject({ 'x': 0, 'y': 0 });
- * // => true
- *
- * _.isPlainObject(Object.create(null));
- * // => true
- */
- function isPlainObject(value) {
- if (!isObjectLike_1(value) || _baseGetTag(value) != objectTag$1) {
- return false;
- }
- var proto = _getPrototype(value);
- if (proto === null) {
- return true;
- }
- var Ctor = hasOwnProperty$2.call(proto, 'constructor') && proto.constructor;
- return typeof Ctor == 'function' && Ctor instanceof Ctor &&
- funcToString.call(Ctor) == objectCtorString;
- }
-
- var isPlainObject_1 = isPlainObject;
-
- /** `Object#toString` result references. */
- var domExcTag = '[object DOMException]',
- errorTag$1 = '[object Error]';
-
- /**
- * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
- * `SyntaxError`, `TypeError`, or `URIError` object.
- *
- * @static
- * @memberOf _
- * @since 3.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
- * @example
- *
- * _.isError(new Error);
- * // => true
- *
- * _.isError(Error);
- * // => false
- */
- function isError(value) {
- if (!isObjectLike_1(value)) {
- return false;
- }
- var tag = _baseGetTag(value);
- return tag == errorTag$1 || tag == domExcTag ||
- (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject_1(value));
- }
-
- var isError_1 = isError;
-
- /** `Object#toString` result references. */
- var weakMapTag = '[object WeakMap]';
-
- /**
- * Checks if `value` is classified as a `WeakMap` object.
- *
- * @static
- * @memberOf _
- * @since 4.3.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
- * @example
- *
- * _.isWeakMap(new WeakMap);
- * // => true
- *
- * _.isWeakMap(new Map);
- * // => false
- */
- function isWeakMap(value) {
- return isObjectLike_1(value) && _getTag(value) == weakMapTag;
- }
-
- var isWeakMap_1 = isWeakMap;
-
- /** Used to stand-in for `undefined` hash values. */
- var HASH_UNDEFINED = '__lodash_hash_undefined__';
-
- /**
- * Adds `value` to the array cache.
- *
- * @private
- * @name add
- * @memberOf SetCache
- * @alias push
- * @param {*} value The value to cache.
- * @returns {Object} Returns the cache instance.
- */
- function setCacheAdd(value) {
- this.__data__.set(value, HASH_UNDEFINED);
- return this;
- }
-
- var _setCacheAdd = setCacheAdd;
-
- /**
- * Checks if `value` is in the array cache.
- *
- * @private
- * @name has
- * @memberOf SetCache
- * @param {*} value The value to search for.
- * @returns {number} Returns `true` if `value` is found, else `false`.
- */
- function setCacheHas(value) {
- return this.__data__.has(value);
- }
-
- var _setCacheHas = setCacheHas;
-
- /**
- *
- * Creates an array cache object to store unique values.
- *
- * @private
- * @constructor
- * @param {Array} [values] The values to cache.
- */
- function SetCache(values) {
- var index = -1,
- length = values == null ? 0 : values.length;
-
- this.__data__ = new _MapCache;
- while (++index < length) {
- this.add(values[index]);
- }
- }
-
- // Add methods to `SetCache`.
- SetCache.prototype.add = SetCache.prototype.push = _setCacheAdd;
- SetCache.prototype.has = _setCacheHas;
-
- var _SetCache = SetCache;
-
- /**
- * A specialized version of `_.some` for arrays without support for iteratee
- * shorthands.
- *
- * @private
- * @param {Array} [array] The array to iterate over.
- * @param {Function} predicate The function invoked per iteration.
- * @returns {boolean} Returns `true` if any element passes the predicate check,
- * else `false`.
- */
- function arraySome(array, predicate) {
- var index = -1,
- length = array == null ? 0 : array.length;
-
- while (++index < length) {
- if (predicate(array[index], index, array)) {
- return true;
- }
- }
- return false;
- }
-
- var _arraySome = arraySome;
-
- /**
- * Checks if a `cache` value for `key` exists.
- *
- * @private
- * @param {Object} cache The cache to query.
- * @param {string} key The key of the entry to check.
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
- */
- function cacheHas(cache, key) {
- return cache.has(key);
- }
-
- var _cacheHas = cacheHas;
-
- /** Used to compose bitmasks for value comparisons. */
- var COMPARE_PARTIAL_FLAG$5 = 1,
- COMPARE_UNORDERED_FLAG$3 = 2;
-
- /**
- * A specialized version of `baseIsEqualDeep` for arrays with support for
- * partial deep comparisons.
- *
- * @private
- * @param {Array} array The array to compare.
- * @param {Array} other The other array to compare.
- * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
- * @param {Function} customizer The function to customize comparisons.
- * @param {Function} equalFunc The function to determine equivalents of values.
- * @param {Object} stack Tracks traversed `array` and `other` objects.
- * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
- */
- function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
- var isPartial = bitmask & COMPARE_PARTIAL_FLAG$5,
- arrLength = array.length,
- othLength = other.length;
-
- if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
- return false;
- }
- // Check that cyclic values are equal.
- var arrStacked = stack.get(array);
- var othStacked = stack.get(other);
- if (arrStacked && othStacked) {
- return arrStacked == other && othStacked == array;
- }
- var index = -1,
- result = true,
- seen = (bitmask & COMPARE_UNORDERED_FLAG$3) ? new _SetCache : undefined;
-
- stack.set(array, other);
- stack.set(other, array);
-
- // Ignore non-index properties.
- while (++index < arrLength) {
- var arrValue = array[index],
- othValue = other[index];
-
- if (customizer) {
- var compared = isPartial
- ? customizer(othValue, arrValue, index, other, array, stack)
- : customizer(arrValue, othValue, index, array, other, stack);
- }
- if (compared !== undefined) {
- if (compared) {
- continue;
- }
- result = false;
- break;
- }
- // Recursively compare arrays (susceptible to call stack limits).
- if (seen) {
- if (!_arraySome(other, function(othValue, othIndex) {
- if (!_cacheHas(seen, othIndex) &&
- (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
- return seen.push(othIndex);
- }
- })) {
- result = false;
- break;
- }
- } else if (!(
- arrValue === othValue ||
- equalFunc(arrValue, othValue, bitmask, customizer, stack)
- )) {
- result = false;
- break;
- }
- }
- stack['delete'](array);
- stack['delete'](other);
- return result;
- }
-
- var _equalArrays = equalArrays;
-
- /**
- * Converts `map` to its key-value pairs.
- *
- * @private
- * @param {Object} map The map to convert.
- * @returns {Array} Returns the key-value pairs.
- */
- function mapToArray(map) {
- var index = -1,
- result = Array(map.size);
-
- map.forEach(function(value, key) {
- result[++index] = [key, value];
- });
- return result;
- }
-
- var _mapToArray = mapToArray;
-
- /**
- * Converts `set` to an array of its values.
- *
- * @private
- * @param {Object} set The set to convert.
- * @returns {Array} Returns the values.
- */
- function setToArray(set) {
- var index = -1,
- result = Array(set.size);
-
- set.forEach(function(value) {
- result[++index] = value;
- });
- return result;
- }
-
- var _setToArray = setToArray;
-
- /** Used to compose bitmasks for value comparisons. */
- var COMPARE_PARTIAL_FLAG$4 = 1,
- COMPARE_UNORDERED_FLAG$2 = 2;
-
- /** `Object#toString` result references. */
- var boolTag = '[object Boolean]',
- dateTag = '[object Date]',
- errorTag = '[object Error]',
- mapTag = '[object Map]',
- numberTag = '[object Number]',
- regexpTag = '[object RegExp]',
- setTag = '[object Set]',
- stringTag = '[object String]',
- symbolTag = '[object Symbol]';
-
- var arrayBufferTag = '[object ArrayBuffer]',
- dataViewTag = '[object DataView]';
-
- /** Used to convert symbols to primitives and strings. */
- var symbolProto$1 = _Symbol ? _Symbol.prototype : undefined,
- symbolValueOf = symbolProto$1 ? symbolProto$1.valueOf : undefined;
-
- /**
- * A specialized version of `baseIsEqualDeep` for comparing objects of
- * the same `toStringTag`.
- *
- * **Note:** This function only supports comparing values with tags of
- * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
- *
- * @private
- * @param {Object} object The object to compare.
- * @param {Object} other The other object to compare.
- * @param {string} tag The `toStringTag` of the objects to compare.
- * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
- * @param {Function} customizer The function to customize comparisons.
- * @param {Function} equalFunc The function to determine equivalents of values.
- * @param {Object} stack Tracks traversed `object` and `other` objects.
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
- */
- function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
- switch (tag) {
- case dataViewTag:
- if ((object.byteLength != other.byteLength) ||
- (object.byteOffset != other.byteOffset)) {
- return false;
- }
- object = object.buffer;
- other = other.buffer;
-
- case arrayBufferTag:
- if ((object.byteLength != other.byteLength) ||
- !equalFunc(new _Uint8Array(object), new _Uint8Array(other))) {
- return false;
- }
- return true;
-
- case boolTag:
- case dateTag:
- case numberTag:
- // Coerce booleans to `1` or `0` and dates to milliseconds.
- // Invalid dates are coerced to `NaN`.
- return eq_1(+object, +other);
-
- case errorTag:
- return object.name == other.name && object.message == other.message;
-
- case regexpTag:
- case stringTag:
- // Coerce regexes to strings and treat strings, primitives and objects,
- // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
- // for more details.
- return object == (other + '');
-
- case mapTag:
- var convert = _mapToArray;
-
- case setTag:
- var isPartial = bitmask & COMPARE_PARTIAL_FLAG$4;
- convert || (convert = _setToArray);
-
- if (object.size != other.size && !isPartial) {
- return false;
- }
- // Assume cyclic values are equal.
- var stacked = stack.get(object);
- if (stacked) {
- return stacked == other;
- }
- bitmask |= COMPARE_UNORDERED_FLAG$2;
-
- // Recursively compare objects (susceptible to call stack limits).
- stack.set(object, other);
- var result = _equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
- stack['delete'](object);
- return result;
-
- case symbolTag:
- if (symbolValueOf) {
- return symbolValueOf.call(object) == symbolValueOf.call(other);
- }
- }
- return false;
- }
-
- var _equalByTag = equalByTag;
-
- /** Used to compose bitmasks for value comparisons. */
- var COMPARE_PARTIAL_FLAG$3 = 1;
-
- /** Used for built-in method references. */
- var objectProto$1 = Object.prototype;
-
- /** Used to check objects for own properties. */
- var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
-
- /**
- * A specialized version of `baseIsEqualDeep` for objects with support for
- * partial deep comparisons.
- *
- * @private
- * @param {Object} object The object to compare.
- * @param {Object} other The other object to compare.
- * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
- * @param {Function} customizer The function to customize comparisons.
- * @param {Function} equalFunc The function to determine equivalents of values.
- * @param {Object} stack Tracks traversed `object` and `other` objects.
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
- */
- function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
- var isPartial = bitmask & COMPARE_PARTIAL_FLAG$3,
- objProps = _getAllKeys(object),
- objLength = objProps.length,
- othProps = _getAllKeys(other),
- othLength = othProps.length;
-
- if (objLength != othLength && !isPartial) {
- return false;
- }
- var index = objLength;
- while (index--) {
- var key = objProps[index];
- if (!(isPartial ? key in other : hasOwnProperty$1.call(other, key))) {
- return false;
- }
- }
- // Check that cyclic values are equal.
- var objStacked = stack.get(object);
- var othStacked = stack.get(other);
- if (objStacked && othStacked) {
- return objStacked == other && othStacked == object;
- }
- var result = true;
- stack.set(object, other);
- stack.set(other, object);
-
- var skipCtor = isPartial;
- while (++index < objLength) {
- key = objProps[index];
- var objValue = object[key],
- othValue = other[key];
-
- if (customizer) {
- var compared = isPartial
- ? customizer(othValue, objValue, key, other, object, stack)
- : customizer(objValue, othValue, key, object, other, stack);
- }
- // Recursively compare objects (susceptible to call stack limits).
- if (!(compared === undefined
- ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
- : compared
- )) {
- result = false;
- break;
- }
- skipCtor || (skipCtor = key == 'constructor');
- }
- if (result && !skipCtor) {
- var objCtor = object.constructor,
- othCtor = other.constructor;
-
- // Non `Object` object instances with different constructors are not equal.
- if (objCtor != othCtor &&
- ('constructor' in object && 'constructor' in other) &&
- !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
- typeof othCtor == 'function' && othCtor instanceof othCtor)) {
- result = false;
- }
- }
- stack['delete'](object);
- stack['delete'](other);
- return result;
- }
-
- var _equalObjects = equalObjects;
-
- /** Used to compose bitmasks for value comparisons. */
- var COMPARE_PARTIAL_FLAG$2 = 1;
-
- /** `Object#toString` result references. */
- var argsTag = '[object Arguments]',
- arrayTag = '[object Array]',
- objectTag = '[object Object]';
-
- /** Used for built-in method references. */
- var objectProto = Object.prototype;
-
- /** Used to check objects for own properties. */
- var hasOwnProperty = objectProto.hasOwnProperty;
-
- /**
- * A specialized version of `baseIsEqual` for arrays and objects which performs
- * deep comparisons and tracks traversed objects enabling objects with circular
- * references to be compared.
- *
- * @private
- * @param {Object} object The object to compare.
- * @param {Object} other The other object to compare.
- * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
- * @param {Function} customizer The function to customize comparisons.
- * @param {Function} equalFunc The function to determine equivalents of values.
- * @param {Object} [stack] Tracks traversed `object` and `other` objects.
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
- */
- function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
- var objIsArr = isArray_1(object),
- othIsArr = isArray_1(other),
- objTag = objIsArr ? arrayTag : _getTag(object),
- othTag = othIsArr ? arrayTag : _getTag(other);
-
- objTag = objTag == argsTag ? objectTag : objTag;
- othTag = othTag == argsTag ? objectTag : othTag;
-
- var objIsObj = objTag == objectTag,
- othIsObj = othTag == objectTag,
- isSameTag = objTag == othTag;
-
- if (isSameTag && isBuffer_1(object)) {
- if (!isBuffer_1(other)) {
- return false;
- }
- objIsArr = true;
- objIsObj = false;
- }
- if (isSameTag && !objIsObj) {
- stack || (stack = new _Stack);
- return (objIsArr || isTypedArray_1(object))
- ? _equalArrays(object, other, bitmask, customizer, equalFunc, stack)
- : _equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
- }
- if (!(bitmask & COMPARE_PARTIAL_FLAG$2)) {
- var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
- othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
-
- if (objIsWrapped || othIsWrapped) {
- var objUnwrapped = objIsWrapped ? object.value() : object,
- othUnwrapped = othIsWrapped ? other.value() : other;
-
- stack || (stack = new _Stack);
- return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
- }
- }
- if (!isSameTag) {
- return false;
- }
- stack || (stack = new _Stack);
- return _equalObjects(object, other, bitmask, customizer, equalFunc, stack);
- }
-
- var _baseIsEqualDeep = baseIsEqualDeep;
-
- /**
- * The base implementation of `_.isEqual` which supports partial comparisons
- * and tracks traversed objects.
- *
- * @private
- * @param {*} value The value to compare.
- * @param {*} other The other value to compare.
- * @param {boolean} bitmask The bitmask flags.
- * 1 - Unordered comparison
- * 2 - Partial comparison
- * @param {Function} [customizer] The function to customize comparisons.
- * @param {Object} [stack] Tracks traversed `value` and `other` objects.
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
- */
- function baseIsEqual(value, other, bitmask, customizer, stack) {
- if (value === other) {
- return true;
- }
- if (value == null || other == null || (!isObjectLike_1(value) && !isObjectLike_1(other))) {
- return value !== value && other !== other;
- }
- return _baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
- }
-
- var _baseIsEqual = baseIsEqual;
-
- /** Used to compose bitmasks for value comparisons. */
- var COMPARE_PARTIAL_FLAG$1 = 1,
- COMPARE_UNORDERED_FLAG$1 = 2;
-
- /**
- * The base implementation of `_.isMatch` without support for iteratee shorthands.
- *
- * @private
- * @param {Object} object The object to inspect.
- * @param {Object} source The object of property values to match.
- * @param {Array} matchData The property names, values, and compare flags to match.
- * @param {Function} [customizer] The function to customize comparisons.
- * @returns {boolean} Returns `true` if `object` is a match, else `false`.
- */
- function baseIsMatch(object, source, matchData, customizer) {
- var index = matchData.length,
- length = index,
- noCustomizer = !customizer;
-
- if (object == null) {
- return !length;
- }
- object = Object(object);
- while (index--) {
- var data = matchData[index];
- if ((noCustomizer && data[2])
- ? data[1] !== object[data[0]]
- : !(data[0] in object)
- ) {
- return false;
- }
- }
- while (++index < length) {
- data = matchData[index];
- var key = data[0],
- objValue = object[key],
- srcValue = data[1];
-
- if (noCustomizer && data[2]) {
- if (objValue === undefined && !(key in object)) {
- return false;
- }
- } else {
- var stack = new _Stack;
- if (customizer) {
- var result = customizer(objValue, srcValue, key, object, source, stack);
- }
- if (!(result === undefined
- ? _baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG$1 | COMPARE_UNORDERED_FLAG$1, customizer, stack)
- : result
- )) {
- return false;
- }
- }
- }
- return true;
- }
-
- var _baseIsMatch = baseIsMatch;
-
- /**
- * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` if suitable for strict
- * equality comparisons, else `false`.
- */
- function isStrictComparable(value) {
- return value === value && !isObject_1(value);
- }
-
- var _isStrictComparable = isStrictComparable;
-
- /**
- * Gets the property names, values, and compare flags of `object`.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {Array} Returns the match data of `object`.
- */
- function getMatchData(object) {
- var result = keys_1(object),
- length = result.length;
-
- while (length--) {
- var key = result[length],
- value = object[key];
-
- result[length] = [key, value, _isStrictComparable(value)];
- }
- return result;
- }
-
- var _getMatchData = getMatchData;
-
- /**
- * A specialized version of `matchesProperty` for source values suitable
- * for strict equality comparisons, i.e. `===`.
- *
- * @private
- * @param {string} key The key of the property to get.
- * @param {*} srcValue The value to match.
- * @returns {Function} Returns the new spec function.
- */
- function matchesStrictComparable(key, srcValue) {
- return function(object) {
- if (object == null) {
- return false;
- }
- return object[key] === srcValue &&
- (srcValue !== undefined || (key in Object(object)));
- };
- }
-
- var _matchesStrictComparable = matchesStrictComparable;
-
- /**
- * The base implementation of `_.matches` which doesn't clone `source`.
- *
- * @private
- * @param {Object} source The object of property values to match.
- * @returns {Function} Returns the new spec function.
- */
- function baseMatches(source) {
- var matchData = _getMatchData(source);
- if (matchData.length == 1 && matchData[0][2]) {
- return _matchesStrictComparable(matchData[0][0], matchData[0][1]);
- }
- return function(object) {
- return object === source || _baseIsMatch(object, source, matchData);
- };
- }
-
- var _baseMatches = baseMatches;
-
- /** Used to match property names within property paths. */
- var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
- reIsPlainProp = /^\w*$/;
-
- /**
- * Checks if `value` is a property name and not a property path.
- *
- * @private
- * @param {*} value The value to check.
- * @param {Object} [object] The object to query keys on.
- * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
- */
- function isKey(value, object) {
- if (isArray_1(value)) {
- return false;
- }
- var type = typeof value;
- if (type == 'number' || type == 'symbol' || type == 'boolean' ||
- value == null || isSymbol_1(value)) {
- return true;
- }
- return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
- (object != null && value in Object(object));
- }
-
- var _isKey = isKey;
-
- /** Error message constants. */
- var FUNC_ERROR_TEXT = 'Expected a function';
-
- /**
- * Creates a function that memoizes the result of `func`. If `resolver` is
- * provided, it determines the cache key for storing the result based on the
- * arguments provided to the memoized function. By default, the first argument
- * provided to the memoized function is used as the map cache key. The `func`
- * is invoked with the `this` binding of the memoized function.
- *
- * **Note:** The cache is exposed as the `cache` property on the memoized
- * function. Its creation may be customized by replacing the `_.memoize.Cache`
- * constructor with one whose instances implement the
- * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
- * method interface of `clear`, `delete`, `get`, `has`, and `set`.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Function
- * @param {Function} func The function to have its output memoized.
- * @param {Function} [resolver] The function to resolve the cache key.
- * @returns {Function} Returns the new memoized function.
- * @example
- *
- * var object = { 'a': 1, 'b': 2 };
- * var other = { 'c': 3, 'd': 4 };
- *
- * var values = _.memoize(_.values);
- * values(object);
- * // => [1, 2]
- *
- * values(other);
- * // => [3, 4]
- *
- * object.a = 2;
- * values(object);
- * // => [1, 2]
- *
- * // Modify the result cache.
- * values.cache.set(object, ['a', 'b']);
- * values(object);
- * // => ['a', 'b']
- *
- * // Replace `_.memoize.Cache`.
- * _.memoize.Cache = WeakMap;
- */
- function memoize(func, resolver) {
- if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
- throw new TypeError(FUNC_ERROR_TEXT);
- }
- var memoized = function() {
- var args = arguments,
- key = resolver ? resolver.apply(this, args) : args[0],
- cache = memoized.cache;
-
- if (cache.has(key)) {
- return cache.get(key);
- }
- var result = func.apply(this, args);
- memoized.cache = cache.set(key, result) || cache;
- return result;
- };
- memoized.cache = new (memoize.Cache || _MapCache);
- return memoized;
- }
-
- // Expose `MapCache`.
- memoize.Cache = _MapCache;
-
- var memoize_1 = memoize;
-
- /** Used as the maximum memoize cache size. */
- var MAX_MEMOIZE_SIZE = 500;
-
- /**
- * A specialized version of `_.memoize` which clears the memoized function's
- * cache when it exceeds `MAX_MEMOIZE_SIZE`.
- *
- * @private
- * @param {Function} func The function to have its output memoized.
- * @returns {Function} Returns the new memoized function.
- */
- function memoizeCapped(func) {
- var result = memoize_1(func, function(key) {
- if (cache.size === MAX_MEMOIZE_SIZE) {
- cache.clear();
- }
- return key;
- });
-
- var cache = result.cache;
- return result;
- }
-
- var _memoizeCapped = memoizeCapped;
-
- /** Used to match property names within property paths. */
- var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
-
- /** Used to match backslashes in property paths. */
- var reEscapeChar = /\\(\\)?/g;
-
- /**
- * Converts `string` to a property path array.
- *
- * @private
- * @param {string} string The string to convert.
- * @returns {Array} Returns the property path array.
- */
- var stringToPath = _memoizeCapped(function(string) {
- var result = [];
- if (string.charCodeAt(0) === 46 /* . */) {
- result.push('');
- }
- string.replace(rePropName, function(match, number, quote, subString) {
- result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
- });
- return result;
- });
-
- var _stringToPath = stringToPath;
-
- /**
- * A specialized version of `_.map` for arrays without support for iteratee
- * shorthands.
- *
- * @private
- * @param {Array} [array] The array to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Array} Returns the new mapped array.
- */
- function arrayMap(array, iteratee) {
- var index = -1,
- length = array == null ? 0 : array.length,
- result = Array(length);
-
- while (++index < length) {
- result[index] = iteratee(array[index], index, array);
- }
- return result;
- }
-
- var _arrayMap = arrayMap;
-
- /** Used as references for various `Number` constants. */
- var INFINITY$1 = 1 / 0;
-
- /** Used to convert symbols to primitives and strings. */
- var symbolProto = _Symbol ? _Symbol.prototype : undefined,
- symbolToString = symbolProto ? symbolProto.toString : undefined;
-
- /**
- * The base implementation of `_.toString` which doesn't convert nullish
- * values to empty strings.
- *
- * @private
- * @param {*} value The value to process.
- * @returns {string} Returns the string.
- */
- function baseToString(value) {
- // Exit early for strings to avoid a performance hit in some environments.
- if (typeof value == 'string') {
- return value;
- }
- if (isArray_1(value)) {
- // Recursively convert values (susceptible to call stack limits).
- return _arrayMap(value, baseToString) + '';
- }
- if (isSymbol_1(value)) {
- return symbolToString ? symbolToString.call(value) : '';
- }
- var result = (value + '');
- return (result == '0' && (1 / value) == -INFINITY$1) ? '-0' : result;
- }
-
- var _baseToString = baseToString;
-
- /**
- * Converts `value` to a string. An empty string is returned for `null`
- * and `undefined` values. The sign of `-0` is preserved.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to convert.
- * @returns {string} Returns the converted string.
- * @example
- *
- * _.toString(null);
- * // => ''
- *
- * _.toString(-0);
- * // => '-0'
- *
- * _.toString([1, 2, 3]);
- * // => '1,2,3'
- */
- function toString(value) {
- return value == null ? '' : _baseToString(value);
- }
-
- var toString_1 = toString;
-
- /**
- * Casts `value` to a path array if it's not one.
- *
- * @private
- * @param {*} value The value to inspect.
- * @param {Object} [object] The object to query keys on.
- * @returns {Array} Returns the cast property path array.
- */
- function castPath(value, object) {
- if (isArray_1(value)) {
- return value;
- }
- return _isKey(value, object) ? [value] : _stringToPath(toString_1(value));
- }
-
- var _castPath = castPath;
-
- /** Used as references for various `Number` constants. */
- var INFINITY = 1 / 0;
-
- /**
- * Converts `value` to a string key if it's not a string or symbol.
- *
- * @private
- * @param {*} value The value to inspect.
- * @returns {string|symbol} Returns the key.
- */
- function toKey(value) {
- if (typeof value == 'string' || isSymbol_1(value)) {
- return value;
- }
- var result = (value + '');
- return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
- }
-
- var _toKey = toKey;
-
- /**
- * The base implementation of `_.get` without support for default values.
- *
- * @private
- * @param {Object} object The object to query.
- * @param {Array|string} path The path of the property to get.
- * @returns {*} Returns the resolved value.
- */
- function baseGet(object, path) {
- path = _castPath(path, object);
-
- var index = 0,
- length = path.length;
-
- while (object != null && index < length) {
- object = object[_toKey(path[index++])];
- }
- return (index && index == length) ? object : undefined;
- }
-
- var _baseGet = baseGet;
-
- /**
- * Gets the value at `path` of `object`. If the resolved value is
- * `undefined`, the `defaultValue` is returned in its place.
- *
- * @static
- * @memberOf _
- * @since 3.7.0
- * @category Object
- * @param {Object} object The object to query.
- * @param {Array|string} path The path of the property to get.
- * @param {*} [defaultValue] The value returned for `undefined` resolved values.
- * @returns {*} Returns the resolved value.
- * @example
- *
- * var object = { 'a': [{ 'b': { 'c': 3 } }] };
- *
- * _.get(object, 'a[0].b.c');
- * // => 3
- *
- * _.get(object, ['a', '0', 'b', 'c']);
- * // => 3
- *
- * _.get(object, 'a.b.c', 'default');
- * // => 'default'
- */
- function get(object, path, defaultValue) {
- var result = object == null ? undefined : _baseGet(object, path);
- return result === undefined ? defaultValue : result;
- }
-
- var get_1 = get;
-
- /**
- * The base implementation of `_.hasIn` without support for deep paths.
- *
- * @private
- * @param {Object} [object] The object to query.
- * @param {Array|string} key The key to check.
- * @returns {boolean} Returns `true` if `key` exists, else `false`.
- */
- function baseHasIn(object, key) {
- return object != null && key in Object(object);
- }
-
- var _baseHasIn = baseHasIn;
-
- /**
- * Checks if `path` exists on `object`.
- *
- * @private
- * @param {Object} object The object to query.
- * @param {Array|string} path The path to check.
- * @param {Function} hasFunc The function to check properties.
- * @returns {boolean} Returns `true` if `path` exists, else `false`.
- */
- function hasPath(object, path, hasFunc) {
- path = _castPath(path, object);
-
- var index = -1,
- length = path.length,
- result = false;
-
- while (++index < length) {
- var key = _toKey(path[index]);
- if (!(result = object != null && hasFunc(object, key))) {
- break;
- }
- object = object[key];
- }
- if (result || ++index != length) {
- return result;
- }
- length = object == null ? 0 : object.length;
- return !!length && isLength_1(length) && _isIndex(key, length) &&
- (isArray_1(object) || isArguments_1(object));
- }
-
- var _hasPath = hasPath;
-
- /**
- * Checks if `path` is a direct or inherited property of `object`.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Object
- * @param {Object} object The object to query.
- * @param {Array|string} path The path to check.
- * @returns {boolean} Returns `true` if `path` exists, else `false`.
- * @example
- *
- * var object = _.create({ 'a': _.create({ 'b': 2 }) });
- *
- * _.hasIn(object, 'a');
- * // => true
- *
- * _.hasIn(object, 'a.b');
- * // => true
- *
- * _.hasIn(object, ['a', 'b']);
- * // => true
- *
- * _.hasIn(object, 'b');
- * // => false
- */
- function hasIn(object, path) {
- return object != null && _hasPath(object, path, _baseHasIn);
- }
-
- var hasIn_1 = hasIn;
-
- /** Used to compose bitmasks for value comparisons. */
- var COMPARE_PARTIAL_FLAG = 1,
- COMPARE_UNORDERED_FLAG = 2;
-
- /**
- * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
- *
- * @private
- * @param {string} path The path of the property to get.
- * @param {*} srcValue The value to match.
- * @returns {Function} Returns the new spec function.
- */
- function baseMatchesProperty(path, srcValue) {
- if (_isKey(path) && _isStrictComparable(srcValue)) {
- return _matchesStrictComparable(_toKey(path), srcValue);
- }
- return function(object) {
- var objValue = get_1(object, path);
- return (objValue === undefined && objValue === srcValue)
- ? hasIn_1(object, path)
- : _baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
- };
- }
-
- var _baseMatchesProperty = baseMatchesProperty;
-
- /**
- * The base implementation of `_.property` without support for deep paths.
- *
- * @private
- * @param {string} key The key of the property to get.
- * @returns {Function} Returns the new accessor function.
- */
- function baseProperty(key) {
- return function(object) {
- return object == null ? undefined : object[key];
- };
- }
-
- var _baseProperty = baseProperty;
-
- /**
- * A specialized version of `baseProperty` which supports deep paths.
- *
- * @private
- * @param {Array|string} path The path of the property to get.
- * @returns {Function} Returns the new accessor function.
- */
- function basePropertyDeep(path) {
- return function(object) {
- return _baseGet(object, path);
- };
- }
-
- var _basePropertyDeep = basePropertyDeep;
-
- /**
- * Creates a function that returns the value at `path` of a given object.
- *
- * @static
- * @memberOf _
- * @since 2.4.0
- * @category Util
- * @param {Array|string} path The path of the property to get.
- * @returns {Function} Returns the new accessor function.
- * @example
- *
- * var objects = [
- * { 'a': { 'b': 2 } },
- * { 'a': { 'b': 1 } }
- * ];
- *
- * _.map(objects, _.property('a.b'));
- * // => [2, 1]
- *
- * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
- * // => [1, 2]
- */
- function property(path) {
- return _isKey(path) ? _baseProperty(_toKey(path)) : _basePropertyDeep(path);
- }
-
- var property_1 = property;
-
- /**
- * The base implementation of `_.iteratee`.
- *
- * @private
- * @param {*} [value=_.identity] The value to convert to an iteratee.
- * @returns {Function} Returns the iteratee.
- */
- function baseIteratee(value) {
- // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
- // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
- if (typeof value == 'function') {
- return value;
- }
- if (value == null) {
- return identity_1;
- }
- if (typeof value == 'object') {
- return isArray_1(value)
- ? _baseMatchesProperty(value[0], value[1])
- : _baseMatches(value);
- }
- return property_1(value);
- }
-
- var _baseIteratee = baseIteratee;
-
- /** Used to compose bitmasks for cloning. */
- var CLONE_DEEP_FLAG = 1;
-
- /**
- * Creates a function that invokes `func` with the arguments of the created
- * function. If `func` is a property name, the created function returns the
- * property value for a given element. If `func` is an array or object, the
- * created function returns `true` for elements that contain the equivalent
- * source properties, otherwise it returns `false`.
- *
- * @static
- * @since 4.0.0
- * @memberOf _
- * @category Util
- * @param {*} [func=_.identity] The value to convert to a callback.
- * @returns {Function} Returns the callback.
- * @example
- *
- * var users = [
- * { 'user': 'barney', 'age': 36, 'active': true },
- * { 'user': 'fred', 'age': 40, 'active': false }
- * ];
- *
- * // The `_.matches` iteratee shorthand.
- * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
- * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
- *
- * // The `_.matchesProperty` iteratee shorthand.
- * _.filter(users, _.iteratee(['user', 'fred']));
- * // => [{ 'user': 'fred', 'age': 40 }]
- *
- * // The `_.property` iteratee shorthand.
- * _.map(users, _.iteratee('user'));
- * // => ['barney', 'fred']
- *
- * // Create custom iteratee shorthands.
- * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
- * return !_.isRegExp(func) ? iteratee(func) : function(string) {
- * return func.test(string);
- * };
- * });
- *
- * _.filter(['abc', 'def'], /ef/);
- * // => ['def']
- */
- function iteratee(func) {
- return _baseIteratee(typeof func == 'function' ? func : _baseClone(func, CLONE_DEEP_FLAG));
- }
-
- var iteratee_1 = iteratee;
-
- /** Built-in value references. */
- var spreadableSymbol = _Symbol ? _Symbol.isConcatSpreadable : undefined;
-
- /**
- * Checks if `value` is a flattenable `arguments` object or array.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
- */
- function isFlattenable(value) {
- return isArray_1(value) || isArguments_1(value) ||
- !!(spreadableSymbol && value && value[spreadableSymbol]);
- }
-
- var _isFlattenable = isFlattenable;
-
- /**
- * The base implementation of `_.flatten` with support for restricting flattening.
- *
- * @private
- * @param {Array} array The array to flatten.
- * @param {number} depth The maximum recursion depth.
- * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
- * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
- * @param {Array} [result=[]] The initial result value.
- * @returns {Array} Returns the new flattened array.
- */
- function baseFlatten(array, depth, predicate, isStrict, result) {
- var index = -1,
- length = array.length;
-
- predicate || (predicate = _isFlattenable);
- result || (result = []);
-
- while (++index < length) {
- var value = array[index];
- if (depth > 0 && predicate(value)) {
- if (depth > 1) {
- // Recursively flatten arrays (susceptible to call stack limits).
- baseFlatten(value, depth - 1, predicate, isStrict, result);
- } else {
- _arrayPush(result, value);
- }
- } else if (!isStrict) {
- result[result.length] = value;
- }
- }
- return result;
- }
-
- var _baseFlatten = baseFlatten;
-
- /**
- * Flattens `array` a single level deep.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Array
- * @param {Array} array The array to flatten.
- * @returns {Array} Returns the new flattened array.
- * @example
- *
- * _.flatten([1, [2, [3, [4]], 5]]);
- * // => [1, 2, [3, [4]], 5]
- */
- function flatten(array) {
- var length = array == null ? 0 : array.length;
- return length ? _baseFlatten(array, 1) : [];
- }
-
- var flatten_1 = flatten;
-
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeMax = Math.max;
-
- /**
- * A specialized version of `baseRest` which transforms the rest array.
- *
- * @private
- * @param {Function} func The function to apply a rest parameter to.
- * @param {number} [start=func.length-1] The start position of the rest parameter.
- * @param {Function} transform The rest array transform.
- * @returns {Function} Returns the new function.
- */
- function overRest(func, start, transform) {
- start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
- return function() {
- var args = arguments,
- index = -1,
- length = nativeMax(args.length - start, 0),
- array = Array(length);
-
- while (++index < length) {
- array[index] = args[start + index];
- }
- index = -1;
- var otherArgs = Array(start + 1);
- while (++index < start) {
- otherArgs[index] = args[index];
- }
- otherArgs[start] = transform(array);
- return _apply(func, this, otherArgs);
- };
- }
-
- var _overRest = overRest;
-
- /**
- * A specialized version of `baseRest` which flattens the rest array.
- *
- * @private
- * @param {Function} func The function to apply a rest parameter to.
- * @returns {Function} Returns the new function.
- */
- function flatRest(func) {
- return _setToString(_overRest(func, undefined, flatten_1), func + '');
- }
-
- var _flatRest = flatRest;
-
- /** Used to compose bitmasks for function metadata. */
- var WRAP_REARG_FLAG = 256;
-
- /**
- * Creates a function that invokes `func` with arguments arranged according
- * to the specified `indexes` where the argument value at the first index is
- * provided as the first argument, the argument value at the second index is
- * provided as the second argument, and so on.
- *
- * @static
- * @memberOf _
- * @since 3.0.0
- * @category Function
- * @param {Function} func The function to rearrange arguments for.
- * @param {...(number|number[])} indexes The arranged argument indexes.
- * @returns {Function} Returns the new function.
- * @example
- *
- * var rearged = _.rearg(function(a, b, c) {
- * return [a, b, c];
- * }, [2, 0, 1]);
- *
- * rearged('b', 'c', 'a')
- * // => ['a', 'b', 'c']
- */
- var rearg = _flatRest(function(func, indexes) {
- return _createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
- });
-
- var rearg_1 = rearg;
-
- /**
- * Converts `value` to a property path array.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Util
- * @param {*} value The value to convert.
- * @returns {Array} Returns the new property path array.
- * @example
- *
- * _.toPath('a.b.c');
- * // => ['a', 'b', 'c']
- *
- * _.toPath('a[0].b.c');
- * // => ['a', '0', 'b', 'c']
- */
- function toPath(value) {
- if (isArray_1(value)) {
- return _arrayMap(value, _toKey);
- }
- return isSymbol_1(value) ? [value] : _copyArray(_stringToPath(toString_1(value)));
- }
-
- var toPath_1 = toPath;
-
- var _util = {
- 'ary': ary_1,
- 'assign': _baseAssign,
- 'clone': clone_1,
- 'curry': commonjsRequire("../curry", "/$$rollup_base$$/node_modules/lodash/fp"),
- 'forEach': _arrayEach,
- 'isArray': isArray_1,
- 'isError': isError_1,
- 'isFunction': isFunction_1,
- 'isWeakMap': isWeakMap_1,
- 'iteratee': iteratee_1,
- 'keys': _baseKeys,
- 'rearg': rearg_1,
- 'toInteger': toInteger_1,
- 'toPath': toPath_1
- };
-
- /**
- * Converts `func` of `name` to an immutable auto-curried iteratee-first data-last
- * version with conversion `options` applied. If `name` is an object its methods
- * will be converted.
- *
- * @param {string} name The name of the function to wrap.
- * @param {Function} [func] The function to wrap.
- * @param {Object} [options] The options object. See `baseConvert` for more details.
- * @returns {Function|Object} Returns the converted function or object.
- */
- function convert$2(name, func, options) {
- return _baseConvert(_util, name, func, options);
- }
-
- var convert_1 = convert$2;
-
- commonjsRegister("/$$rollup_base$$/node_modules/lodash/fp/curry.js", function (module, exports) {
- var convert = convert_1,
- func = convert('curry', commonjsRequire("../curry", "/$$rollup_base$$/node_modules/lodash/fp"));
-
- func.placeholder = placeholder;
- module.exports = func;
-
- });
-
- commonjsRegister("/$$rollup_base$$/node_modules/lodash/fp/curryN.js", function (module, exports) {
- var convert = convert_1,
- func = convert('curryN', commonjsRequire("../curry", "/$$rollup_base$$/node_modules/lodash/fp"));
-
- func.placeholder = placeholder;
- module.exports = func;
-
- });
-
- commonjsRegister("/$$rollup_base$$/node_modules/lodash/fp/curryRight.js", function (module, exports) {
- var convert = convert_1,
- func = convert('curryRight', commonjsRequire("../curryRight", "/$$rollup_base$$/node_modules/lodash/fp"));
-
- func.placeholder = placeholder;
- module.exports = func;
-
- });
-
- commonjsRegister("/$$rollup_base$$/node_modules/lodash/fp/curryRightN.js", function (module, exports) {
- var convert = convert_1,
- func = convert('curryRightN', commonjsRequire("../curryRight", "/$$rollup_base$$/node_modules/lodash/fp"));
-
- func.placeholder = placeholder;
- module.exports = func;
-
- });
-
- const crossfilter = crossfilterreq__default['default'].default ? crossfilterreq__default['default'].default : crossfilterreq__default['default'];
- // -------------------------------------------------------------------
- // dx = multidimensional Crossfilter = Wrapper for crossfilter
- var dx = {
- indexFns : { id : function (d) { return d.id || "" } }
- , createIndexFn : function(indexFn, dim){
-
- var indexFns = {
- dim : function(d) { return d[dim] || "" }
- , dimId : function(d) { return d[dim + 'Id'] || "" }
- };
- if(Object.prototype.toString.call(indexFn) === '[object Function]' ) return indexFn;
- if(indexFn) return function(d) { return d[indexFn] || "" } // Assume its the column name on the data.
-
- indexFn = function(d){
- // First time execution detects key to use. We try [dim] then[{{dim}}Id] then [id]
- // This is though dangerous if first item has missing data i.e. d[dim] is undefined even though other rows have d[dim]
- console.error('default generated indexFn on non existence of model property is dangerous.');
- indexFn = d[dim] ? indexFns['dim'] : d[dim + 'Id'] ? indexFns['dimId'] : dx.indexFns['id'];
- dx.indexFns['id'] === indexFn ? console.error('Warning : dimension name not found. Using id as default is not recommended.') : null;
- // Since we were called after the dimension processing has started we will continue to get called until each item is processed.
- // We therefore switch the function that will get called from next time onwards.
- return indexFn(d); //
- };
-
- return function(d){ return indexFn(d) }
- }
-
- , filter : function(filter, dim){
- // Note : Ensure that the filter function that you pass in is the same function object. This is the only way to prevent bloat.
- if(!filter) { console.warn('Useless call to filter without a real filter.'); return;} // All filters should already be in place since we are stateful.
-
- var filterable = dim ? this.dims[dim] : this;
- // Filters are shared between master and dimension on data.
- if(!filterable.wkFilters.get(filter)) {
- filterable.wkFilters.set(filter, true);
- filterable.filters.push(filter); // PB : Note -- Push unique distinct filters ! This will bloat if duplicates are pushed.
- }
-
- // PB : TODO -- Check CF may not re-evaluate filters if it detects no change in filter.
- if(filterable.dxFd){
- // This is a master dim with attached fact dimension. this.model should give us the column name on the fact data.
- filterable.dxFd.filter( filterable.__filter );
- }
- filterable.dxF.filter(filterable.__filter);
-
- // If it does re-evaluate following cascade code is not required.
- // Cascade to all nested dimensions which are implicitly bound.
- // Object.keys(specs.dims).forEach((dim)=>{
- // this.dims[dim].dxF.filter( this.dims[dim].__filter )
- // })
-
- // Handle other custom bound Dimensions on this dimension.
- // Master and Data crossfilters are implicitly bound.
- // this.dims[dim].dxFm ? this.dims[dim].dxFm.filter( this.dims[dim].__filter ) : null;
- // this.dims[dim].dxFd ? this.dims[dim].dxFd.filter( this.dims[dim].__filter ) : null;
-
- }
- , filterAll : function(dim){
-
- var filterable = dim ? this.dims[dim] : this;
-
- if(filterable.dxFd){
- // This is a master dim with attached fact dimension. this.model should give us the column name on the fact data.
- filterable.dxFd.filterAll();
- }
- filterable.dxF.filterAll( );
-
- // Cascade to all nested dimensions.
- // Object.keys(specs.dims).forEach((dim)=>{
- // specs[dim][dx] = specs[dim].data ? dx.create( specs[dim] ) : null;
- // dx.__createPairedDx(specs, dim);
- // })
- }
- , addFilter : function(filter, dim) {
- dim = dim || 'id';
- this.dims[dim].filters.push(filter);
- }
- , __initDim : function(oDim){
- var __filter = function(d){
- for(var f=0; f < oDim.filters.length; f++) {
- // Filter function will be called on the dimension.
- // PB : TODO accept any scope instead of only the dimension.
- if(!oDim.filters[f].call(oDim, d)) return false;
- }
- return true;
- };
- return oDim ? (()=>{
- oDim.wkFilters = new(WeakMap);
- oDim.filters = []; oDim.__filter = __filter;
- return oDim
- })()
- : { wkFilters : new(WeakMap), filters : [], __filter : __filter }
- }
- , __createPairedDx : function(specs, dim, idxFn){
- var oDim = dim === 'id' ? specs : specs.dims[dim];
- idxFn = idxFn || dx.createIndexFn(oDim.indexFn, dim);
-
- oDim.dxU = specs.ndxU.dimension( idxFn );
- oDim.dxF = specs.ndxF.dimension( idxFn );
- }
- , create : function( specs ){
-
- specs.ndxF = crossfilter(specs.data);
- specs.ndxU = crossfilter(specs.data);
-
- // specs.dims ? null : specs.dims = { 'id' : null }
- // specs.dims['id'] = dx.__initDim(specs.dims['id'])
- dx.__initDim(specs); // id Dimension is merged with dx itself. Other dimensions will be found in dims.
- dx.__createPairedDx(specs, 'id', dx.indexFns.id);
-
- specs.dims ? Object.keys(specs.dims).forEach((dim)=>{
- specs.dims[dim].data ? (()=>{
- // We have some master data for this dimension.
- dx.create( specs.dims[dim] );
- // PB : TODO -- We should probably bind the an array dx's ...
- // Eg: An array of master dx's for a fact dx...
- // i.e specs.bound = [ dx1 = practitioner, dx2 = xyz etc...]
-
- })()
- : dx.__initDim(specs.dims[dim]);
-
- var idxFn = dx.createIndexFn(specs.dims[dim].indexFn, dim);
- specs.dims[dim].dxFd = specs.ndxF.dimension( idxFn );
- specs.dims[dim].dxUd = specs.ndxU.dimension( idxFn );
-
- }) : null;
-
- specs.filter = this.filter;
- specs.filterAll = this.filterAll;
- return specs;
- }
- // , exclude : ( dxU, dxF, filterFn )=>{
- // // Excludes filtered from unfiltered.
- // var filterFn = null;
- // if(this.get('selected_doctor.id')) {
-
- // }
- // else {
-
- // var __inclusions = [];
- // var __exclusions = [];
-
- // practitionersDimUnfiltered.top(Infinity).forEach((availablePractitioner)=>{
- // // Per Doc
- // ndxFiltered.filterAll()
- // practitionersDimFiltered.filter(availablePractitioner.id);
- // var freeTimes = getFreeTimes(tRange, practitionersDimFiltered);
- // if(freeTimes.length > 0) { /*available*/
- // __inclusions.push(availablePractitioner) }
- // else {
- // __exclusions.push(availablePractitioner)
- // }
-
- // })
-
- // filterFn = ()=> { return ((inclusions, exclusions)=>{
- // for(var f in filters) {
- // if(!filters[f]) return false;
- // }
- // return true;
- // })(__inclusions, __exclusions) } ;
-
- // practitionersDimFiltered.filter(filterFn);
- // }
- // return filterFn;
- // }
- };
-
- var dx_1 = dx;
-
- try {
- var x$1 = BigInt(0);
- }
- catch(e){
- console.warn('BigInt check failed. Falling back to Number');
- // PB : TODO -- All Number issues with bitmasks will fail since BigInt is not available.
- // Eg : Older Safari versions will not work
- // PB : TODO -- provide a proper polyfill for older Safari Browsers in the ember build.
- BigInt = Number;
- }
-
- // -------------------------------
- // Command line option parsing
- // -------------------------------
- function cliargs$1(args, opts) {
- if (!opts) opts = {};
-
- var flags = { bools : {}, strings : {}, unknownFn: null };
-
- if (typeof opts['unknown'] === 'function') {
- flags.unknownFn = opts['unknown'];
- }
-
- if (typeof opts['boolean'] === 'boolean' && opts['boolean']) {
- flags.allBools = true;
- } else {
- [].concat(opts['boolean']).filter(Boolean).forEach(function (key) {
- flags.bools[key] = true;
- });
- }
-
- var aliases = {};
- Object.keys(opts.alias || {}).forEach(function (key) {
- aliases[key] = [].concat(opts.alias[key]);
- aliases[key].forEach(function (x) {
- aliases[x] = [key].concat(aliases[key].filter(function (y) {
- return x !== y;
- }));
- });
- });
-
- [].concat(opts.string).filter(Boolean).forEach(function (key) {
- flags.strings[key] = true;
- if (aliases[key]) {
- flags.strings[aliases[key]] = true;
- }
- });
-
- var defaults = opts['default'] || {};
-
- var argv = { _ : [] };
- Object.keys(flags.bools).forEach(function (key) {
- setArg(key, defaults[key] === undefined ? false : defaults[key]);
- });
-
- var notFlags = [];
-
- if (args.indexOf('--') !== -1) {
- notFlags = args.slice(args.indexOf('--')+1);
- args = args.slice(0, args.indexOf('--'));
- }
-
- function argDefined(key, arg) {
- return (flags.allBools && /^--[^=]+$/.test(arg)) ||
- flags.strings[key] || flags.bools[key] || aliases[key];
- }
-
- function setArg (key, val, arg) {
- if (arg && flags.unknownFn && !argDefined(key, arg)) {
- if (flags.unknownFn(arg) === false) return;
- }
-
- var value = !flags.strings[key] && isNumber(val)
- ? Number(val) : val
- ;
- setKey(argv, key.split('.'), value);
-
- (aliases[key] || []).forEach(function (x) {
- setKey(argv, x.split('.'), value);
- });
- }
-
- function setKey (obj, keys, value) {
- var o = obj;
- keys.slice(0,-1).forEach(function (key) {
- if (o[key] === undefined) o[key] = {};
- o = o[key];
- });
-
- var key = keys[keys.length - 1];
- if (o[key] === undefined || flags.bools[key] || typeof o[key] === 'boolean') {
- o[key] = value;
- }
- else if (Array.isArray(o[key])) {
- o[key].push(value);
- }
- else {
- o[key] = [ o[key], value ];
- }
- }
-
- function aliasIsBoolean(key) {
- return aliases[key].some(function (x) {
- return flags.bools[x];
- });
- }
-
- for (var i = 0; i < args.length; i++) {
- var arg = args[i];
-
- if (/^--.+=/.test(arg)) {
- // Using [\s\S] instead of . because js doesn't support the
- // 'dotall' regex modifier. See:
- // http://stackoverflow.com/a/1068308/13216
- var m = arg.match(/^--([^=]+)=([\s\S]*)$/);
- var key = m[1];
- var value = m[2];
- if (flags.bools[key]) {
- value = value !== 'false';
- }
- setArg(key, value, arg);
- }
- else if (/^--no-.+/.test(arg)) {
- var key = arg.match(/^--no-(.+)/)[1];
- setArg(key, false, arg);
- }
- else if (/^--.+/.test(arg)) {
- var key = arg.match(/^--(.+)/)[1];
- var next = args[i + 1];
- if (next !== undefined && !/^-/.test(next)
- && !flags.bools[key]
- && !flags.allBools
- && (aliases[key] ? !aliasIsBoolean(key) : true)) {
- setArg(key, next, arg);
- i++;
- }
- else if (/^(true|false)$/.test(next)) {
- setArg(key, next === 'true', arg);
- i++;
- }
- else {
- setArg(key, flags.strings[key] ? '' : true, arg);
- }
- }
- else if (/^-[^-]+/.test(arg)) {
- var letters = arg.slice(1,-1).split('');
-
- var broken = false;
- for (var j = 0; j < letters.length; j++) {
- var next = arg.slice(j+2);
-
- if (next === '-') {
- setArg(letters[j], next, arg);
- continue;
- }
-
- if (/[A-Za-z]/.test(letters[j]) && /=/.test(next)) {
- setArg(letters[j], next.split('=')[1], arg);
- broken = true;
- break;
- }
-
- if (/[A-Za-z]/.test(letters[j])
- && /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
- setArg(letters[j], next, arg);
- broken = true;
- break;
- }
-
- if (letters[j+1] && letters[j+1].match(/\W/)) {
- setArg(letters[j], arg.slice(j+2), arg);
- broken = true;
- break;
- }
- else {
- setArg(letters[j], flags.strings[letters[j]] ? '' : true, arg);
- }
- }
-
- var key = arg.slice(-1)[0];
- if (!broken && key !== '-') {
- if (args[i+1] && !/^(-|--)[^-]/.test(args[i+1])
- && !flags.bools[key]
- && (aliases[key] ? !aliasIsBoolean(key) : true)) {
- setArg(key, args[i+1], arg);
- i++;
- }
- else if (args[i+1] && /true|false/.test(args[i+1])) {
- setArg(key, args[i+1] === 'true', arg);
- i++;
- }
- else {
- setArg(key, flags.strings[key] ? '' : true, arg);
- }
- }
- }
- else {
- if (!flags.unknownFn || flags.unknownFn(arg) !== false) {
- argv._.push(
- flags.strings['_'] || !isNumber(arg) ? arg : Number(arg)
- );
- }
- if (opts.stopEarly) {
- argv._.push.apply(argv._, args.slice(i + 1));
- break;
- }
- }
- }
-
- Object.keys(defaults).forEach(function (key) {
- if (!hasKey(argv, key.split('.'))) {
- setKey(argv, key.split('.'), defaults[key]);
-
- (aliases[key] || []).forEach(function (x) {
- setKey(argv, x.split('.'), defaults[key]);
- });
- }
- });
-
- if (opts['--']) {
- argv['--'] = new Array();
- notFlags.forEach(function(key) {
- argv['--'].push(key);
- });
- }
- else {
- notFlags.forEach(function(key) {
- argv._.push(key);
- });
- }
-
- return argv;
- }
- /*
- Iterable task should return either truthy or false
- Any fn will return only one value for an array of iterables. If any one iterable fails, the return value would be false.
- If all succeed , the return value will be true.
- If continueOnFailure is false, an execption is raised on any one failure
- */
- function any$1(iterable, continueOnFailure) {
- var cancelsignal = Symbol();
- return iterable.reduce(
- (p, tasq, i ,a) => {
- var handleError = (err, pVal)=>{
- if(err !== cancelsignal) {
- // Cancel only once on first failure.
- console.log('Failed : ' + err.message + ' ' + JSON.stringify(pVal));
- console.dir(p);
- console.warn('Possible failure for task with result : ' + JSON.stringify(pVal));
- if(i>0 && a[i-1].info) console.dir(a[i-1].info);
- console.error('Error : ' + err.stack);
- console.error(a[i-1]);
- a[i-1] ? console.log("tasq : " + a[i-1].toString()) : null;
- if(!continueOnFailure) {console.log("Cancelling remaining on any one failure ..."); throw cancelsignal}
- else return pVal;
- // tasq ? console.log("tasq : " + tasq.toString()) : null; // Previous task is what failed not the one we are going to run.
- }
- };
-
- if(Promise.resolve(p) === p ) {
- if(i>0 && a[i-1].info) p.info = a[i-1].info;
- return p.then((pVal) => {
- // Falsy values are no longer treated as task failure exceptions. Specially for Promises.
- // Even tasq function wrappers are required to return promises that eventually either resolve or reject..
- // Failures are known for promises on reject.
- // In future if we support direct sync function execution with a result examination for failure
- // we could examine the result of the function as falsy's... or a result evaluator handler needs to be passed in...
- // if(!pVal) handleError({ error : true, message : 'Failed without result' }, pVal)
-
- // Truthy values are failures if obj has error=true.
- if(pVal && pVal.error) handleError(pVal, pVal);
-
- var trycall = function(tasq){
- try {
- var result = tasq(); // PB : TODO -- Handle scope for call
- if(tasq.resultHandler) return tasq.resultHandler(result)
- // if(!result) throw result; // Default failure detection for functions is falsy values.
- return result
- } catch (error) {
- console.error(error);
- console.error('Error : ' + error ? error.stack : 'No stack');
- if(!continueOnFailure) throw error; // PB : TODO -- Support array of results for any with or without continueonfailure.
- }
- };
-
- var handleNext = ()=>{
- console.log('Task finished with result : ' + JSON.stringify(pVal));
- if(i>0 && a[i-1].info) console.dir(a[i-1].info);
- if(!tasq && !continueOnFailure) { console.log('Error : No task specified.'); throw false;}
- else if(!tasq) { console.log('Error : No task specified.'); return false;}
- return (Promise.resolve(tasq) === tasq ) ? tasq : trycall(tasq) ;
- };
-
- if(Promise.resolve(pVal) === pVal) {
- // Passed in function retured a promise. We still need to wait for it.
- pVal.then((pVal)=>{ return handleNext(); });
- }
- else return handleNext()
-
- }).catch((error) => {
- if(error !== cancelsignal) {
- console.log(`E3 : i = ${i} `);
- console.error('Error : ' + error.message);
- console.error('Error : ' + error.stack);
- tasq ? console.log("tasq : " + tasq.toString()) : null;
- console.log('debugData 3-------------------------');
- // handleError()
- throw error
- }
- else throw cancelsignal;
- })
- }
- else if(!p) {
- handleError({ error : true, message : 'Failed without result' }, pVal);
- console.log("Bypass remaining on prior failure");
- return false; // All remaining tasks will return false in the any results even if they are promisies still running or functions not initiated.
- }
- else return p; // A truthy value
- }
- , Promise.resolve(true)
- );
- }
-
- function hasKey (obj, keys) {
- var o = obj;
- keys.slice(0,-1).forEach(function (key) {
- o = (o[key] || {});
- });
-
- var key = keys[keys.length - 1];
- return key in o;
- }
-
- function isNumber (x) {
- if (typeof x === 'number') return true;
- if (/^0x[0-9a-f]+$/i.test(x)) return true;
- return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
- }
-
-
-
-
-
-
- // -------------------------------------------------------------------
- // timeUtils
- const daysbits = 7;
- const datesbits = 31;
- const monthsbits = 12;
-
- // 2**53-1 (+/-) is largest integer precision for 64 bit floating point IEE 754
- // 7 + 31 + 12 = 50 bits which fits.
- const datebitOffset = daysbits;
- const monthbitOffset = datesbits + daysbits; // Months are 0 based. So we need to offeset by 1 more so 31st is not overrwritten.
-
- const monthsMask = 0b111111111111 * 2** (monthbitOffset);
- const datesMask = 0b1111111111111111111111111111111 * 2 ** (datebitOffset);
- const daysMask = 0b1111111;
-
- var timeUtils = {
- // PB : TODO -- Currently assuming event e1 is a sub 1 day duration. Which may not be true.
- toRecurringPattern( event ){
- var dayBitToSet = event.from.getDay(); // 0 based Index
- var dateBitToSet = event.from.getDate() + datebitOffset - 1; // Dates are 1 based.
- var monthBitToSet = event.from.getMonth() + monthbitOffset; // 0 based
-
- var recurring = 2**dayBitToSet + 2**dateBitToSet + 2**monthBitToSet;
- // PB : TODO -- loop through all matching masks until the end.
- return {
- from : event.from, to : event.to, recurring: recurring
- , start: new Date ( event.from - new Date( moment__default['default'](event.from).startOf('day') ) )
- , end: new Date ( event.to - new Date( moment__default['default'](event.to).startOf('day') ) )
- }
- }
- , getSkipFunction(r, boundedRange){
- var areMonthsSelected = monthsMask & r.recurring;
- var areDatesSelected = datesMask & r.recurring;
- var areDaysSelected = daysMask & r.recurring;
-
- if(!areMonthsSelected && !areDatesSelected && !areDaysSelected) {
- console.error("Null patterns are useless for selection. This is probably not a recurring pattern");
- return null;
- }
-
- var filter = { from : boundedRange && boundedRange.from || new Date(moment__default['default']().startOf('day')), to : boundedRange && boundedRange.to };
-
- // Returns how much to skip for next available value for a dimension.
- var reset = Symbol('reset');
- var stop = Symbol('stop');
- var skipFn = {
- create : (options)=>{
- var startFrom = options.startFrom;
- options.nBits;
- return {
- originOffset : null // From the origin.
- , getSkipGenerator : (selected)=>{
- var startOffset = null; // From position to start from.
-
- // var cycleEntryPoint = null;
- var nextCycleIndex = 0;
- var incrementCycle = [];
- var previous = 0;
- // Discover the cycle from the bitmask.
- for(var b = 0; b < nBits; b++) {
- if(selected & 1) {
- if(utils.js.isNull(originOffset)) this.originOffset = b;
- if(utils.js.isNull(startOffset) && (startFrom - b) <= 0){
- // startOffset cannot be negative. cycleEntryPoint is from the origin and is the entrypoint when there is no fitler.from...
- startOffset = b - startFrom; // As measured from filter.from i.e from startingPoint
- // cycleEntryPoint = b
- nextCycleIndex = incrementCycle.length-1; // The place to enter cycle after startoffset aligns to currentCycleIndex.
- }
- incrementCycle.push(1 + b - previous); // We keep pushing and then splice in the first item as the last item to make this cyclical.
- previous = 1 + b; // Minimum incrment is always 1;
- }
- }
- // Due to the cyclical nature incrementCycle[0] has the increment to the second item
- // and incrementCycle[incrementCycle.length-1] points to first item in cycle.
- incrementCycle.push(incrementCycle.splice(0,1));
- if(nextCycleIndex < 0) nextCycleIndex = 0;
- return function*(){
- var signal = false;
- signal = yield startOffset; // Could be 0. Aligns to the first match in the cycle after from.
- var i = nextCycleIndex;
- for(;;){
- for(; i < incrementCycle.length; i++ ) {
- signal = yield incrementCycle[i];
- if(reset === signal) { signal = yield this.originOffset; break; }
- if(signal === stop || signal.done) return null;
- }
- i = 0;
- }
- }
- }
-
- // Generator for Irregular boundaries.
- , getNextDateGenerator(selection){
- var iterator = this.getSkipGenerator(selection);
-
- return function*(){
- var nextPotentialDate = moment__default['default'](potentialDate).add(iterator.next(), 'd');
- if(nextPotentialDate.month() != potentialDate.getMonth()) {
- // Handle month boundary increments.
- nextPotentialDate.startOf('month').add(dateIterator.next(reset), 'm');
- }
- var potentialDate = nextPotentialDate;
- yield nextPotentialDate;
- }
- }
- // Cyclical Generator.
- , getNextGenerator(options, selection){
- this.getSkipGenerator(selection);
- var next = filter.from;
-
- return function*(){
- yield next = moment__default['default'](next).add(dayIterator.next(), 'd');
- }
- }
- }
- }
- };
- var monthSkipper = skipFn.create({ nBits : monthsbits, startFrom : filter.from.getMonth() });
- var daySkipper = skipFn.create({ nBits : daysbits, startFrom : filter.from.getDay() });
- var dateSkipper = skipFn.create({ nBits : datebits, startFrom : filter.from.getDate()-1 }); // Skipfn requires a 0 based startFrom.
-
- if(!areMonthsSelected && !areDatesSelected) return daySkipper(areDaysSelected)
- else if(!areDatesSelected && !areDaysSelected) return monthSkipper(areMonthsSelected/2**(datesbits + daysbits))
- else if(!areMonthsSelected && !areDaysSelected) return dateSkipper(areDatesSelected/2**(daysbits))
- else {
- if(!areMonthsSelected) {
- // Dates, Days are selected.
- return function*(){
-
- var dateIterator = dateSkipper.getNextDateGenerator({ nBits : datebits, startFrom : filter.from.getDate()-1 }, areDatesSelected/2**(daysbits));
- var dayIterator = daySkipper.getNextGenerator({ nBits : daysbits, startFrom : filter.from.getDay() }, areDaysSelected);
-
- var potentialDay = null;
- var potentialDate = dateIterator.next(); // Irregular cycle end...
- if(isAnd) {
- // Both day and date shuld match.
- for(;;){
-
- for(; (potentialDay = dayIterator.next()) < potentialDate ;);
- // PB : TODO -- If we never hit the equals condition this will be a perpetual loop.
- // If both are integer skips we will have a LCM and therefore hit this condition.
- // In the case of sets of irregular skips we still will have the sum of each set also have an LCM.
- // However for irregular boundaries we cannot predict whether an LCM exists and if a equality condition will ever be met.
- // In such cases we need to protect from an infinite loop that will never yield.
- // For dates though despite the irregular boundaries the pattern is that every date, month combination falls on every day of week.
- if(potentialDay == potentialDate) {
- yield potentialDay;
- potentialDate = dateIterator.next();
- continue;
- }
- for(; (potentialDate = dateIterator.next()) < potentialDay;);
- }
- }
- else {
-
- for(;;){
-
- for(; (potentialDay = dayIterator.next()) < potentialDate ;) {
- if(stop === (yield potentialDay)) return null;
- }
- if(potentialDay == potentialDate) {
- potentialDate = dateIterator.next();
- continue; // We need to yield in sorted sequence.
- }
- for(; (potentialDate = dateIterator.next()) < potentialDay;) {
- if(stop === (yield potentialDate)) return null;
- }
- }
- }
- }
- }
-
- }
- }
- , skipThisRecurrable : Symbol('skipThisRecurrable')
- , stopThisIterator : Symbol('stopThisIterator')
- , toEvents( r, boundedRange){
- if(!boundedRange.to) throw 'toEvents requires a bounded Range with an end to terminate. Use generater for unbounded operations'
- ({ from : boundedRange.from || new Date(moment__default['default'](new Date()).startOf('day')), to : boundedRange.to });
- }
- , jsstart : function(){
- return new Date(moment__default['default'](new Date(0)).startOf('day')) //1st Jan 1970 12AM local time
- }
- // Returns the whole event that is qualified even by a partial intersection.
- , getEventGenerator : function* (objOrArray, boundedRange, getEvent) {
-
-
- getEvent = getEvent || function(r, startOfDayFrom, start, end) {
- var event = Object.assign( {}, r);
- delete event.recurring;
-
-
- event.from = new Date (startOfDayFrom.getTime() + start.getTime() + utils.getTZOffsetMilliseconds() );
- event.to = new Date ( startOfDayFrom.getTime() + end.getTime() + utils.getTZOffsetMilliseconds());
- // { from : new Date ( startOfDayFrom.getTime() + start.getTime() ) , to : new Date ( startOfDayFrom.getTime() + end.getTime()) }
- return event
- };
-
- var recurrables = utils.js.isObject(objOrArray) ? [objOrArray] : objOrArray;
-
- // We need to start somewhere. We dont need an end as we keep generating perpetually.
- var filter = { from : boundedRange && boundedRange.from || new Date(moment__default['default']().startOf('day')), to : boundedRange && boundedRange.to };
- for(var gIdx=0; gIdx < recurrables.length; gIdx++){
- // Explode eachRecurrable to list of qualified events
- var eachRecurrable = recurrables[gIdx]; // eachRecurrable -> Recurrable event (eg)
- if( eachRecurrable.to && eachRecurrable.to <= filter.from ) continue; // Disjoint. No need to generate. Usually a past recurring pattern.
-
- var startFrom = filter.from;
-
- if( eachRecurrable.from) {
- if(filter.to && filter.to <= eachRecurrable.from ) continue; // Disjoint.
- if(eachRecurrable.from >= filter.from) startFrom = eachRecurrable.from;
- }
-
- var startOfDayFrom = new Date( moment__default['default'](startFrom).startOf('day') ); // PB : TODO -- IMP pattern TZ...
- var next = null;
-
- var stopAt = eachRecurrable.to ? filter.to ? Math.min(filter.to, eachRecurrable.to) : eachRecurrable.to : filter.to ? filter.to : false;
- var shouldStop = stopAt ? ()=>{ return option === this.skipThisRecurrable || next.from >= stopAt } : ()=>{ return option === this.skipThisRecurrable || false }; // Perpetual callee can stop asking for next()..
-
- // time recurring patterns are sorted and sequential so there is no chance we will find any more after end.
- // which implies there is no need to test the rest of the recurring patterns until end of the boundary
- if(filter.to && eachRecurrable.to) {
- var stopAt = new Date(Min(filter.to, eachRecurrable.to));
- shouldStop = ()=>{ return option === this.skipThisRecurrable || (stopAt <= next.to ? stopAt : false) };
- }
-
- var start = eachRecurrable.start || this.jsstart();
- var end = eachRecurrable.end || new Date(moment__default['default'](start).add(1, "d"));
-
- var option = true;
- next = getEvent(eachRecurrable, startOfDayFrom, start, end);
-
- while( !shouldStop() ) {
- // PB : TODO -- If we provide an impossible pattern match we will perpetually not match and end up in an infinite loop.
- var patternMatched = this.__hasPatternIntersection(next, eachRecurrable);
- if(patternMatched) option = yield next;
- if(option === this.stopThisIterator) return null;
- // PB : TODO -- Instead of checking every day skip straightaway to the next sequential pattern match.
- startOfDayFrom = new Date( moment__default['default'](startOfDayFrom).add(1, 'd') );
- next = getEvent(eachRecurrable, startOfDayFrom, start, end);
- }
- }
- }
-
- // PB : TODO -- Generator that returns a series of intersections events.
- // , recurringIntersectionsG : ()=>{}
-
- , isEvent : function(obj){
- return !obj.recurring
- }
- , isRecurringPattern : function(obj){
- return obj.recurring
- }
- , hasEventIntersection( e1Orr1, e2Orr2 ){
- return utils.timeUtils.isEvent(e1Orr1) && utils.timeUtils.isRecurringPattern( e2Orr2 ) ? utils.timeUtils.__recurringHasIntersection( e1Orr1, e2Orr2 )
- : utils.timeUtils.isEvent(e2Orr2 ) && utils.timeUtils.isRecurringPattern( e1Orr1 ) ? utils.timeUtils.__recurringHasIntersection( e2Orr2, e1Orr1 )
- : utils.timeUtils.isEvent(e1Orr1) && utils.timeUtils.isEvent(e2Orr2) ? utils.timeUtils.__hasEventIntersection( e1Orr1, e2Orr2 )
- : utils.timeUtils.__willPatternsIntersect( e1Orr1, e2Orr2 ) //(()=>{throw 'PB : TDOO -- To Be implemented'})()
- }
-
- , __hasPatternIntersection( e1, p2 ){
-
- var areMonthsSelected = monthsMask & p2.recurring;
- var areDatesSelected = datesMask & p2.recurring;
- var areDaysSelected = daysMask & p2.recurring;
-
- // PB : TODO -- Gaurd against impossible patters like 29th Feb, 31st April etc...
-
- if(!areMonthsSelected && !areDatesSelected && !areDaysSelected) {
- console.error("Null patterns are useless for selection. This is probably not a recurring pattern");
- return null; // Null patterns result in null intersection.
- }
-
- var isAnd = false;
- if(!areMonthsSelected && !areDatesSelected || !areMonthsSelected && !areDaysSelected || !areDatesSelected && !areDaysSelected ) ;
- else {
- isAnd = p2.isAnd;
- }
-
- var p1 = this.toRecurringPattern(e1);
- var patternMatched = p1.recurring & p2.recurring;
- // In the and case asserts if p1 is a subset of p2 not the other way around. A recurring pattern should always be a superset of an event.
- // And that is what is being queried... for any degree of usefulness.
- return ( isAnd ? p1.recurring === patternMatched : patternMatched );
- // returns truthy pattern that intersects.
- }
-
- , __willPatternsIntersect( p1, p2 ){
-
- if(p1.from && p2.to && p2.to <= p1.from) return false;
- if(p2.from && p1.to && p1.to <= p2.from) return false;
-
- var areMonthsSelected = monthsMask & p2.recurring;
- var areDatesSelected = datesMask & p2.recurring;
- var areDaysSelected = daysMask & p2.recurring;
-
- // PB : TODO -- Gaurd against impossible patters like 29th Feb, 31st April etc...
-
- if(!areMonthsSelected && !areDatesSelected && !areDaysSelected) {
- console.error("Null patterns are useless for selection. This is probably not a recurring pattern");
- return null; // Null patterns result in null intersection.
- }
-
- var isAnd = false;
- if(!areMonthsSelected && !areDatesSelected || !areMonthsSelected && !areDaysSelected || !areDatesSelected && !areDaysSelected ) ;
- else {
- isAnd = p2.isAnd;
- }
-
- var areP1MonthsSelected = monthsMask & p1.recurring;
- var areP1DatesSelected = datesMask & p1.recurring;
- var areP1DaysSelected = daysMask & p1.recurring;
-
- // PB : TODO -- Gaurd against impossible patters like 29th Feb, 31st April etc...
-
- if(!areP1MonthsSelected && !areP1DatesSelected && !areP1DaysSelected) {
- console.error("Null patterns are useless for selection. This is probably not a recurring pattern");
- return null; // Null patterns result in null intersection.
- }
-
- var isP1And = false;
- if(!areP1MonthsSelected && !areP1DatesSelected || !areP1MonthsSelected && !areP1DaysSelected || !areP1DatesSelected && !areP1DaysSelected ) ;
- else {
- isP1And = p1.isAnd;
- }
-
-
- if(isAnd && isP1And === isAnd ) {
- return p1.recurring === p2.recurring;
- }
- else if(isAnd) {
- matchtarget = p2.recurring ;
- }
- else if(isP1And ) {
- matchtarget = p1.recurring ;
- }
-
- var patternMatched = p1.recurring & p2.recurring;
- // In the and case asserts if p1 is a subset of p2 not the other way around. A recurring pattern should always be a superset of an event.
- // And that is what is being queried... for any degree of usefulness.
-
- var __patternMatched = ( isAnd || isP1And ? matchtarget === patternMatched : patternMatched );
-
- if(__patternMatched) {
- if(p1.start && p2.end && p2.end <= p1.start) return false;
- if(p2.start && p1.end && p1.end <= p2.start) return false;
-
- return true;
-
- }
- else {
- return false
- }
- // returns truthy pattern that intersects.
- }
- , __recurringHasIntersection(e1, r1){
-
- // PB : TODO -- Date patterns UTC or Local ? i.e does a Monday mask match UTC Mondays or Local Mondays ????
- // PB : TODO -- Use recunrence generator insteadof startOf today hack based on simplified same day start end assumptions.
- if(e1.from && r1.to && r1.to <= e1.from) return false;
- if(r1.from && e1.to && e1.to <= r1.from) return false;
- // Returns intersection or false.
- return ( utils.timeUtils.__hasPatternIntersection(e1, r1) ) ? (()=>{
- // new Date ( new Date( this.rdata.get('unavailablefrom') ) - new Date( moment().startOf('day') ) )
-
- var startOfe1 = new Date( moment__default['default'](e1.from).startOf('day') );
- var r1E = {
- from: new Date(startOfe1.getTime() + r1.start.getTime() + utils.getTZOffsetMilliseconds() )
- , to: new Date(startOfe1.getTime() + r1.end.getTime() + utils.getTZOffsetMilliseconds() )
- };
- return utils.timeUtils.__hasEventIntersection(e1, r1E)
- })()
- : false
- }
-
- // Checks if two non recurring i.e singular events intersect and if so returns the actual intersection.
- , __hasEventIntersection(e1, e2){
-
- // PB : TODO -- No assertions for invalid inputs e.from is expected to be <= e.to
- if(!e1.from && !e1.to) return e2;
- if(!e2.from && !e2.to) return e1;
-
- var e1FromAnde2To = e1.from && e2.to;
- var e2FromAnde1To = e2.from && e1.to;
-
- var __aFrombTo = (a, b)=>{
- // boundary value overlap is insufficient for intersection. At least 1 millisecond diff is required.
- return (a.from >= b.to ? false
- : a.to && a.to > b.to || !a.to ?
- { from : b.from && b.from > a.from ? b.from : a.from, to : b.to }
- : b.from && b.from >= a.to ? false : { from : b.from && b.from > a.from ? b.from : a.from, to : a.to }
- )
- };
-
- var result = e1FromAnde2To ? __aFrombTo(e1, e2)
- :( e2FromAnde1To ? __aFrombTo(e2, e1)
- : /* e1FromAnde2To is false and e2FromAnde1To is false => either both froms or both tos exist */
- e1.from ? { from: new Date(Math.max(e1.from, e2.from)) } : { to: new Date(Math.min(e1.to, e2.to)) });
-
- return result
- }
-
- , exludeIntersection(freeTimes, e) {
- // Removal of unavilable times will split and splice into the same freeTimes array.
- for(var i =0; i < freeTimes.length; i++) {
- var intersection = timeUtils.hasEventIntersection(freeTimes[i], e);
- if(intersection) {
- // Edit freetime to correct for current collision.
- if(freeTimes[i].from >= intersection.from && freeTimes[i].to <= intersection.to) {
- freeTimes.splice(i,1); i = i--;
- }
- else {
- var right = Object.assign({}, freeTimes[i]);
- right.from = intersection.to;
- freeTimes[i].to = intersection.from;
- if( right.from < right.to ) {
- freeTimes.splice(++i,0, right); // Skip this we have already processed it.
- }
- }
- }
- }
- }
-
- , getFreeTimes( tRange, events, dimensions) {
- var freeTimes = [tRange];
- for(var eIdx = 0; eIdx < events.length; eIdx++) {
- var e = events[eIdx];
- timeUtils.exludeIntersection(freeTimes, e);
- if(freeTimes.length === 0) break;
- }
- // { result : freeTimes.length > 0, freeTimes : freeTimes}
- return freeTimes;
- }
-
- // PB : TODO -- Timeutils Test cases. Comment in production.
- , testAll(){
-
- // // Disjoint
- // var expected = false
- // var actual = null;
-
- expected = 2**4 + 2**(6+21) + 2**(5+31+6);
- actual = this.toRecurringPattern(
- { from : new Date('5/21/2020, 11:45:00 PM'), to : new Date('5/22/2020, 00:15:00 AM') } ).recurring;
- if(expected !== actual ) throw (' TEST FAILED toRecurringPattern : expected = ' + expected + ' actual = ' + actual)
-
- // actual = this.__hasEventIntersection(
- // { from : new Date('5/21/2020, 11:45:00 PM'), to : new Date('5/22/2020, 00:15:00 AM') }
- // , { from : new Date('5/22/2020, 11:45:00 PM'), to : new Date('5/23/2020, 00:15:00 AM') })
- // if(expected !== actual ) throw (' TEST FAILED Disjoint : expected = ' + expected + ' actual = ' + actual)
-
- // // Interleaved
- // expected = JSON.stringify({ from : new Date('5/22/2020, 00:00:00 AM'), to : new Date('5/22/2020, 00:15:00 AM') })
- // actual = this.__hasEventIntersection(
- // { from : new Date('5/21/2020, 11:45:00 PM'), to : new Date('5/22/2020, 00:15:00 AM') }
- // , { from : new Date('5/22/2020, 00:00:00 AM'), to : new Date('5/22/2020, 00:30:00 AM') })
- // if(expected !== JSON.stringify(actual) ) throw (' TEST FAILED Interleaved : expected = ' + expected + ' actual = ' + JSON.stringify(actual))
-
- // // Subset
- // expected = JSON.stringify({ from : new Date('5/22/2020, 00:00:00 AM'), to : new Date('5/22/2020, 00:10:00 AM') })
- // actual = this.__hasEventIntersection(
- // { from : new Date('5/21/2020, 11:45:00 PM'), to : new Date('5/22/2020, 00:15:00 AM') }
- // , { from : new Date('5/22/2020, 00:00:00 AM'), to : new Date('5/22/2020, 00:10:00 AM') })
- // if(expected !== JSON.stringify(actual) ) throw (' TEST FAILED Interleaved : expected = ' + expected + ' actual = ' + JSON.stringify(actual))
-
- // Null
-
- // Boundary Test Cases....
-
- var r1 = {
- end: new Date("1970-01-01T11:00:00.000Z")
- , every: null
- , from: new Date("2020-06-04T06:30:00.000Z")
- , id: "DC664060-A0A8-11EA-8B3D-7771F3D49CC1"
- , migrationstate: 1
- , practitionerId: "5FDF1790-8288-11E9-9044-91D8D8658887"
- , purpose: "Meeting"
- , recurring: 106
- , start: new Date("1970-01-01T06:30:00.000Z")
- , status: "SCHEDULED"
- , to: null
- };
- var e1 = {
- availability: false
- , end: null
- , every: null
- , for: null
- , from: new Date("2020-06-08T11:00:00.000Z")
- , id: "AEC5A7E1-A96D-11EA-8DE7-19E354C126F4"
- , migrationstate: 8
- , patientId: "271F4970-F173-4530-A894-68F520BF7945"
- , patientmob: "9944715969"
- , patientname: "SAMUEL RAJA DURAI J"
- , practitionerId: "5FDF1790-8288-11E9-9044-91D8D8658887"
- , purpose: "Appointment"
- , start: null
- , status: "SCHEDULED"
- , to: new Date("2020-06-08T11:15:00.000Z")
- };
-
- this.hasEventIntersection(e1, r1);
- debugger
- // Iterators
- var eventIterator = this.getEventGenerator({ recurring : 2**1 }); // All Mondays from today.
- for(var i=0, e; i<10 && !(e=eventIterator.next()).done; i++) {
- console.dir(e);
- }
-
- }
- };
-
- function promisify(ctx, asyncoperation, arraylikearguments) {
- var originalcallback = arraylikearguments.splice(arraylikearguments.length-1, 1)[0];
- return new Promise(function(resolve, reject) {
- asyncoperation.call(ctx, ...arraylikearguments, function(err, result) {
- if (err) return reject(arguments);
- resolve(arguments);
- });
- }).then((aArr)=>{
- originalcallback(...aArr);
- return aArr[1]
- }).catch(function(aArr){
- originalcallback(...aArr);
- throw aArr[0];
- });
- }
-
-
-
- var Tasq$1 = (function(){
-
- var __proto__ = {
- };
-
- var listeners = [];
-
- function Tasq(first, ...rest){
- first.info = utils.assign({ args : rest }, __proto__);
- return first
- }
- Tasq.create = Tasq;
- Tasq.addlistener = (l)=>{ listeners.push(l); };
- Tasq.catch = (e)=>{ console.error(e); console.error(e.messages.join(' ')); listeners.forEach(l => { l(e); } );};
- Tasq.then = (d)=>{ listeners.forEach(l => { l(null, d); } ); return d};
- return Tasq
- })();
-
-
-
- var Traq$1 = (function(){
- var __proto__ = {};
-
- var log = {
- SUCCESS : []
- , FAILURE : []
- , SKIPPED : []
- };
-
- Traq$1 = function(){ return utils.assign({}, __proto__) };
- Traq$1.create = Traq$1;
- Traq$1.statuslog = statuslog;
- function statuslog(err, data){
- if(err) log.FAILURE.push( {err, data} );
- else log.SUCCESS.push(data);
- }
- Traq$1.notify = (event)=>{
- if(event.error) log.FAILURE.push( event );
- else log.SUCCESS.push(event);
- };
- Traq$1.finally = ()=>{
- console.log('Total : ' + (log.SKIPPED.length + log.SUCCESS.length + log.FAILURE.length));
- console.log('Pass : ' + log.SUCCESS.length );
- console.log('Fail : ' + log.FAILURE.length);
- console.log('Skipped : ' + log.SKIPPED.length);
-
- console.log('FAILURES');
- console.log([JSON.stringify(log.FAILURE)]);
- };
- return Traq$1
- })();
-
-
- var tzoffset = 0;
- var utils = {
-
- escapeRegExp(string) {
- return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
- }
-
- , getTZOffsetMilliseconds : (()=>{
- var d = new Date();
- var t1 = d.toISOString().replace('Z','');
- var t2 = d.toISOString();
- tzoffset = ( new Date(t2) - (new Date(t1))); // /60/60/1000 -- milliseconds.
- return ()=>{ return tzoffset}
- })()
-
- , getLocalDateYYYYMMDD(date){
- var d = new Date();
- d.setTime(tzoffset + new Date(date).getTime());
- return d.toISOString().slice(0,10).replace(/-/g,"")
- }
-
- , assign(target /** , ...sources */) {
- return utils.assign_core(false, ...arguments)
- }
-
- , assign_caseless(target /** , ...sources */) {
- return utils.assign_core(true, ...arguments)
- }
-
- // assign
- , assign_core(ignorecase, target /** , ...sources */) {
- // Important use this instead of Object.assign.
- // Object.assign has several limitations.
- // 1) It doesn't skip intermediates if the final overriden value is already determined.
- // This implementation address this.
- // 2) It is shallow and doesn't clone object references and therefore risks side effects to original nested objects.
- // This implementation deep clones objects arrays and other types with some limitations.
- // 3) Does not merge but allways overrides.
- // Merges objects and arrays. Overides primitives.
- // Array merge is by default a concatenation.
- // PB : TODO -- If corresponding array indices have objects they can be merged like lodash.
- // 4) Does not retain non writable and configurable attributes.
- // This implementation copies descirptors so clones retain non writability and configurability identical to the source.
- // 5) Recursion can cause infinite recursion. Object.assign doesn't deal with this.
- // Detects and avides ininite recursion.
-
- var cpi = {}; // Caseless property index of already processed target keys. Since we do not alter the target key we need a lookup that gives the actual key.
- var getNormalizedKey = ignorecase ? (key)=>key : (key)=> key.toLowerCase(); // returns a normalized equivalent key.
-
- // We do a right to left iterations!
- // overrideKeys = true;
-
- // PB : Note -- IMPORTANT alreadyScanned has side effects..
- var alreadyScanned = (key)=>{
-
- Object.keys(target).forEach(k => {
- cpi[k.toLowerCase()] = k;
-
- if(cpi[k.toLowerCase()] !== k){
- Object.defineProperty( target, cpi[k.toLowerCase()], Object.getOwnPropertyDescriptor(target, k) ); // Relocate to new overridden key
- delete target[tkeys[tkidx]]; // PB : TODO -- review that accessors are not called during delete !
- }
- });
- alreadyScanned = ()=>{ return true; }; // Dont do anything next time we are called.
- // Its not necessary that we found it.
- cpi[key.toLowerCase()] ? null : cpi[key.toLowerCase()] = key;
- return false;
- };
-
- // PB : Note -- IMPORTANT findEqualKey has side effects..
- var findEqualKey = (key) => {
- // If equiv key on the target is what the target key should ultimately be we will cache all possible now.
- // However in the overrideKeys case this is not true in which case we postpone until the first one found in the overrider.
- {
-
- if(alreadyScanned(key)) { cpi[key.toLowerCase()] ? null : cpi[key.toLowerCase()] = key; } }
- var targetKey = cpi[key.toLowerCase()];
- return { targetKey, propertyDescriptor : Object.getOwnPropertyDescriptor(target, targetKey) }
- };
-
- var hOP = Object.prototype.hasOwnProperty;
-
- var __assign = function(ignorecase, target /** , ...sources */) {
-
- if(utils.js.isUndefined(target)) return; // There is noting to assign to. We just play dumb. Why did the caller even call us ?
-
- // PB : TODO -- we need a flag to support undefined overrides. Default behavior is to retain as much as possible.
- // if(utils.js.isUndefined(arguments[arguments.length-1])) return undefined;
- var undef = 0;
- for(; undef < arguments.length-1 && utils.js.isUndefined(arguments[arguments.length-undef-1]); undef++); // Skip all undefined overrides.
- if(undef === arguments.length-1) return target;
-
- if(utils.js.isPrimitive(arguments[arguments.length-1-undef])) return arguments[arguments.length-1-undef];
- else {
- // PB : TODO -- Primitive targets cannot be preserved.
- // Target should be decided on first non primitive discovery.
- // Arrays don't work properly yet...
- // We start with a temporary object and if there is a primitive override it will override this temporary object altogether.
- // PB : TODO -- We could convert primitives to their respective object counterparts... Howeer strings with indexes and arrays will get messy.
- if(utils.js.isPrimitive(target)) {
- target = {};
- } }
-
- for(var
- finalized = {} // One instance for each structurally corresponding key that has already been overridden. Order need not be guaranteed.
- , overrideOrMerge = function (originalkey) {
- // Decision merge or override default to the following.
- // Primitives are overridden by non Primitives ( arrays or objects )
- // Non Primitives are overridden by Primitives. There is no concept of assigning Primitives as new named attributes of Objects.
- // Objects assigned to Objects will be merged.
- // Arrays assigned to Arrays will be merged i.e concatenated. PB : TOOD -- Order will be ??? target then right to left for sources.
-
- // PB : TODO -- We should avoid examining or tampering with the value during clone and should find another way to make this decision.
- // We do not want side effects to occur while examining the value. Accessors and proxies can do this.
- // Currently assuming simple use cases at this point...
- // Ideally Accessor Descriptors should be postponed for evaluation when runtime access to value is required.
-
- var { targetKey, dL } = findEqualKey(originalkey);
- var dR = Object.getOwnPropertyDescriptor(this, originalkey);
-
- if(!dL) {
- // target did not have what it should be according to what was specifed. Lets check for other possibilities.
- dL = Object.getOwnPropertyDescriptor(target, originalkey);
- if(!dL) { Object.defineProperty( target, targetKey, dR ); finalized[targetKey] = true; return; }
- }
-
- if(!utils.js.isUndefined( dR.writable )) { // writable attribute is present only in Data Descriptor Case
- var valR = this[originalkey]; // We can examine data descriptors without any side effects. ( PB : TODO -- Proxies ! are expected to be transparent !! )
- if(utils.js.isPrimitive( valR )) {
- finalized[targetKey] = true;
-
- // Primitive values also are implicitly cloned by Data Descriptors when defineProperty is called.
- // Advantage is writable / configurable permissions are retained instead of simple assignment.
- Object.defineProperty( target, targetKey, dR );
- return
- }
- // If its not primitive it may need to get merged if the Left value is also non primitive and of a compatible type...
- }
-
- // PB : TODO -- Data descriptor that is not writable needs to be handled !? proper check to handle value etc required.
- if(utils.js.isUndefined( dR.writable ) || utils.js.isUndefined( dL.writable ) ){
- // One or both of them is an accessor descriptor.
- // If either one of them is an accessor we need to postpone the merge to runtime evaluation on access.
-
- var dChosen = !utils.js.isUndefined( dL.writable ) ? dR : dL; // Figure out which one is the accessor.
-
- // Accessor Descriptors cannot be examined due to possible side effects and possible differences
- // in the value and its type at the point of execution.
- // Since the accessed value here is meaningless we don't know what type it will eventually be at the point wehre
- // real program code needs the value !!!
- // There are 2 options
- // 1) we could do a decoupling here (at clone time) and capture the value.
- // 2) or we could postpone until run time evaluation.
- // Since in either case We need to examine the value it may be superior to evaluate at runtime and decide then.
- // Although decoupling is important and better done as early as possible the delayed value is more important.
- // PB : TODO -- We should provide a pref to evaluate and decouple at clone time
- // PB : TODO -- The postponing strategy has one more issue where delayed override can clobber target modifications on the left side.
- // -- Causing unexpected values specifically when the delayed override value from the source is expected.
- // Ideally the value that was set intermediately should supercede.
- // -- The preferred behaviour implemented here is to decouple on first set such that the intermediate value set on the clone supercedes.
- // Original getter needs to access value in original context.
- // Setters need to be redirected to "cloned setter" in current context.
- var ctx = this;
- var dRGetter = !utils.js.isUndefined( dR.writable ) ? function(){ return dR.value} : dR.get;
- var dLGetter = !utils.js.isUndefined( dL.writable ) ? function(){ return dL.value} : dL.get;
- var valForSetter = null;
- dR.configurable;
-
- if(!utils.js.isUndefined( dL.writable )) {
- // Oridinarily since we postpone we need to refrence and reevaluete valL also at access time coz the target val could have been switched.
- // The target is now an accessor which gets decoupled on first set in that case there is no need to re-evaluate.
- // These getters are still valid until such a first set happens until which time the valL remains
- // It is therefore possible to cache the valL and use it instead of target[key] at access time....
- var valL = target[targetKey];
- if(utils.js.isPrimitive(valL)) { dChosen.get = function(){ return dRGetter.call(ctx) }; }
- else { dChosen.get = function(){
- // In this case decoupling could happen on first access instead of first set.
- return utils.assign_core(ignorecase, valL, dRGetter.call(ctx))
- };
- }
- }
- else {
- // rVal could be an accessor or a nonPrimitive. Either case it needs to be mreged in.
- dChosen.get = function(){ return utils.assign_core(ignorecase, dLGetter.call(target), dRGetter.call(ctx)) };
- }
-
- // __setter ! Although this is running in the current context we cant use the dR.set setter like so dL.set = dR.set
- // this is dangerous as we do not know what else the setter does !!!. We don't konw what the getter does either
- // but we need to do a one time read in any case wheter at clone time or at access time.
- dChosen.set = function(val) {
- // First time set on clone decouples
- dChosen.get = function() { return valForSetter};
- dChosen.set = function(val) { return valForSetter = val };
- dChosen.configurable = true;
- Object.defineProperty( target, targetKey, dChosen );
- return valForSetter = val
- };
- dChosen.configurable = true;
- Object.defineProperty( target, targetKey, dChosen );
- finalized[targetKey] = true;
- return
- }
-
- // Neither is an accessor. valR is nonPrimitive, dL is not an Accessor
- // Target is also a Data Descriptor. We can examine it as well to take a decision.
- var valL = target[targetKey]; // We can examine data descriptors without any side effects. ( Proxies ! are expected to be transparent !! )
- if(utils.js.isPrimitive( valL )) {
- if(!utils.js.isNull( valR ) && !utils.js.isUndefined( valR )) {
- finalized[targetKey] = true;
- Object.defineProperty( target, targetKey, dR );
- }
- return
- }
- else {
- // Neither is Primitive.
- // console.log('Assign Iter...')
- if(valL === valR) { finalized[targetKey] = true; return true;}
- if(utils.js.isObject( valL ) && utils.js.isObject( valR )) { utils.assign_core(ignorecase, valL, valR ); finalized[targetKey] = true; return;}
- if(utils.js.isArray( valL ) && utils.js.isArray( valR )) { target[targetKey] = valL.concat(valR); finalized[targetKey] = true; return;}
- if(utils.js.isNull( valL ) || utils.js.isNull( valR )) { target[targetKey] = valR; finalized[targetKey] = true; return;}
- if(utils.js.isUndefined( valL ) && utils.js.isUndefined( valR )) { target[targetKey] = valR; finalized[targetKey] = true; return;}
-
- // Functions are tricky. Closures and bound functinos will continue to refer to source locations and could cause unpredictable behaviour.
- // However if such bound functions are being used the intention must be retention of such linkage.
- if(utils.js.isFunction( valL ) && utils.js.isFunction( valR )) { target[targetKey] = valR; return;}
-
- // Unsupported assign / merge for property datemodified data types Thu Sep 10 2020 15:59:38 GMT+0530 (India Standard Time)
- // , Thu Sep 10 2020 15:54:22 GMT+0530 (India Standard Time)
- // SAM : TODO dates are not getting merged.
- // if(utils.js.isDate( valL ) && utils.js.isDate( valR )) { target[targetKey] = valR; return;}
-
- var msg = `Unsupported assign / merge for property ${targetKey} data types ` + valL + ' , ' + valR;
- console.error(msg);
- throw msg;
- }
- }
- , appendmissing = function (originalkey) {
- var standardizedKey = getNormalizedKey(originalkey);
- if (!hOP.call(finalized, standardizedKey)) overrideOrMerge.call(this, originalkey);
- }
- // Start from the rightmost and override or merge.
- , _junkvar = Object.keys(arguments[arguments.length-1-undef]).forEach(overrideOrMerge, arguments[arguments.length-1-undef])
- , i = arguments.length-1-undef;
- 2 < i--;
- utils.js.isUndefined(arguments[i]) ? null :
- // Intermediate primitives are useless. Skipped coz the target has already been assigned.
- utils.js.isPrimitive(arguments[i]) ? null
- : Object.keys(arguments[i]).forEach(appendmissing, arguments[i])
- ){}
-
-
- return target;
- };
-
- return __assign(...arguments)
- }
-
-
- // PB : TODO -- Proper type checking.
- // , __TPL__typeHandlers : {
- // '[object String]' : defaultFn
- // , '[object Array]' : defaultFn
- // , '[object Object]' : defaultFn
- // , '[object Null]' : defaultFn
- // , '[object Undefined]' : defaultFn
- // , '[object Date]' : defaultFn
- // , '[object RegExp]' : defaultFn
- // , '[object Function]' : defaultFn
- // }
-
- // PB : TODO -- Proper type checking.
- // Javascript language utilities that should have been really in the language itself.
- , js : {
-
- typeInstances : [
- ""
- , 0
- , true
- , null
- , // undefined
- , []
- , {}
- , Symbol()
- , new Date()
- , /.*/
- , Promise.resolve(true)
- , function() {}
- , BigInt(0)
- ]
- , proxyable : []
- , nonproxyable : []
-
- , isString(x) {
- return Object.prototype.toString.call(x) === "[object String]"
- }
- , isNumber(x) {
- return Object.prototype.toString.call(x) === '[object Number]'
- }
- , isBoolean(x) {
- return Object.prototype.toString.call(x) === '[object Boolean]'
- }
- , isNull(x) {
- return Object.prototype.toString.call(x) === '[object Null]'
- }
- , isUndefined(x) {
- return Object.prototype.toString.call(x) === '[object Undefined]'
- }
- , isArray(x) {
- return Object.prototype.toString.call(x) === '[object Array]'
- }
- , isObject(x) {
- return Object.prototype.toString.call(x) === '[object Object]'
- }
- , isSymbol(x) {
- return Object.prototype.toString.call(x) === '[object Symbol]'
- }
- , isDate(x) {
- return Object.prototype.toString.call(x) === '[object Date]'
- }
- , isRegExp(x) {
- return Object.prototype.toString.call(x) === '[object RegExp]'
- }
- , isPromise(x) {
- return Promise.resolve(x) === x
- }
- , isPromiseOrFunction(o) {
- if(utils.js.isPromise( o ) || utils.js.isFunction(o)) return true;
- return false;
- }
- , isFunction(x) {
- return Object.prototype.toString.call(x) === '[object Function]'
- }
- , isBigInt(x) {
- return Object.prototype.toString.call(x) === '[object BigInt]'
- }
-
- , isDataDescriptor(d) { return (utils.js.isUndefined(d.set) && utils.js.isUndefined(d.get)) ? d : false }
-
- // Grouping JS Types into 4 Groups
- // Primitives
- // -- boolean, String, Number
- // Arrays
- // Objects
- // Special
- // -- date, regexp, function ... and other unkown types
- , typeGroups() {
- return [
- '[Primitive]'
- , '[Null]'
- , '[Undefined]'
- , '[Symbol]'
- , '[Array]'
- , '[Object]'
- , '[Special]'
- ]
- }
-
- , typeGroup(x) {
- var tgMap = {
- '[object String]' : '[Primitive]'
- , '[object Number]' : '[Primitive]'
- , '[object Boolean]' : '[Primitive]'
- , '[object Null]' : '[Null]'
- , '[object Undefined]' : '[Undefined]'
- , '[object Symbol]' : '[Symbol]'
- , '[object BigInt]' : '[BigInt]'
-
- , '[object Array]' : '[Array]'
- , '[object Object]' : '[Object]'
- , '[object Date]' : '[Special]'
- , '[object RegExp]' : '[Special]'
- , '[object Function]' : '[Special]'
- , '[object Promise]' : '[Special]'
- };
- return tgMap[Object.prototype.toString.call(x)]
- }
-
- , getTypeInfo(x) {
-
- var typeMap = {
- '[object String]' : //__assign(typeInfo,
- { typeGroup : '[Primitive]', isString : true, isPrimitive : true
- , create : ()=>{return ""} }
- //)
- , '[object Number]' : { typeGroup : '[Primitive]', isNumber : true, isNumeric : true, isPrimitive : true
- , create : ()=>{return 1}}
- , '[object Boolean]' : { typeGroup : '[Primitive]', isBoolean : true, isPrimitive : true
- , create : ()=>{return true}}
- , '[object Null]' : { typeGroup : '[Null]', isNull : true
- , create : ()=>{return null}}
- , '[object Undefined]' : { typeGroup : '[Undefined]', isUndefined : true
- , create : ()=>{return }}
- , '[object Symbol]' : { typeGroup : '[Symbol]', isSymbol : true
- , create : ()=>{return new Symbol()}}
- , '[object BigInt]' : { typeGroup : '[BigInt]', isNumeric : true, isPrimitive : true
- , create : ()=>{return new BigInt()}}
-
- , '[object Array]' : { typeGroup : '[Array]', isArray : true
- , create : ()=>{return []}}
- , '[object Object]' : { typeGroup : '[Object]', isObject : true
- , create : ()=>{return {}}}
- , '[object Date]' : { typeGroup : '[Special]', isDate : true
- , create : ()=>{return new Date}}
- , '[object RegExp]' : { typeGroup : '[Special]', isRegExp : true
- , create : ()=>{return new RegExp}}
- , '[object Function]' : { typeGroup : '[Special]', isFunction : true
- , create : ()=>{return new Function}}
- , '[object Promise]' : { typeGroup : '[Special]', isPromise : true
- , create : ()=>{ throw "Blank promise cannot be created."}}
- };
- return typeMap[Object.prototype.toString.call(x)]
- }
-
- , isPrimitive(x) {
- var xType = this.nativeType(x);
- return xType === '[object Boolean]' || xType === '[object String]' || xType === '[object Number]' || xType === '[object Symbol]' ||
- xType === '[object BigInt]'
- }
-
- , isSpecial(x) {
- return !isArray(x) && !isObject(x) && !isPrimitive(x)
- }
-
- , nativeTypes() {
- return [
- // Primitives
- '[object String]'
- , '[object Number]'
- , '[object Boolean]'
- , '[object Null]'
- , '[object Undefined]'
- , '[object Symbol]'
- , '[object BigInt]'
-
- // Non Primitives.
- , '[object Array]'
- , '[object Object]'
- , '[object Date]'
- , '[object RegExp]'
- , '[object Function]'
- , '[object Promise]'
- ]
- }
-
- , nativeType(x) { return Object.prototype.toString.call(x) }
-
- }
-
- // Upsert for a hash ??
- , hashupsert : function(oA, oB){
- Object.keys(oA).forEach(( oAKey )=>{
- if(oB[oAKey]) {
- var distinct = new Set(oA[oAKey]);
- oB[oAKey].forEach((each)=>{
- distinct.add(each);
- });
- oA[oAKey] = Array.from(distinct);
- }
- });
- }
-
- // Upsert for an array.
- // Also the same as pushdistinct. Target is expected to have only one instance.
- , upsert(arr, val) {
- // 0 -- did nothing
- // 2 -- inserted
- // 3 -- updated
- // PB: TODO -- We can use (new Set(arr)).add ???. But is this more expensive ?
- var found = arr.find((element)=>{ return element === val});
- return found ? utils.js.isObject(val) && utils.js.isObject(val) ? (Object.assign( found, val), 3) : 0
- : (arr.push(val), 2) ;
- }
-
- // accumulate
- // o[toVectorPropName] which is an array
- // and o[propName] which is a string
- // into vectorTarget which is an array
- // already previously accumulated in a similar manner probably already attached as oTarget[toVectorPropName]
-
- // 0 or undefined or null -- didnt do anything. ( val doesn't exist )
- // 1 -- created target and inserted val
- // 2 -- didn't create target but inserted val
- // 3 -- didn't create target but updated val and also handled o[propName].
- , accumulate : function(val, o, propName, toVectorPropName, vectorTargetCreator,
- identityEvaluator
- ){
- var created = 0;
-
- if(utils.js.isUndefined(val)) return; // Nothing to do i.e. nothing was provided to accumulate. We don't accumulate undefined.
- if(val === o[propName]) return; // Nothing to do.
-
- var vectorTargetContainer = o[toVectorPropName] || (o[toVectorPropName] = {});
- if(!vectorTargetCreator) vectorTargetCreator = { create : (val)=>{
- return val ? vectorTargetContainer[o["id"]] = [val] : [] } };
-
- var vectorTarget = vectorTargetContainer[o["id"]];
-
- if(!vectorTarget) {
- created = 1;
- vectorTarget = vectorTargetContainer[o["id"]] = vectorTargetCreator.create(o[propName]);
- }
-
- if(!identityEvaluator) identityEvaluator = (a, b)=>{ return a === b };
-
- var upsertResult = 0;
- if(!created && !utils.js.isUndefined(o[propName])) {
- if(!vectorTargetContainer[o["id"]].find((element)=>{ return identityEvaluator(element, o[propName]) })) {
- upsertResult = utils.upsert(vectorTarget, o[propName]);
- }
- }
- upsertResult = utils.upsert(vectorTarget, val);
- return created ? created : upsertResult;
- }
-
- // async Utils
- , async : {
- all(list, task){
- var queueditems=[];
- list.forEach(function(v, i, a) {
- queueditems.push(task(v, i, a));
- });
- return Promise.all(queueditems)
- }
- }
-
-
- // PB : TODO -- Remove these.
- // , fsdb : require('./fsdb/fsdb')
- // , xlsx : require('./fsdb/xlsx')
- // , xlsxvalidator : require('./fsdb/xlsxvalidator')
-
- , timeUtils
- , dx: dx_1
- , cliargs: cliargs$1
- , any: any$1
- , promisify
- , moment: moment__default['default']
- , Tasq: Tasq$1
- , Traq: Traq$1
- };
-
- var utils_1 = utils;
-
- var naiveFallback = function () {
- if (typeof self === "object" && self) return self;
- if (typeof window === "object" && window) return window;
- throw new Error("Unable to resolve global `this`");
- };
-
-
- // https://mathiasbynens.be/notes/globalthis
- var globalThis_1 = (function () {
- if (this) return this;
-
- // Unexpected strict mode (may happen if e.g. bundled into ESM module)
-
- // Fallback to standard globalThis if available
- if (typeof globalThis === "object" && globalThis) return globalThis;
-
- // Thanks @mathiasbynens -> https://mathiasbynens.be/notes/globalthis
- // In all ES5+ engines global object inherits from Object.prototype
- // (if you approached one that doesn't please report)
- try {
-
- Object.prototype.__defineGetter__('__global__', function() {
- return this;
- });
- __global__.globalThis = __global__; // lolwat
-
- } catch (error) {
- // Unfortunate case of updates to Object.prototype being restricted
- // via preventExtensions, seal or freeze
- return naiveFallback();
- }
- try {
- // Safari case (window.__global__ works, but __global__ does not)
- if (!__global__) return naiveFallback();
- return __global__;
- } finally {
- delete Object.prototype.__global__;
- }
- })();
-
- // A selector based channels implementation as compared to a simple array.
- var channelMixin = (function() {
-
- // get channels that qualify for a selector.
- function getSubscriptions(selector) {
- console.dir(this.__channels);
- var filtered = this.__channels; // start with the world...
- // Selector is a simple list of tags.
- for(var select in selector) {
- if(!filtered[selector[select]]) {
- // If the assumption is that all indexes are properly built it implies this channel doesn't exist.
- return []; // We are looking for all selectors therefore if even one fails we don't have anything.
- }
- filtered = filtered[selector[select]];
- }
-
- return filtered['__data']; // Flattened array
- }
-
- function addSubscription(selector, func, context) {
-
- var unfulfilled = selector.splice(0);
- var filtered = this.__channels; // start with the world...
- console.log(filtered);
- for(var select in unfulfilled) {
- if(!filtered[unfulfilled[select]]) {
- filtered[unfulfilled[select]] = { __data : [] };
- }
- filtered = filtered[unfulfilled[select]];
- unfulfilled = unfulfilled.splice(0,1);
- }
-
- // PB : TODO -- All accessor paths need to be indexed !
- // Will currently fail if not published and queried in the same order.
- filtered.__data.push({context: context, callback: func});
- }
-
- return function(){
- this.__channels = {};
- this.getSubscriptions = getSubscriptions;
- this.addSubscription = addSubscription;
- return this;
- }
- })();
-
- // Mediator pattern.
- var mediator = (function() {
-
- var __subscribe = function(selector, func, context) {
- var subscriptions = this.channels.getSubscriptions(selector);
-
- if(subscriptions.length < 1){
- this.channels.addSubscription(selector, func, context);
- }
-
- return this;
- };
-
- var __publish = function(selector) {
- console.log('publishing for selector ' + selector);
- var subscriptions = this.channels.getSubscriptions(selector);
- console.log(subscriptions);
- if(subscriptions.length < 1){ return; }
- var args = Array.prototype.slice.call(arguments, 1);
- for(i=0; i < subscriptions.length; i++) {
- subscription = subscriptions[i];
- subscription.callback.apply(subscription.context, args);
- }
- return this;
- };
-
- return function mediator() {
- var thisObj = this ? this : {};
- Object.defineProperty(thisObj, 'channels', { value : channelMixin.apply({}), writable: false, enumerable : false});
- thisObj.publish = __publish;
- thisObj.subscribe = __subscribe;
- return thisObj;
- };
- })();
-
- // Unique ID creation requires a high quality random # generator. In node.js
- // this is pretty straight-forward - we use the crypto API.
-
-
-
- var rng = function nodeRNG() {
- return crypto__default['default'].randomBytes(16);
- };
-
- /**
- * Convert array of 16 byte values to UUID string format of the form:
- * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
- */
- var byteToHex = [];
- for (var i$1 = 0; i$1 < 256; ++i$1) {
- byteToHex[i$1] = (i$1 + 0x100).toString(16).substr(1);
- }
-
- function bytesToUuid(buf, offset) {
- var i = offset || 0;
- var bth = byteToHex;
- // join used to fix memory issue caused by concatenation: https://bugs.chromium.org/p/v8/issues/detail?id=3175#c4
- return ([bth[buf[i++]], bth[buf[i++]],
- bth[buf[i++]], bth[buf[i++]], '-',
- bth[buf[i++]], bth[buf[i++]], '-',
- bth[buf[i++]], bth[buf[i++]], '-',
- bth[buf[i++]], bth[buf[i++]], '-',
- bth[buf[i++]], bth[buf[i++]],
- bth[buf[i++]], bth[buf[i++]],
- bth[buf[i++]], bth[buf[i++]]]).join('');
- }
-
- var bytesToUuid_1 = bytesToUuid;
-
- // **`v1()` - Generate time-based UUID**
- //
- // Inspired by https://github.com/LiosK/UUID.js
- // and http://docs.python.org/library/uuid.html
-
- var _nodeId;
- var _clockseq;
-
- // Previous uuid creation time
- var _lastMSecs = 0;
- var _lastNSecs = 0;
-
- // See https://github.com/broofa/node-uuid for API details
- function v1(options, buf, offset) {
- var i = buf && offset || 0;
- var b = buf || [];
-
- options = options || {};
- var node = options.node || _nodeId;
- var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq;
-
- // node and clockseq need to be initialized to random values if they're not
- // specified. We do this lazily to minimize issues related to insufficient
- // system entropy. See #189
- if (node == null || clockseq == null) {
- var seedBytes = rng();
- if (node == null) {
- // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
- node = _nodeId = [
- seedBytes[0] | 0x01,
- seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]
- ];
- }
- if (clockseq == null) {
- // Per 4.2.2, randomize (14 bit) clockseq
- clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;
- }
- }
-
- // UUID timestamps are 100 nano-second units since the Gregorian epoch,
- // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
- // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
- // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
- var msecs = options.msecs !== undefined ? options.msecs : new Date().getTime();
-
- // Per 4.2.1.2, use count of uuid's generated during the current clock
- // cycle to simulate higher resolution clock
- var nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1;
-
- // Time since last uuid creation (in msecs)
- var dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs)/10000;
-
- // Per 4.2.1.2, Bump clockseq on clock regression
- if (dt < 0 && options.clockseq === undefined) {
- clockseq = clockseq + 1 & 0x3fff;
- }
-
- // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
- // time interval
- if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {
- nsecs = 0;
- }
-
- // Per 4.2.1.2 Throw error if too many uuids are requested
- if (nsecs >= 10000) {
- throw new Error('uuid.v1(): Can\'t create more than 10M uuids/sec');
- }
-
- _lastMSecs = msecs;
- _lastNSecs = nsecs;
- _clockseq = clockseq;
-
- // Per 4.1.4 - Convert from unix epoch to Gregorian epoch
- msecs += 12219292800000;
-
- // `time_low`
- var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
- b[i++] = tl >>> 24 & 0xff;
- b[i++] = tl >>> 16 & 0xff;
- b[i++] = tl >>> 8 & 0xff;
- b[i++] = tl & 0xff;
-
- // `time_mid`
- var tmh = (msecs / 0x100000000 * 10000) & 0xfffffff;
- b[i++] = tmh >>> 8 & 0xff;
- b[i++] = tmh & 0xff;
-
- // `time_high_and_version`
- b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
- b[i++] = tmh >>> 16 & 0xff;
-
- // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
- b[i++] = clockseq >>> 8 | 0x80;
-
- // `clock_seq_low`
- b[i++] = clockseq & 0xff;
-
- // `node`
- for (var n = 0; n < 6; ++n) {
- b[i + n] = node[n];
- }
-
- return buf ? buf : bytesToUuid_1(b);
- }
-
- var v1_1 = v1;
-
- // var __g = __G.__g;
- globalThis_1.mediator = mediator.apply({});
- // __g.mediator = __g.mediator.apply({})
- console.dir(globalThis_1.mediator);
-
-
- const indexHelper = (function(){
-
- var getPermutations = function(array){
- var permutations = {};
- // l(array.splice(0, 1))
- for(var i in array) {
- // l(array[i]);
- var aclone = array.slice(0);
- aclone.splice(i, 1);
- permutations[array[i]] = getPermutations(aclone );
- }
- return permutations
- };
-
- var getCombinations = function(array){
- // P & C
- // http://www.scielo.br/scielo.php?script=sci_arttext&pid=S0104-65002001000200009
- var set = [];
- var alen = array.length;
- var combinations = 1 << alen; // Math.pow(2, array.length);
-
- for (var i = 1; i < combinations ; i++){
- var combination= [];
- for (var j=0;j<alen;j++) {
- if ((i & (1 << j))){
- combination.push(array[j]);
- }
- }
- set.push(combination);
- }
-
- return set;
- };
-
- return function(obj) {
- obj.getPermutations = getPermutations;
- // obj.getPermutations = getPermutations_HeapsMethod;
- obj.getCombinations = getCombinations;
-
- return obj;
- };
- })();
-
- const AnyStore = (function(){
- // A store that can store any type and lookup any type.
- // Weakmaps cannot have primitives as keys and hashs cannot have objects as keys.
- // This wraps hash and a weakmap into an abstract class that routes to the appropriate
- // store based on the type of the object.
-
- const getForPrimitive = function(primitive, target) { return target.storeForPrmitives[primitive] };
- const getForObject = function(obj, target) { return target.storeForObjects.get(obj) };
- const getForSymbol = function(symbol, target) { return target.storeForObjects.get(target.__symbolToObj[symbol]) };
-
- const setForPrimitive = function(primitive, content, target) {
- // PB : -- Note : Importatn -- No difference between 100 and "100" due to JS keys all being strings...
- target.storeForPrmitives[primitive] = content;
- return content;
- };
-
- const setForObject = function(obj, content, target) {
- // PB : TODO -- need to listen to changes in content and its attributes to re-index it.
- target.storeForObjects.set(obj, content);
- return content;
- };
- const setForSymbol = function(symbol, content, target) {
- // PB : TODO -- need to listen to changes in content and its attributes to re-index it.
- target.storeForObjects.set(target.__symbolToObj[symbol], content);
- return content;
- };
-
- const getFor = {
- '[object String]' : getForPrimitive
- , '[object Object]' : getForObject
- , '[object Symbol]' : getForSymbol
- };
- getFor['[object Number]'] = getFor['[object String]'];
- getFor['[object Array]'] = getFor['[object Object]'];
-
- const setFor = {
- '[object String]' : setForPrimitive
- , '[object Object]' : setForObject
- , '[object Symbol]' : setForSymbol
- };
- setFor['[object Number]'] = setFor['[object String]'];
- setFor['[object Array]'] = setFor['[object Object]'];
-
- function IndexFactory(__symbolFromObj, __symbolToObj, valuecompare) {
- // In some cases we are looking for value equivalence and in others referenced object equivalence.
- // Implicit behavior is to use referenced object equivalence as valuecompare is undefined.
- // What we really need is dereferencing until real value is reached.
- // And value compare in scope even if the value is an extremely long stream of bits..
- // Both of these are expensive in terms of scanning and finding the info required.
- // p[p.Index(what, true)] !! is not a value compare for find.
- // We also need to deal with sorting and filtering....
- if(valuecompare) throw "Not yet implemented."
- return function Index(anyThing, bDontCreate){ return utils_1.js.isPrimitive(anyThing) ? anyThing : (__symbolFromObj.get(anyThing) ? __symbolFromObj.get(anyThing) :
- (()=>{
- if(bDontCreate) return
- var newSymbol = Symbol();
- __symbolFromObj.set(anyThing, newSymbol);
- __symbolToObj[newSymbol] = anyThing;
- return newSymbol })()
- ) }
- }
- function AnyStore(){
-
- // Dispatch based on type of prop.
- var targ = { storeForPrmitives : {}, storeForObjects : new WeakMap(), __symbolToObj : {}, __symbolFromObj : new WeakMap() };
- var p = new Proxy( targ
- , {
- // PB : TODO -- Proxy handler gets hit for Index function prop..
- get: function (target, prop) { return getFor[utils_1.js.nativeType(prop)](prop, target); }
- , set: function (target, prop, content) { return setFor[utils_1.js.nativeType(prop)](prop, content, target); }
- });
- p.Index = IndexFactory(targ.__symbolFromObj, targ.__symbolToObj);
- p.get = (what)=>{ return p[p.Index(what, true)] };
- p.set = (what, content)=>{ return p[p.Index(what)] = content};
- return p
- }
- AnyStore.create = AnyStore;
- return AnyStore
- })();
-
-
- function expandUint32Array(arr, data) {
- const newArray = new Uint32Array(arr.length + data.length);
- newArray.set(arr); // copy old data
- newArray.set(data, arr.length); // copy new data after end of old data
- return newArray;
- }
-
- const HEX_FFFFFFFF = 0xFFFFFFFF;
- const HEX_FFFF0000 = 0xFFFF0000;
- const HEX_FF00 = 0xFF00;
- const HEX_F0 = 0xF0;
- const HEX_0C = 0x0C;
-
- const MAX_32BITS = HEX_FFFFFFFF;
- const MAX_53BITS = Number.MAX_SAFE_INTEGER;
-
- const BIGINT_HEX_FFFFFFFF = BigInt(HEX_FFFFFFFF);
- BigInt(HEX_FFFF0000);
- BigInt(HEX_FF00);
- BigInt(HEX_F0);
- BigInt(HEX_0C);
-
- const BIGINT_MAX_32BITS = BIGINT_HEX_FFFFFFFF;
-
- const BIGINT_0 = BigInt(0);
- const BIGINT_1 = BigInt(1);
- BigInt(2);
- BigInt(4);
- BigInt(8);
- BigInt(16);
- const BIGINT_32 = BigInt(32);
-
- // Only Positive numbers;
- function *bigIntBufferGenerator(bn){
- // len = len || find32BitArrLen(bn); // Inefficeint to detect. Lets just iterate and see where it ends...
- var signal = {};
- var stop = Symbol();
- var i = 0;
- for(;;){
- var bits32 = new Uint32Array(1);
- if(bn > MAX_32BITS){
- bits32[0]= Number((bn & BIGINT_MAX_32BITS));
- signal = (yield {i, bits32}) || {};
- if(signal === stop || signal.done) return {i, bits32};
- bn >>= BIGINT_32;
- i++;
- }
- else {
- bits32[0] = Number(bn);
- return {i, bits32};
- }
- }
- }
-
- function bigIntToBuffer(bn) {
- // if(utils.js.isUndefined(bn) || utils.js.isNull(bn)) throw 'bigIntToBuffer suported only for BigInts...'
- if(!utils_1.js.isBigInt(bn)) throw 'bigIntToBuffer suported only for BigInts...'
- // PB : Note -- bn must be passed in. Callee should validate.
- var buffer = null;
- var iterator = bigIntBufferGenerator(bn);
- var next = iterator.next();
- if(next && !next.done) buffer = next.value.bits32;
- else return next.value.bits32;
- while(!(next = iterator.next()).done) {
- // PB : TODO -- Ineffficient copy in a loop !!
- // It would be really nice to know how much space is needed. In the absence lets do binary expansion.
- buffer = expandUint32Array(buffer, next.value.bits32);
- }
- buffer = expandUint32Array(buffer, next.value.bits32);
- return buffer;
- }
-
- function bufferToBigInt(buffer) {
- // PB : Note -- buffer must be a Uint32Array. Callee should validate.
- var bn = BIGINT_0;
- for(var i=buffer.length; --i > -1;){ bn <<= BIGINT_32; bn |= BigInt(buffer[i]); }
- return bn;
- }
- // A bitmask can also be specified by a index number of the bit in a BitArray
- // Implemented as a class to distinguish from a mask value.
- // For convenieance mask value is provided the ability to be passed in as a Number althout BitIndexes are more naturally in the Number Space..
- // mask values larger than 32 bits will implicitly need to be converted to BitArrays.
- const BitIndex = (function() { function BitIndex(){ return this } // BitIndex constructor.
- // Should support Numbers, BigInt and Uint32Array.
-
- function __is__(t){ if(t === BitIndex) return true; }
- function __is(type){ return typeof this === type ? true : __is__(type) }
-
- function __create(n){
-
- return BitIndex.apply({
- value : n
- , is : __is
- })
- }
-
- __create.create = __create;
- return __create
- })();
-
- // function leftshift(m){ return utils.js.isNumber(m) ? leftshift_Number(m) : leftshift_BigInt(m) } // Universal.
- function leftshift_Number(m){ return m << 1 }
- function leftshift_BigInt(m){ return m << BIGINT_1 }
- // function leftshift_Uint32Array(m) { throw "leftshift_Uint32Array not yet implemented." }
-
- function indexOfLSB32(x, gptwo){
- // x needs to be a 32 bit number.
- // Private functions don't do validations to avoid overhead of validation.
- // Only public api's need to validate inputs.
- if(x === 0) return null;
-
- var i = 0;
- x & 0xFFFF0000 && (i += 16, x >>= 16),
- x & 0xFF00 && (i += 8, x >>= 8),
- x & 0xF0 && (i += 4, x >>= 4),
- x & 0x0C && (i += 2, x>>= 2),
- x & 2 && (i += 1);
- // x & 1 && (i = 0);
- return i;
- }
-
- // PB : TODO -- Not yet implemented... profile to see if this is any more performant.
- // function indexOfLSB_BigInt_DeBruijn(x, gptwo){
- // // x needs to be a BigInt.
- // // gptwo needs to be BigInt
- // // Private functions don't do validations to avoid overhead of validation.
- // // Only public api's need to validate inputs.
- // if(x === 0) return null;
- // gptwo = gptwo || x & -x;
-
- // // DeBruijn explodes on multiplication and needs to work on BigInts even if the results are containted in 32 bits...
- // // PB : TODO -- Not sure if this is faster. In any case BigInts are slower.
- // var MultiplyDeBruijnBitPosition = [
- // 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
- // 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9
- // ];
- // return MultiplyDeBruijnBitPosition[( ( gptwo * BigInt( 0x077CB531 )) >> BigInt(27) ) % BigInt(32) ];
- // }
-
- // https://stackoverflow.com/questions/757059/position-of-least-significant-bit-that-is-set
- // http://graphics.stanford.edu/~seander/bithacks.html
-
- const BitArrayUpto32Bits = (function(){
- function validateBitLength(length){ if(length > 32) throw 'BitArrayUpto32Bits doesnt accept BitLength > 32' }
-
- function __createA(arr){
- validateBitLength(arr.length);
- var created = __create();
-
- // PB : TODO -- Changes this to preincrement. Mask need not overflow for 32 bits...
- var iterateUpto = [
- ()=>{for(var i =0 ; i < 1; i++) { console.log(i); created.assignMask(arr[i], { title : arr[i]}); }}
- , ()=>{for(var i =1 ; i < Math.min(31, arr.length); i++) { console.log(i); created.assignMask(arr[i], { title : arr[i]}, leftshift_Number ); }}
- , ()=>{for(var i =31; i < Math.min(32, arr.length); i++) { console.log(i); created.assignMask(arr[i], { title : arr[i]}, (m)=>{ return leftshift_Number(m)>>>0 } ); }}
- ];
- arr.length > 31 ? iterateUpto.forEach(f=>f()) :
- arr.length > 1 ? iterateUpto.slice(0,2).forEach(f=>f()) :
- iterateUpto[0]();
- return created;
- }
-
- function __createO(o){
- var arr = Object.keys(o);
- validateBitLength(arr.length);
-
- var created = __create();
-
- var iterateUpto = [
- ()=>{for(var i =0 ; i < 1; i++) { console.log(i); created.assignMask(arr[i], o[arr[i]]); }}
- , ()=>{for(var i =1 ; i < Math.min(31, arr.length); i++) { console.log(i); created.assignMask(arr[i], o[arr[i]], leftshift_Number ); }}
- , ()=>{for(var i =31; i < Math.min(32, arr.length); i++) { console.log(i); created.assignMask(arr[i], o[arr[i]], (m)=>{ return leftshift_Number(m)>>>0 } ); }}
- ];
- arr.length > 31 ? iterateUpto.forEach(f=>f()) :
- arr.length > 1 ? iterateUpto.slice(0,2).forEach(f=>f()) :
- iterateUpto[0]();
-
- return created;
- }
-
- function __create(){
- var labels = {};
- var masks = {};
-
- var currentMaxMask;
- function __nextMask(){ __nextMask = leftshift_Number;
- return currentMaxMask = 1; }
-
- // var store = ??? new Uint32Array(1)var mxn = Mixin.create()
- utils_1.assign(mxn,
- {
- validateMask(m){
- if(__is(m, BitIndex)) {
- if(m > 32) throw 'BitArrayUpto32Bits doesnt accept BitIndex > 32'
- return { BitIndex, labels : [masks[indexToMask(m.value)]]
- // , indices : m.value
- }
- }
- if(m > MAX_32BITS) throw "BitArrayUpto32Bits only supports numbers upto MAX_32BITS "
- if(!utils_1.js.isNumber(+m)) throw "BitArrayUpto32Bits requires Numbers upto MAX_32BITS "
- return true;
- }
- , labelsToMask : (__labels)=>{
- var result = 0; __labels.forEach(l=>{ result |= labels[l]; });
- return result >>> 0;
- }
- , hasMask : function(label) { return labels[label] ? labels[label].mask : null ; }
- , maskToLabels(m, transformEach){
- var valid = this.validateMask(m);
- if(!valid) throw "Invalid Mask"
- if(valid.BitIndex) return valid.labels;
-
- var __labels = [];
- for(var gptwo;gptwo=m&-m;m^=gptwo) {
- if(!masks[gptwo]) { console.log('Error : Invalid mask passed in.'); }
- else __labels.push( transformEach(masks[Number(gptwo)], labels[masks[Number(gptwo)]]) );
- }
- return __labels;
- }
- , labelToMask : (l)=>{ return labels[l] }
- , bit_or : (a, b)=>a | b
- , bit_and : (a, b)=>a & b
- , bit_xor : (a, b)=>a ^ b
- , bit_not : (a)=> ~a
-
- , assignMask : function(label, entity, incrementFn) {
- var lmask = this.hasMask(label); if(lmask) return lmask; // Already assigned.
- labels[label] = entity;
- labels[label].mask = currentMaxMask = incrementFn ? incrementFn(currentMaxMask) : __nextMask(); // Use the next unused mask for this dictionary of labels. Currently random. We should eventually have a sort order.
- masks[labels[label].mask] = label;
- return labels[label];
- }
- , msbIndex : function(v) { throw "msb Not yet implemented" }
- , indexToMask : function(index) {
- if(index > 31) throw 'Not supported beyond 32 bits.'
- return (1 << index) >>> 0;
- }
- , indicesToMask : function(indices){
- var mask = 0;
- indices.forEach(index=>{
- if(index > 31) throw 'Not supported beyond 32 bits.'
- mask |= (1 << index);
- });
- return mask >>> 0;
- }
- , maskToIndices : function(m) {
- var valid = this.validateMask(m);
- if(!valid) throw "Invalid Mask"
- if(valid.BitIndex) return [m.value];
- var indices = [];
- var gptwo;
- for (;gptwo=m&-m;m^=gptwo) indices.push(indexOfLSB32(gptwo));
- return indices;
- }
- , bit_shiftl : (a, s)=>{ return a << s }
- , bit_shiftr : (a, s)=>{ return a >> s }
- , bit_shiftr_uz : (a)=>{ return a >>> 0} // Unsigned right shift by 0.
- // , bit_shiftl_1 : ()=>{}
-
- , toJSON(radix, eachFn){
- var transFormed = {};
- if(!eachFn) return labels;
- Object.keys(labels).forEach(label =>{
- transFormed[label] = eachFn(labels[label]);
- });
- return transFormed;
- }
- , test(){
- Object.keys(masks).forEach((v, i)=> {
- console.log( v );
- console.log( i + ' : ' + v.toString(2) );
- console.log( this.maskToIndices(v));
- });
- console.log( (173).toString(2) );
- this.maskToIndices(173).map( (i)=>{ console.log( i ); });
- console.log('indicesToMask :' + this.indicesToMask([1,4,31]).toString(2));
- }
- });
- }
-
- var creatorFor = {
- '[object Array]' : __createA
- , '[object Object]' : __createO
- , 'undefined' : function(){ return __create() }
- };
-
- // PB : TODO -- Constructor is not preserved... But mixing in an external passed in object is what we want to achive.
- function BitArrayUpto32Bits(){
- return arguments.length ? creatorFor[utils_1.js.nativeType(arguments[0])](...arguments) :
- creatorFor['undefined'](...arguments)}
-
- BitArrayUpto32Bits.create = BitArrayUpto32Bits;
- return BitArrayUpto32Bits
- })();
-
- const Mixin = (function(){
-
- function create(){
-
- var __mixins = new WeakMap();
- __mixins.set(Mixin, true);
-
- function __is__(t, type){
- if(utils_1.js.isPrimitive(t)) return false;
- if(!t || !t.mixins) return false;
- return t.mixins().get(type) ? true : false ; }
- function __is(v, type){ return typeof v === type ? true : __is__(v, type) }
-
- return { addMixin : (clazz)=>{ __mixins.set(clazz, true);}
- , is : __is
- }
- }
-
- return {create}
- })();
-
- const BitArrayBigInt = (function(){
-
-
- function __createA(arr){
- var created = __create();
-
- for(var i =0 ; i < 1; i++) { created.assignMask(arr[i], { title : arr[i]}); }
- for(var i =1 ; i < arr.length; i++) { created.assignMask(arr[i], { title : arr[i]}, leftshift_BigInt ); }
- return created;
- }
-
- function __createO(o){
- var arr = Object.keys(o);
- var created = __create();
-
- for(var i =0 ; i < 1; i++) { created.assignMask(arr[i], o[arr[i]]); }
- for(var i =1 ; i < arr.length; i++) { created.assignMask(arr[i], o[arr[i]], leftshift_BigInt ); }
-
- return created;
- }
-
- function __create(){
- var labels = {};
- var masks = {};
-
- var currentMaxMask;
- function __nextMask(){ __nextMask = leftshift_BigInt;
- return currentMaxMask = BIGINT_1; }
-
- // var store = ??? new Uint32Array(1)
- var mxn = Mixin.create();
- var created = utils_1.assign(mxn,
- {
- validateMask(m){
- if(mxn.is(m, BitIndex)) {
- return { BitIndex, labels : [masks[indexToMask(m.value)]] }
- }
- if(!utils_1.js.isBigInt(BigInt(m))) throw "BitArrayBigInt requires BigInt Mask "
- return true;
- }
- , labelsToMask : (__labels)=>{
- var result = BIGINT_0; __labels.forEach(l=>{ result |= labels[l]; });
- return result ;
- }
- , hasMask : function(label) { return labels[label] ? labels[label].mask : null ; }
- , maskToLabels(m, transformEach){
- m = BigInt(m);
- var valid = this.validateMask(m);
- if(!valid) throw "Invalid Mask"
- if(valid.BitIndex) return valid.labels;
-
- var __labels = [];
- for(var gptwo;gptwo=m&-m;m^=gptwo) {
- if(!masks[gptwo]) { console.log('Error : Invalid mask passed in.'); }
- else __labels.push( transformEach(masks[Number(gptwo)], labels[masks[Number(gptwo)]]) );
- }
- return __labels;
- }
- , labelToMask : (l)=>{ return labels[l] }
- , bit_or : (a, b)=>a | b
- , bit_and : (a, b)=>a & b
- , bit_xor : (a, b)=>a ^ b
- , bit_not : (a)=> ~a
-
- , assignMask : function(label, entity, incrementFn) {
- var lmask = this.hasMask(label); if(lmask) throw `Duplicate assignment for same label ${label} not allowed : mask (${lmask}) ` // Already assigned.
- labels[label] = entity;
- labels[label].mask = currentMaxMask = incrementFn ? incrementFn(currentMaxMask) : __nextMask(); // Use the next unused mask for this dictionary of labels. Currently random. We should eventually have a sort order.
- masks[labels[label].mask] = label;
- return labels[label];
- }
- , msbIndex : function(v) { throw "msb Not yet implemented" }
- , indexToMask : function(index) {
- return BIGINT_1 << index;
- }
- , indicesToMask : function(indices){
- var mask = 0;
- indices.forEach(index=>{
- mask |= (1 << index);
- });
- return mask;
- }
- , maskToIndices : function(m) {
- var valid = this.validateMask(m);
- if(!valid) throw "Invalid Mask"
- if(valid.BitIndex) return [m.value];
- var indices = [];
- var gptwo;
-
- var iterator = bigIntBufferGenerator(BigInt(m));
-
- var next;
- // if(next && !next.done) buffer = next.value.bits32;
- // else return next.value.bits32;
- var i = 0;
- while(!(next = iterator.next()).done) {
- next.value.bits32 > 0 ?
- ( ()=> { for(;gptwo=(next.value.bits32& -next.value.bits32) ;next.value.bits32^=gptwo) indices.push(32 * i + indexOfLSB32(gptwo)); } )
- : null;
- i++;
- }
- for(;gptwo=(next.value.bits32&-next.value.bits32);next.value.bits32^=gptwo) indices.push(32 * i + indexOfLSB32(gptwo));
-
- return indices;
- }
- , bit_shiftl : (a, s)=>{ return a << s }
- , bit_shiftr : (a, s)=>{ return a >> s }
- , bit_shiftr_uz : (a)=>{ throw "BigInt doesnt suppored unsigned right shift."} // Unsigned right shift by 0.
- // , bit_shiftl_1 : ()=>{}
- , toJSON(radix, eachFn){
- var transFormed = {};
- if(!eachFn) return labels;
- Object.keys(labels).forEach(label =>{
- transFormed[label] = eachFn(labels[label]);
- });
- return transFormed;
- }
- , tosqlcte() {
-
- var select = '';
- // debugger
- Object.keys(labels).forEach((label, index, array) =>{
- var labelObject = labels[label];
- var rowselect = 'select ';
- Object.keys(labelObject).forEach((key, index, array) =>{
- rowselect = rowselect + ` '${labelObject[key]}' ${key}`;
- if(array.length !== index+1) rowselect = rowselect + ',';
- });
- select = select + rowselect;
- if(array.length !== index+1) select = select + '\n union all \n';
- });
-
- console.log(select);
- return labels
-
-
- }
- , test(){
- Object.keys(masks).forEach((v, i)=> {
- console.log( v );
- console.log( i + ' : ' + v.toString(2) );
- console.log( this.maskToIndices(v));
- });
- console.log( (173).toString(2) );
- this.maskToIndices(173).map( (i)=>{ console.log( i ); });
- console.log('indicesToMask :' + this.indicesToMask([1,4,31]).toString(2));
- console.log(BigInt(2535301200456458802993406410752));
- console.log('bigIntToBuffer : ' + bigIntToBuffer(BigInt(2535301200456458802993406410752) ));
- console.log('bufferToBigInt : ' + bufferToBigInt( bigIntToBuffer(BigInt(2535301200456458802993406410752)) ));
- }
- }
- );
- created.addMixin(BitArrayBigInt);
- return created;
- }
-
- var creatorFor = {
- '[object Array]' : __createA
- , '[object Object]' : __createO
- , 'undefined' : function(){ return __create() }
- };
-
- // PB : TODO -- Constructor is not preserved... But mixing in an external passed in object is what we want to achive.
- function BitArrayBigInt(){
- return arguments.length ? creatorFor[utils_1.js.nativeType(arguments[0])](...arguments) :
- creatorFor['undefined'](...arguments)}
-
- BitArrayBigInt.create = BitArrayBigInt;
- return BitArrayBigInt
- })();
-
- // > 32 bits upto 53 bits.
- const BitArrayUpto53Bits = (function(){
-
- function validateBitLength(length){ if(length > 53) throw 'BitArrayUpto53Bits doesnt accept BitLength > 53' }
-
- function __createO(o, options){
- var arr = Object.keys(o);
- validateBitLength(arr.length);
-
- var created = __create();
-
- var iterateUpto = [
- ()=>{for(var i =0 ; i < 1; i++) { console.log(i); created.assignMask(arr[i], o[arr[i]]); }}
- , ()=>{for(var i =1 ; i < Math.min(31, arr.length); i++) { console.log(i); created.assignMask(arr[i], o[arr[i]], leftshift_Number ); }}
- , ()=>{for(var i =31; i < Math.min(32, arr.length); i++) { console.log(i); created.assignMask(arr[i], o[arr[i]], (m)=>{ return leftshift_Number(m)>>>0 } ); }}
- , ()=>{for(var i =32; i < Math.min(53, arr.length); i++) { console.log(i); created.assignMask(arr[i], o[arr[i]], (m)=>{ return Number(BigInt(m) << BIGINT_1) } ); }}
- ];
- arr.length > 32 ? iterateUpto.forEach(f=>f()) :
- arr.length > 31 ? iterateUpto.slice(0,3).forEach(f=>f()) :
- arr.length > 1 ? iterateUpto.slice(0,2).forEach(f=>f()) :
- iterateUpto[0]();
-
- return created;
- }
-
- function __createA(arrInp, options){
- validateBitLength(arrInp.length);
-
- var created = __create();
-
- var arr = [];
- var pregencache = [];
- // PB : Changed to preincrement. Mask need not overflow for 53 bits...
- var iterateUpto = [
- (prelen)=>{for(var i =Math.max(0, prelen) ; i < 1; i++) { console.log(i); created.assignMask(arr[i-prelen], pregencache[arr[i-prelen]] || { title : arr[i-prelen]} ); }}
- , (prelen)=>{for(var i =Math.max(1, prelen) ; i < Math.min(31, arr.length + prelen); i++) { console.log(i); created.assignMask(arr[i-prelen], pregencache[arr[i-prelen]] || { title : arr[i-prelen]}, leftshift_Number ); }}
- , (prelen)=>{for(var i =Math.max(31, prelen); i < Math.min(32, arr.length + prelen); i++) { console.log(i); created.assignMask(arr[i-prelen], pregencache[arr[i-prelen]] || { title : arr[i-prelen]}, (m)=>{ return leftshift_Number(m)>>>0 } ); }}
- , (prelen)=>{for(var i =Math.max(32, prelen); i < Math.min(53, arr.length + prelen); i++) { console.log(i); created.assignMask(arr[i-prelen], pregencache[arr[i-prelen]] || { title : arr[i-prelen]}, (m)=>{ return Number(BigInt(m) << BIGINT_1) } ); }}
- ];
-
- if(options && options.pregenerated) {
- arrInp.forEach((inp=>{
- if(!options.pregenerated[inp] || !options.pregenerated[inp].mask) {
- // Doesn't have a mask so needs generation.
- arr.push(inp);
- pregencache[inp] = options.pregenerated[inp];
- }
- else if(!options.pregenerated[inp]) arr.push(inp);
- }));
-
- Object.keys(options.pregenerated).forEach(p=>{
- if(pregencache[p]) return;
- created.assignMask(p, options.pregenerated[p], created.assignMaxAsNextIncrement );
- });
- var prelen = Object.keys(created.toJSON()).length;
- prelen > 31 ? iterateUpto.slice(3).forEach(f=>f(prelen)) :
- prelen > 30 ?
- (prelen + arr.length) > 32 ? iterateUpto.slice(2).forEach(f=>f(prelen))
- : iterateUpto.slice(2, 3).forEach(f=>f(prelen))
- :
- prelen > 0 ?
- (prelen + arr.length) > 32 ? iterateUpto.slice(1).forEach(f=>f(prelen))
- : (prelen + arr.length) > 31 ? iterateUpto.slice(1,3).forEach(f=>f(prelen)) :
- iterateUpto.slice(1,2).forEach(f=>f(prelen))
- :
- arr.length > 32 ? iterateUpto.forEach(f=>f(prelen)) :
- arr.length > 31 ? iterateUpto.slice(0,3).forEach(f=>f(prelen)) :
- arr.length > 1 ? iterateUpto.slice(0,2).forEach(f=>f(prelen)) :
- iterateUpto[0](prelen);
- }
- else {
- arr = arrInp;
- arr.length > 32 ? iterateUpto.forEach(f=>f(0)) :
- arr.length > 31 ? iterateUpto.slice(0,3).forEach(f=>f(0)) :
- arr.length > 1 ? iterateUpto.slice(0,2).forEach(f=>f(0)) :
- iterateUpto[0](0);
- }
-
- return created;
- }
-
- function __create(){
- var labels = {};
- var masks = {};
-
- var currentMaxMask;
- function __nextMask(){ __nextMask = leftshift_Number;
- return currentMaxMask = 1; }
-
-
-
- // var store = ??? new Uint32Array(1)
- var mxn = Mixin.create();
- var created = utils_1.assign(mxn,
- {
-
- assignMaxAsNextIncrement(possibleMax) {
- if(currentMaxMask && currentMaxMask < possibleMax) currentMaxMask = possibleMax;
- else currentMaxMask = possibleMax;
- }
- , validateMask(m){
- if(mxn.is(m, BitIndex)) {
- return { BitIndex, labels : [masks[indexToMask(m.value)]] }
- }
- if(m > MAX_53BITS) throw "BitArrayUpto53Bits only supports numbers upto MAX_53BITS "
- if(!utils_1.js.isNumber(+m)) throw "BitArrayUpto53Bits requires Numbers upto MAX_53BITS "
- return true;
- }
- , labelsToMask : (__labels)=>{
- var result = 0; __labels.forEach(l=>{ result |= labels[l]; });
- return result >>> 0;
- }
- , hasMask : function(label) { return labels[label] ? labels[label].mask : null ; }
- , maskToLabels(m, transformEach){
-
- var valid = this.validateMask(m);
- if(!valid) throw "Invalid Mask"
- if(valid.BitIndex) return valid.labels;
-
- var __labels = [];
- var m = BigInt(m);
- // for(var gptwo;gptwo=this.bit_and(m,-m); gptwo = this.bit_xor(m,gptwo)) {
- for(var gptwo;gptwo=m&-m;m^=gptwo) {
- if(!masks[Number(gptwo)]) { console.log('Error : Invalid mask passed in.'); }
- else __labels.push( transformEach(masks[Number(gptwo)], labels[masks[Number(gptwo)]]) );
- }
- return __labels;
- }
- , labelToMask : (l)=>{ return labels[l] }
- , bit_or : (a, b) => {
- return bit_opFn_Upto53(a,b, (a, b)=>a | b)
- }
- , bit_and : (a, b) => bit_opFn_Upto53(a,b, (a, b)=>a & b)
- , bit_xor : (a, b) => bit_opFn_Upto53(a,b, (a, b)=>a ^ b)
- , bit_not : (a) => Number(~BigInt(a))
- , assignMask : function(label, entity, onassignment) {
-
- if(entity && entity.mask && masks[entity.mask]) {
- throw 'Mask collision. Cannot assign requested mask. ' + entity
- }
- var pregenerated = labels[label] || entity;
- // var lmask = this.hasMask(label); if(lmask) return lmask; // Already assigned.
- // Everything is overridable except mask.
- if(pregenerated && pregenerated.mask) {
- onassignment = (onassignment || created.assignMaxAsNextIncrement);
-
- labels[label] = utils_1.assign(pregenerated, entity, {mask : pregenerated.mask});
- onassignment(pregenerated.mask);
- }
- else {
- onassignment = (onassignment || __nextMask);
-
- labels[label] = entity;
- labels[label].mask = currentMaxMask = onassignment ? onassignment(currentMaxMask) : __nextMask(); // Use the next unused mask for this dictionary of labels. Currently random. We should eventually have a sort order.
- }
- masks[labels[label].mask] = label;
- return labels[label];
- }
- , msbIndex : function(v) { throw "msb Not yet implemented" }
- , indexToMask : function(index) {
- if(index > 52) throw 'Not supported beyond 53 bits.'
- return Number(BigInt(1) << BigInt(index));
- }
- , indicesToMask : function(indices){
- var mask = BigInt(0);
- indices.forEach(index=>{
- if(index > 52) throw 'Not supported beyond 53 bits.'
- mask |= (BIGINT_1 << BigInt(index));
- });
- return Number(mask);
- }
- , maskToIndices : function(m) {
- var valid = this.validateMask(m);
- if(!valid) throw "Invalid Mask"
- if(valid.BitIndex) return [m.value];
- var indices = [];
- var gptwo;
- if(m > MAX_32BITS) {
- var iterator = bigIntBufferGenerator(BigInt(m));
-
- var next;
- // if(next && !next.done) buffer = next.value.bits32;
- // else return next.value.bits32;
- var i = 0;
- while(!(next = iterator.next()).done) {
- next.value.bits32 > 0 ?
- ( ()=> { for(;gptwo=(next.value.bits32& -next.value.bits32) ;next.value.bits32^=gptwo) indices.push(32 * i + indexOfLSB32(gptwo)); } )
- : null;
- i++;
- }
- for(;gptwo=(next.value.bits32&-next.value.bits32);next.value.bits32^=gptwo) indices.push(32 * i + indexOfLSB32(gptwo));
- }
- else {
- m = Number(m);
- for (;gptwo=m&-m;m^=gptwo) indices.push(indexOfLSB32(gptwo)); }
- // for (;gptwo=BigInt(m)&BigInt(-m);m^=gptwo) indices.push(indexOfLSB32(m, gptwo))
-
- return indices;
- }
- , bit_shiftl : (a, s)=>{ return a << s }
- , bit_shiftr : (a, s)=>{ return a >> s }
- , bit_shiftr_uz : (a)=>{ return a >>> 0} // Unsigned right shift by 0.
- // , bit_shiftl_1 : ()=>{}
- , toJSON(radix, eachFn){
- var transFormed = {};
- if(!eachFn) return labels;
- Object.keys(labels).forEach(label =>{
- transFormed[label] = eachFn(labels[label]);
- });
- return transFormed;
- }
- , tosqlcte() {
-
- var select = '';
- // debugger
- Object.keys(labels).forEach((label, index, array) =>{
- var labelObject = labels[label];
- var rowselect = 'select ';
- Object.keys(labelObject).forEach((key, index, array) =>{
- rowselect = rowselect + ` '${labelObject[key]}' ${key}`;
- if(array.length !== index+1) rowselect = rowselect + ',';
- });
- select = select + rowselect;
- if(array.length !== index+1) select = select + '\n union all \n';
- });
-
- console.log(select);
- return labels
-
-
- }
- , test(){
- Object.keys(masks).forEach((v, i)=> {
- console.log( v );
- console.log( i + ' : ' + v.toString(2) );
- console.log( this.maskToIndices(v));
- });
- console.log( (173).toString(2) );
- this.maskToIndices(173).map( (i)=>{ console.log( i ); });
- console.log('indicesToMask :' + this.indicesToMask([1,4,31]).toString(2));
- }
- });
-
- return created;
- }
-
- var creatorFor = {
- '[object Array]' : __createA
- , '[object Object]' : __createO
- , 'undefined' : function(){ return __create() }
-
- };
-
- // PB : TODO -- Constructor is not preserved... But mixing in an external passed in object is what we want to achive.
- function BitArrayUpto53Bits(){
- return arguments.length ? creatorFor[utils_1.js.nativeType(arguments[0])](...arguments) :
- creatorFor['undefined'](...arguments)}
-
- BitArrayUpto53Bits.create = BitArrayUpto53Bits;
- return BitArrayUpto53Bits
- })();
- function bit_opFn_Upto53(a, b, opFn){
-
- return Number(opFn(BigInt(a), BigInt(b) ))
- // var result = new Uint32Array(2);
- // result[0] = opFn( (a / POWER32)>>0 , (b / POWER32)>>0 )
- // result[1] = opFn(a % POWER32, b % POWER32)
- // return POWER32 * result[0] + result[1];
- }
-
- // An arbitrarily-wide array of bits. Can be used for bitmasks longer than 32 bits in JS.
- const BitArray = (function(){
-
- // const NEEDS_BIT_SPLIT = (b)=> b > Number.MAX_SAFE_INTEGER;
- // const MAX_SAFE_MASK_LENGTH = 32
-
- // function getMinMax(a, b){
- // return a.length > b.length ? { min : b.length, minX : b, max : a.length, maxX : a }
- // : { min : a.length, minX : a, max : b.length, maxX : b }
- // }
-
- // function getTypes(a, b){
- // var aIsPrimitive = utils.js.isPrimitive(a);
- // var bIsPrimitive = utils.js.isPrimitive(b);
- // return { a : aIsPrimitive, b : bIsPrimitive }
- // }
-
- // // Binary oprations
- // function bit_opFn(a, b, opFn){
- // var tt = getTypes(a, b);
- // var mm = {}
- // var getRemaining = function(){ return mm.maxX.subarray(mm.min, mm.max-1)}
- // if(tt.a && tt.b) {
- // // both are primitive
- // mm = { min : 1, minX : [a], max : 1, maxX : [b]}
- // getRemaining = function(){ return []}
- // }
- // else if(tt.a){
- // // b is bitarray
- // mm = { min : 1, minX : [a], max : b.length, maxX : b}
- // }
- // else if(tt.b){
- // mm = { min : 1, minX : [b], max : a.length, maxX : a}
- // }
- // else {
- // var mm = getMinMax(a, b)
- // }
-
- // var result = new Uint32Array(mm.max);
- // for (var i = 0; i < mm.min; ++i) { result.set( [opFn(mm.minX[i], mm.maxX[i])], i) }
- // // js.utils.isPrimitive(mm.maxX) ?
- // var remaining = getRemaining()
- // remaining.length > 0 ? result.set( remaining, mm.min) : null;
- // return result;
- // }
-
- // // Unary operations
- // function bit_opFnU(mm, opFn){
- // var result = new Uint32Array(mm.length);
- // for (var i = 0; i < mm.min; ++i) { result.set( opFn(a), i) }
- // result.set( mm.maxX.subarray(mm.min, mm.max-1), mm.min)
- // return result;
- // }
- // function __expand(){
-
- // }
-
- function __createA(arr){
- // Create a new BitArray
- // Assign Unique bits to each item in an array of labels.
- arr.length % 32;
- arr.length/32 >>> 0;
- var created = arr.length > 53 ?
- BitArrayBigInt.create(...arguments) : arr.length > 32 ?
- BitArrayUpto53Bits.create(...arguments) :
- BitArrayUpto32Bits.create(...arguments);
- return created;
- }
-
- function __createO(o){
- // Create a new BitArray
- // Assign Unique bits to each item in an array of labels.
- var arr = Object.keys(o);
-
- arr.length % 32;
- arr.length/32 >>> 0;
- var created = arr.length > 53 ?
- BitArrayBigInt.create(...arguments) : arr.length > 32 ?
- BitArrayUpto53Bits.create(...arguments) :
- BitArrayUpto32Bits.create(...arguments);
- return created;
- }
-
- function __create(){
-
-
- // var store = new Uint32Array(1)
- Mixin.create();
- var created = BitArrayBigInt.create();
- created.addMixin(BitArray);
- return created;
- }
-
- var creatorFor = {
- '[object Array]' : __createA
- , '[object Object]' : __createO
- , 'undefined' : function(){ return __create() }
- };
- // PB : TODO -- Constructor for BitArrays read from files that have been generated and saved.
- // PB : TODO -- Constructor is not preserved... But mixing in an external passed in object is what we want to achive.
- function BitArray(){
- return arguments.length ? creatorFor[utils_1.js.nativeType(arguments[0])](...arguments) :
- creatorFor['undefined'](...arguments)}
- BitArray.create = BitArray;
- return BitArray
- })();
-
-
-
-
- // Mixins.
- const mixs = {
- // __JSTPL : (function() {
- // function __f() {}
- // return function() {
- // this.f = __f;
- // return this;
- // };
- // })()
-
- // Return a set of mixins.
-
- kernelMixin : (function() {
-
- // Wrapper to generate the currently chosen UUID version
- // In JS UUID v4 vs v1 -> In browsers v1 has the timestamp but uses a random number for the node part.
- function __getuuid() {
- return v1_1();
- }
-
- // uuid property Mainstream getter after lazy init
- function __get() {
- return this.kernel.uuidv1;
- }
-
- // uuid property First Time getter for lazy init.
- function __firstGet() {
- this.kernel.uuidv1 = __getuuid();
-
- __finalize.apply(this);
- return this.uuid;
- }
-
- function __finalize(){
- Object.defineProperty(this.kernel, 'uuidv1', { writable : false, configurable : false});
- Object.defineProperty(this, 'uuid', {
-
- get : __get
- , enumerable : true
- , configurable : false
- });
-
- Object.defineProperty(this, 'kernel', {
-
- enumerable : false
- , configurable : false
- , writable : false
- });
- }
-
- function __defineKernel(){
-
- // MAC and time. Guaranteed unique unless generated way too fast or parallelly.
- //const uuidV1 = utils.core.uuidV1; // (date-time and MAC address)
- //const uuidv2 = // (date-time and MAC Address, DCE security version)
-
- // (namespace name-based) ...
- //const uuidv3md5 = require('uuid/v3');
- //const uuidv5sha1 = require('uuid/v3'); // SHA1(v5) is broken
-
- //const uuidv4 = require('uuid/v4'); //(random)
-
-
- // Kernel Properties are promoted onto the object itself without value as getters and setters as
- // configurable = false
- // enumerable = false
- // writable = false
- Object.defineProperty(this, 'kernel', { value :{}, writable : true });
-
-
- // Keep it lazy. Only generate on first use. Which could be first time persistence.
- Object.defineProperty(this.kernel, 'uuidv1', { writable : true, configurable : true});
-
- // PB : TODO -- Note : A hash of the content may need to be computed dynamically.
- // The best place to do this is on persistance. In memory objects undergo a lot of changes so the hash keeps varying.
- // It therefore becomes unnecessary to compute the hash very frequently. We may need to do this lazily when accessed or
- // simply use all attributes for comparison. The value of a hash is useful only when the attributes are not changing
- // and the hash is precomputed and ready to be used. We need to use gits methodology to track changes.
- }
-
- function __loadKernel() {
- // Reinitialize the kernel for an object that already has a uuid probably loaded from a JSON.
- this.kernel.uuidv1 = this.uuid;
- __finalize.apply(this);
- }
-
- function __attachKernel() {
-
- // Dont mess with something that already has a kernel.
- if(this.hasOwnProperty('kernel')) {
- l('Already has kernel');
- return this;
- }
-
- __defineKernel.apply(this);
-
- if(this.hasOwnProperty('uuid')) {
- l('Already has uuid');
- __loadKernel.apply(this);
-
- return this;
- }
- Object.defineProperty(this, 'uuid', { get : __firstGet, configurable : true});
- return this;
- }
-
- var __kernelInstanceMixin = function() {
- return __attachKernel.apply(this);
- };
- __kernelInstanceMixin.getuuid = __getuuid;
- return __kernelInstanceMixin;
- })()
-
- // Publishes messages to a message queue broker or mediator.
- , publisherMixin : (function() {
- function __publish() {
-
- }
- return function() {
- this.publish = __publish;
- return this;
- };
- })()
- };
-
- // Note : Prophelpers are not mixed into the object and hence need to be applied on some other object.
- const helpers = {
- indexHelper : indexHelper
- , meta : (function() {
-
- // Mainly to observe changes to object properties.
- // A kernel uuid is a prerequisite.
- function spy(obj, prop, action) {
- action = action || 'set';
- if(action != 'set') {
- throw 'Currently only set actions can be observed on properties';
- }
-
- // Get the current descriptor
- var descriptor = Object.getOwnPropertyDescriptor(obj, prop);
- var value = obj[prop];
-
- if(descriptor && descriptor.get && descriptor.get.$meta){
- var originalset = descriptor.set;
- descriptor.set = function(newValue) {
- globalThis_1.mediator.publish(obj.uuid + '.' + prop, 'willchange', {from : value, to : newValue});
- originalset(newValue);
- globalThis_1.mediator.publish(obj.uuid + '.' + prop, 'haschanged', {from : value, to : newValue});
- };
- return this;
- }
-
- descriptor = {
- get: function() {
- return value;
- },
- set: function(newValue) {
- globalThis_1.mediator.publish([obj.uuid, prop, 'willchange'], {from : value, to : newValue});
- value = newValue;
- globalThis_1.mediator.publish([obj.uuid, prop, 'haschanged' ], {from : value, to : newValue});
- }
- };
- descriptor.get.$meta = {};
- Object.defineProperty(obj, prop, descriptor);
- return this;
- }
-
- function getCustomPropertyDescriptor(obj, prop) {
- var actualDescriptor = Object.getOwnPropertyDescriptor(obj, prop);
- if (actualDescriptor && actualDescriptor.get && actualDescriptor.get.$meta) {
- return actualDescriptor;
- }
-
- var value = obj[prop];
- var descriptor = {
- get: function() {
- return value;
- },
- set: function(newValue) {
- value = newValue;
- }
- };
- descriptor.get.$meta = {};
-
- Object.defineProperty(obj, prop, descriptor);
- return Object.getOwnPropertyDescriptor(obj, prop);
- }
-
- function setPropertyAttribute(obj, propertyName, attributeName, attributeValue) {
- var descriptor = getCustomPropertyDescriptor(obj, propertyName);
-
- descriptor.get.$meta[attributeName] = attributeValue;
- }
-
- function getPropertyAttributes(obj, propertyName) {
- var descriptor = getCustomPropertyDescriptor(obj, propertyName);
-
- return descriptor.get.$meta;
- }
-
- function getPropertyAttribute(obj, propertyName, attributeName) {
- return getPropertyAttributes(obj, propertyName)[attributeName];
- }
-
- return function(obj) {
- obj.getPropertyAttribute = getPropertyAttribute;
- obj.getPropertyAttributes = getPropertyAttributes;
- obj.setPropertyAttribute = setPropertyAttribute;
- obj.spy = spy;
-
- return obj;
- };
- })()
- };
-
- var core = function(object){
- // l('in \tFunction core')
- return {
- mixs
- , helpers
- , AnyStore
- , BitArray
- , BitArrayUpto32Bits
- , BitArrayUpto53Bits
- , BitArrayBigInt
- // core object instances
- , uuidv1: v1_1
- , Rule
- }
- };
-
- // export default core;
- var core_1 = core;
- // console.dir(__g.mediator)
- // try {
- // console.log( '__g === global : ' + (__g === global) )
- // }
- // catch(e){
- // console.log( '__g === global : ' + false )
- // }
- // try {
- // console.log( '__g === globalThis : ' + (__g === globalThis) )
- // }
- // catch(e){
- // console.log( '__g === globalThis : ' + false )
- // }
-
-
- function *bigIntBitGenerator(){
- var signal = {};
- var stop = Symbol();
- var iId = 0;
- var bit = BIGINT_1;
- for(;;){
- signal = (yield { iId, bit }) || {};
- if(signal === stop || signal.done) return { iId, bit };
- bit = bit << BIGINT_1;
- iId++;
- }
- }
-
- var Rule = (function(){
-
-
- // Immutable private static.
- var __Rule = {};
-
- // Overridable public static shared on the instance as well as convenience functions.
- // When the extend method is used the instance methods also correspond.
- // IMP : NOTE -- However instance overrides do not switch the static ones attached to the class.
- // These could also be called statically with call or apply Eg: fn.apply(this)
- var _XRule = { assignbit, getParticipating };
- // Extendable public static
- // _Rule should not be referenced anywhere... as its members can be swithed.
-
-
- var _Rule = {
-
- extend : function(extension){
-
- function __create(){ return init.call({}) }
- function __createO(o){ return init.call(o) }
- function __createA(a){ a.forEach(r=> __createO(r)); return a }
- var creatorFor = {
- '[object Array]' : __createA
- , '[object Object]' : __createO
- , 'undefined' : function(){ return __create() }
- };
-
- function Rule(){ return arguments.length ? creatorFor[utils_1.js.nativeType(arguments[0])](...arguments) : creatorFor['undefined'](...arguments) }
-
- // All static extensions shall be available on the instance as well.
- var _extension = utils_1.assign({}, _XRule, extension);
- function init() { return utils_1.assign(this, rProto, _extension, __newInstance(this), this) } _extension.init = init;
- utils_1.assign(Rule, _Rule, _extension, __Rule);
-
- // Immutable public static methods.
- Rule.create = Rule;
- Rule.build = buildRules;
- Rule.match = match;
- Rule.connect = connectRules;
- Rule.branch = function(as, ...rest){
- // PB : TODO -- All lists will be invalidated when we splice rules in...
- // Rule.create()
- // Replace an exisiting rule node with an intermediate rule that connects this rule to another rule.
- console.error('Not yet implemented.');
- };
-
- // from loopback-connector/lib/sql.js
- // PB : TODO -- a generic multipurpose buildwhere which doesn't enforce model property existence
- // Convert from a natural filter to key val expanded filter.
- // Convert In clauses to one rule for each listed values.
- // Do not output the where clause but inlude the operator in the result assosiated with the respective params.
- // Handle mask overflows gracefully
- /**
- * @param where
- * @returns {ChoppedRules}
- */
- function buildRules(where, data, fullResult, parentRule) {
- let columnValue;
- if (!where) return Promise.resolve(fullResult) ;
-
- if (typeof where !== 'object' || Array.isArray(where)) {
- debug('Invalid value for where: %j', where);
- return Promise.resolve(fullResult);
- }
-
- var ruleset = [];
- // var id = Object.keys(where).length > 1 ? null : data ? data.id : null;
- var id = data ? data.id : null;
- fullResult = fullResult || [];
- var createIntermediate = createIntermediateParentLess;
- var immediateParentP = null;
- if(parentRule) {
- immediateParentP = parentRule;
- createIntermediate = createIntermediateWithParent;
- }
-
- if(Object.keys(where).length > 1) {
- immediateParentP = createIntermediate({operator : AND}, ()=>{ return [] }, parentRule);
- ruleset.push(immediateParentP);
- fullResult.push(immediateParentP);
- createIntermediate = createIntermediateWithParent;
- }
-
- for (const key in where) {
- // Handle and/or operators
- if (key === AND || key === OR) {
- const clauses = where[key];
- if (Array.isArray(clauses)) {
- if(clauses.length > 1) {
- var rp = createIntermediate({operator : key}, (rParent)=>{
- var list = [];
- for (let i = 0, n = clauses.length; i < n; i++) {
- list.push(buildRules(clauses[i], null, fullResult).then( ruleForClause => {
- connectRules(operators[rParent.operator].bit, ruleForClause, rParent);
- return ruleForClause;
- }));
- }
- return list;
- }, immediateParentP);
- ruleset.push(rp);
- fullResult.push(rp);
- }
- else {
- // An outer 'or' OR 'and' condition is meaningless if we have only 1 clause. At least two are required to make sense.
- // We just drop the wrapped grouped (or or and) condition and promote then inner clause to the same level. =
- var rP = buildRules(clauses[0], null, fullResult, immediateParentP);
- // fullResult.push(rP) // Buildrules should should have already pushed this.
- ruleset.push(rP); // buildRules should have already linked parent and child.
- }
- continue;
- }
- else {
- throw 'Invalid filter '
- }
- }
- // eslint-disable one-var
- let expression = where[key];
- let p = key;
- var op ='eq;';
- const columnName = columnEscaped(/* modelinstance || */ where, key);
- // eslint-enable one-var
- if (expression === null || expression === undefined) {
- // If null has been passed in we should match null.
- expression = null;
-
- var rpromise = assignbit(Rule.create(rChild, { key : columnName, value : toColumnValue(p, expression)})).then((rChild)=>{
- if(immediateParentP) {
- return immediateParentP.then((immediateParent)=> {
- connectRules(operators[immediateParent.operator].bit, rChild, immediateParent);
- return rChild
- })
- }
-
- // PB : TODO -- Unwrapped decendents update on parent!!!
- return rChild
- }).catch(e=>{ console.error('null expression : ' + e); });
-
- fullResult.push(rpromise);
- ruleset.push(rpromise);
- } else if (expression && expression.constructor === Object) {
- const operator = Object.keys(expression)[0];
- expression = expression[operator];
- if (operator === INQ || operator === NIN || operator === BETWEEN) {
- columnValue = [];
- op = operator === INQ ? (EQ) : operator === NIN ? (NEQ) : (LTE);
- if (Array.isArray(expression)) {
- // Column value is a list
- for (let j = 0, m = expression.length; j < m; j++) {
- columnValue.push(toColumnValue(p, expression[j]));
- }
- } else {
- columnValue.push(toColumnValue(p, expression[j]));
- }
-
- if (operator === BETWEEN) {
- var rp = createIntermediate({operator : AND}, (rParent)=>{
- // BETWEEN v1 AND v2
- columnValue[0] === undefined ? null : columnValue[0];
- columnValue[1] === undefined ? null : columnValue[1];
- if(expression.length !== 2) console.error('Invalid between operator parameter length');
-
- var list = [];
- list.push(assignbit(Rule.create({key : columnName, value : columnValue[0], operator : GTE})).then((rChild)=>{
- connectRules(operators[rParent.operator].bit, rChild, rParent);
- return rChild
- }));
- list.push(assignbit(Rule.create({key : columnName, value : columnValue[1], operator : LTE})).then((rChild)=>{
- connectRules(operators[rParent.operator].bit, rChild, rParent);
- return rChild
- }));
- fullResult.push.apply(fullResult, list);
- return list;
- }, immediateParentP);
- ruleset.push(rp);
- fullResult.push(rp);
-
- } else {
- var rp = createIntermediate({operator : OR}, (rParent)=>{
- // IN (v1,v2,v3) or NOT IN (v1,v2,v3)
- // PB : TODO -- loopbacks handling of nulls is questionable. Invalid rules match nulls and return data.
- if (columnValue.length === 0) {
- if (operator === INQ) {
- columnValue = [null];
- } else {
- // nin () is true
- // nin : [null] is a world query which is an invalid filter. We don't support yet.
- return [];
- }
- }
- var list = [];
- for (let j = 0, m = columnValue.length; j < m; j++) {
- list.push(
- assignbit(Rule.create({key : columnName, value : toColumnValue(p, columnValue[j]), operator : op})).then((rChild)=>{
- connectRules(operators[rParent.operator].bit, rChild, rParent);
- return rChild
- })
- );
- }
- fullResult.push.apply(fullResult, list);
- return list
- }, immediateParentP);
- ruleset.push(rp);
- fullResult.push(rp);
- }
- } else if (operator === 'regexp' && expression instanceof RegExp) {
- // do not coerce RegExp based on property definitions
-
- var rpromise = assignbit(Rule.create({key : columnName, value : toColumnValue(p, expression), operator})).then((rChild)=>{
- if(immediateParentP) {
- return immediateParentP.then((immediateParent)=> {
- connectRules(operators[immediateParent.operator].bit, rChild, immediateParent);
- return rChild
- })
- }
-
- // PB : TODO -- Unwrapped decendents update on parent!!!
- return rChild
- }).catch(e=>{ console.error('Regexp expression : ' + e); });
-
- fullResult.push(rpromise);
- ruleset.push(rpromise);
- // columnValue = expression;
- } else {
- var rpromise = assignbit(Rule.create({key : columnName, value : toColumnValue(p, expression), operator})).then((rChild)=>{
- if(immediateParentP) {
- return immediateParentP.then((immediateParent)=> {
- connectRules(operators[immediateParent.operator].bit, rChild, immediateParent);
- return rChild
- })
- }
-
- // PB : TODO -- Unwrapped decendents update on parent!!!
- return rChild
- }).catch(e=>{ console.error('other expression : ' + e); });
- fullResult.push(rpromise);
- ruleset.push(rpromise);
-
- // columnValue = toColumnValue(p, expression);
- }
-
- } else {
-
- if(utils_1.js.isArray(expression)) throw 'Invalid array value for filter. Implicit INQ not supported. '
- // ruleProcessor[EQ]();
-
- var rpromise = assignbit(Rule.create({key : columnName, value : toColumnValue(p, expression), operator : EQ})).then((rChild)=>{
- if(immediateParentP) {
- return immediateParentP.then((immediateParent)=> {
- connectRules(operators[immediateParent.operator].bit, rChild, immediateParent);
- return rChild
- })
- }
-
- // PB : TODO -- Unwrapped decendents update on parent!!!
- return rChild
- }).catch(e=>{ console.error('other expression : ' + e); });
-
- fullResult.push(rpromise);
- ruleset.push(rpromise);
- }
- }
-
- return Promise.all(ruleset).then(()=>{
-
- if(immediateParentP){
- return immediateParentP;
- }
- if(ruleset.length > 1) {
- // If only 1 rule there is no point in having an outer implicit and.
- // If length is > 1 it implies there are a mixture of ands ors and raw rules specified as an outer object
- // and we need to return the grouped rule.
-
- // var grpromise = Promise.all(ruleset).then( (list)=>{
- // var grouped = Rule.create({ id, operator : AND }).assignbit();
- // return grouped.then(r=>{
- // r.list = list;
- // return r
- // })
- // });
-
- // fullResult.push(grpromise)
- // return grpromise
-
- return ruleset[ruleset.length-1].then((r)=>{ r.id = id || r.id; return r});
- }
- else if(ruleset.length > 0) {
- return ruleset[0].then((r)=>{ r.id = id || r.id; return r});
- }
- else {
- return fullResult[fullResult.length-1].then((r)=>{ r.id = id || r.id; return r});
- }
- })
-
- }
- return Rule
- }
- };
- var createIntermediateParentLess = (interMediatGroupParent, createChildren)=>{
- var interMediatGroupParentP = assignbit(Rule.create(interMediatGroupParent)).then((rIntermediate)=>{
- return rIntermediate
- });
-
- var grpromise = interMediatGroupParentP.then((rParent)=>{
-
- // var rParent = resolved[1]
- // if(immediateParentP) {
- // connectRules( operators[ resolved[0].operator].bit, rParent, resolved[0] )
- // // PB : Note -- we connect right here and after children are properly created we update parent descendents when we unwrap to root parent.
- // rParent.ancestors |= resolved[0].ancestors | resolved[0].bit // PB : TODO -- should ancestors be included in the mask ???
- // }
-
- // PB : TODO -- When we unwind descendents on ancestors need to be updated.
- // PB : TODO -- Why is this group not getting pushed into the full list.
- // Also what happens when caluse[i] is an array ? Does a group get created and also clause i ?
- return Promise.all(createChildren(rParent)).then( (list)=>{
- // PB : TODO -- We don't know yet whether id needs to be assigned to this rule
- // or an outer grouped rule.
- rParent.list = list;
- return rParent
- });
- });
- return grpromise;
- };
-
- var createIntermediateWithParent = (interMediatGroupParent, createChildren, immediateParentP)=>{
-
- var interMediatGroupParentP = assignbit(Rule.create(interMediatGroupParent)).then((rIntermediate)=>{
- return immediateParentP.then((immediateParent)=>{
- connectRules(operators[immediateParent.operator].bit, rIntermediate, immediateParent);
- return rIntermediate
- })
- });
-
- var grpromise = interMediatGroupParentP.then((rParent)=>{
-
- // var rParent = resolved[1]
- // if(immediateParentP) {
- // connectRules( operators[ resolved[0].operator].bit, rParent, resolved[0] )
- // // PB : Note -- we connect right here and after children are properly created we update parent descendents when we unwrap to root parent.
- // rParent.ancestors |= resolved[0].ancestors | resolved[0].bit // PB : TODO -- should ancestors be included in the mask ???
- // }
-
- // PB : TODO -- When we unwind descendents on ancestors need to be updated.
- // PB : TODO -- Why is this group not getting pushed into the full list.
- // Also what happens when caluse[i] is an array ? Does a group get created and also clause i ?
- return Promise.all(createChildren(rParent)).then( (list)=>{
- // PB : TODO -- We don't know yet whether id needs to be assigned to this rule
- // or an outer grouped rule.
- rParent.list = list;
- return rParent
- });
- });
- return grpromise;
- };
-
- // Literals
- const EQ = 'eq';
- const LTE = 'lte';
- const GTE = 'gte';
- const LT = 'lt';
- const GT = 'gt';
- const AND = 'and';
- const OR = 'or';
- const INQ = 'inq';
- const BETWEEN = 'between';
- const NIN = 'nin';
- const NEQ = 'neq';
- __Rule.EQ = 1;
- __Rule.LTE = 2;
- __Rule.GTE = 4;
- __Rule.LT = 8;
- __Rule.GT = 16;
- __Rule.AND = 32;
- __Rule.OR = 64;
-
- var operators = {
- eq : { operator : '=', bit : __Rule.EQ}
- , lte : { operator : '<=', bit : __Rule.LTE}
- , gte : { operator : '>=', bit : __Rule.GTE}
- , lt : { operator : '<', bit : __Rule.LT}
- , gt : { operator : '>', bit : __Rule.GT}
- , and : { operator : AND, bit : __Rule.AND}
- , or : { operator : OR, bit : __Rule.OR}
- };
-
- var operatorsIndex = {};
- Object.keys(operators).forEach(op => operatorsIndex[operators[op].bit] = operators[op] );
-
- function __newInstance(o){
- var d = new Date();
- var id = o.id || v1_1();
- return { v1ruleId : id, id, datecreated : d, datemodified : d
- , permissive : BIGINT_0, restrictive : BIGINT_0, descendents : BIGINT_0, ancestors : BIGINT_0, list :[] }
- }
-
- var globalBitIterator = bigIntBitGenerator();
- function assignbit(rule){ var g = globalBitIterator.next().value; rule.bit = g.bit; rule.ruleiId = g.iId;
- return Promise.resolve(rule); // PB : TODO -- remove backward compatible promisification...
- }
- // Find leaf rules from a set of rules ( in a database of rules ) that match the inputs
- function getParticipating(iRule, rList, cb){
- return Promise.all(iRule.results).then((iRules)=>{
- var SUCCESS = BIGINT_0;
- var FAILURE = BIGINT_0;
- var mask = BIGINT_0;
- var results = rList.filter(rule => {
- var found = iRules.find( iR => {
- if(iR === rule || iR.id === rule.id ||
- iR.key === rule.key &&
- ( rule.operator == GT && (
- rule.value <= iR.value && iR.operator == GT
- || rule.value < iR.value && ( iR.operator == GTE || iR.operator == EQ )
- )
- || rule.operator == GTE && (
- rule.value <= iR.value && (iR.operator == GTE || iR.operator == EQ)
- || (iR.value - rule.value) >= 0 && iR.operator == GT
- )
- || rule.operator == LT && (
- rule.value >= iR.value && iR.operator == LT
- || rule.value > iR.value && ( iR.operator == LTE || iR.operator == EQ )
- )
- || rule.operator == LTE && (
- rule.value >= iR.value && (iR.operator == LTE || iR.operator == EQ)
- || (rule.value - iR.value) >= 0 && iR.operator == LT
- )
- || rule.operator == EQ && (
- rule.value == iR.value && iR.operator == EQ
- )
- )
- ) {
-
- SUCCESS |= rule.bit;
- mask |= rule.mask;
- return true;
- }
- });
-
- if(!found) {
- if(rule.isleaf) { FAILURE |= rule.bit; }
- else {
- // Composite rule evaluation here is incomplete since we are still iterating and finding leaf level participants.
- // Optimistically computed in case we get lucky here on first pass for result caching efficiency.
- // No point in attempting a full evaluation for composite rule through parts as parts are still being evaluated.
- // A priority evaluation registration of leaf level descendents with a async postponed evaluation task for this rule...
- // may help with evaulation of relevant rules earlier....
- // This specific rules full evaluation may be moot if no asserting participants can be found.
- // Or all its ancestral rules are already true without needing this rule to be evaluated....
-
- if(rule.permissive & SUCCESS ) { SUCCESS |= rule.bit; mask |= rule.mask; return true; }
- if(rule.restrictive & FAILURE) {FAILURE |= rule.bit; }
- if(rule.restrictive && (rule.restrictive & SUCCESS) === rule.restrictive) { SUCCESS |= rule.bit; mask |= rule.mask; return true; }
- if(rule.permissive && (rule.permissive & FAILURE) === rule.permissive) {FAILURE |= rule.bit; }
-
- // if((rule.descendents & SUCCESS) === rule.descendents) {
- // // Implies all intermediate groups are true. We only need to examine direct leaf connections.
- // SUCCESS |= rule.bit;
- // mask |= rule.mask;
- // }
- }
- }
-
- return found;
- });
-
- if(utils_1.js.isFunction(arguments[arguments.length-1])) { return cb(null, { SUCCESS, FAILURE, mask, results} ) }
- else return { mask, list : found};
- });
- }
-
- function getParticipatingRoots(participating, rList, cb){
- var qualifiedRoots = [];
- rList.forEach((r)=>{
- if(r.isRoot && evaluate(r, participating)){ qualifiedRoots.push(r); }
- });
- cb(null, qualifiedRoots);
- }
-
- function toColumnValue(p, v) { return v; }
- function columnEscaped(inst, p) { return p; }
-
- function getsql_cond_group(){
- if(!this.list) { console.warn(`${this.operator} condition without list is moot`); return ''}
- if(this.list.length < 2) {
- this.list.push( this.list[0] ); // PB : TOOD -- We are adding instead of eliminating Redundant groups ...
- }
- var slqexprs = [];
- this.list.forEach(r => slqexprs.push(r.sql) );
- return '( ' + slqexprs.join( ` ${this.operator} `) + ' )'
- }
-
- function getfilter_cond_group(){
- if(!this.list) { console.warn(`${this.operator} condition without list is moot`); return ''}
- if(this.list.length < 2) {
- this.list.push( this.list[0] ); // PB : TOOD -- We are adding instead of eliminating Redundant groups ...
- }
- var filterexprs = [];
- this.list.forEach(r => filterexprs.push(r.filter) );
- return filterexprs;
- }
-
-
-
-
- // PB : TODO -- This might be easier done in a stored procedure.
- // It will also help if participating is not the whole list but the filtered list relevant for this rule.
- // Relocation so inline functions don't need to be redefined again and again.
- // Implement __Rule.isRoot
- var evaluate = function(rule, participating){
-
- if(rule.bit & participating.SUCCESS ) return true;
- if(rule.bit & participating.FAILURE) return false
- if(rule.permissive & participating.SUCCESS ) { participating.SUCCESS |= rule.bit; return true }
- if(rule.restrictive & participating.FAILURE) {participating.FAILURE |= rule.bit; return false;}
- if(rule.restrictive && (rule.restrictive & participating.SUCCESS) === rule.restrictive) { participating.SUCCESS |= rule.bit; return true }
- if(rule.permissive && (rule.permissive & participating.FAILURE) === rule.permissive) {participating.FAILURE |= rule.bit; return false;}
-
- // PB : TODO -- Truth value of grouped could be driven from the roots so we can limit to those rules that are relevant and avoid evaluation of each one.
-
- if(rule.isleaf) {
- if(participating.results.find( pp => pp === rule )) { participating.SUCCESS |= rule.bit; return true }
- else { participating.FAILURE |= rule.bit; return false; }
- }
- // else {
- // // If descendents are true we can extract only the ones that are direct connections and
- // // Evaluate...
- // var alldescendentsAreTrue = false;
- // if((rule.descendents & participating.SUCCESS) === rule.descendents) {
- // // Implies all intermediate groups are true. We only need to examine direct leaf connections.
- // alldescendentsAreTrue = true;
- // }
- // }
-
- // getUnevaluated
- var permissive = rule.permissive & (BigInt(-1)-participating.SUCCESS) & (BigInt(-1)-participating.FAILURE);
- for(var rc in rule.list){
- var r = rule.list[rc];
- if(r.bit & permissive) {
- if(evaluate(r, participating)) { participating.SUCCESS |= r.bit; participating.SUCCESS |= rule.bit; return true }
- else participating.FAILURE |= r.bit;
- }
- }
- if(rule.permissive){ participating.FAILURE |= rule.bit; return false; }
-
- // getUnevaluated.
- var restrictive = rule.restrictive & (BigInt(-1)-participating.SUCCESS) & (BigInt(-1)-participating.FAILURE);
- for(var rc in rule.list){
- var r = rule.list[rc];
- if(r.bit & restrictive) {
- if(!evaluate(r, participating)) { participating.FAILURE |= r.bit; participating.FAILURE |= rule.bit; return false}
- participating.SUCCESS |= r.bit;
- }
- }
- if(rule.restrictive){ participating.SUCCESS |= rule.bit; return true; }
-
- throw 'Error : A group rule should either be permissive or restrictive...'
-
- };
-
- var match = function (inputs, rList, cb) {
- var results = [];
- Rule.build(inputs, clause, results).then((inputRule)=>{
- inputRule.results = results;
- // inputs are usually individual assertions. An and / or condition between individual assertions are usually not useful.
- // Unless the assertion is of the form
- // Eg : this indiviudal's age is between x and y which is kind of rare.
- // A negation is also not how an assertion is typically made. However not from location C or D is a possible assertion.
- // An or assertion is still more rare and is usually an abstraction to not be specific.
- // Eg : The user is from location A or B and uses either a Mac or Ubuntu OS.
- // Although the user has specific characteristics the specificity is not disclosed in the inputs.
- // And is adequate to distinguish the inputs from amongst a superset.
- // In the above example the user cannot be from both locations A and B at the same time but could be using both Mac and Ubuntu probably even at the same time.
- // 1) The simplest and fastest use case is exact matches of input assertions with and exact match of saved rules.
- // 2) exact input values with condition groups in the rules is also supportable.
- // 3) complex input rules as abstract or range assertions matching
- // complex rules that have range or absctract conditions -- How to Implement ??
- // IMPLEMENTATION AS SQL
- // FIND PARTICIPATING rules that evaluate true.
- /* WHERE rule.key = input.key ( rule.operator = '>' AND rule.value <= input.value AND input.operator = '>'
- OR rule.operator = '>' AND rule.value < input.value AND input.operator = '>='
- OR rule.operator = '>=' AND rule.value <= input.value AND (input.operator = '>=' OR input.operator = '=')
- ) AND
- ( rule.operator = '<' AND rule.value <= input.value AND input.operator = '<'
- OR rule.operator = '<' AND rule.value < input.value AND input.operator = '<='
- OR rule.operator = '<=' AND rule.value <= input.value AND (input.operator = '<=' OR input.operator = '=')
- )
- */
- // QUALIFY ALL ( GROUPED and LEAF ) RULES that evaluate true using the assertions from the participating rules.
- /*
- LEFT JOIN rule
- WHERE participating.bit = (participating.bit & rule.mask)
- -- and rule.operator = 'or'
- -- or rule.mask = (allparticipating.mask & rule.mask ) and rule.operator = 'and'
- */
- /* USE THE QUALIFED RULES TO EVALUEATE RESULTS for GROUP LEVELS and ROOT RULES.
- Any grouped rule is associated with 3 kinds evaluation sets composed of rules that are either leaf
- level rules directly or through other promoted grouped rules or groups.
- Evaluation Sets.
- Permissive rules, Restrictive rules, Indeterminant rules
- 1) Permissive bits turn the whole group to true if any one is true.
- Irrespective of all the other participating leaf rules.
- It is therefore not required to evaluate any other types of leaf rules.
- 2) Restrictive rules turn the whole group to false if any one is false.
- If there are no permissive rules it then becomes relevant to evaluate the restrictive rules.
- Other Indeterminant rule evaluation is therefore not relevant.
- 3) Indeterminant rules need to be evaluated at run time.
- -- Are typically unevaluated nested groups
- -- Or can be Individual Evaluated results
- which don't yet determine the overall result and mean anything
- until a complex hierarchy of conditions
- are evaluated and collectively satisifed.
-
- -- Since we do not (yet) support rule negations
- -- it necessarily implies that if all of the Indeterminant set items are true then the whole group is true.
- -- which then implies we can bypass the Indeterminant group and subgroup structure evaluation for efficiency.
-
- -- Pre-Evaluated promotion to parent group evaluation sets to parent groups evaluation sets.
- Composition of a subgroup can be promoted directly into the parent groups evaluation sets when certain conditions are met.
-
- When There are no Permissive rules
- AND ( There are no restrictive rules OR all the restrictive rules are true )
- Then evaluation of the descendents rule set is required until we reach all leaf level nodes.
- Subgroups are recursively evaluated using these same 3 steps.
-
- Following caching efficiencies can be precomputed and stored with the parents rule sets as rule promotions.
- If the sub group rule participates in parents permissive set.
- All of its permissive rules should be added to the parent groups permissive set.
- -- The sub group has no restrictive and descendents sets sub group bit need not be in the parents permissive set.
- If subgroup has restricitve sets and no descendents sets
- -- and is a subset of the parent groups restrictive set
- -- then subgroup bit can be removed from parents permissive and restrictive groups.
- -- This is good for preventing re-evaluation of the sub group for efficiency.
- -- else subgroup bit should be present in the permissive
- Sub group has descendents sets
- -- the sub group bit must necessarily be added to the parents permissive set.
-
- If the sub group rule participates in the parents restrictive set
- - Sub Group is Pure Permissive = Has no restrictive set or descendents set
- Runtime Evaluate.
-
- - Sub Group is Pure Restrictive = Has no permissive or descendents set
- -- Restrictive set of sub group should be promoted into the restrictive set of the parent
- -- sub group bit should be removed from all parent sets for effciency by bypassing subgroup evaluation.
-
- - All other cases Runtime Evaluate.
-
- Sub Group participates in descendents set.
- -- Run time evaluation.
- */
-
- getParticipating(inputRule, rList, (err, participating)=>{
- getParticipatingRoots(participating, rList, (err, participatingRoots)=>{
- cb(null, participatingRoots);
- });
- });
- });
- };
-
- // PB : TODO -- Creations are easy. Edits and updates for addition of a single rule are expensive due to cascading updates to all relations.
- // Connections can be made in multiple dimensions. For Rules we currlently only implement the child and parent dimensions.
- // PB : TODO -ve dimensions ?? In this implementation there are no negative dimensions...
- // So both -ve and +ve dimensions are independent. But can be marked as opposites.
- // Note : Therefore Child and Parent are different independent dimensions.
- // They may not be exactly oposing in this case ( Rules are networks ) and some circular loops may exist.
- var connectRules = function(as, ...rest){ return branch[as](...rest) };
-
- var branch = {};
- branch[__Rule.AND] = function(rChild, rParent, refresh){
- rChild.ancestors |= rParent.ancestors | rParent.bit; // This should set the whole ancestral network.
-
- if(rParent.permissive || rParent.operator === OR) throw 'Error Invalid rule addition to parent'
-
- if(rParent.restrictive & rChild.bit) return; // Was already connected within this and.
- rParent.list.push(rChild);
-
- // if(!rParent.permissive && !rParent.restrictive) {
- // if(rParent.operator !== AND && rParent.operator !== OR) {
- // if(!rParent.operator) rParent.operator = AND; // Implicit AND if unspeicified
- // else throw 'Incomplete parent. Invalid operator or no operator specified.'
- // }
- // rParent.operator === AND ? rParent.restrictive |= rChild.bit : rParent.permissive |= rChild.bit ;
- // }
-
- // Promotions : All child rules are only a bunch of Ands or ors
- // they can be flattened directly into the containing rule.
- // if(!rParent.permissive) { rParent.restrictive |= rChild.restrictive; rParent.restrictive |= rChild.bit; }
- // if(!rParent.restrictive) { rParent.permissive |= rChild.permissive; rParent.permissive |= rChild.bit; }
- rParent.restrictive |= rChild.restrictive | rChild.bit;
-
- // Descendents should be all non immediate descendents.
- // Immmediate descendents can always be computed as (r.permissive | r.restrictive) & !r.descendents
- // child may be either permissive or restrictive. Since child.restrictive is already added in.
- rParent.descendents |= rChild.descendents | rChild.permissive | rChild.restrictive ;
-
- // If we add another ancestral network to one of the ancestors we need to cascaded it down to the child network.
- // and vice versa.
- if(refresh){
- // PB : TODO -- Cascading refreshes should avoid circular loops..
- rChild.refreshDescendents(rChild.ancestors);
- rParent.refreshAncestors(rParent.descendents);
- }
- };
-
- branch[__Rule.OR] = function(rChild, rParent, refresh){
- rChild.ancestors |= rParent.ancestors | rParent.bit;
-
- if(rParent.restrictive || rParent.operator !== OR) throw 'Error Invalid rule addition to parent'
- if(rParent.permissive & rChild.bit) return
- rParent.list.push(rChild);
-
- rParent.permissive |= rChild.permissive | rChild.bit;
-
- rParent.descendents |= rChild.descendents | rChild.permissive | rChild.restrictive ;
- if(refresh){
- rChild.refreshDescendents(rChild.ancestors); // This should set the whole ancestral network.
- rParent.refreshAncestors(rParent.descendents);
- }
- };
-
- var rProto = { migrationstate : 8, operator : EQ
- , evaluate // PB : TODO -- Enforce preconditions for evaluate on instance. Eg. Assignbit is a precondition for evaluate or match.
- , connect : function(parent){
- connectRules(operators[parent.operator].bit, this, parent);
- }
- // PB : TODO -- Cloning descriptors using assgin is expense. Review and just atttach to each new instance...
- , get sql(){
- var getSql = this.operator === AND ? getsql_cond_group : this.operator === OR ? getsql_cond_group
- : ()=>this.key + ' ' + operators[this.operator].operator + ` '${this.value}' `;
- return getSql.call(this)
- }
- , get filter(){
- var getFilter = this.operator === AND ? getfilter_cond_group : this.operator === OR ? getgetfilter_cond_group
- : ()=>{
- var f = {};
- f[this.key] = {};
- f[this.key][this.operator] = this.value; return f;};
- return getFilter.call(this)
- }
- // PB : TODO -- this.siblings will be a nice addtion.
- , get mask(){ return this.permissive | this.restrictive | this.descendents | this.ancestors | this.bit }
- , get isIndependent() { return this.bit === this.mask }
- , get isRoot() { return !this.ancestors }
- , get isChild() { return this.ancestors }
- , get isParent() { return (this.permissive | this.restrictive | this.descendents) }
- , get isleaf() { return !(this.permissive | this.restrictive | this.descendents) }
- , get iscomposite() { return this.list.length > 1 } // PB : TODO -- Non composite parents may be possible to collapse
- };
-
- return _Rule.extend()
- })();
-
- utils_1.core = core_1;
- var bbhverse = utils_1;
-
- const { spawn: spawn$1, spawnSync } = childProcess__default['default'];
-
-
- function nodeShellExec$1() {
-
- var args = Array.from(arguments);
- var opts = args[2] = args[2] || {};
- opts.title ? null : opts.title = `${args[0]} ${args[1] }`;
- const child = spawn$1(...arguments);
- // // const spawn = require('child_process').spawn;
- // const s = spawn(
- // 'C:\\Program Files\\Git\\bin\\sh.exe'
- // , ['notepad', 'index'], { cwd: __dirname });
-
-
- var p = new Promise(function(resolve, reject){
- if(!opts.detached) {
- var messages = []; // PB : TODO -- Explore stream for Task level aggregation to prevent interleaved messages from multiple tasks...
- var success = true;
-
- if(opts.stdio !== 'ignore') {
- child.stdout.setEncoding('utf8');
- child.stderr.setEncoding('utf8');
- child.stdout.on('data', (chunk) => { chunk.trim() === '' ? null : messages.push(chunk); /* console.log('d: ' + chunk) */ });
- child.on('error', (chunk) => { success = false; messages.push(chunk); /* console.error('e: ' + chunk) */ } );
- child.stderr.on('data', (chunk) => {
- if(messages.join('').indexOf('fatal: not a git repository') > -1) opts.haserrors = true;
- messages.push(chunk);
- // console.error('stderr e: ' + chunk)
- });
- }
- child.on('close', (code) => {
- if(+code !== 0 || opts.haserrors) success = false;
- if(opts.stdio !== 'ignore') {
- var logEntry = { result: `${opts.title} exited with code ${code}`, messages };
- logEntry.success = success;
-
- if(opts.runas){
- // success ? logEntry.success = true : null;
- fs__default['default'].writeFileSync('run.log', ', ' + JSON.stringify(logEntry), {'flag':'a+'} );
- }
- else {
- // console.log( messages.join('') )
- process.stdout.write( messages.join('') );
- }
- }
- if(code !== 0 || opts.haserrors) return reject(logEntry)
- resolve(logEntry);
- });
- }
- else {
- child.unref();
- resolve(true);
- }
- });
- p.process = child;
- return p;
- }
-
-
-
- var cli = {
- nodeShellExec: nodeShellExec$1
- , get prompt() {
- const clii = readline__default['default'].createInterface({ input: process.stdin, output: process.stdout });
- clii.ask = function(q){
- return new Promise((resolve, reject)=>{
- clii.question(q, (answer)=>{ resolve(answer); });
- })
- };
- return clii
- }
- };
-
- var cliverse = cli;
-
- var colorName = {
- "aliceblue": [240, 248, 255],
- "antiquewhite": [250, 235, 215],
- "aqua": [0, 255, 255],
- "aquamarine": [127, 255, 212],
- "azure": [240, 255, 255],
- "beige": [245, 245, 220],
- "bisque": [255, 228, 196],
- "black": [0, 0, 0],
- "blanchedalmond": [255, 235, 205],
- "blue": [0, 0, 255],
- "blueviolet": [138, 43, 226],
- "brown": [165, 42, 42],
- "burlywood": [222, 184, 135],
- "cadetblue": [95, 158, 160],
- "chartreuse": [127, 255, 0],
- "chocolate": [210, 105, 30],
- "coral": [255, 127, 80],
- "cornflowerblue": [100, 149, 237],
- "cornsilk": [255, 248, 220],
- "crimson": [220, 20, 60],
- "cyan": [0, 255, 255],
- "darkblue": [0, 0, 139],
- "darkcyan": [0, 139, 139],
- "darkgoldenrod": [184, 134, 11],
- "darkgray": [169, 169, 169],
- "darkgreen": [0, 100, 0],
- "darkgrey": [169, 169, 169],
- "darkkhaki": [189, 183, 107],
- "darkmagenta": [139, 0, 139],
- "darkolivegreen": [85, 107, 47],
- "darkorange": [255, 140, 0],
- "darkorchid": [153, 50, 204],
- "darkred": [139, 0, 0],
- "darksalmon": [233, 150, 122],
- "darkseagreen": [143, 188, 143],
- "darkslateblue": [72, 61, 139],
- "darkslategray": [47, 79, 79],
- "darkslategrey": [47, 79, 79],
- "darkturquoise": [0, 206, 209],
- "darkviolet": [148, 0, 211],
- "deeppink": [255, 20, 147],
- "deepskyblue": [0, 191, 255],
- "dimgray": [105, 105, 105],
- "dimgrey": [105, 105, 105],
- "dodgerblue": [30, 144, 255],
- "firebrick": [178, 34, 34],
- "floralwhite": [255, 250, 240],
- "forestgreen": [34, 139, 34],
- "fuchsia": [255, 0, 255],
- "gainsboro": [220, 220, 220],
- "ghostwhite": [248, 248, 255],
- "gold": [255, 215, 0],
- "goldenrod": [218, 165, 32],
- "gray": [128, 128, 128],
- "green": [0, 128, 0],
- "greenyellow": [173, 255, 47],
- "grey": [128, 128, 128],
- "honeydew": [240, 255, 240],
- "hotpink": [255, 105, 180],
- "indianred": [205, 92, 92],
- "indigo": [75, 0, 130],
- "ivory": [255, 255, 240],
- "khaki": [240, 230, 140],
- "lavender": [230, 230, 250],
- "lavenderblush": [255, 240, 245],
- "lawngreen": [124, 252, 0],
- "lemonchiffon": [255, 250, 205],
- "lightblue": [173, 216, 230],
- "lightcoral": [240, 128, 128],
- "lightcyan": [224, 255, 255],
- "lightgoldenrodyellow": [250, 250, 210],
- "lightgray": [211, 211, 211],
- "lightgreen": [144, 238, 144],
- "lightgrey": [211, 211, 211],
- "lightpink": [255, 182, 193],
- "lightsalmon": [255, 160, 122],
- "lightseagreen": [32, 178, 170],
- "lightskyblue": [135, 206, 250],
- "lightslategray": [119, 136, 153],
- "lightslategrey": [119, 136, 153],
- "lightsteelblue": [176, 196, 222],
- "lightyellow": [255, 255, 224],
- "lime": [0, 255, 0],
- "limegreen": [50, 205, 50],
- "linen": [250, 240, 230],
- "magenta": [255, 0, 255],
- "maroon": [128, 0, 0],
- "mediumaquamarine": [102, 205, 170],
- "mediumblue": [0, 0, 205],
- "mediumorchid": [186, 85, 211],
- "mediumpurple": [147, 112, 219],
- "mediumseagreen": [60, 179, 113],
- "mediumslateblue": [123, 104, 238],
- "mediumspringgreen": [0, 250, 154],
- "mediumturquoise": [72, 209, 204],
- "mediumvioletred": [199, 21, 133],
- "midnightblue": [25, 25, 112],
- "mintcream": [245, 255, 250],
- "mistyrose": [255, 228, 225],
- "moccasin": [255, 228, 181],
- "navajowhite": [255, 222, 173],
- "navy": [0, 0, 128],
- "oldlace": [253, 245, 230],
- "olive": [128, 128, 0],
- "olivedrab": [107, 142, 35],
- "orange": [255, 165, 0],
- "orangered": [255, 69, 0],
- "orchid": [218, 112, 214],
- "palegoldenrod": [238, 232, 170],
- "palegreen": [152, 251, 152],
- "paleturquoise": [175, 238, 238],
- "palevioletred": [219, 112, 147],
- "papayawhip": [255, 239, 213],
- "peachpuff": [255, 218, 185],
- "peru": [205, 133, 63],
- "pink": [255, 192, 203],
- "plum": [221, 160, 221],
- "powderblue": [176, 224, 230],
- "purple": [128, 0, 128],
- "rebeccapurple": [102, 51, 153],
- "red": [255, 0, 0],
- "rosybrown": [188, 143, 143],
- "royalblue": [65, 105, 225],
- "saddlebrown": [139, 69, 19],
- "salmon": [250, 128, 114],
- "sandybrown": [244, 164, 96],
- "seagreen": [46, 139, 87],
- "seashell": [255, 245, 238],
- "sienna": [160, 82, 45],
- "silver": [192, 192, 192],
- "skyblue": [135, 206, 235],
- "slateblue": [106, 90, 205],
- "slategray": [112, 128, 144],
- "slategrey": [112, 128, 144],
- "snow": [255, 250, 250],
- "springgreen": [0, 255, 127],
- "steelblue": [70, 130, 180],
- "tan": [210, 180, 140],
- "teal": [0, 128, 128],
- "thistle": [216, 191, 216],
- "tomato": [255, 99, 71],
- "turquoise": [64, 224, 208],
- "violet": [238, 130, 238],
- "wheat": [245, 222, 179],
- "white": [255, 255, 255],
- "whitesmoke": [245, 245, 245],
- "yellow": [255, 255, 0],
- "yellowgreen": [154, 205, 50]
- };
-
- /* MIT license */
-
- /* eslint-disable no-mixed-operators */
-
-
- // NOTE: conversions should only return primitive values (i.e. arrays, or
- // values that give correct `typeof` results).
- // do not use box values types (i.e. Number(), String(), etc.)
-
- const reverseKeywords = {};
- for (const key of Object.keys(colorName)) {
- reverseKeywords[colorName[key]] = key;
- }
-
- const convert$1 = {
- rgb: {channels: 3, labels: 'rgb'},
- hsl: {channels: 3, labels: 'hsl'},
- hsv: {channels: 3, labels: 'hsv'},
- hwb: {channels: 3, labels: 'hwb'},
- cmyk: {channels: 4, labels: 'cmyk'},
- xyz: {channels: 3, labels: 'xyz'},
- lab: {channels: 3, labels: 'lab'},
- lch: {channels: 3, labels: 'lch'},
- hex: {channels: 1, labels: ['hex']},
- keyword: {channels: 1, labels: ['keyword']},
- ansi16: {channels: 1, labels: ['ansi16']},
- ansi256: {channels: 1, labels: ['ansi256']},
- hcg: {channels: 3, labels: ['h', 'c', 'g']},
- apple: {channels: 3, labels: ['r16', 'g16', 'b16']},
- gray: {channels: 1, labels: ['gray']}
- };
-
- var conversions = convert$1;
-
- // Hide .channels and .labels properties
- for (const model of Object.keys(convert$1)) {
- if (!('channels' in convert$1[model])) {
- throw new Error('missing channels property: ' + model);
- }
-
- if (!('labels' in convert$1[model])) {
- throw new Error('missing channel labels property: ' + model);
- }
-
- if (convert$1[model].labels.length !== convert$1[model].channels) {
- throw new Error('channel and label counts mismatch: ' + model);
- }
-
- const {channels, labels} = convert$1[model];
- delete convert$1[model].channels;
- delete convert$1[model].labels;
- Object.defineProperty(convert$1[model], 'channels', {value: channels});
- Object.defineProperty(convert$1[model], 'labels', {value: labels});
- }
-
- convert$1.rgb.hsl = function (rgb) {
- const r = rgb[0] / 255;
- const g = rgb[1] / 255;
- const b = rgb[2] / 255;
- const min = Math.min(r, g, b);
- const max = Math.max(r, g, b);
- const delta = max - min;
- let h;
- let s;
-
- if (max === min) {
- h = 0;
- } else if (r === max) {
- h = (g - b) / delta;
- } else if (g === max) {
- h = 2 + (b - r) / delta;
- } else if (b === max) {
- h = 4 + (r - g) / delta;
- }
-
- h = Math.min(h * 60, 360);
-
- if (h < 0) {
- h += 360;
- }
-
- const l = (min + max) / 2;
-
- if (max === min) {
- s = 0;
- } else if (l <= 0.5) {
- s = delta / (max + min);
- } else {
- s = delta / (2 - max - min);
- }
-
- return [h, s * 100, l * 100];
- };
-
- convert$1.rgb.hsv = function (rgb) {
- let rdif;
- let gdif;
- let bdif;
- let h;
- let s;
-
- const r = rgb[0] / 255;
- const g = rgb[1] / 255;
- const b = rgb[2] / 255;
- const v = Math.max(r, g, b);
- const diff = v - Math.min(r, g, b);
- const diffc = function (c) {
- return (v - c) / 6 / diff + 1 / 2;
- };
-
- if (diff === 0) {
- h = 0;
- s = 0;
- } else {
- s = diff / v;
- rdif = diffc(r);
- gdif = diffc(g);
- bdif = diffc(b);
-
- if (r === v) {
- h = bdif - gdif;
- } else if (g === v) {
- h = (1 / 3) + rdif - bdif;
- } else if (b === v) {
- h = (2 / 3) + gdif - rdif;
- }
-
- if (h < 0) {
- h += 1;
- } else if (h > 1) {
- h -= 1;
- }
- }
-
- return [
- h * 360,
- s * 100,
- v * 100
- ];
- };
-
- convert$1.rgb.hwb = function (rgb) {
- const r = rgb[0];
- const g = rgb[1];
- let b = rgb[2];
- const h = convert$1.rgb.hsl(rgb)[0];
- const w = 1 / 255 * Math.min(r, Math.min(g, b));
-
- b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
-
- return [h, w * 100, b * 100];
- };
-
- convert$1.rgb.cmyk = function (rgb) {
- const r = rgb[0] / 255;
- const g = rgb[1] / 255;
- const b = rgb[2] / 255;
-
- const k = Math.min(1 - r, 1 - g, 1 - b);
- const c = (1 - r - k) / (1 - k) || 0;
- const m = (1 - g - k) / (1 - k) || 0;
- const y = (1 - b - k) / (1 - k) || 0;
-
- return [c * 100, m * 100, y * 100, k * 100];
- };
-
- function comparativeDistance(x, y) {
- /*
- See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
- */
- return (
- ((x[0] - y[0]) ** 2) +
- ((x[1] - y[1]) ** 2) +
- ((x[2] - y[2]) ** 2)
- );
- }
-
- convert$1.rgb.keyword = function (rgb) {
- const reversed = reverseKeywords[rgb];
- if (reversed) {
- return reversed;
- }
-
- let currentClosestDistance = Infinity;
- let currentClosestKeyword;
-
- for (const keyword of Object.keys(colorName)) {
- const value = colorName[keyword];
-
- // Compute comparative distance
- const distance = comparativeDistance(rgb, value);
-
- // Check if its less, if so set as closest
- if (distance < currentClosestDistance) {
- currentClosestDistance = distance;
- currentClosestKeyword = keyword;
- }
- }
-
- return currentClosestKeyword;
- };
-
- convert$1.keyword.rgb = function (keyword) {
- return colorName[keyword];
- };
-
- convert$1.rgb.xyz = function (rgb) {
- let r = rgb[0] / 255;
- let g = rgb[1] / 255;
- let b = rgb[2] / 255;
-
- // Assume sRGB
- r = r > 0.04045 ? (((r + 0.055) / 1.055) ** 2.4) : (r / 12.92);
- g = g > 0.04045 ? (((g + 0.055) / 1.055) ** 2.4) : (g / 12.92);
- b = b > 0.04045 ? (((b + 0.055) / 1.055) ** 2.4) : (b / 12.92);
-
- const x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);
- const y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);
- const z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);
-
- return [x * 100, y * 100, z * 100];
- };
-
- convert$1.rgb.lab = function (rgb) {
- const xyz = convert$1.rgb.xyz(rgb);
- let x = xyz[0];
- let y = xyz[1];
- let z = xyz[2];
-
- x /= 95.047;
- y /= 100;
- z /= 108.883;
-
- x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);
- y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);
- z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);
-
- const l = (116 * y) - 16;
- const a = 500 * (x - y);
- const b = 200 * (y - z);
-
- return [l, a, b];
- };
-
- convert$1.hsl.rgb = function (hsl) {
- const h = hsl[0] / 360;
- const s = hsl[1] / 100;
- const l = hsl[2] / 100;
- let t2;
- let t3;
- let val;
-
- if (s === 0) {
- val = l * 255;
- return [val, val, val];
- }
-
- if (l < 0.5) {
- t2 = l * (1 + s);
- } else {
- t2 = l + s - l * s;
- }
-
- const t1 = 2 * l - t2;
-
- const rgb = [0, 0, 0];
- for (let i = 0; i < 3; i++) {
- t3 = h + 1 / 3 * -(i - 1);
- if (t3 < 0) {
- t3++;
- }
-
- if (t3 > 1) {
- t3--;
- }
-
- if (6 * t3 < 1) {
- val = t1 + (t2 - t1) * 6 * t3;
- } else if (2 * t3 < 1) {
- val = t2;
- } else if (3 * t3 < 2) {
- val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
- } else {
- val = t1;
- }
-
- rgb[i] = val * 255;
- }
-
- return rgb;
- };
-
- convert$1.hsl.hsv = function (hsl) {
- const h = hsl[0];
- let s = hsl[1] / 100;
- let l = hsl[2] / 100;
- let smin = s;
- const lmin = Math.max(l, 0.01);
-
- l *= 2;
- s *= (l <= 1) ? l : 2 - l;
- smin *= lmin <= 1 ? lmin : 2 - lmin;
- const v = (l + s) / 2;
- const sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s);
-
- return [h, sv * 100, v * 100];
- };
-
- convert$1.hsv.rgb = function (hsv) {
- const h = hsv[0] / 60;
- const s = hsv[1] / 100;
- let v = hsv[2] / 100;
- const hi = Math.floor(h) % 6;
-
- const f = h - Math.floor(h);
- const p = 255 * v * (1 - s);
- const q = 255 * v * (1 - (s * f));
- const t = 255 * v * (1 - (s * (1 - f)));
- v *= 255;
-
- switch (hi) {
- case 0:
- return [v, t, p];
- case 1:
- return [q, v, p];
- case 2:
- return [p, v, t];
- case 3:
- return [p, q, v];
- case 4:
- return [t, p, v];
- case 5:
- return [v, p, q];
- }
- };
-
- convert$1.hsv.hsl = function (hsv) {
- const h = hsv[0];
- const s = hsv[1] / 100;
- const v = hsv[2] / 100;
- const vmin = Math.max(v, 0.01);
- let sl;
- let l;
-
- l = (2 - s) * v;
- const lmin = (2 - s) * vmin;
- sl = s * vmin;
- sl /= (lmin <= 1) ? lmin : 2 - lmin;
- sl = sl || 0;
- l /= 2;
-
- return [h, sl * 100, l * 100];
- };
-
- // http://dev.w3.org/csswg/css-color/#hwb-to-rgb
- convert$1.hwb.rgb = function (hwb) {
- const h = hwb[0] / 360;
- let wh = hwb[1] / 100;
- let bl = hwb[2] / 100;
- const ratio = wh + bl;
- let f;
-
- // Wh + bl cant be > 1
- if (ratio > 1) {
- wh /= ratio;
- bl /= ratio;
- }
-
- const i = Math.floor(6 * h);
- const v = 1 - bl;
- f = 6 * h - i;
-
- if ((i & 0x01) !== 0) {
- f = 1 - f;
- }
-
- const n = wh + f * (v - wh); // Linear interpolation
-
- let r;
- let g;
- let b;
- /* eslint-disable max-statements-per-line,no-multi-spaces */
- switch (i) {
- default:
- case 6:
- case 0: r = v; g = n; b = wh; break;
- case 1: r = n; g = v; b = wh; break;
- case 2: r = wh; g = v; b = n; break;
- case 3: r = wh; g = n; b = v; break;
- case 4: r = n; g = wh; b = v; break;
- case 5: r = v; g = wh; b = n; break;
- }
- /* eslint-enable max-statements-per-line,no-multi-spaces */
-
- return [r * 255, g * 255, b * 255];
- };
-
- convert$1.cmyk.rgb = function (cmyk) {
- const c = cmyk[0] / 100;
- const m = cmyk[1] / 100;
- const y = cmyk[2] / 100;
- const k = cmyk[3] / 100;
-
- const r = 1 - Math.min(1, c * (1 - k) + k);
- const g = 1 - Math.min(1, m * (1 - k) + k);
- const b = 1 - Math.min(1, y * (1 - k) + k);
-
- return [r * 255, g * 255, b * 255];
- };
-
- convert$1.xyz.rgb = function (xyz) {
- const x = xyz[0] / 100;
- const y = xyz[1] / 100;
- const z = xyz[2] / 100;
- let r;
- let g;
- let b;
-
- r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);
- g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);
- b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);
-
- // Assume sRGB
- r = r > 0.0031308
- ? ((1.055 * (r ** (1.0 / 2.4))) - 0.055)
- : r * 12.92;
-
- g = g > 0.0031308
- ? ((1.055 * (g ** (1.0 / 2.4))) - 0.055)
- : g * 12.92;
-
- b = b > 0.0031308
- ? ((1.055 * (b ** (1.0 / 2.4))) - 0.055)
- : b * 12.92;
-
- r = Math.min(Math.max(0, r), 1);
- g = Math.min(Math.max(0, g), 1);
- b = Math.min(Math.max(0, b), 1);
-
- return [r * 255, g * 255, b * 255];
- };
-
- convert$1.xyz.lab = function (xyz) {
- let x = xyz[0];
- let y = xyz[1];
- let z = xyz[2];
-
- x /= 95.047;
- y /= 100;
- z /= 108.883;
-
- x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);
- y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);
- z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);
-
- const l = (116 * y) - 16;
- const a = 500 * (x - y);
- const b = 200 * (y - z);
-
- return [l, a, b];
- };
-
- convert$1.lab.xyz = function (lab) {
- const l = lab[0];
- const a = lab[1];
- const b = lab[2];
- let x;
- let y;
- let z;
-
- y = (l + 16) / 116;
- x = a / 500 + y;
- z = y - b / 200;
-
- const y2 = y ** 3;
- const x2 = x ** 3;
- const z2 = z ** 3;
- y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
- x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
- z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
-
- x *= 95.047;
- y *= 100;
- z *= 108.883;
-
- return [x, y, z];
- };
-
- convert$1.lab.lch = function (lab) {
- const l = lab[0];
- const a = lab[1];
- const b = lab[2];
- let h;
-
- const hr = Math.atan2(b, a);
- h = hr * 360 / 2 / Math.PI;
-
- if (h < 0) {
- h += 360;
- }
-
- const c = Math.sqrt(a * a + b * b);
-
- return [l, c, h];
- };
-
- convert$1.lch.lab = function (lch) {
- const l = lch[0];
- const c = lch[1];
- const h = lch[2];
-
- const hr = h / 360 * 2 * Math.PI;
- const a = c * Math.cos(hr);
- const b = c * Math.sin(hr);
-
- return [l, a, b];
- };
-
- convert$1.rgb.ansi16 = function (args, saturation = null) {
- const [r, g, b] = args;
- let value = saturation === null ? convert$1.rgb.hsv(args)[2] : saturation; // Hsv -> ansi16 optimization
-
- value = Math.round(value / 50);
-
- if (value === 0) {
- return 30;
- }
-
- let ansi = 30
- + ((Math.round(b / 255) << 2)
- | (Math.round(g / 255) << 1)
- | Math.round(r / 255));
-
- if (value === 2) {
- ansi += 60;
- }
-
- return ansi;
- };
-
- convert$1.hsv.ansi16 = function (args) {
- // Optimization here; we already know the value and don't need to get
- // it converted for us.
- return convert$1.rgb.ansi16(convert$1.hsv.rgb(args), args[2]);
- };
-
- convert$1.rgb.ansi256 = function (args) {
- const r = args[0];
- const g = args[1];
- const b = args[2];
-
- // We use the extended greyscale palette here, with the exception of
- // black and white. normal palette only has 4 greyscale shades.
- if (r === g && g === b) {
- if (r < 8) {
- return 16;
- }
-
- if (r > 248) {
- return 231;
- }
-
- return Math.round(((r - 8) / 247) * 24) + 232;
- }
-
- const ansi = 16
- + (36 * Math.round(r / 255 * 5))
- + (6 * Math.round(g / 255 * 5))
- + Math.round(b / 255 * 5);
-
- return ansi;
- };
-
- convert$1.ansi16.rgb = function (args) {
- let color = args % 10;
-
- // Handle greyscale
- if (color === 0 || color === 7) {
- if (args > 50) {
- color += 3.5;
- }
-
- color = color / 10.5 * 255;
-
- return [color, color, color];
- }
-
- const mult = (~~(args > 50) + 1) * 0.5;
- const r = ((color & 1) * mult) * 255;
- const g = (((color >> 1) & 1) * mult) * 255;
- const b = (((color >> 2) & 1) * mult) * 255;
-
- return [r, g, b];
- };
-
- convert$1.ansi256.rgb = function (args) {
- // Handle greyscale
- if (args >= 232) {
- const c = (args - 232) * 10 + 8;
- return [c, c, c];
- }
-
- args -= 16;
-
- let rem;
- const r = Math.floor(args / 36) / 5 * 255;
- const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
- const b = (rem % 6) / 5 * 255;
-
- return [r, g, b];
- };
-
- convert$1.rgb.hex = function (args) {
- const integer = ((Math.round(args[0]) & 0xFF) << 16)
- + ((Math.round(args[1]) & 0xFF) << 8)
- + (Math.round(args[2]) & 0xFF);
-
- const string = integer.toString(16).toUpperCase();
- return '000000'.substring(string.length) + string;
- };
-
- convert$1.hex.rgb = function (args) {
- const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
- if (!match) {
- return [0, 0, 0];
- }
-
- let colorString = match[0];
-
- if (match[0].length === 3) {
- colorString = colorString.split('').map(char => {
- return char + char;
- }).join('');
- }
-
- const integer = parseInt(colorString, 16);
- const r = (integer >> 16) & 0xFF;
- const g = (integer >> 8) & 0xFF;
- const b = integer & 0xFF;
-
- return [r, g, b];
- };
-
- convert$1.rgb.hcg = function (rgb) {
- const r = rgb[0] / 255;
- const g = rgb[1] / 255;
- const b = rgb[2] / 255;
- const max = Math.max(Math.max(r, g), b);
- const min = Math.min(Math.min(r, g), b);
- const chroma = (max - min);
- let grayscale;
- let hue;
-
- if (chroma < 1) {
- grayscale = min / (1 - chroma);
- } else {
- grayscale = 0;
- }
-
- if (chroma <= 0) {
- hue = 0;
- } else
- if (max === r) {
- hue = ((g - b) / chroma) % 6;
- } else
- if (max === g) {
- hue = 2 + (b - r) / chroma;
- } else {
- hue = 4 + (r - g) / chroma;
- }
-
- hue /= 6;
- hue %= 1;
-
- return [hue * 360, chroma * 100, grayscale * 100];
- };
-
- convert$1.hsl.hcg = function (hsl) {
- const s = hsl[1] / 100;
- const l = hsl[2] / 100;
-
- const c = l < 0.5 ? (2.0 * s * l) : (2.0 * s * (1.0 - l));
-
- let f = 0;
- if (c < 1.0) {
- f = (l - 0.5 * c) / (1.0 - c);
- }
-
- return [hsl[0], c * 100, f * 100];
- };
-
- convert$1.hsv.hcg = function (hsv) {
- const s = hsv[1] / 100;
- const v = hsv[2] / 100;
-
- const c = s * v;
- let f = 0;
-
- if (c < 1.0) {
- f = (v - c) / (1 - c);
- }
-
- return [hsv[0], c * 100, f * 100];
- };
-
- convert$1.hcg.rgb = function (hcg) {
- const h = hcg[0] / 360;
- const c = hcg[1] / 100;
- const g = hcg[2] / 100;
-
- if (c === 0.0) {
- return [g * 255, g * 255, g * 255];
- }
-
- const pure = [0, 0, 0];
- const hi = (h % 1) * 6;
- const v = hi % 1;
- const w = 1 - v;
- let mg = 0;
-
- /* eslint-disable max-statements-per-line */
- switch (Math.floor(hi)) {
- case 0:
- pure[0] = 1; pure[1] = v; pure[2] = 0; break;
- case 1:
- pure[0] = w; pure[1] = 1; pure[2] = 0; break;
- case 2:
- pure[0] = 0; pure[1] = 1; pure[2] = v; break;
- case 3:
- pure[0] = 0; pure[1] = w; pure[2] = 1; break;
- case 4:
- pure[0] = v; pure[1] = 0; pure[2] = 1; break;
- default:
- pure[0] = 1; pure[1] = 0; pure[2] = w;
- }
- /* eslint-enable max-statements-per-line */
-
- mg = (1.0 - c) * g;
-
- return [
- (c * pure[0] + mg) * 255,
- (c * pure[1] + mg) * 255,
- (c * pure[2] + mg) * 255
- ];
- };
-
- convert$1.hcg.hsv = function (hcg) {
- const c = hcg[1] / 100;
- const g = hcg[2] / 100;
-
- const v = c + g * (1.0 - c);
- let f = 0;
-
- if (v > 0.0) {
- f = c / v;
- }
-
- return [hcg[0], f * 100, v * 100];
- };
-
- convert$1.hcg.hsl = function (hcg) {
- const c = hcg[1] / 100;
- const g = hcg[2] / 100;
-
- const l = g * (1.0 - c) + 0.5 * c;
- let s = 0;
-
- if (l > 0.0 && l < 0.5) {
- s = c / (2 * l);
- } else
- if (l >= 0.5 && l < 1.0) {
- s = c / (2 * (1 - l));
- }
-
- return [hcg[0], s * 100, l * 100];
- };
-
- convert$1.hcg.hwb = function (hcg) {
- const c = hcg[1] / 100;
- const g = hcg[2] / 100;
- const v = c + g * (1.0 - c);
- return [hcg[0], (v - c) * 100, (1 - v) * 100];
- };
-
- convert$1.hwb.hcg = function (hwb) {
- const w = hwb[1] / 100;
- const b = hwb[2] / 100;
- const v = 1 - b;
- const c = v - w;
- let g = 0;
-
- if (c < 1) {
- g = (v - c) / (1 - c);
- }
-
- return [hwb[0], c * 100, g * 100];
- };
-
- convert$1.apple.rgb = function (apple) {
- return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255];
- };
-
- convert$1.rgb.apple = function (rgb) {
- return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535];
- };
-
- convert$1.gray.rgb = function (args) {
- return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
- };
-
- convert$1.gray.hsl = function (args) {
- return [0, 0, args[0]];
- };
-
- convert$1.gray.hsv = convert$1.gray.hsl;
-
- convert$1.gray.hwb = function (gray) {
- return [0, 100, gray[0]];
- };
-
- convert$1.gray.cmyk = function (gray) {
- return [0, 0, 0, gray[0]];
- };
-
- convert$1.gray.lab = function (gray) {
- return [gray[0], 0, 0];
- };
-
- convert$1.gray.hex = function (gray) {
- const val = Math.round(gray[0] / 100 * 255) & 0xFF;
- const integer = (val << 16) + (val << 8) + val;
-
- const string = integer.toString(16).toUpperCase();
- return '000000'.substring(string.length) + string;
- };
-
- convert$1.rgb.gray = function (rgb) {
- const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
- return [val / 255 * 100];
- };
-
- /*
- This function routes a model to all other models.
-
- all functions that are routed have a property `.conversion` attached
- to the returned synthetic function. This property is an array
- of strings, each with the steps in between the 'from' and 'to'
- color models (inclusive).
-
- conversions that are not possible simply are not included.
- */
-
- function buildGraph() {
- const graph = {};
- // https://jsperf.com/object-keys-vs-for-in-with-closure/3
- const models = Object.keys(conversions);
-
- for (let len = models.length, i = 0; i < len; i++) {
- graph[models[i]] = {
- // http://jsperf.com/1-vs-infinity
- // micro-opt, but this is simple.
- distance: -1,
- parent: null
- };
- }
-
- return graph;
- }
-
- // https://en.wikipedia.org/wiki/Breadth-first_search
- function deriveBFS(fromModel) {
- const graph = buildGraph();
- const queue = [fromModel]; // Unshift -> queue -> pop
-
- graph[fromModel].distance = 0;
-
- while (queue.length) {
- const current = queue.pop();
- const adjacents = Object.keys(conversions[current]);
-
- for (let len = adjacents.length, i = 0; i < len; i++) {
- const adjacent = adjacents[i];
- const node = graph[adjacent];
-
- if (node.distance === -1) {
- node.distance = graph[current].distance + 1;
- node.parent = current;
- queue.unshift(adjacent);
- }
- }
- }
-
- return graph;
- }
-
- function link(from, to) {
- return function (args) {
- return to(from(args));
- };
- }
-
- function wrapConversion(toModel, graph) {
- const path = [graph[toModel].parent, toModel];
- let fn = conversions[graph[toModel].parent][toModel];
-
- let cur = graph[toModel].parent;
- while (graph[cur].parent) {
- path.unshift(graph[cur].parent);
- fn = link(conversions[graph[cur].parent][cur], fn);
- cur = graph[cur].parent;
- }
-
- fn.conversion = path;
- return fn;
- }
-
- var route = function (fromModel) {
- const graph = deriveBFS(fromModel);
- const conversion = {};
-
- const models = Object.keys(graph);
- for (let len = models.length, i = 0; i < len; i++) {
- const toModel = models[i];
- const node = graph[toModel];
-
- if (node.parent === null) {
- // No possible conversion, or this node is the source model.
- continue;
- }
-
- conversion[toModel] = wrapConversion(toModel, graph);
- }
-
- return conversion;
- };
-
- const convert = {};
-
- const models = Object.keys(conversions);
-
- function wrapRaw(fn) {
- const wrappedFn = function (...args) {
- const arg0 = args[0];
- if (arg0 === undefined || arg0 === null) {
- return arg0;
- }
-
- if (arg0.length > 1) {
- args = arg0;
- }
-
- return fn(args);
- };
-
- // Preserve .conversion property if there is one
- if ('conversion' in fn) {
- wrappedFn.conversion = fn.conversion;
- }
-
- return wrappedFn;
- }
-
- function wrapRounded(fn) {
- const wrappedFn = function (...args) {
- const arg0 = args[0];
-
- if (arg0 === undefined || arg0 === null) {
- return arg0;
- }
-
- if (arg0.length > 1) {
- args = arg0;
- }
-
- const result = fn(args);
-
- // We're assuming the result is an array here.
- // see notice in conversions.js; don't use box types
- // in conversion functions.
- if (typeof result === 'object') {
- for (let len = result.length, i = 0; i < len; i++) {
- result[i] = Math.round(result[i]);
- }
- }
-
- return result;
- };
-
- // Preserve .conversion property if there is one
- if ('conversion' in fn) {
- wrappedFn.conversion = fn.conversion;
- }
-
- return wrappedFn;
- }
-
- models.forEach(fromModel => {
- convert[fromModel] = {};
-
- Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels});
- Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels});
-
- const routes = route(fromModel);
- const routeModels = Object.keys(routes);
-
- routeModels.forEach(toModel => {
- const fn = routes[toModel];
-
- convert[fromModel][toModel] = wrapRounded(fn);
- convert[fromModel][toModel].raw = wrapRaw(fn);
- });
- });
-
- var colorConvert = convert;
-
- var ansiStyles = createCommonjsModule(function (module) {
-
- const wrapAnsi16 = (fn, offset) => (...args) => {
- const code = fn(...args);
- return `\u001B[${code + offset}m`;
- };
-
- const wrapAnsi256 = (fn, offset) => (...args) => {
- const code = fn(...args);
- return `\u001B[${38 + offset};5;${code}m`;
- };
-
- const wrapAnsi16m = (fn, offset) => (...args) => {
- const rgb = fn(...args);
- return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
- };
-
- const ansi2ansi = n => n;
- const rgb2rgb = (r, g, b) => [r, g, b];
-
- const setLazyProperty = (object, property, get) => {
- Object.defineProperty(object, property, {
- get: () => {
- const value = get();
-
- Object.defineProperty(object, property, {
- value,
- enumerable: true,
- configurable: true
- });
-
- return value;
- },
- enumerable: true,
- configurable: true
- });
- };
-
- /** @type {typeof import('color-convert')} */
- let colorConvert$1;
- const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
- if (colorConvert$1 === undefined) {
- colorConvert$1 = colorConvert;
- }
-
- const offset = isBackground ? 10 : 0;
- const styles = {};
-
- for (const [sourceSpace, suite] of Object.entries(colorConvert$1)) {
- const name = sourceSpace === 'ansi16' ? 'ansi' : sourceSpace;
- if (sourceSpace === targetSpace) {
- styles[name] = wrap(identity, offset);
- } else if (typeof suite === 'object') {
- styles[name] = wrap(suite[targetSpace], offset);
- }
- }
-
- return styles;
- };
-
- function assembleStyles() {
- const codes = new Map();
- const styles = {
- modifier: {
- reset: [0, 0],
- // 21 isn't widely supported and 22 does the same thing
- bold: [1, 22],
- dim: [2, 22],
- italic: [3, 23],
- underline: [4, 24],
- inverse: [7, 27],
- hidden: [8, 28],
- strikethrough: [9, 29]
- },
- color: {
- black: [30, 39],
- red: [31, 39],
- green: [32, 39],
- yellow: [33, 39],
- blue: [34, 39],
- magenta: [35, 39],
- cyan: [36, 39],
- white: [37, 39],
-
- // Bright color
- blackBright: [90, 39],
- redBright: [91, 39],
- greenBright: [92, 39],
- yellowBright: [93, 39],
- blueBright: [94, 39],
- magentaBright: [95, 39],
- cyanBright: [96, 39],
- whiteBright: [97, 39]
- },
- bgColor: {
- bgBlack: [40, 49],
- bgRed: [41, 49],
- bgGreen: [42, 49],
- bgYellow: [43, 49],
- bgBlue: [44, 49],
- bgMagenta: [45, 49],
- bgCyan: [46, 49],
- bgWhite: [47, 49],
-
- // Bright color
- bgBlackBright: [100, 49],
- bgRedBright: [101, 49],
- bgGreenBright: [102, 49],
- bgYellowBright: [103, 49],
- bgBlueBright: [104, 49],
- bgMagentaBright: [105, 49],
- bgCyanBright: [106, 49],
- bgWhiteBright: [107, 49]
- }
- };
-
- // Alias bright black as gray (and grey)
- styles.color.gray = styles.color.blackBright;
- styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
- styles.color.grey = styles.color.blackBright;
- styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
-
- for (const [groupName, group] of Object.entries(styles)) {
- for (const [styleName, style] of Object.entries(group)) {
- styles[styleName] = {
- open: `\u001B[${style[0]}m`,
- close: `\u001B[${style[1]}m`
- };
-
- group[styleName] = styles[styleName];
-
- codes.set(style[0], style[1]);
- }
-
- Object.defineProperty(styles, groupName, {
- value: group,
- enumerable: false
- });
- }
-
- Object.defineProperty(styles, 'codes', {
- value: codes,
- enumerable: false
- });
-
- styles.color.close = '\u001B[39m';
- styles.bgColor.close = '\u001B[49m';
-
- setLazyProperty(styles.color, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, false));
- setLazyProperty(styles.color, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, false));
- setLazyProperty(styles.color, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, false));
- setLazyProperty(styles.bgColor, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, true));
- setLazyProperty(styles.bgColor, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, true));
- setLazyProperty(styles.bgColor, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, true));
-
- return styles;
- }
-
- // Make the export immutable
- Object.defineProperty(module, 'exports', {
- enumerable: true,
- get: assembleStyles
- });
- }, "/$$rollup_base$$/node_modules/ansi-styles");
-
- var hasFlag = (flag, argv = process.argv) => {
- const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
- const position = argv.indexOf(prefix + flag);
- const terminatorPosition = argv.indexOf('--');
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
- };
-
- const {env: env$1} = process;
-
- let forceColor;
- if (hasFlag('no-color') ||
- hasFlag('no-colors') ||
- hasFlag('color=false') ||
- hasFlag('color=never')) {
- forceColor = 0;
- } else if (hasFlag('color') ||
- hasFlag('colors') ||
- hasFlag('color=true') ||
- hasFlag('color=always')) {
- forceColor = 1;
- }
-
- if ('FORCE_COLOR' in env$1) {
- if (env$1.FORCE_COLOR === 'true') {
- forceColor = 1;
- } else if (env$1.FORCE_COLOR === 'false') {
- forceColor = 0;
- } else {
- forceColor = env$1.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env$1.FORCE_COLOR, 10), 3);
- }
- }
-
- function translateLevel(level) {
- if (level === 0) {
- return false;
- }
-
- return {
- level,
- hasBasic: true,
- has256: level >= 2,
- has16m: level >= 3
- };
- }
-
- function supportsColor(haveStream, streamIsTTY) {
- if (forceColor === 0) {
- return 0;
- }
-
- if (hasFlag('color=16m') ||
- hasFlag('color=full') ||
- hasFlag('color=truecolor')) {
- return 3;
- }
-
- if (hasFlag('color=256')) {
- return 2;
- }
-
- if (haveStream && !streamIsTTY && forceColor === undefined) {
- return 0;
- }
-
- const min = forceColor || 0;
-
- if (env$1.TERM === 'dumb') {
- return min;
- }
-
- if (process.platform === 'win32') {
- // Windows 10 build 10586 is the first Windows release that supports 256 colors.
- // Windows 10 build 14931 is the first release that supports 16m/TrueColor.
- const osRelease = os__default['default'].release().split('.');
- if (
- Number(osRelease[0]) >= 10 &&
- Number(osRelease[2]) >= 10586
- ) {
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
- }
-
- return 1;
- }
-
- if ('CI' in env$1) {
- if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE'].some(sign => sign in env$1) || env$1.CI_NAME === 'codeship') {
- return 1;
- }
-
- return min;
- }
-
- if ('TEAMCITY_VERSION' in env$1) {
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env$1.TEAMCITY_VERSION) ? 1 : 0;
- }
-
- if (env$1.COLORTERM === 'truecolor') {
- return 3;
- }
-
- if ('TERM_PROGRAM' in env$1) {
- const version = parseInt((env$1.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
-
- switch (env$1.TERM_PROGRAM) {
- case 'iTerm.app':
- return version >= 3 ? 3 : 2;
- case 'Apple_Terminal':
- return 2;
- // No default
- }
- }
-
- if (/-256(color)?$/i.test(env$1.TERM)) {
- return 2;
- }
-
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env$1.TERM)) {
- return 1;
- }
-
- if ('COLORTERM' in env$1) {
- return 1;
- }
-
- return min;
- }
-
- function getSupportLevel(stream) {
- const level = supportsColor(stream, stream && stream.isTTY);
- return translateLevel(level);
- }
-
- var supportsColor_1 = {
- supportsColor: getSupportLevel,
- stdout: translateLevel(supportsColor(true, tty__default['default'].isatty(1))),
- stderr: translateLevel(supportsColor(true, tty__default['default'].isatty(2)))
- };
-
- const stringReplaceAll$1 = (string, substring, replacer) => {
- let index = string.indexOf(substring);
- if (index === -1) {
- return string;
- }
-
- const substringLength = substring.length;
- let endIndex = 0;
- let returnValue = '';
- do {
- returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
- endIndex = index + substringLength;
- index = string.indexOf(substring, endIndex);
- } while (index !== -1);
-
- returnValue += string.substr(endIndex);
- return returnValue;
- };
-
- const stringEncaseCRLFWithFirstIndex$1 = (string, prefix, postfix, index) => {
- let endIndex = 0;
- let returnValue = '';
- do {
- const gotCR = string[index - 1] === '\r';
- returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? '\r\n' : '\n') + postfix;
- endIndex = index + 1;
- index = string.indexOf('\n', endIndex);
- } while (index !== -1);
-
- returnValue += string.substr(endIndex);
- return returnValue;
- };
-
- var util = {
- stringReplaceAll: stringReplaceAll$1,
- stringEncaseCRLFWithFirstIndex: stringEncaseCRLFWithFirstIndex$1
- };
-
- 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;
- const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
- const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
- const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
-
- const ESCAPES = new Map([
- ['n', '\n'],
- ['r', '\r'],
- ['t', '\t'],
- ['b', '\b'],
- ['f', '\f'],
- ['v', '\v'],
- ['0', '\0'],
- ['\\', '\\'],
- ['e', '\u001B'],
- ['a', '\u0007']
- ]);
-
- function unescape(c) {
- const u = c[0] === 'u';
- const bracket = c[1] === '{';
-
- if ((u && !bracket && c.length === 5) || (c[0] === 'x' && c.length === 3)) {
- return String.fromCharCode(parseInt(c.slice(1), 16));
- }
-
- if (u && bracket) {
- return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
- }
-
- return ESCAPES.get(c) || c;
- }
-
- function parseArguments(name, arguments_) {
- const results = [];
- const chunks = arguments_.trim().split(/\s*,\s*/g);
- let matches;
-
- for (const chunk of chunks) {
- const number = Number(chunk);
- if (!Number.isNaN(number)) {
- results.push(number);
- } else if ((matches = chunk.match(STRING_REGEX))) {
- results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));
- } else {
- throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
- }
- }
-
- return results;
- }
-
- function parseStyle(style) {
- STYLE_REGEX.lastIndex = 0;
-
- const results = [];
- let matches;
-
- while ((matches = STYLE_REGEX.exec(style)) !== null) {
- const name = matches[1];
-
- if (matches[2]) {
- const args = parseArguments(name, matches[2]);
- results.push([name].concat(args));
- } else {
- results.push([name]);
- }
- }
-
- return results;
- }
-
- function buildStyle(chalk, styles) {
- const enabled = {};
-
- for (const layer of styles) {
- for (const style of layer.styles) {
- enabled[style[0]] = layer.inverse ? null : style.slice(1);
- }
- }
-
- let current = chalk;
- for (const [styleName, styles] of Object.entries(enabled)) {
- if (!Array.isArray(styles)) {
- continue;
- }
-
- if (!(styleName in current)) {
- throw new Error(`Unknown Chalk style: ${styleName}`);
- }
-
- current = styles.length > 0 ? current[styleName](...styles) : current[styleName];
- }
-
- return current;
- }
-
- var templates = (chalk, temporary) => {
- const styles = [];
- const chunks = [];
- let chunk = [];
-
- // eslint-disable-next-line max-params
- temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
- if (escapeCharacter) {
- chunk.push(unescape(escapeCharacter));
- } else if (style) {
- const string = chunk.join('');
- chunk = [];
- chunks.push(styles.length === 0 ? string : buildStyle(chalk, styles)(string));
- styles.push({inverse, styles: parseStyle(style)});
- } else if (close) {
- if (styles.length === 0) {
- throw new Error('Found extraneous } in Chalk template literal');
- }
-
- chunks.push(buildStyle(chalk, styles)(chunk.join('')));
- chunk = [];
- styles.pop();
- } else {
- chunk.push(character);
- }
- });
-
- chunks.push(chunk.join(''));
-
- if (styles.length > 0) {
- const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
- throw new Error(errMessage);
- }
-
- return chunks.join('');
- };
-
- const {stdout: stdoutColor, stderr: stderrColor} = supportsColor_1;
- const {
- stringReplaceAll,
- stringEncaseCRLFWithFirstIndex
- } = util;
-
- const {isArray: isArray$2} = Array;
-
- // `supportsColor.level` → `ansiStyles.color[name]` mapping
- const levelMapping = [
- 'ansi',
- 'ansi',
- 'ansi256',
- 'ansi16m'
- ];
-
- const styles = Object.create(null);
-
- const applyOptions = (object, options = {}) => {
- if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
- throw new Error('The `level` option should be an integer from 0 to 3');
- }
-
- // Detect level if not set manually
- const colorLevel = stdoutColor ? stdoutColor.level : 0;
- object.level = options.level === undefined ? colorLevel : options.level;
- };
-
- class ChalkClass {
- constructor(options) {
- // eslint-disable-next-line no-constructor-return
- return chalkFactory(options);
- }
- }
-
- const chalkFactory = options => {
- const chalk = {};
- applyOptions(chalk, options);
-
- chalk.template = (...arguments_) => chalkTag(chalk.template, ...arguments_);
-
- Object.setPrototypeOf(chalk, Chalk.prototype);
- Object.setPrototypeOf(chalk.template, chalk);
-
- chalk.template.constructor = () => {
- throw new Error('`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.');
- };
-
- chalk.template.Instance = ChalkClass;
-
- return chalk.template;
- };
-
- function Chalk(options) {
- return chalkFactory(options);
- }
-
- for (const [styleName, style] of Object.entries(ansiStyles)) {
- styles[styleName] = {
- get() {
- const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
- Object.defineProperty(this, styleName, {value: builder});
- return builder;
- }
- };
- }
-
- styles.visible = {
- get() {
- const builder = createBuilder(this, this._styler, true);
- Object.defineProperty(this, 'visible', {value: builder});
- return builder;
- }
- };
-
- const usedModels = ['rgb', 'hex', 'keyword', 'hsl', 'hsv', 'hwb', 'ansi', 'ansi256'];
-
- for (const model of usedModels) {
- styles[model] = {
- get() {
- const {level} = this;
- return function (...arguments_) {
- const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
- return createBuilder(this, styler, this._isEmpty);
- };
- }
- };
- }
-
- for (const model of usedModels) {
- const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
- styles[bgModel] = {
- get() {
- const {level} = this;
- return function (...arguments_) {
- const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
- return createBuilder(this, styler, this._isEmpty);
- };
- }
- };
- }
-
- const proto = Object.defineProperties(() => {}, {
- ...styles,
- level: {
- enumerable: true,
- get() {
- return this._generator.level;
- },
- set(level) {
- this._generator.level = level;
- }
- }
- });
-
- const createStyler = (open, close, parent) => {
- let openAll;
- let closeAll;
- if (parent === undefined) {
- openAll = open;
- closeAll = close;
- } else {
- openAll = parent.openAll + open;
- closeAll = close + parent.closeAll;
- }
-
- return {
- open,
- close,
- openAll,
- closeAll,
- parent
- };
- };
-
- const createBuilder = (self, _styler, _isEmpty) => {
- const builder = (...arguments_) => {
- if (isArray$2(arguments_[0]) && isArray$2(arguments_[0].raw)) {
- // Called as a template literal, for example: chalk.red`2 + 3 = {bold ${2+3}}`
- return applyStyle(builder, chalkTag(builder, ...arguments_));
- }
-
- // Single argument is hot path, implicit coercion is faster than anything
- // eslint-disable-next-line no-implicit-coercion
- return applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));
- };
-
- // We alter the prototype because we must return a function, but there is
- // no way to create a function with a different prototype
- Object.setPrototypeOf(builder, proto);
-
- builder._generator = self;
- builder._styler = _styler;
- builder._isEmpty = _isEmpty;
-
- return builder;
- };
-
- const applyStyle = (self, string) => {
- if (self.level <= 0 || !string) {
- return self._isEmpty ? '' : string;
- }
-
- let styler = self._styler;
-
- if (styler === undefined) {
- return string;
- }
-
- const {openAll, closeAll} = styler;
- if (string.indexOf('\u001B') !== -1) {
- while (styler !== undefined) {
- // Replace any instances already present with a re-opening code
- // otherwise only the part of the string until said closing code
- // will be colored, and the rest will simply be 'plain'.
- string = stringReplaceAll(string, styler.close, styler.open);
-
- styler = styler.parent;
- }
- }
-
- // We can move both next actions out of loop, because remaining actions in loop won't have
- // any/visible effect on parts we add here. Close the styling before a linebreak and reopen
- // after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92
- const lfIndex = string.indexOf('\n');
- if (lfIndex !== -1) {
- string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
- }
-
- return openAll + string + closeAll;
- };
-
- let template;
- const chalkTag = (chalk, ...strings) => {
- const [firstString] = strings;
-
- if (!isArray$2(firstString) || !isArray$2(firstString.raw)) {
- // If chalk() was called by itself or with a string,
- // return the string itself as a string.
- return strings.join(' ');
- }
-
- const arguments_ = strings.slice(1);
- const parts = [firstString.raw[0]];
-
- for (let i = 1; i < firstString.length; i++) {
- parts.push(
- String(arguments_[i - 1]).replace(/[{}\\]/g, '\\$&'),
- String(firstString.raw[i])
- );
- }
-
- if (template === undefined) {
- template = templates;
- }
-
- return template(chalk, parts.join(''));
- };
-
- Object.defineProperties(Chalk.prototype, styles);
-
- const chalk = Chalk(); // eslint-disable-line new-cap
- chalk.supportsColor = stdoutColor;
- chalk.stderr = Chalk({level: stderrColor ? stderrColor.level : 0}); // eslint-disable-line new-cap
- chalk.stderr.supportsColor = stderrColor;
-
- var source = chalk;
-
- // Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-
- var isWindows = process.platform === 'win32';
-
-
- // JavaScript implementation of realpath, ported from node pre-v6
-
- var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG);
-
- function rethrow() {
- // Only enable in debug mode. A backtrace uses ~1000 bytes of heap space and
- // is fairly slow to generate.
- var callback;
- if (DEBUG) {
- var backtrace = new Error;
- callback = debugCallback;
- } else
- callback = missingCallback;
-
- return callback;
-
- function debugCallback(err) {
- if (err) {
- backtrace.message = err.message;
- err = backtrace;
- missingCallback(err);
- }
- }
-
- function missingCallback(err) {
- if (err) {
- if (process.throwDeprecation)
- throw err; // Forgot a callback but don't know where? Use NODE_DEBUG=fs
- else if (!process.noDeprecation) {
- var msg = 'fs: missing callback ' + (err.stack || err.message);
- if (process.traceDeprecation)
- console.trace(msg);
- else
- console.error(msg);
- }
- }
- }
- }
-
- function maybeCallback(cb) {
- return typeof cb === 'function' ? cb : rethrow();
- }
-
- path__default['default'].normalize;
-
- // Regexp that finds the next partion of a (partial) path
- // result is [base_with_slash, base], e.g. ['somedir/', 'somedir']
- if (isWindows) {
- var nextPartRe = /(.*?)(?:[\/\\]+|$)/g;
- } else {
- var nextPartRe = /(.*?)(?:[\/]+|$)/g;
- }
-
- // Regex to find the device root, including trailing slash. E.g. 'c:\\'.
- if (isWindows) {
- var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;
- } else {
- var splitRootRe = /^[\/]*/;
- }
-
- var realpathSync$1 = function realpathSync(p, cache) {
- // make p is absolute
- p = path__default['default'].resolve(p);
-
- if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
- return cache[p];
- }
-
- var original = p,
- seenLinks = {},
- knownHard = {};
-
- // current character position in p
- var pos;
- // the partial path so far, including a trailing slash if any
- var current;
- // the partial path without a trailing slash (except when pointing at a root)
- var base;
- // the partial path scanned in the previous round, with slash
- var previous;
-
- start();
-
- function start() {
- // Skip over roots
- var m = splitRootRe.exec(p);
- pos = m[0].length;
- current = m[0];
- base = m[0];
- previous = '';
-
- // On windows, check that the root exists. On unix there is no need.
- if (isWindows && !knownHard[base]) {
- fs__default['default'].lstatSync(base);
- knownHard[base] = true;
- }
- }
-
- // walk down the path, swapping out linked pathparts for their real
- // values
- // NB: p.length changes.
- while (pos < p.length) {
- // find the next part
- nextPartRe.lastIndex = pos;
- var result = nextPartRe.exec(p);
- previous = current;
- current += result[0];
- base = previous + result[1];
- pos = nextPartRe.lastIndex;
-
- // continue if not a symlink
- if (knownHard[base] || (cache && cache[base] === base)) {
- continue;
- }
-
- var resolvedLink;
- if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
- // some known symbolic link. no need to stat again.
- resolvedLink = cache[base];
- } else {
- var stat = fs__default['default'].lstatSync(base);
- if (!stat.isSymbolicLink()) {
- knownHard[base] = true;
- if (cache) cache[base] = base;
- continue;
- }
-
- // read the link if it wasn't read before
- // dev/ino always return 0 on windows, so skip the check.
- var linkTarget = null;
- if (!isWindows) {
- var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
- if (seenLinks.hasOwnProperty(id)) {
- linkTarget = seenLinks[id];
- }
- }
- if (linkTarget === null) {
- fs__default['default'].statSync(base);
- linkTarget = fs__default['default'].readlinkSync(base);
- }
- resolvedLink = path__default['default'].resolve(previous, linkTarget);
- // track this, if given a cache.
- if (cache) cache[base] = resolvedLink;
- if (!isWindows) seenLinks[id] = linkTarget;
- }
-
- // resolve the link, then start over
- p = path__default['default'].resolve(resolvedLink, p.slice(pos));
- start();
- }
-
- if (cache) cache[original] = p;
-
- return p;
- };
-
-
- var realpath$1 = function realpath(p, cache, cb) {
- if (typeof cb !== 'function') {
- cb = maybeCallback(cache);
- cache = null;
- }
-
- // make p is absolute
- p = path__default['default'].resolve(p);
-
- if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
- return process.nextTick(cb.bind(null, null, cache[p]));
- }
-
- var original = p,
- seenLinks = {},
- knownHard = {};
-
- // current character position in p
- var pos;
- // the partial path so far, including a trailing slash if any
- var current;
- // the partial path without a trailing slash (except when pointing at a root)
- var base;
- // the partial path scanned in the previous round, with slash
- var previous;
-
- start();
-
- function start() {
- // Skip over roots
- var m = splitRootRe.exec(p);
- pos = m[0].length;
- current = m[0];
- base = m[0];
- previous = '';
-
- // On windows, check that the root exists. On unix there is no need.
- if (isWindows && !knownHard[base]) {
- fs__default['default'].lstat(base, function(err) {
- if (err) return cb(err);
- knownHard[base] = true;
- LOOP();
- });
- } else {
- process.nextTick(LOOP);
- }
- }
-
- // walk down the path, swapping out linked pathparts for their real
- // values
- function LOOP() {
- // stop if scanned past end of path
- if (pos >= p.length) {
- if (cache) cache[original] = p;
- return cb(null, p);
- }
-
- // find the next part
- nextPartRe.lastIndex = pos;
- var result = nextPartRe.exec(p);
- previous = current;
- current += result[0];
- base = previous + result[1];
- pos = nextPartRe.lastIndex;
-
- // continue if not a symlink
- if (knownHard[base] || (cache && cache[base] === base)) {
- return process.nextTick(LOOP);
- }
-
- if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
- // known symbolic link. no need to stat again.
- return gotResolvedLink(cache[base]);
- }
-
- return fs__default['default'].lstat(base, gotStat);
- }
-
- function gotStat(err, stat) {
- if (err) return cb(err);
-
- // if not a symlink, skip to the next path part
- if (!stat.isSymbolicLink()) {
- knownHard[base] = true;
- if (cache) cache[base] = base;
- return process.nextTick(LOOP);
- }
-
- // stat & read the link if not read before
- // call gotTarget as soon as the link target is known
- // dev/ino always return 0 on windows, so skip the check.
- if (!isWindows) {
- var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
- if (seenLinks.hasOwnProperty(id)) {
- return gotTarget(null, seenLinks[id], base);
- }
- }
- fs__default['default'].stat(base, function(err) {
- if (err) return cb(err);
-
- fs__default['default'].readlink(base, function(err, target) {
- if (!isWindows) seenLinks[id] = target;
- gotTarget(err, target);
- });
- });
- }
-
- function gotTarget(err, target, base) {
- if (err) return cb(err);
-
- var resolvedLink = path__default['default'].resolve(previous, target);
- if (cache) cache[base] = resolvedLink;
- gotResolvedLink(resolvedLink);
- }
-
- function gotResolvedLink(resolvedLink) {
- // resolve the link, then start over
- p = path__default['default'].resolve(resolvedLink, p.slice(pos));
- start();
- }
- };
-
- var old = {
- realpathSync: realpathSync$1,
- realpath: realpath$1
- };
-
- var fs_realpath = realpath;
- realpath.realpath = realpath;
- realpath.sync = realpathSync;
- realpath.realpathSync = realpathSync;
- realpath.monkeypatch = monkeypatch;
- realpath.unmonkeypatch = unmonkeypatch;
-
-
- var origRealpath = fs__default['default'].realpath;
- var origRealpathSync = fs__default['default'].realpathSync;
-
- var version = process.version;
- var ok = /^v[0-5]\./.test(version);
-
-
- function newError (er) {
- return er && er.syscall === 'realpath' && (
- er.code === 'ELOOP' ||
- er.code === 'ENOMEM' ||
- er.code === 'ENAMETOOLONG'
- )
- }
-
- function realpath (p, cache, cb) {
- if (ok) {
- return origRealpath(p, cache, cb)
- }
-
- if (typeof cache === 'function') {
- cb = cache;
- cache = null;
- }
- origRealpath(p, cache, function (er, result) {
- if (newError(er)) {
- old.realpath(p, cache, cb);
- } else {
- cb(er, result);
- }
- });
- }
-
- function realpathSync (p, cache) {
- if (ok) {
- return origRealpathSync(p, cache)
- }
-
- try {
- return origRealpathSync(p, cache)
- } catch (er) {
- if (newError(er)) {
- return old.realpathSync(p, cache)
- } else {
- throw er
- }
- }
- }
-
- function monkeypatch () {
- fs__default['default'].realpath = realpath;
- fs__default['default'].realpathSync = realpathSync;
- }
-
- function unmonkeypatch () {
- fs__default['default'].realpath = origRealpath;
- fs__default['default'].realpathSync = origRealpathSync;
- }
-
- var concatMap = function (xs, fn) {
- var res = [];
- for (var i = 0; i < xs.length; i++) {
- var x = fn(xs[i], i);
- if (isArray$1(x)) res.push.apply(res, x);
- else res.push(x);
- }
- return res;
- };
-
- var isArray$1 = Array.isArray || function (xs) {
- return Object.prototype.toString.call(xs) === '[object Array]';
- };
-
- var balancedMatch = balanced;
- function balanced(a, b, str) {
- if (a instanceof RegExp) a = maybeMatch(a, str);
- if (b instanceof RegExp) b = maybeMatch(b, str);
-
- var r = range(a, b, str);
-
- return r && {
- start: r[0],
- end: r[1],
- pre: str.slice(0, r[0]),
- body: str.slice(r[0] + a.length, r[1]),
- post: str.slice(r[1] + b.length)
- };
- }
-
- function maybeMatch(reg, str) {
- var m = str.match(reg);
- return m ? m[0] : null;
- }
-
- balanced.range = range;
- function range(a, b, str) {
- var begs, beg, left, right, result;
- var ai = str.indexOf(a);
- var bi = str.indexOf(b, ai + 1);
- var i = ai;
-
- if (ai >= 0 && bi > 0) {
- begs = [];
- left = str.length;
-
- while (i >= 0 && !result) {
- if (i == ai) {
- begs.push(i);
- ai = str.indexOf(a, i + 1);
- } else if (begs.length == 1) {
- result = [ begs.pop(), bi ];
- } else {
- beg = begs.pop();
- if (beg < left) {
- left = beg;
- right = bi;
- }
-
- bi = str.indexOf(b, i + 1);
- }
-
- i = ai < bi && ai >= 0 ? ai : bi;
- }
-
- if (begs.length) {
- result = [ left, right ];
- }
- }
-
- return result;
- }
-
- var braceExpansion = expandTop;
-
- var escSlash = '\0SLASH'+Math.random()+'\0';
- var escOpen = '\0OPEN'+Math.random()+'\0';
- var escClose = '\0CLOSE'+Math.random()+'\0';
- var escComma = '\0COMMA'+Math.random()+'\0';
- var escPeriod = '\0PERIOD'+Math.random()+'\0';
-
- function numeric(str) {
- return parseInt(str, 10) == str
- ? parseInt(str, 10)
- : str.charCodeAt(0);
- }
-
- function escapeBraces(str) {
- return str.split('\\\\').join(escSlash)
- .split('\\{').join(escOpen)
- .split('\\}').join(escClose)
- .split('\\,').join(escComma)
- .split('\\.').join(escPeriod);
- }
-
- function unescapeBraces(str) {
- return str.split(escSlash).join('\\')
- .split(escOpen).join('{')
- .split(escClose).join('}')
- .split(escComma).join(',')
- .split(escPeriod).join('.');
- }
-
-
- // Basically just str.split(","), but handling cases
- // where we have nested braced sections, which should be
- // treated as individual members, like {a,{b,c},d}
- function parseCommaParts(str) {
- if (!str)
- return [''];
-
- var parts = [];
- var m = balancedMatch('{', '}', str);
-
- if (!m)
- return str.split(',');
-
- var pre = m.pre;
- var body = m.body;
- var post = m.post;
- var p = pre.split(',');
-
- p[p.length-1] += '{' + body + '}';
- var postParts = parseCommaParts(post);
- if (post.length) {
- p[p.length-1] += postParts.shift();
- p.push.apply(p, postParts);
- }
-
- parts.push.apply(parts, p);
-
- return parts;
- }
-
- function expandTop(str) {
- if (!str)
- return [];
-
- // I don't know why Bash 4.3 does this, but it does.
- // Anything starting with {} will have the first two bytes preserved
- // but *only* at the top level, so {},a}b will not expand to anything,
- // but a{},b}c will be expanded to [a}c,abc].
- // One could argue that this is a bug in Bash, but since the goal of
- // this module is to match Bash's rules, we escape a leading {}
- if (str.substr(0, 2) === '{}') {
- str = '\\{\\}' + str.substr(2);
- }
-
- return expand(escapeBraces(str), true).map(unescapeBraces);
- }
-
- function embrace(str) {
- return '{' + str + '}';
- }
- function isPadded(el) {
- return /^-?0\d/.test(el);
- }
-
- function lte(i, y) {
- return i <= y;
- }
- function gte(i, y) {
- return i >= y;
- }
-
- function expand(str, isTop) {
- var expansions = [];
-
- var m = balancedMatch('{', '}', str);
- if (!m || /\$$/.test(m.pre)) return [str];
-
- var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
- var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
- var isSequence = isNumericSequence || isAlphaSequence;
- var isOptions = m.body.indexOf(',') >= 0;
- if (!isSequence && !isOptions) {
- // {a},b}
- if (m.post.match(/,.*\}/)) {
- str = m.pre + '{' + m.body + escClose + m.post;
- return expand(str);
- }
- return [str];
- }
-
- var n;
- if (isSequence) {
- n = m.body.split(/\.\./);
- } else {
- n = parseCommaParts(m.body);
- if (n.length === 1) {
- // x{{a,b}}y ==> x{a}y x{b}y
- n = expand(n[0], false).map(embrace);
- if (n.length === 1) {
- var post = m.post.length
- ? expand(m.post, false)
- : [''];
- return post.map(function(p) {
- return m.pre + n[0] + p;
- });
- }
- }
- }
-
- // at this point, n is the parts, and we know it's not a comma set
- // with a single entry.
-
- // no need to expand pre, since it is guaranteed to be free of brace-sets
- var pre = m.pre;
- var post = m.post.length
- ? expand(m.post, false)
- : [''];
-
- var N;
-
- if (isSequence) {
- var x = numeric(n[0]);
- var y = numeric(n[1]);
- var width = Math.max(n[0].length, n[1].length);
- var incr = n.length == 3
- ? Math.abs(numeric(n[2]))
- : 1;
- var test = lte;
- var reverse = y < x;
- if (reverse) {
- incr *= -1;
- test = gte;
- }
- var pad = n.some(isPadded);
-
- N = [];
-
- for (var i = x; test(i, y); i += incr) {
- var c;
- if (isAlphaSequence) {
- c = String.fromCharCode(i);
- if (c === '\\')
- c = '';
- } else {
- c = String(i);
- if (pad) {
- var need = width - c.length;
- if (need > 0) {
- var z = new Array(need + 1).join('0');
- if (i < 0)
- c = '-' + z + c.slice(1);
- else
- c = z + c;
- }
- }
- }
- N.push(c);
- }
- } else {
- N = concatMap(n, function(el) { return expand(el, false) });
- }
-
- for (var j = 0; j < N.length; j++) {
- for (var k = 0; k < post.length; k++) {
- var expansion = pre + N[j] + post[k];
- if (!isTop || isSequence || expansion)
- expansions.push(expansion);
- }
- }
-
- return expansions;
- }
-
- var minimatch_1 = minimatch;
- minimatch.Minimatch = Minimatch$1;
-
- var path = { sep: '/' };
- try {
- path = path__default['default'];
- } catch (er) {}
-
- var GLOBSTAR = minimatch.GLOBSTAR = Minimatch$1.GLOBSTAR = {};
-
-
- var plTypes = {
- '!': { open: '(?:(?!(?:', close: '))[^/]*?)'},
- '?': { open: '(?:', close: ')?' },
- '+': { open: '(?:', close: ')+' },
- '*': { open: '(?:', close: ')*' },
- '@': { open: '(?:', close: ')' }
- };
-
- // any single thing other than /
- // don't need to escape / when using new RegExp()
- var qmark = '[^/]';
-
- // * => any number of characters
- var star = qmark + '*?';
-
- // ** when dots are allowed. Anything goes, except .. and .
- // not (^ or / followed by one or two dots followed by $ or /),
- // followed by anything, any number of times.
- var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?';
-
- // not a ^ or / followed by a dot,
- // followed by anything, any number of times.
- var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?';
-
- // characters that need to be escaped in RegExp.
- var reSpecials = charSet('().*{}+?[]^$\\!');
-
- // "abc" -> { a:true, b:true, c:true }
- function charSet (s) {
- return s.split('').reduce(function (set, c) {
- set[c] = true;
- return set
- }, {})
- }
-
- // normalizes slashes.
- var slashSplit = /\/+/;
-
- minimatch.filter = filter;
- function filter (pattern, options) {
- options = options || {};
- return function (p, i, list) {
- return minimatch(p, pattern, options)
- }
- }
-
- function ext (a, b) {
- a = a || {};
- b = b || {};
- var t = {};
- Object.keys(b).forEach(function (k) {
- t[k] = b[k];
- });
- Object.keys(a).forEach(function (k) {
- t[k] = a[k];
- });
- return t
- }
-
- minimatch.defaults = function (def) {
- if (!def || !Object.keys(def).length) return minimatch
-
- var orig = minimatch;
-
- var m = function minimatch (p, pattern, options) {
- return orig.minimatch(p, pattern, ext(def, options))
- };
-
- m.Minimatch = function Minimatch (pattern, options) {
- return new orig.Minimatch(pattern, ext(def, options))
- };
-
- return m
- };
-
- Minimatch$1.defaults = function (def) {
- if (!def || !Object.keys(def).length) return Minimatch$1
- return minimatch.defaults(def).Minimatch
- };
-
- function minimatch (p, pattern, options) {
- if (typeof pattern !== 'string') {
- throw new TypeError('glob pattern string required')
- }
-
- if (!options) options = {};
-
- // shortcut: comments match nothing.
- if (!options.nocomment && pattern.charAt(0) === '#') {
- return false
- }
-
- // "" only matches ""
- if (pattern.trim() === '') return p === ''
-
- return new Minimatch$1(pattern, options).match(p)
- }
-
- function Minimatch$1 (pattern, options) {
- if (!(this instanceof Minimatch$1)) {
- return new Minimatch$1(pattern, options)
- }
-
- if (typeof pattern !== 'string') {
- throw new TypeError('glob pattern string required')
- }
-
- if (!options) options = {};
- pattern = pattern.trim();
-
- // windows support: need to use /, not \
- if (path.sep !== '/') {
- pattern = pattern.split(path.sep).join('/');
- }
-
- this.options = options;
- this.set = [];
- this.pattern = pattern;
- this.regexp = null;
- this.negate = false;
- this.comment = false;
- this.empty = false;
-
- // make the set of regexps etc.
- this.make();
- }
-
- Minimatch$1.prototype.debug = function () {};
-
- Minimatch$1.prototype.make = make;
- function make () {
- // don't do it more than once.
- if (this._made) return
-
- var pattern = this.pattern;
- var options = this.options;
-
- // empty patterns and comments match nothing.
- if (!options.nocomment && pattern.charAt(0) === '#') {
- this.comment = true;
- return
- }
- if (!pattern) {
- this.empty = true;
- return
- }
-
- // step 1: figure out negation, etc.
- this.parseNegate();
-
- // step 2: expand braces
- var set = this.globSet = this.braceExpand();
-
- if (options.debug) this.debug = console.error;
-
- this.debug(this.pattern, set);
-
- // step 3: now we have a set, so turn each one into a series of path-portion
- // matching patterns.
- // These will be regexps, except in the case of "**", which is
- // set to the GLOBSTAR object for globstar behavior,
- // and will not contain any / characters
- set = this.globParts = set.map(function (s) {
- return s.split(slashSplit)
- });
-
- this.debug(this.pattern, set);
-
- // glob --> regexps
- set = set.map(function (s, si, set) {
- return s.map(this.parse, this)
- }, this);
-
- this.debug(this.pattern, set);
-
- // filter out everything that didn't compile properly.
- set = set.filter(function (s) {
- return s.indexOf(false) === -1
- });
-
- this.debug(this.pattern, set);
-
- this.set = set;
- }
-
- Minimatch$1.prototype.parseNegate = parseNegate;
- function parseNegate () {
- var pattern = this.pattern;
- var negate = false;
- var options = this.options;
- var negateOffset = 0;
-
- if (options.nonegate) return
-
- for (var i = 0, l = pattern.length
- ; i < l && pattern.charAt(i) === '!'
- ; i++) {
- negate = !negate;
- negateOffset++;
- }
-
- if (negateOffset) this.pattern = pattern.substr(negateOffset);
- this.negate = negate;
- }
-
- // Brace expansion:
- // a{b,c}d -> abd acd
- // a{b,}c -> abc ac
- // a{0..3}d -> a0d a1d a2d a3d
- // a{b,c{d,e}f}g -> abg acdfg acefg
- // a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg
- //
- // Invalid sets are not expanded.
- // a{2..}b -> a{2..}b
- // a{b}c -> a{b}c
- minimatch.braceExpand = function (pattern, options) {
- return braceExpand(pattern, options)
- };
-
- Minimatch$1.prototype.braceExpand = braceExpand;
-
- function braceExpand (pattern, options) {
- if (!options) {
- if (this instanceof Minimatch$1) {
- options = this.options;
- } else {
- options = {};
- }
- }
-
- pattern = typeof pattern === 'undefined'
- ? this.pattern : pattern;
-
- if (typeof pattern === 'undefined') {
- throw new TypeError('undefined pattern')
- }
-
- if (options.nobrace ||
- !pattern.match(/\{.*\}/)) {
- // shortcut. no need to expand.
- return [pattern]
- }
-
- return braceExpansion(pattern)
- }
-
- // parse a component of the expanded set.
- // At this point, no pattern may contain "/" in it
- // so we're going to return a 2d array, where each entry is the full
- // pattern, split on '/', and then turned into a regular expression.
- // A regexp is made at the end which joins each array with an
- // escaped /, and another full one which joins each regexp with |.
- //
- // Following the lead of Bash 4.1, note that "**" only has special meaning
- // when it is the *only* thing in a path portion. Otherwise, any series
- // of * is equivalent to a single *. Globstar behavior is enabled by
- // default, and can be disabled by setting options.noglobstar.
- Minimatch$1.prototype.parse = parse;
- var SUBPARSE = {};
- function parse (pattern, isSub) {
- if (pattern.length > 1024 * 64) {
- throw new TypeError('pattern is too long')
- }
-
- var options = this.options;
-
- // shortcuts
- if (!options.noglobstar && pattern === '**') return GLOBSTAR
- if (pattern === '') return ''
-
- var re = '';
- var hasMagic = !!options.nocase;
- var escaping = false;
- // ? => one single character
- var patternListStack = [];
- var negativeLists = [];
- var stateChar;
- var inClass = false;
- var reClassStart = -1;
- var classStart = -1;
- // . and .. never match anything that doesn't start with .,
- // even when options.dot is set.
- var patternStart = pattern.charAt(0) === '.' ? '' // anything
- // not (start or / followed by . or .. followed by / or end)
- : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))'
- : '(?!\\.)';
- var self = this;
-
- function clearStateChar () {
- if (stateChar) {
- // we had some state-tracking character
- // that wasn't consumed by this pass.
- switch (stateChar) {
- case '*':
- re += star;
- hasMagic = true;
- break
- case '?':
- re += qmark;
- hasMagic = true;
- break
- default:
- re += '\\' + stateChar;
- break
- }
- self.debug('clearStateChar %j %j', stateChar, re);
- stateChar = false;
- }
- }
-
- for (var i = 0, len = pattern.length, c
- ; (i < len) && (c = pattern.charAt(i))
- ; i++) {
- this.debug('%s\t%s %s %j', pattern, i, re, c);
-
- // skip over any that are escaped.
- if (escaping && reSpecials[c]) {
- re += '\\' + c;
- escaping = false;
- continue
- }
-
- switch (c) {
- case '/':
- // completely not allowed, even escaped.
- // Should already be path-split by now.
- return false
-
- case '\\':
- clearStateChar();
- escaping = true;
- continue
-
- // the various stateChar values
- // for the "extglob" stuff.
- case '?':
- case '*':
- case '+':
- case '@':
- case '!':
- this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c);
-
- // all of those are literals inside a class, except that
- // the glob [!a] means [^a] in regexp
- if (inClass) {
- this.debug(' in class');
- if (c === '!' && i === classStart + 1) c = '^';
- re += c;
- continue
- }
-
- // if we already have a stateChar, then it means
- // that there was something like ** or +? in there.
- // Handle the stateChar, then proceed with this one.
- self.debug('call clearStateChar %j', stateChar);
- clearStateChar();
- stateChar = c;
- // if extglob is disabled, then +(asdf|foo) isn't a thing.
- // just clear the statechar *now*, rather than even diving into
- // the patternList stuff.
- if (options.noext) clearStateChar();
- continue
-
- case '(':
- if (inClass) {
- re += '(';
- continue
- }
-
- if (!stateChar) {
- re += '\\(';
- continue
- }
-
- patternListStack.push({
- type: stateChar,
- start: i - 1,
- reStart: re.length,
- open: plTypes[stateChar].open,
- close: plTypes[stateChar].close
- });
- // negation is (?:(?!js)[^/]*)
- re += stateChar === '!' ? '(?:(?!(?:' : '(?:';
- this.debug('plType %j %j', stateChar, re);
- stateChar = false;
- continue
-
- case ')':
- if (inClass || !patternListStack.length) {
- re += '\\)';
- continue
- }
-
- clearStateChar();
- hasMagic = true;
- var pl = patternListStack.pop();
- // negation is (?:(?!js)[^/]*)
- // The others are (?:<pattern>)<type>
- re += pl.close;
- if (pl.type === '!') {
- negativeLists.push(pl);
- }
- pl.reEnd = re.length;
- continue
-
- case '|':
- if (inClass || !patternListStack.length || escaping) {
- re += '\\|';
- escaping = false;
- continue
- }
-
- clearStateChar();
- re += '|';
- continue
-
- // these are mostly the same in regexp and glob
- case '[':
- // swallow any state-tracking char before the [
- clearStateChar();
-
- if (inClass) {
- re += '\\' + c;
- continue
- }
-
- inClass = true;
- classStart = i;
- reClassStart = re.length;
- re += c;
- continue
-
- case ']':
- // a right bracket shall lose its special
- // meaning and represent itself in
- // a bracket expression if it occurs
- // first in the list. -- POSIX.2 2.8.3.2
- if (i === classStart + 1 || !inClass) {
- re += '\\' + c;
- escaping = false;
- continue
- }
-
- // handle the case where we left a class open.
- // "[z-a]" is valid, equivalent to "\[z-a\]"
- if (inClass) {
- // split where the last [ was, make sure we don't have
- // an invalid re. if so, re-walk the contents of the
- // would-be class to re-translate any characters that
- // were passed through as-is
- // TODO: It would probably be faster to determine this
- // without a try/catch and a new RegExp, but it's tricky
- // to do safely. For now, this is safe and works.
- var cs = pattern.substring(classStart + 1, i);
- try {
- RegExp('[' + cs + ']');
- } catch (er) {
- // not a valid class!
- var sp = this.parse(cs, SUBPARSE);
- re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]';
- hasMagic = hasMagic || sp[1];
- inClass = false;
- continue
- }
- }
-
- // finish up the class.
- hasMagic = true;
- inClass = false;
- re += c;
- continue
-
- default:
- // swallow any state char that wasn't consumed
- clearStateChar();
-
- if (escaping) {
- // no need
- escaping = false;
- } else if (reSpecials[c]
- && !(c === '^' && inClass)) {
- re += '\\';
- }
-
- re += c;
-
- } // switch
- } // for
-
- // handle the case where we left a class open.
- // "[abc" is valid, equivalent to "\[abc"
- if (inClass) {
- // split where the last [ was, and escape it
- // this is a huge pita. We now have to re-walk
- // the contents of the would-be class to re-translate
- // any characters that were passed through as-is
- cs = pattern.substr(classStart + 1);
- sp = this.parse(cs, SUBPARSE);
- re = re.substr(0, reClassStart) + '\\[' + sp[0];
- hasMagic = hasMagic || sp[1];
- }
-
- // handle the case where we had a +( thing at the *end*
- // of the pattern.
- // each pattern list stack adds 3 chars, and we need to go through
- // and escape any | chars that were passed through as-is for the regexp.
- // Go through and escape them, taking care not to double-escape any
- // | chars that were already escaped.
- for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) {
- var tail = re.slice(pl.reStart + pl.open.length);
- this.debug('setting tail', re, pl);
- // maybe some even number of \, then maybe 1 \, followed by a |
- tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, function (_, $1, $2) {
- if (!$2) {
- // the | isn't already escaped, so escape it.
- $2 = '\\';
- }
-
- // need to escape all those slashes *again*, without escaping the
- // one that we need for escaping the | character. As it works out,
- // escaping an even number of slashes can be done by simply repeating
- // it exactly after itself. That's why this trick works.
- //
- // I am sorry that you have to see this.
- return $1 + $1 + $2 + '|'
- });
-
- this.debug('tail=%j\n %s', tail, tail, pl, re);
- var t = pl.type === '*' ? star
- : pl.type === '?' ? qmark
- : '\\' + pl.type;
-
- hasMagic = true;
- re = re.slice(0, pl.reStart) + t + '\\(' + tail;
- }
-
- // handle trailing things that only matter at the very end.
- clearStateChar();
- if (escaping) {
- // trailing \\
- re += '\\\\';
- }
-
- // only need to apply the nodot start if the re starts with
- // something that could conceivably capture a dot
- var addPatternStart = false;
- switch (re.charAt(0)) {
- case '.':
- case '[':
- case '(': addPatternStart = true;
- }
-
- // Hack to work around lack of negative lookbehind in JS
- // A pattern like: *.!(x).!(y|z) needs to ensure that a name
- // like 'a.xyz.yz' doesn't match. So, the first negative
- // lookahead, has to look ALL the way ahead, to the end of
- // the pattern.
- for (var n = negativeLists.length - 1; n > -1; n--) {
- var nl = negativeLists[n];
-
- var nlBefore = re.slice(0, nl.reStart);
- var nlFirst = re.slice(nl.reStart, nl.reEnd - 8);
- var nlLast = re.slice(nl.reEnd - 8, nl.reEnd);
- var nlAfter = re.slice(nl.reEnd);
-
- nlLast += nlAfter;
-
- // Handle nested stuff like *(*.js|!(*.json)), where open parens
- // mean that we should *not* include the ) in the bit that is considered
- // "after" the negated section.
- var openParensBefore = nlBefore.split('(').length - 1;
- var cleanAfter = nlAfter;
- for (i = 0; i < openParensBefore; i++) {
- cleanAfter = cleanAfter.replace(/\)[+*?]?/, '');
- }
- nlAfter = cleanAfter;
-
- var dollar = '';
- if (nlAfter === '' && isSub !== SUBPARSE) {
- dollar = '$';
- }
- var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast;
- re = newRe;
- }
-
- // if the re is not "" at this point, then we need to make sure
- // it doesn't match against an empty path part.
- // Otherwise a/* will match a/, which it should not.
- if (re !== '' && hasMagic) {
- re = '(?=.)' + re;
- }
-
- if (addPatternStart) {
- re = patternStart + re;
- }
-
- // parsing just a piece of a larger pattern.
- if (isSub === SUBPARSE) {
- return [re, hasMagic]
- }
-
- // skip the regexp for non-magical patterns
- // unescape anything in it, though, so that it'll be
- // an exact match against a file etc.
- if (!hasMagic) {
- return globUnescape(pattern)
- }
-
- var flags = options.nocase ? 'i' : '';
- try {
- var regExp = new RegExp('^' + re + '$', flags);
- } catch (er) {
- // If it was an invalid regular expression, then it can't match
- // anything. This trick looks for a character after the end of
- // the string, which is of course impossible, except in multi-line
- // mode, but it's not a /m regex.
- return new RegExp('$.')
- }
-
- regExp._glob = pattern;
- regExp._src = re;
-
- return regExp
- }
-
- minimatch.makeRe = function (pattern, options) {
- return new Minimatch$1(pattern, options || {}).makeRe()
- };
-
- Minimatch$1.prototype.makeRe = makeRe;
- function makeRe () {
- if (this.regexp || this.regexp === false) return this.regexp
-
- // at this point, this.set is a 2d array of partial
- // pattern strings, or "**".
- //
- // It's better to use .match(). This function shouldn't
- // be used, really, but it's pretty convenient sometimes,
- // when you just want to work with a regex.
- var set = this.set;
-
- if (!set.length) {
- this.regexp = false;
- return this.regexp
- }
- var options = this.options;
-
- var twoStar = options.noglobstar ? star
- : options.dot ? twoStarDot
- : twoStarNoDot;
- var flags = options.nocase ? 'i' : '';
-
- var re = set.map(function (pattern) {
- return pattern.map(function (p) {
- return (p === GLOBSTAR) ? twoStar
- : (typeof p === 'string') ? regExpEscape(p)
- : p._src
- }).join('\\\/')
- }).join('|');
-
- // must match entire pattern
- // ending in a * or ** will make it less strict.
- re = '^(?:' + re + ')$';
-
- // can match anything, as long as it's not this.
- if (this.negate) re = '^(?!' + re + ').*$';
-
- try {
- this.regexp = new RegExp(re, flags);
- } catch (ex) {
- this.regexp = false;
- }
- return this.regexp
- }
-
- minimatch.match = function (list, pattern, options) {
- options = options || {};
- var mm = new Minimatch$1(pattern, options);
- list = list.filter(function (f) {
- return mm.match(f)
- });
- if (mm.options.nonull && !list.length) {
- list.push(pattern);
- }
- return list
- };
-
- Minimatch$1.prototype.match = match;
- function match (f, partial) {
- this.debug('match', f, this.pattern);
- // short-circuit in the case of busted things.
- // comments, etc.
- if (this.comment) return false
- if (this.empty) return f === ''
-
- if (f === '/' && partial) return true
-
- var options = this.options;
-
- // windows: need to use /, not \
- if (path.sep !== '/') {
- f = f.split(path.sep).join('/');
- }
-
- // treat the test path as a set of pathparts.
- f = f.split(slashSplit);
- this.debug(this.pattern, 'split', f);
-
- // just ONE of the pattern sets in this.set needs to match
- // in order for it to be valid. If negating, then just one
- // match means that we have failed.
- // Either way, return on the first hit.
-
- var set = this.set;
- this.debug(this.pattern, 'set', set);
-
- // Find the basename of the path by looking for the last non-empty segment
- var filename;
- var i;
- for (i = f.length - 1; i >= 0; i--) {
- filename = f[i];
- if (filename) break
- }
-
- for (i = 0; i < set.length; i++) {
- var pattern = set[i];
- var file = f;
- if (options.matchBase && pattern.length === 1) {
- file = [filename];
- }
- var hit = this.matchOne(file, pattern, partial);
- if (hit) {
- if (options.flipNegate) return true
- return !this.negate
- }
- }
-
- // didn't get any hits. this is success if it's a negative
- // pattern, failure otherwise.
- if (options.flipNegate) return false
- return this.negate
- }
-
- // set partial to true to test if, for example,
- // "/a/b" matches the start of "/*/b/*/d"
- // Partial means, if you run out of file before you run
- // out of pattern, then that's fine, as long as all
- // the parts match.
- Minimatch$1.prototype.matchOne = function (file, pattern, partial) {
- var options = this.options;
-
- this.debug('matchOne',
- { 'this': this, file: file, pattern: pattern });
-
- this.debug('matchOne', file.length, pattern.length);
-
- for (var fi = 0,
- pi = 0,
- fl = file.length,
- pl = pattern.length
- ; (fi < fl) && (pi < pl)
- ; fi++, pi++) {
- this.debug('matchOne loop');
- var p = pattern[pi];
- var f = file[fi];
-
- this.debug(pattern, p, f);
-
- // should be impossible.
- // some invalid regexp stuff in the set.
- if (p === false) return false
-
- if (p === GLOBSTAR) {
- this.debug('GLOBSTAR', [pattern, p, f]);
-
- // "**"
- // a/**/b/**/c would match the following:
- // a/b/x/y/z/c
- // a/x/y/z/b/c
- // a/b/x/b/x/c
- // a/b/c
- // To do this, take the rest of the pattern after
- // the **, and see if it would match the file remainder.
- // If so, return success.
- // If not, the ** "swallows" a segment, and try again.
- // This is recursively awful.
- //
- // a/**/b/**/c matching a/b/x/y/z/c
- // - a matches a
- // - doublestar
- // - matchOne(b/x/y/z/c, b/**/c)
- // - b matches b
- // - doublestar
- // - matchOne(x/y/z/c, c) -> no
- // - matchOne(y/z/c, c) -> no
- // - matchOne(z/c, c) -> no
- // - matchOne(c, c) yes, hit
- var fr = fi;
- var pr = pi + 1;
- if (pr === pl) {
- this.debug('** at the end');
- // a ** at the end will just swallow the rest.
- // We have found a match.
- // however, it will not swallow /.x, unless
- // options.dot is set.
- // . and .. are *never* matched by **, for explosively
- // exponential reasons.
- for (; fi < fl; fi++) {
- if (file[fi] === '.' || file[fi] === '..' ||
- (!options.dot && file[fi].charAt(0) === '.')) return false
- }
- return true
- }
-
- // ok, let's see if we can swallow whatever we can.
- while (fr < fl) {
- var swallowee = file[fr];
-
- this.debug('\nglobstar while', file, fr, pattern, pr, swallowee);
-
- // XXX remove this slice. Just pass the start index.
- if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
- this.debug('globstar found match!', fr, fl, swallowee);
- // found a match.
- return true
- } else {
- // can't swallow "." or ".." ever.
- // can only swallow ".foo" when explicitly asked.
- if (swallowee === '.' || swallowee === '..' ||
- (!options.dot && swallowee.charAt(0) === '.')) {
- this.debug('dot detected!', file, fr, pattern, pr);
- break
- }
-
- // ** swallows a segment, and continue.
- this.debug('globstar swallow a segment, and continue');
- fr++;
- }
- }
-
- // no match was found.
- // However, in partial mode, we can't say this is necessarily over.
- // If there's more *pattern* left, then
- if (partial) {
- // ran out of file
- this.debug('\n>>> no match, partial?', file, fr, pattern, pr);
- if (fr === fl) return true
- }
- return false
- }
-
- // something other than **
- // non-magic patterns just have to match exactly
- // patterns with magic have been turned into regexps.
- var hit;
- if (typeof p === 'string') {
- if (options.nocase) {
- hit = f.toLowerCase() === p.toLowerCase();
- } else {
- hit = f === p;
- }
- this.debug('string match', p, f, hit);
- } else {
- hit = f.match(p);
- this.debug('pattern match', p, f, hit);
- }
-
- if (!hit) return false
- }
-
- // Note: ending in / means that we'll get a final ""
- // at the end of the pattern. This can only match a
- // corresponding "" at the end of the file.
- // If the file ends in /, then it can only match a
- // a pattern that ends in /, unless the pattern just
- // doesn't have any more for it. But, a/b/ should *not*
- // match "a/b/*", even though "" matches against the
- // [^/]*? pattern, except in partial mode, where it might
- // simply not be reached yet.
- // However, a/b/ should still satisfy a/*
-
- // now either we fell off the end of the pattern, or we're done.
- if (fi === fl && pi === pl) {
- // ran out of pattern and filename at the same time.
- // an exact hit!
- return true
- } else if (fi === fl) {
- // ran out of file, but still had pattern left.
- // this is ok if we're doing the match as part of
- // a glob fs traversal.
- return partial
- } else if (pi === pl) {
- // ran out of pattern, still have file left.
- // this is only acceptable if we're on the very last
- // empty segment of a file with a trailing slash.
- // a/* should match a/b/
- var emptyFileEnd = (fi === fl - 1) && (file[fi] === '');
- return emptyFileEnd
- }
-
- // should be unreachable.
- throw new Error('wtf?')
- };
-
- // replace stuff like \* with *
- function globUnescape (s) {
- return s.replace(/\\(.)/g, '$1')
- }
-
- function regExpEscape (s) {
- return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')
- }
-
- var inherits_browser = createCommonjsModule(function (module) {
- if (typeof Object.create === 'function') {
- // implementation from standard node.js 'util' module
- module.exports = function inherits(ctor, superCtor) {
- if (superCtor) {
- ctor.super_ = superCtor;
- ctor.prototype = Object.create(superCtor.prototype, {
- constructor: {
- value: ctor,
- enumerable: false,
- writable: true,
- configurable: true
- }
- });
- }
- };
- } else {
- // old school shim for old browsers
- module.exports = function inherits(ctor, superCtor) {
- if (superCtor) {
- ctor.super_ = superCtor;
- var TempCtor = function () {};
- TempCtor.prototype = superCtor.prototype;
- ctor.prototype = new TempCtor();
- ctor.prototype.constructor = ctor;
- }
- };
- }
- }, "/$$rollup_base$$/node_modules/inherits");
-
- var inherits = createCommonjsModule(function (module) {
- try {
- var util = require$$0__default['default'];
- /* istanbul ignore next */
- if (typeof util.inherits !== 'function') throw '';
- module.exports = util.inherits;
- } catch (e) {
- /* istanbul ignore next */
- module.exports = inherits_browser;
- }
- }, "/$$rollup_base$$/node_modules/inherits");
-
- function posix(path) {
- return path.charAt(0) === '/';
- }
-
- function win32(path) {
- // https://github.com/nodejs/node/blob/b3fcc245fb25539909ef1d5eaa01dbf92e168633/lib/path.js#L56
- var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/;
- var result = splitDeviceRe.exec(path);
- var device = result[1] || '';
- var isUnc = Boolean(device && device.charAt(1) !== ':');
-
- // UNC paths are always absolute
- return Boolean(result[2] || isUnc);
- }
-
- var pathIsAbsolute = process.platform === 'win32' ? win32 : posix;
- var posix_1 = posix;
- var win32_1 = win32;
- pathIsAbsolute.posix = posix_1;
- pathIsAbsolute.win32 = win32_1;
-
- var alphasort_1 = alphasort;
- var alphasorti_1 = alphasorti;
- var setopts_1 = setopts$2;
- var ownProp_1 = ownProp$2;
- var makeAbs_1 = makeAbs;
- var finish_1 = finish;
- var mark_1 = mark;
- var isIgnored_1 = isIgnored$2;
- var childrenIgnored_1 = childrenIgnored$2;
-
- function ownProp$2 (obj, field) {
- return Object.prototype.hasOwnProperty.call(obj, field)
- }
-
-
-
-
- var Minimatch = minimatch_1.Minimatch;
-
- function alphasorti (a, b) {
- return a.toLowerCase().localeCompare(b.toLowerCase())
- }
-
- function alphasort (a, b) {
- return a.localeCompare(b)
- }
-
- function setupIgnores (self, options) {
- self.ignore = options.ignore || [];
-
- if (!Array.isArray(self.ignore))
- self.ignore = [self.ignore];
-
- if (self.ignore.length) {
- self.ignore = self.ignore.map(ignoreMap);
- }
- }
-
- // ignore patterns are always in dot:true mode.
- function ignoreMap (pattern) {
- var gmatcher = null;
- if (pattern.slice(-3) === '/**') {
- var gpattern = pattern.replace(/(\/\*\*)+$/, '');
- gmatcher = new Minimatch(gpattern, { dot: true });
- }
-
- return {
- matcher: new Minimatch(pattern, { dot: true }),
- gmatcher: gmatcher
- }
- }
-
- function setopts$2 (self, pattern, options) {
- if (!options)
- options = {};
-
- // base-matching: just use globstar for that.
- if (options.matchBase && -1 === pattern.indexOf("/")) {
- if (options.noglobstar) {
- throw new Error("base matching requires globstar")
- }
- pattern = "**/" + pattern;
- }
-
- self.silent = !!options.silent;
- self.pattern = pattern;
- self.strict = options.strict !== false;
- self.realpath = !!options.realpath;
- self.realpathCache = options.realpathCache || Object.create(null);
- self.follow = !!options.follow;
- self.dot = !!options.dot;
- self.mark = !!options.mark;
- self.nodir = !!options.nodir;
- if (self.nodir)
- self.mark = true;
- self.sync = !!options.sync;
- self.nounique = !!options.nounique;
- self.nonull = !!options.nonull;
- self.nosort = !!options.nosort;
- self.nocase = !!options.nocase;
- self.stat = !!options.stat;
- self.noprocess = !!options.noprocess;
- self.absolute = !!options.absolute;
-
- self.maxLength = options.maxLength || Infinity;
- self.cache = options.cache || Object.create(null);
- self.statCache = options.statCache || Object.create(null);
- self.symlinks = options.symlinks || Object.create(null);
-
- setupIgnores(self, options);
-
- self.changedCwd = false;
- var cwd = process.cwd();
- if (!ownProp$2(options, "cwd"))
- self.cwd = cwd;
- else {
- self.cwd = path__default['default'].resolve(options.cwd);
- self.changedCwd = self.cwd !== cwd;
- }
-
- self.root = options.root || path__default['default'].resolve(self.cwd, "/");
- self.root = path__default['default'].resolve(self.root);
- if (process.platform === "win32")
- self.root = self.root.replace(/\\/g, "/");
-
- // TODO: is an absolute `cwd` supposed to be resolved against `root`?
- // e.g. { cwd: '/test', root: __dirname } === path.join(__dirname, '/test')
- self.cwdAbs = pathIsAbsolute(self.cwd) ? self.cwd : makeAbs(self, self.cwd);
- if (process.platform === "win32")
- self.cwdAbs = self.cwdAbs.replace(/\\/g, "/");
- self.nomount = !!options.nomount;
-
- // disable comments and negation in Minimatch.
- // Note that they are not supported in Glob itself anyway.
- options.nonegate = true;
- options.nocomment = true;
-
- self.minimatch = new Minimatch(pattern, options);
- self.options = self.minimatch.options;
- }
-
- function finish (self) {
- var nou = self.nounique;
- var all = nou ? [] : Object.create(null);
-
- for (var i = 0, l = self.matches.length; i < l; i ++) {
- var matches = self.matches[i];
- if (!matches || Object.keys(matches).length === 0) {
- if (self.nonull) {
- // do like the shell, and spit out the literal glob
- var literal = self.minimatch.globSet[i];
- if (nou)
- all.push(literal);
- else
- all[literal] = true;
- }
- } else {
- // had matches
- var m = Object.keys(matches);
- if (nou)
- all.push.apply(all, m);
- else
- m.forEach(function (m) {
- all[m] = true;
- });
- }
- }
-
- if (!nou)
- all = Object.keys(all);
-
- if (!self.nosort)
- all = all.sort(self.nocase ? alphasorti : alphasort);
-
- // at *some* point we statted all of these
- if (self.mark) {
- for (var i = 0; i < all.length; i++) {
- all[i] = self._mark(all[i]);
- }
- if (self.nodir) {
- all = all.filter(function (e) {
- var notDir = !(/\/$/.test(e));
- var c = self.cache[e] || self.cache[makeAbs(self, e)];
- if (notDir && c)
- notDir = c !== 'DIR' && !Array.isArray(c);
- return notDir
- });
- }
- }
-
- if (self.ignore.length)
- all = all.filter(function(m) {
- return !isIgnored$2(self, m)
- });
-
- self.found = all;
- }
-
- function mark (self, p) {
- var abs = makeAbs(self, p);
- var c = self.cache[abs];
- var m = p;
- if (c) {
- var isDir = c === 'DIR' || Array.isArray(c);
- var slash = p.slice(-1) === '/';
-
- if (isDir && !slash)
- m += '/';
- else if (!isDir && slash)
- m = m.slice(0, -1);
-
- if (m !== p) {
- var mabs = makeAbs(self, m);
- self.statCache[mabs] = self.statCache[abs];
- self.cache[mabs] = self.cache[abs];
- }
- }
-
- return m
- }
-
- // lotta situps...
- function makeAbs (self, f) {
- var abs = f;
- if (f.charAt(0) === '/') {
- abs = path__default['default'].join(self.root, f);
- } else if (pathIsAbsolute(f) || f === '') {
- abs = f;
- } else if (self.changedCwd) {
- abs = path__default['default'].resolve(self.cwd, f);
- } else {
- abs = path__default['default'].resolve(f);
- }
-
- if (process.platform === 'win32')
- abs = abs.replace(/\\/g, '/');
-
- return abs
- }
-
-
- // Return true, if pattern ends with globstar '**', for the accompanying parent directory.
- // Ex:- If node_modules/** is the pattern, add 'node_modules' to ignore list along with it's contents
- function isIgnored$2 (self, path) {
- if (!self.ignore.length)
- return false
-
- return self.ignore.some(function(item) {
- return item.matcher.match(path) || !!(item.gmatcher && item.gmatcher.match(path))
- })
- }
-
- function childrenIgnored$2 (self, path) {
- if (!self.ignore.length)
- return false
-
- return self.ignore.some(function(item) {
- return !!(item.gmatcher && item.gmatcher.match(path))
- })
- }
-
- var common = {
- alphasort: alphasort_1,
- alphasorti: alphasorti_1,
- setopts: setopts_1,
- ownProp: ownProp_1,
- makeAbs: makeAbs_1,
- finish: finish_1,
- mark: mark_1,
- isIgnored: isIgnored_1,
- childrenIgnored: childrenIgnored_1
- };
-
- var sync = globSync;
- globSync.GlobSync = GlobSync$1;
- var setopts$1 = common.setopts;
- var ownProp$1 = common.ownProp;
- var childrenIgnored$1 = common.childrenIgnored;
- var isIgnored$1 = common.isIgnored;
-
- function globSync (pattern, options) {
- if (typeof options === 'function' || arguments.length === 3)
- throw new TypeError('callback provided to sync glob\n'+
- 'See: https://github.com/isaacs/node-glob/issues/167')
-
- return new GlobSync$1(pattern, options).found
- }
-
- function GlobSync$1 (pattern, options) {
- if (!pattern)
- throw new Error('must provide pattern')
-
- if (typeof options === 'function' || arguments.length === 3)
- throw new TypeError('callback provided to sync glob\n'+
- 'See: https://github.com/isaacs/node-glob/issues/167')
-
- if (!(this instanceof GlobSync$1))
- return new GlobSync$1(pattern, options)
-
- setopts$1(this, pattern, options);
-
- if (this.noprocess)
- return this
-
- var n = this.minimatch.set.length;
- this.matches = new Array(n);
- for (var i = 0; i < n; i ++) {
- this._process(this.minimatch.set[i], i, false);
- }
- this._finish();
- }
-
- GlobSync$1.prototype._finish = function () {
- assert__default['default'](this instanceof GlobSync$1);
- if (this.realpath) {
- var self = this;
- this.matches.forEach(function (matchset, index) {
- var set = self.matches[index] = Object.create(null);
- for (var p in matchset) {
- try {
- p = self._makeAbs(p);
- var real = fs_realpath.realpathSync(p, self.realpathCache);
- set[real] = true;
- } catch (er) {
- if (er.syscall === 'stat')
- set[self._makeAbs(p)] = true;
- else
- throw er
- }
- }
- });
- }
- common.finish(this);
- };
-
-
- GlobSync$1.prototype._process = function (pattern, index, inGlobStar) {
- assert__default['default'](this instanceof GlobSync$1);
-
- // Get the first [n] parts of pattern that are all strings.
- var n = 0;
- while (typeof pattern[n] === 'string') {
- n ++;
- }
- // now n is the index of the first one that is *not* a string.
-
- // See if there's anything else
- var prefix;
- switch (n) {
- // if not, then this is rather simple
- case pattern.length:
- this._processSimple(pattern.join('/'), index);
- return
-
- case 0:
- // pattern *starts* with some non-trivial item.
- // going to readdir(cwd), but not include the prefix in matches.
- prefix = null;
- break
-
- default:
- // pattern has some string bits in the front.
- // whatever it starts with, whether that's 'absolute' like /foo/bar,
- // or 'relative' like '../baz'
- prefix = pattern.slice(0, n).join('/');
- break
- }
-
- var remain = pattern.slice(n);
-
- // get the list of entries.
- var read;
- if (prefix === null)
- read = '.';
- else if (pathIsAbsolute(prefix) || pathIsAbsolute(pattern.join('/'))) {
- if (!prefix || !pathIsAbsolute(prefix))
- prefix = '/' + prefix;
- read = prefix;
- } else
- read = prefix;
-
- var abs = this._makeAbs(read);
-
- //if ignored, skip processing
- if (childrenIgnored$1(this, read))
- return
-
- var isGlobStar = remain[0] === minimatch_1.GLOBSTAR;
- if (isGlobStar)
- this._processGlobStar(prefix, read, abs, remain, index, inGlobStar);
- else
- this._processReaddir(prefix, read, abs, remain, index, inGlobStar);
- };
-
-
- GlobSync$1.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar) {
- var entries = this._readdir(abs, inGlobStar);
-
- // if the abs isn't a dir, then nothing can match!
- if (!entries)
- return
-
- // It will only match dot entries if it starts with a dot, or if
- // dot is set. Stuff like @(.foo|.bar) isn't allowed.
- var pn = remain[0];
- var negate = !!this.minimatch.negate;
- var rawGlob = pn._glob;
- var dotOk = this.dot || rawGlob.charAt(0) === '.';
-
- var matchedEntries = [];
- for (var i = 0; i < entries.length; i++) {
- var e = entries[i];
- if (e.charAt(0) !== '.' || dotOk) {
- var m;
- if (negate && !prefix) {
- m = !e.match(pn);
- } else {
- m = e.match(pn);
- }
- if (m)
- matchedEntries.push(e);
- }
- }
-
- var len = matchedEntries.length;
- // If there are no matched entries, then nothing matches.
- if (len === 0)
- return
-
- // if this is the last remaining pattern bit, then no need for
- // an additional stat *unless* the user has specified mark or
- // stat explicitly. We know they exist, since readdir returned
- // them.
-
- if (remain.length === 1 && !this.mark && !this.stat) {
- if (!this.matches[index])
- this.matches[index] = Object.create(null);
-
- for (var i = 0; i < len; i ++) {
- var e = matchedEntries[i];
- if (prefix) {
- if (prefix.slice(-1) !== '/')
- e = prefix + '/' + e;
- else
- e = prefix + e;
- }
-
- if (e.charAt(0) === '/' && !this.nomount) {
- e = path__default['default'].join(this.root, e);
- }
- this._emitMatch(index, e);
- }
- // This was the last one, and no stats were needed
- return
- }
-
- // now test all matched entries as stand-ins for that part
- // of the pattern.
- remain.shift();
- for (var i = 0; i < len; i ++) {
- var e = matchedEntries[i];
- var newPattern;
- if (prefix)
- newPattern = [prefix, e];
- else
- newPattern = [e];
- this._process(newPattern.concat(remain), index, inGlobStar);
- }
- };
-
-
- GlobSync$1.prototype._emitMatch = function (index, e) {
- if (isIgnored$1(this, e))
- return
-
- var abs = this._makeAbs(e);
-
- if (this.mark)
- e = this._mark(e);
-
- if (this.absolute) {
- e = abs;
- }
-
- if (this.matches[index][e])
- return
-
- if (this.nodir) {
- var c = this.cache[abs];
- if (c === 'DIR' || Array.isArray(c))
- return
- }
-
- this.matches[index][e] = true;
-
- if (this.stat)
- this._stat(e);
- };
-
-
- GlobSync$1.prototype._readdirInGlobStar = function (abs) {
- // follow all symlinked directories forever
- // just proceed as if this is a non-globstar situation
- if (this.follow)
- return this._readdir(abs, false)
-
- var entries;
- var lstat;
- try {
- lstat = fs__default['default'].lstatSync(abs);
- } catch (er) {
- if (er.code === 'ENOENT') {
- // lstat failed, doesn't exist
- return null
- }
- }
-
- var isSym = lstat && lstat.isSymbolicLink();
- this.symlinks[abs] = isSym;
-
- // If it's not a symlink or a dir, then it's definitely a regular file.
- // don't bother doing a readdir in that case.
- if (!isSym && lstat && !lstat.isDirectory())
- this.cache[abs] = 'FILE';
- else
- entries = this._readdir(abs, false);
-
- return entries
- };
-
- GlobSync$1.prototype._readdir = function (abs, inGlobStar) {
-
- if (inGlobStar && !ownProp$1(this.symlinks, abs))
- return this._readdirInGlobStar(abs)
-
- if (ownProp$1(this.cache, abs)) {
- var c = this.cache[abs];
- if (!c || c === 'FILE')
- return null
-
- if (Array.isArray(c))
- return c
- }
-
- try {
- return this._readdirEntries(abs, fs__default['default'].readdirSync(abs))
- } catch (er) {
- this._readdirError(abs, er);
- return null
- }
- };
-
- GlobSync$1.prototype._readdirEntries = function (abs, entries) {
- // if we haven't asked to stat everything, then just
- // assume that everything in there exists, so we can avoid
- // having to stat it a second time.
- if (!this.mark && !this.stat) {
- for (var i = 0; i < entries.length; i ++) {
- var e = entries[i];
- if (abs === '/')
- e = abs + e;
- else
- e = abs + '/' + e;
- this.cache[e] = true;
- }
- }
-
- this.cache[abs] = entries;
-
- // mark and cache dir-ness
- return entries
- };
-
- GlobSync$1.prototype._readdirError = function (f, er) {
- // handle errors, and cache the information
- switch (er.code) {
- case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205
- case 'ENOTDIR': // totally normal. means it *does* exist.
- var abs = this._makeAbs(f);
- this.cache[abs] = 'FILE';
- if (abs === this.cwdAbs) {
- var error = new Error(er.code + ' invalid cwd ' + this.cwd);
- error.path = this.cwd;
- error.code = er.code;
- throw error
- }
- break
-
- case 'ENOENT': // not terribly unusual
- case 'ELOOP':
- case 'ENAMETOOLONG':
- case 'UNKNOWN':
- this.cache[this._makeAbs(f)] = false;
- break
-
- default: // some unusual error. Treat as failure.
- this.cache[this._makeAbs(f)] = false;
- if (this.strict)
- throw er
- if (!this.silent)
- console.error('glob error', er);
- break
- }
- };
-
- GlobSync$1.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar) {
-
- var entries = this._readdir(abs, inGlobStar);
-
- // no entries means not a dir, so it can never have matches
- // foo.txt/** doesn't match foo.txt
- if (!entries)
- return
-
- // test without the globstar, and with every child both below
- // and replacing the globstar.
- var remainWithoutGlobStar = remain.slice(1);
- var gspref = prefix ? [ prefix ] : [];
- var noGlobStar = gspref.concat(remainWithoutGlobStar);
-
- // the noGlobStar pattern exits the inGlobStar state
- this._process(noGlobStar, index, false);
-
- var len = entries.length;
- var isSym = this.symlinks[abs];
-
- // If it's a symlink, and we're in a globstar, then stop
- if (isSym && inGlobStar)
- return
-
- for (var i = 0; i < len; i++) {
- var e = entries[i];
- if (e.charAt(0) === '.' && !this.dot)
- continue
-
- // these two cases enter the inGlobStar state
- var instead = gspref.concat(entries[i], remainWithoutGlobStar);
- this._process(instead, index, true);
-
- var below = gspref.concat(entries[i], remain);
- this._process(below, index, true);
- }
- };
-
- GlobSync$1.prototype._processSimple = function (prefix, index) {
- // XXX review this. Shouldn't it be doing the mounting etc
- // before doing stat? kinda weird?
- var exists = this._stat(prefix);
-
- if (!this.matches[index])
- this.matches[index] = Object.create(null);
-
- // If it doesn't exist, then just mark the lack of results
- if (!exists)
- return
-
- if (prefix && pathIsAbsolute(prefix) && !this.nomount) {
- var trail = /[\/\\]$/.test(prefix);
- if (prefix.charAt(0) === '/') {
- prefix = path__default['default'].join(this.root, prefix);
- } else {
- prefix = path__default['default'].resolve(this.root, prefix);
- if (trail)
- prefix += '/';
- }
- }
-
- if (process.platform === 'win32')
- prefix = prefix.replace(/\\/g, '/');
-
- // Mark this as a match
- this._emitMatch(index, prefix);
- };
-
- // Returns either 'DIR', 'FILE', or false
- GlobSync$1.prototype._stat = function (f) {
- var abs = this._makeAbs(f);
- var needDir = f.slice(-1) === '/';
-
- if (f.length > this.maxLength)
- return false
-
- if (!this.stat && ownProp$1(this.cache, abs)) {
- var c = this.cache[abs];
-
- if (Array.isArray(c))
- c = 'DIR';
-
- // It exists, but maybe not how we need it
- if (!needDir || c === 'DIR')
- return c
-
- if (needDir && c === 'FILE')
- return false
-
- // otherwise we have to stat, because maybe c=true
- // if we know it exists, but not what it is.
- }
- var stat = this.statCache[abs];
- if (!stat) {
- var lstat;
- try {
- lstat = fs__default['default'].lstatSync(abs);
- } catch (er) {
- if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) {
- this.statCache[abs] = false;
- return false
- }
- }
-
- if (lstat && lstat.isSymbolicLink()) {
- try {
- stat = fs__default['default'].statSync(abs);
- } catch (er) {
- stat = lstat;
- }
- } else {
- stat = lstat;
- }
- }
-
- this.statCache[abs] = stat;
-
- var c = true;
- if (stat)
- c = stat.isDirectory() ? 'DIR' : 'FILE';
-
- this.cache[abs] = this.cache[abs] || c;
-
- if (needDir && c === 'FILE')
- return false
-
- return c
- };
-
- GlobSync$1.prototype._mark = function (p) {
- return common.mark(this, p)
- };
-
- GlobSync$1.prototype._makeAbs = function (f) {
- return common.makeAbs(this, f)
- };
-
- // Returns a wrapper function that returns a wrapped callback
- // The wrapper function should do some stuff, and return a
- // presumably different callback function.
- // This makes sure that own properties are retained, so that
- // decorations and such are not lost along the way.
- var wrappy_1 = wrappy;
- function wrappy (fn, cb) {
- if (fn && cb) return wrappy(fn)(cb)
-
- if (typeof fn !== 'function')
- throw new TypeError('need wrapper function')
-
- Object.keys(fn).forEach(function (k) {
- wrapper[k] = fn[k];
- });
-
- return wrapper
-
- function wrapper() {
- var args = new Array(arguments.length);
- for (var i = 0; i < args.length; i++) {
- args[i] = arguments[i];
- }
- var ret = fn.apply(this, args);
- var cb = args[args.length-1];
- if (typeof ret === 'function' && ret !== cb) {
- Object.keys(cb).forEach(function (k) {
- ret[k] = cb[k];
- });
- }
- return ret
- }
- }
-
- var once_1 = wrappy_1(once);
- var strict = wrappy_1(onceStrict);
-
- once.proto = once(function () {
- Object.defineProperty(Function.prototype, 'once', {
- value: function () {
- return once(this)
- },
- configurable: true
- });
-
- Object.defineProperty(Function.prototype, 'onceStrict', {
- value: function () {
- return onceStrict(this)
- },
- configurable: true
- });
- });
-
- function once (fn) {
- var f = function () {
- if (f.called) return f.value
- f.called = true;
- return f.value = fn.apply(this, arguments)
- };
- f.called = false;
- return f
- }
-
- function onceStrict (fn) {
- var f = function () {
- if (f.called)
- throw new Error(f.onceError)
- f.called = true;
- return f.value = fn.apply(this, arguments)
- };
- var name = fn.name || 'Function wrapped with `once`';
- f.onceError = name + " shouldn't be called more than once";
- f.called = false;
- return f
- }
- once_1.strict = strict;
-
- var reqs = Object.create(null);
-
-
- var inflight_1 = wrappy_1(inflight);
-
- function inflight (key, cb) {
- if (reqs[key]) {
- reqs[key].push(cb);
- return null
- } else {
- reqs[key] = [cb];
- return makeres(key)
- }
- }
-
- function makeres (key) {
- return once_1(function RES () {
- var cbs = reqs[key];
- var len = cbs.length;
- var args = slice(arguments);
-
- // XXX It's somewhat ambiguous whether a new callback added in this
- // pass should be queued for later execution if something in the
- // list of callbacks throws, or if it should just be discarded.
- // However, it's such an edge case that it hardly matters, and either
- // choice is likely as surprising as the other.
- // As it happens, we do go ahead and schedule it for later execution.
- try {
- for (var i = 0; i < len; i++) {
- cbs[i].apply(null, args);
- }
- } finally {
- if (cbs.length > len) {
- // added more in the interim.
- // de-zalgo, just in case, but don't call again.
- cbs.splice(0, len);
- process.nextTick(function () {
- RES.apply(null, args);
- });
- } else {
- delete reqs[key];
- }
- }
- })
- }
-
- function slice (args) {
- var length = args.length;
- var array = [];
-
- for (var i = 0; i < length; i++) array[i] = args[i];
- return array
- }
-
- var EE = require$$0__default$1['default'].EventEmitter;
- var setopts = common.setopts;
- var ownProp = common.ownProp;
-
-
- var childrenIgnored = common.childrenIgnored;
- var isIgnored = common.isIgnored;
- var GlobSync = sync.GlobSync;
- inherits(Glob, EE);
- function Glob (pattern, options, cb) {
- if (typeof options === 'function') {
- cb = options;
- options = null;
- }
-
- if (options && options.sync) {
- if (cb)
- throw new TypeError('callback provided to sync glob')
- return new GlobSync(pattern, options)
- }
-
- if (!(this instanceof Glob))
- return new Glob(pattern, options, cb)
-
- setopts(this, pattern, options);
- this._didRealPath = false;
-
- // process each pattern in the minimatch set
- var n = this.minimatch.set.length;
-
- // The matches are stored as {<filename>: true,...} so that
- // duplicates are automagically pruned.
- // Later, we do an Object.keys() on these.
- // Keep them as a list so we can fill in when nonull is set.
- this.matches = new Array(n);
-
- if (typeof cb === 'function') {
- cb = once_1(cb);
- this.on('error', cb);
- this.on('end', function (matches) {
- cb(null, matches);
- });
- }
-
- var self = this;
- this._processing = 0;
-
- this._emitQueue = [];
- this._processQueue = [];
- this.paused = false;
-
- if (this.noprocess)
- return this
-
- if (n === 0)
- return done()
-
- var sync = true;
- for (var i = 0; i < n; i ++) {
- this._process(this.minimatch.set[i], i, false, done);
- }
- sync = false;
-
- function done () {
- --self._processing;
- if (self._processing <= 0) {
- if (sync) {
- process.nextTick(function () {
- self._finish();
- });
- } else {
- self._finish();
- }
- }
- }
- }
-
- Glob.prototype._finish = function () {
- assert__default['default'](this instanceof Glob);
- if (this.aborted)
- return
-
- if (this.realpath && !this._didRealpath)
- return this._realpath()
-
- common.finish(this);
- this.emit('end', this.found);
- };
-
- Glob.prototype._realpath = function () {
- if (this._didRealpath)
- return
-
- this._didRealpath = true;
-
- var n = this.matches.length;
- if (n === 0)
- return this._finish()
-
- var self = this;
- for (var i = 0; i < this.matches.length; i++)
- this._realpathSet(i, next);
-
- function next () {
- if (--n === 0)
- self._finish();
- }
- };
-
- Glob.prototype._realpathSet = function (index, cb) {
- var matchset = this.matches[index];
- if (!matchset)
- return cb()
-
- var found = Object.keys(matchset);
- var self = this;
- var n = found.length;
-
- if (n === 0)
- return cb()
-
- var set = this.matches[index] = Object.create(null);
- found.forEach(function (p, i) {
- // If there's a problem with the stat, then it means that
- // one or more of the links in the realpath couldn't be
- // resolved. just return the abs value in that case.
- p = self._makeAbs(p);
- fs_realpath.realpath(p, self.realpathCache, function (er, real) {
- if (!er)
- set[real] = true;
- else if (er.syscall === 'stat')
- set[p] = true;
- else
- self.emit('error', er); // srsly wtf right here
-
- if (--n === 0) {
- self.matches[index] = set;
- cb();
- }
- });
- });
- };
-
- Glob.prototype._mark = function (p) {
- return common.mark(this, p)
- };
-
- Glob.prototype._makeAbs = function (f) {
- return common.makeAbs(this, f)
- };
-
- Glob.prototype.abort = function () {
- this.aborted = true;
- this.emit('abort');
- };
-
- Glob.prototype.pause = function () {
- if (!this.paused) {
- this.paused = true;
- this.emit('pause');
- }
- };
-
- Glob.prototype.resume = function () {
- if (this.paused) {
- this.emit('resume');
- this.paused = false;
- if (this._emitQueue.length) {
- var eq = this._emitQueue.slice(0);
- this._emitQueue.length = 0;
- for (var i = 0; i < eq.length; i ++) {
- var e = eq[i];
- this._emitMatch(e[0], e[1]);
- }
- }
- if (this._processQueue.length) {
- var pq = this._processQueue.slice(0);
- this._processQueue.length = 0;
- for (var i = 0; i < pq.length; i ++) {
- var p = pq[i];
- this._processing--;
- this._process(p[0], p[1], p[2], p[3]);
- }
- }
- }
- };
-
- Glob.prototype._process = function (pattern, index, inGlobStar, cb) {
- assert__default['default'](this instanceof Glob);
- assert__default['default'](typeof cb === 'function');
-
- if (this.aborted)
- return
-
- this._processing++;
- if (this.paused) {
- this._processQueue.push([pattern, index, inGlobStar, cb]);
- return
- }
-
- //console.error('PROCESS %d', this._processing, pattern)
-
- // Get the first [n] parts of pattern that are all strings.
- var n = 0;
- while (typeof pattern[n] === 'string') {
- n ++;
- }
- // now n is the index of the first one that is *not* a string.
-
- // see if there's anything else
- var prefix;
- switch (n) {
- // if not, then this is rather simple
- case pattern.length:
- this._processSimple(pattern.join('/'), index, cb);
- return
-
- case 0:
- // pattern *starts* with some non-trivial item.
- // going to readdir(cwd), but not include the prefix in matches.
- prefix = null;
- break
-
- default:
- // pattern has some string bits in the front.
- // whatever it starts with, whether that's 'absolute' like /foo/bar,
- // or 'relative' like '../baz'
- prefix = pattern.slice(0, n).join('/');
- break
- }
-
- var remain = pattern.slice(n);
-
- // get the list of entries.
- var read;
- if (prefix === null)
- read = '.';
- else if (pathIsAbsolute(prefix) || pathIsAbsolute(pattern.join('/'))) {
- if (!prefix || !pathIsAbsolute(prefix))
- prefix = '/' + prefix;
- read = prefix;
- } else
- read = prefix;
-
- var abs = this._makeAbs(read);
-
- //if ignored, skip _processing
- if (childrenIgnored(this, read))
- return cb()
-
- var isGlobStar = remain[0] === minimatch_1.GLOBSTAR;
- if (isGlobStar)
- this._processGlobStar(prefix, read, abs, remain, index, inGlobStar, cb);
- else
- this._processReaddir(prefix, read, abs, remain, index, inGlobStar, cb);
- };
-
- Glob.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar, cb) {
- var self = this;
- this._readdir(abs, inGlobStar, function (er, entries) {
- return self._processReaddir2(prefix, read, abs, remain, index, inGlobStar, entries, cb)
- });
- };
-
- Glob.prototype._processReaddir2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) {
-
- // if the abs isn't a dir, then nothing can match!
- if (!entries)
- return cb()
-
- // It will only match dot entries if it starts with a dot, or if
- // dot is set. Stuff like @(.foo|.bar) isn't allowed.
- var pn = remain[0];
- var negate = !!this.minimatch.negate;
- var rawGlob = pn._glob;
- var dotOk = this.dot || rawGlob.charAt(0) === '.';
-
- var matchedEntries = [];
- for (var i = 0; i < entries.length; i++) {
- var e = entries[i];
- if (e.charAt(0) !== '.' || dotOk) {
- var m;
- if (negate && !prefix) {
- m = !e.match(pn);
- } else {
- m = e.match(pn);
- }
- if (m)
- matchedEntries.push(e);
- }
- }
-
- //console.error('prd2', prefix, entries, remain[0]._glob, matchedEntries)
-
- var len = matchedEntries.length;
- // If there are no matched entries, then nothing matches.
- if (len === 0)
- return cb()
-
- // if this is the last remaining pattern bit, then no need for
- // an additional stat *unless* the user has specified mark or
- // stat explicitly. We know they exist, since readdir returned
- // them.
-
- if (remain.length === 1 && !this.mark && !this.stat) {
- if (!this.matches[index])
- this.matches[index] = Object.create(null);
-
- for (var i = 0; i < len; i ++) {
- var e = matchedEntries[i];
- if (prefix) {
- if (prefix !== '/')
- e = prefix + '/' + e;
- else
- e = prefix + e;
- }
-
- if (e.charAt(0) === '/' && !this.nomount) {
- e = path__default['default'].join(this.root, e);
- }
- this._emitMatch(index, e);
- }
- // This was the last one, and no stats were needed
- return cb()
- }
-
- // now test all matched entries as stand-ins for that part
- // of the pattern.
- remain.shift();
- for (var i = 0; i < len; i ++) {
- var e = matchedEntries[i];
- if (prefix) {
- if (prefix !== '/')
- e = prefix + '/' + e;
- else
- e = prefix + e;
- }
- this._process([e].concat(remain), index, inGlobStar, cb);
- }
- cb();
- };
-
- Glob.prototype._emitMatch = function (index, e) {
- if (this.aborted)
- return
-
- if (isIgnored(this, e))
- return
-
- if (this.paused) {
- this._emitQueue.push([index, e]);
- return
- }
-
- var abs = pathIsAbsolute(e) ? e : this._makeAbs(e);
-
- if (this.mark)
- e = this._mark(e);
-
- if (this.absolute)
- e = abs;
-
- if (this.matches[index][e])
- return
-
- if (this.nodir) {
- var c = this.cache[abs];
- if (c === 'DIR' || Array.isArray(c))
- return
- }
-
- this.matches[index][e] = true;
-
- var st = this.statCache[abs];
- if (st)
- this.emit('stat', e, st);
-
- this.emit('match', e);
- };
-
- Glob.prototype._readdirInGlobStar = function (abs, cb) {
- if (this.aborted)
- return
-
- // follow all symlinked directories forever
- // just proceed as if this is a non-globstar situation
- if (this.follow)
- return this._readdir(abs, false, cb)
-
- var lstatkey = 'lstat\0' + abs;
- var self = this;
- var lstatcb = inflight_1(lstatkey, lstatcb_);
-
- if (lstatcb)
- fs__default['default'].lstat(abs, lstatcb);
-
- function lstatcb_ (er, lstat) {
- if (er && er.code === 'ENOENT')
- return cb()
-
- var isSym = lstat && lstat.isSymbolicLink();
- self.symlinks[abs] = isSym;
-
- // If it's not a symlink or a dir, then it's definitely a regular file.
- // don't bother doing a readdir in that case.
- if (!isSym && lstat && !lstat.isDirectory()) {
- self.cache[abs] = 'FILE';
- cb();
- } else
- self._readdir(abs, false, cb);
- }
- };
-
- Glob.prototype._readdir = function (abs, inGlobStar, cb) {
- if (this.aborted)
- return
-
- cb = inflight_1('readdir\0'+abs+'\0'+inGlobStar, cb);
- if (!cb)
- return
-
- //console.error('RD %j %j', +inGlobStar, abs)
- if (inGlobStar && !ownProp(this.symlinks, abs))
- return this._readdirInGlobStar(abs, cb)
-
- if (ownProp(this.cache, abs)) {
- var c = this.cache[abs];
- if (!c || c === 'FILE')
- return cb()
-
- if (Array.isArray(c))
- return cb(null, c)
- }
- fs__default['default'].readdir(abs, readdirCb(this, abs, cb));
- };
-
- function readdirCb (self, abs, cb) {
- return function (er, entries) {
- if (er)
- self._readdirError(abs, er, cb);
- else
- self._readdirEntries(abs, entries, cb);
- }
- }
-
- Glob.prototype._readdirEntries = function (abs, entries, cb) {
- if (this.aborted)
- return
-
- // if we haven't asked to stat everything, then just
- // assume that everything in there exists, so we can avoid
- // having to stat it a second time.
- if (!this.mark && !this.stat) {
- for (var i = 0; i < entries.length; i ++) {
- var e = entries[i];
- if (abs === '/')
- e = abs + e;
- else
- e = abs + '/' + e;
- this.cache[e] = true;
- }
- }
-
- this.cache[abs] = entries;
- return cb(null, entries)
- };
-
- Glob.prototype._readdirError = function (f, er, cb) {
- if (this.aborted)
- return
-
- // handle errors, and cache the information
- switch (er.code) {
- case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205
- case 'ENOTDIR': // totally normal. means it *does* exist.
- var abs = this._makeAbs(f);
- this.cache[abs] = 'FILE';
- if (abs === this.cwdAbs) {
- var error = new Error(er.code + ' invalid cwd ' + this.cwd);
- error.path = this.cwd;
- error.code = er.code;
- this.emit('error', error);
- this.abort();
- }
- break
-
- case 'ENOENT': // not terribly unusual
- case 'ELOOP':
- case 'ENAMETOOLONG':
- case 'UNKNOWN':
- this.cache[this._makeAbs(f)] = false;
- break
-
- default: // some unusual error. Treat as failure.
- this.cache[this._makeAbs(f)] = false;
- if (this.strict) {
- this.emit('error', er);
- // If the error is handled, then we abort
- // if not, we threw out of here
- this.abort();
- }
- if (!this.silent)
- console.error('glob error', er);
- break
- }
-
- return cb()
- };
-
- Glob.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar, cb) {
- var self = this;
- this._readdir(abs, inGlobStar, function (er, entries) {
- self._processGlobStar2(prefix, read, abs, remain, index, inGlobStar, entries, cb);
- });
- };
-
-
- Glob.prototype._processGlobStar2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) {
- //console.error('pgs2', prefix, remain[0], entries)
-
- // no entries means not a dir, so it can never have matches
- // foo.txt/** doesn't match foo.txt
- if (!entries)
- return cb()
-
- // test without the globstar, and with every child both below
- // and replacing the globstar.
- var remainWithoutGlobStar = remain.slice(1);
- var gspref = prefix ? [ prefix ] : [];
- var noGlobStar = gspref.concat(remainWithoutGlobStar);
-
- // the noGlobStar pattern exits the inGlobStar state
- this._process(noGlobStar, index, false, cb);
-
- var isSym = this.symlinks[abs];
- var len = entries.length;
-
- // If it's a symlink, and we're in a globstar, then stop
- if (isSym && inGlobStar)
- return cb()
-
- for (var i = 0; i < len; i++) {
- var e = entries[i];
- if (e.charAt(0) === '.' && !this.dot)
- continue
-
- // these two cases enter the inGlobStar state
- var instead = gspref.concat(entries[i], remainWithoutGlobStar);
- this._process(instead, index, true, cb);
-
- var below = gspref.concat(entries[i], remain);
- this._process(below, index, true, cb);
- }
-
- cb();
- };
-
- Glob.prototype._processSimple = function (prefix, index, cb) {
- // XXX review this. Shouldn't it be doing the mounting etc
- // before doing stat? kinda weird?
- var self = this;
- this._stat(prefix, function (er, exists) {
- self._processSimple2(prefix, index, er, exists, cb);
- });
- };
- Glob.prototype._processSimple2 = function (prefix, index, er, exists, cb) {
-
- //console.error('ps2', prefix, exists)
-
- if (!this.matches[index])
- this.matches[index] = Object.create(null);
-
- // If it doesn't exist, then just mark the lack of results
- if (!exists)
- return cb()
-
- if (prefix && pathIsAbsolute(prefix) && !this.nomount) {
- var trail = /[\/\\]$/.test(prefix);
- if (prefix.charAt(0) === '/') {
- prefix = path__default['default'].join(this.root, prefix);
- } else {
- prefix = path__default['default'].resolve(this.root, prefix);
- if (trail)
- prefix += '/';
- }
- }
-
- if (process.platform === 'win32')
- prefix = prefix.replace(/\\/g, '/');
-
- // Mark this as a match
- this._emitMatch(index, prefix);
- cb();
- };
-
- // Returns either 'DIR', 'FILE', or false
- Glob.prototype._stat = function (f, cb) {
- var abs = this._makeAbs(f);
- var needDir = f.slice(-1) === '/';
-
- if (f.length > this.maxLength)
- return cb()
-
- if (!this.stat && ownProp(this.cache, abs)) {
- var c = this.cache[abs];
-
- if (Array.isArray(c))
- c = 'DIR';
-
- // It exists, but maybe not how we need it
- if (!needDir || c === 'DIR')
- return cb(null, c)
-
- if (needDir && c === 'FILE')
- return cb()
-
- // otherwise we have to stat, because maybe c=true
- // if we know it exists, but not what it is.
- }
- var stat = this.statCache[abs];
- if (stat !== undefined) {
- if (stat === false)
- return cb(null, stat)
- else {
- var type = stat.isDirectory() ? 'DIR' : 'FILE';
- if (needDir && type === 'FILE')
- return cb()
- else
- return cb(null, type, stat)
- }
- }
-
- var self = this;
- var statcb = inflight_1('stat\0' + abs, lstatcb_);
- if (statcb)
- fs__default['default'].lstat(abs, statcb);
-
- function lstatcb_ (er, lstat) {
- if (lstat && lstat.isSymbolicLink()) {
- // If it's a symlink, then treat it as the target, unless
- // the target does not exist, then treat it as a file.
- return fs__default['default'].stat(abs, function (er, stat) {
- if (er)
- self._stat2(f, abs, null, lstat, cb);
- else
- self._stat2(f, abs, er, stat, cb);
- })
- } else {
- self._stat2(f, abs, er, lstat, cb);
- }
- }
- };
-
- Glob.prototype._stat2 = function (f, abs, er, stat, cb) {
- if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) {
- this.statCache[abs] = false;
- return cb()
- }
-
- var needDir = f.slice(-1) === '/';
- this.statCache[abs] = stat;
-
- if (abs.slice(-1) === '/' && stat && !stat.isDirectory())
- return cb(null, false, stat)
-
- var c = true;
- if (stat)
- c = stat.isDirectory() ? 'DIR' : 'FILE';
- this.cache[abs] = this.cache[abs] || c;
-
- if (needDir && c === 'FILE')
- return cb()
-
- return cb(null, c, stat)
- };
-
- var spawn = childProcess__default['default'].spawn;
- var exec = childProcess__default['default'].exec;
-
- var treeKill = function (pid, signal, callback) {
- if (typeof signal === 'function' && callback === undefined) {
- callback = signal;
- signal = undefined;
- }
-
- pid = parseInt(pid);
- if (Number.isNaN(pid)) {
- if (callback) {
- return callback(new Error("pid must be a number"));
- } else {
- throw new Error("pid must be a number");
- }
- }
-
- var tree = {};
- var pidsToProcess = {};
- tree[pid] = [];
- pidsToProcess[pid] = 1;
-
- switch (process.platform) {
- case 'win32':
- exec('taskkill /pid ' + pid + ' /T /F', callback);
- break;
- case 'darwin':
- buildProcessTree(pid, tree, pidsToProcess, function (parentPid) {
- return spawn('pgrep', ['-P', parentPid]);
- }, function () {
- killAll(tree, signal, callback);
- });
- break;
- // case 'sunos':
- // buildProcessTreeSunOS(pid, tree, pidsToProcess, function () {
- // killAll(tree, signal, callback);
- // });
- // break;
- default: // Linux
- buildProcessTree(pid, tree, pidsToProcess, function (parentPid) {
- return spawn('ps', ['-o', 'pid', '--no-headers', '--ppid', parentPid]);
- }, function () {
- killAll(tree, signal, callback);
- });
- break;
- }
- };
-
- function killAll (tree, signal, callback) {
- var killed = {};
- try {
- Object.keys(tree).forEach(function (pid) {
- tree[pid].forEach(function (pidpid) {
- if (!killed[pidpid]) {
- killPid(pidpid, signal);
- killed[pidpid] = 1;
- }
- });
- if (!killed[pid]) {
- killPid(pid, signal);
- killed[pid] = 1;
- }
- });
- } catch (err) {
- if (callback) {
- return callback(err);
- } else {
- throw err;
- }
- }
- if (callback) {
- return callback();
- }
- }
-
- function killPid(pid, signal) {
- try {
- process.kill(parseInt(pid, 10), signal);
- }
- catch (err) {
- if (err.code !== 'ESRCH') throw err;
- }
- }
-
- function buildProcessTree (parentPid, tree, pidsToProcess, spawnChildProcessesList, cb) {
- var ps = spawnChildProcessesList(parentPid);
- var allData = '';
- ps.stdout.on('data', function (data) {
- var data = data.toString('ascii');
- allData += data;
- });
-
- var onClose = function (code) {
- delete pidsToProcess[parentPid];
-
- if (code != 0) {
- // no more parent processes
- if (Object.keys(pidsToProcess).length == 0) {
- cb();
- }
- return;
- }
-
- allData.match(/\d+/g).forEach(function (pid) {
- pid = parseInt(pid, 10);
- tree[parentPid].push(pid);
- tree[pid] = [];
- pidsToProcess[pid] = 1;
- buildProcessTree(pid, tree, pidsToProcess, spawnChildProcessesList, cb);
- });
- };
-
- ps.on('close', onClose);
- }
-
- var any = bbhverse.any;
- var Tasq = bbhverse.Tasq;
- var statuslog = bbhverse.Traq;
- var Traq = bbhverse.Traq;
- Tasq.addlistener(statuslog.statuslog);
-
- var nodeShellExec = cliverse.nodeShellExec;
-
-
-
- const BUILD_VERSION = 'Version: 1.0.0 - built on March 24, 2021 22:27:48';
- function getVersion() { return BUILD_VERSION; }
- console.log(getVersion());
-
- // 'use strict';
-
- // PB : TODO -- make sure folder context is proper coz we can now run elxr from anywhere.
-
- // PB : TODO --
- // runas bypass non elevated tasks when we request privelege
- // runas message is always error needs to be fixed.
- // runas wait needs to be parallelized.
- // suppress elevation check error messages
- // support runas lauched directly from shell.
- // pass in environment in hta to shellexecute.
-
- const { existsSync } = fs__default['default'];
- const fs = fs__default['default'];
-
- const cliargs = bbhverse.cliargs;
- const processedArgs = cliargs(process.argv.slice(2));
- console.dir(processedArgs);
-
- var ENV = Object.assign({}, process.env); // Shallow clone it.
-
- var getShellTask = (command, args, options) => {
- return () => {
- var p = nodeShellExec.apply(null, [command, args, Object.assign({
- inherit: true, shell: true, env: ENV, title: `${command} ${args}`
- }, options)
- ]);
- if (options.ignorefailures) {
- return p.catch(e => {
- // Ignore. Not a major error.
- })
- }
- else return p;
- }
- };
-
- var callsheltask = (args) => { return () => { return nodeShellExec.apply(null, args) } };
-
- var getTaskCheckExists = (command, options) => {
- options = options || {};
- return () => {
- var p = nodeShellExec.apply(null, ['where', [command]]);
- if (options.ignorefailures) {
- return p.then(() => { return true }).catch(e => { // Ignore. Not a major error.
- return false;
- })
- }
- else return p.then(() => { return true });
- }
- };
-
- var getPullCmd = (repo) => {
- // console.log(useGitPull)
-
- var pullCmd = [gitInstallDir
- , ['-c', 'branch=`git rev-parse --abbrev-ref HEAD`;for i in `git remote`; do git pull $i $branch; done;']
- , { cwd: instanceroot + '/' + repo, title: 'pull all origins for ' + repo }];
- // var pullCmd = ['pullall', [], { cwd : repo }]
- if (useGitPull) pullCmd = ['git', ['pull'], {
- inherit: true, shell: true,
- cwd: instanceroot + '/' + repo
- // , env: process.env
- , runas: processedArgs.runas
- , title: `git pull ${repo}`
- }];
- return pullCmd
- };
-
- var performPull = (repo) => {
- if (existsSync(instanceroot + '/' + repo)) {
- console.log('pulling ' + instanceroot + '/' + repo);
- return nodeShellExec.apply(null, getPullCmd(repo)).then(() => {
- if (__isElevated) {
- fs.writeFileSync('run.log', ', ' + JSON.stringify({ repo, success: true }), { 'flag': 'a+' });
- }
- else statuslog.statuslog(null, repo);
- return true;
- })
- .catch((e) => {
- e.repo = repo;
- if (__isElevated) {
- fs.writeFileSync('run.log', ', ' + JSON.stringify(e), { 'flag': 'a+' });
- }
- else statuslog.statuslog(e); console.error(e);
- })
- }
- else {
- console.log('cloning ' + repo);
- // PB : TODO -- detect if a clonable repo exists in currentGitAuthUser
- return nodeShellExec('git', ['clone', '-c', 'core.symlinks=true', defaultRepoServer + `/${defaultRepoOwner}/` + repo + '.git'],
- {
- inherit: true, shell: true,
- env: process.env
- , cwd : instanceroot
- , runas: processedArgs.runas
- }).catch((e) => {
- throw e;
- }).then(() => {
-
- return nodeShellExec('git', ['config', '--replace-all', 'core.symlinks', true],
- {
- inherit: true, shell: true,
- env: process.env
- , cwd: instanceroot + '/' + repo
- , runas: processedArgs.runas
- , title: `git core.symlinks --replace-all true for ${defaultRepoServer + `/${defaultRepoOwner}/` + repo + '.git'}`
- })
- .then(() => {
- if (__isElevated) {
- fs.writeFileSync('run.log', ', ' + JSON.stringify({ repo, success: true }), { 'flag': 'a+' });
- }
- else statuslog.statuslog(null, repo);
- })
- .catch((e) => {
- e.repo = repo;
- if (__isElevated) {
- fs.writeFileSync('run.log', ', ' + JSON.stringify(e), { 'flag': 'a+' });
- }
- else statuslog.statuslog(e);
- })
- })
- .catch(e => {
- e.repo = repo;
- if (__isElevated) {
- fs.writeFileSync('run.log', ', ' + JSON.stringify(e), { 'flag': 'a+' });
- }
- else statuslog.statuslog(e);
- })
- }
- };
-
- // PB : TODO -- If we are run from an elevated shell it never moves forward and simply exits.
- // -- Currently workaround is to always run from a non-elevated shell.
- var __isElevated = null; // We assume non-Elevated until someone evaluates and sets this variable.
- var acquireElevationState = () => {
- if (__isElevated === null) {
- return nodeShellExec("fsutil", ["dirty", "query", "C:"], {
- inherit: true
- // , shell: true
- , stdio: 'ignore'
- , env: process.env
- , title: `check privileged execution mode using "fsutil dirty query C:"`
- }).then((exitcode) => {
- console.log('Elevated');
- __isElevated = true;
- return true;
- }).catch(() => {
- __isElevated = false;
- console.log('Not Elevated');
- return false;
- });
- }
- else return Promise.resolve(__isElevated);
- };
-
-
- var repomanifest = null;
- var defaultRepoOwner = 'chess';
- var elevatedRunasRepos = null;
- var gitRepos = null;
- var defaultRepoServer = null;
-
- // grep -qxF 'alias elxr="node elxr/index.js"' ~/.bash_profile || echo 'alias elxr="node elxr/index.js"' >> ~/.bash_profile
-
-
- // nodeShellExec('echo', ['elxr'], { inherit : true}) //, {stdio: "inherit"}
-
- var dbForLabel = function (label) {
- var dbsForLabel = {
- devmysql: 'mysql'
- , development: 'mssql'
- , production: 'mssql'
- };
- return dbsForLabel[label] || 'mysql'
- };
-
- // SAM : TODO Use nodeshellexec where to detect git installation dir
- var gitInstallDir = "C:\\Program Files\\Git\\bin\\sh.exe";
- // var gitInstallDir = "G:\\Installed\\Git\\bin\\sh.exe"
- // Relevant git repos
- // var repomanifest = require('../'+repomanifest.instanceName+'-config-'+ nodeenv +'/repo-manifest')()
- var exludeMergeRepos = [];
- var useGitPull = processedArgs.useGitPull || false;
-
- // elxr cli operations
- var op = {
- 'h': () => { console.log(elxr.info()); return '-h' }
- , 'undefined': () => { return op.h(); }
- , 'reset': () => {
-
- // Reset NPM packages semver so major versions can be updated.
-
- const fs = fs__default['default'];
- const wipeDependencies = (__package) => {
- const file = fs.readFileSync(__package + '/package.json');
- const content = JSON.parse(file);
- for (var devDep in content.devDependencies) {
- if (content.devDependencies[devDep].match(/\W+\d+.\d+.\d+-?((alpha|beta|rc)?.\d+)?/g)) {
- content.devDependencies[devDep] = '*';
- }
- }
- for (var dep in content.dependencies) {
- if (content.dependencies[dep].match(/\W+\d+.\d+.\d+-?((alpha|beta|rc)?.\d+)?/g)) {
- content.dependencies[dep] = '*';
- }
- }
- fs.writeFileSync(__package + '/package.json', JSON.stringify(content));
- };
-
- var repos = ['client'];
- // repos = gitRepos;
- repos.forEach(wipeDependencies);
- // if (require.main === module) {
- // } else {
- // module.exports = wipeDependencies
- // }
-
- }
- , 'upgrade': () => {
- console.log('upgrade.......');
- var tasks = [
- () => {
- var p = nodeShellExec('npm', ['i', '-g', 'npm-upgrade'], {
- inherit: true, shell: true
- , env: process.env
- }).catch((e) => { console.error(e); });
- p.position = 1;
- console.log('One');
- return p;
- }
- , () => {
- var p = nodeShellExec('npm', ['cache', 'clean', '-f'], {
- inherit: true, shell: true
- , env: process.env
- }).catch((e) => { console.error(e); });
-
- p.position = 2;
- console.log('Two');
- return p;
- }
- , () => {
- var p = nodeShellExec('npm', ['install', '-g', 'n'], {
- inherit: true, shell: true
- , env: process.env
- }).catch((e) => { console.error(e); });
- p.position = 3;
- console.log('Three');
- return p;
- }
- , () => {
- var p = nodeShellExec('n', ['latest'], {
- inherit: true, shell: true
- , env: process.env
- }).catch((e) => { console.error(e); });
- p.position = 4;
- console.log('Four');
- return p;
- }
- ];
- any(tasks);
- console.log('.......done');
- console.log('Running exlr upgrade in : ' + path__default['default'].dirname(__dirname));
- console.log('Currently only upgrades ember : ' + path__default['default'].dirname(__dirname));
- console.info('Uninstalling existing ember globally');
- var step1 = nodeShellExec('cmd', ['/c', 'npm', 'uninstall', '-g', 'ember-cli'], {
- stdio: ['pipe', process.stdout, process.stderr],
- inherit: true,
- shell: true,
- cwd: path__default['default'].dirname(__dirname),
- env: env
- });
- step1.on('close', () => {
- console.info('Installing ember globally');
- var step2 = nodeShellExec('cmd', ['/c', 'npm', 'install', '-g', 'ember-cli'], {
- stdio: ['pipe', process.stdout, process.stderr],
- inherit: true,
- shell: true,
- cwd: path__default['default'].dirname(__dirname),
- env: env
- });
-
- step2.on('close', () => {
- nodeShellExec('cmd', ['/c', 'ember', '--version'], {
- stdio: ['pipe', process.stdout, process.stderr],
- inherit: true,
- shell: true,
- cwd: path__default['default'].dirname(__dirname),
- env: env
- });
- });
- });
- }
- , 'runas': () => {
- console.log('Testing Elevation');
-
- if (__isElevated) {
- try {
- op[processedArgs.label || processedArgs._[0] || 'h']();
- }
- catch (e) {
- console.error('Error Invalid command : ' + e);
- fs.writeFileSync('run.done', 'error');
- }
- finally {
- }
- }
- else {
- console.log('Requesting Elevated Privileges');
- // Wait for the runas to complete before we read it.
- try {
- fs.unlinkSync('run.done');
- fs.unlinkSync('run.log');
- }
- catch (e) { } //Ignore
-
- // Find node path to send to hta.
- return nodeShellExec('where', ['node']).then(r => {
- var namedArgs = [];
- console.log('result : ' + JSON.stringify(r));
- Object.keys(processedArgs).forEach((v) => { v != '_' ? namedArgs.push('--' + v + '=' + processedArgs[v]) : null; });
- // PB : TODO -- Convert all the cli args back to string.
- var args = [__dirname + '/windowselevate.hta'].concat(processedArgs._).concat(namedArgs.join(' ')); args.push('--runas=self');
- args.push('--nodepath=' + r[r.length - 1]);
- if (!processedArgs.node_env) args.push('--node_env=' + ENV.NODE_ENV);
- if (processedArgs.debug) args.push('--debug=true'); // Enable to debug elevated..
-
- return nodeShellExec('MSHTA', [`"${args.join('" "')}"`]
- , {
- inherit: true
- , shell: true
- , env: ENV
- , runas: 'self'
- , title: `runas`
- }
- ).then(() => {
- // runas returned.
- try {
- // PB : TODO -- Log is comma prefixed. Needs to be proper JSON.
- var runaslog = JSON.parse('[ { "success" : true, "result" : "started"}' + fs.readFileSync('run.log', { flags: 'a+' }) + ']');
- runaslog.forEach((logEntry) => {
- statuslog.statuslog(logEntry.success ? null : logEntry, logEntry);
- logEntry.success ? (console.log(['success :' + logEntry.result]), console.log((logEntry.messages || []).join(' '))) : (console.error(['error :' + logEntry.result]), console.error((logEntry.messages || []).join(' ')));
- });
- }
- catch (e) {
- // We must have a runas log
- statuslog.statuslog(e);
- console.error('Run log error probably was not created by runas : ' + e);
- }
- })
- .catch(err => console.error('Elevation failed : ' + err));
- })
-
- }
- }
- , 'push': () => {
- if (!processedArgs._[1]) { console.error('push all not supported. Specify repo name'); return }
- // init remote bare from local
- // pushandinitremotebare
- // https://www.jeffgeerling.com/blogs/jeff-geerling/push-your-git-repositories
- // connect to repo server -- net use 172.16.0.27
- // cd 172.16.0.27/repos/
- // mkdir repo.git
- // cd repo.git
- // git init --bare
- // cd localrepo
- // git remote rename origin githubclone
- // git remote add origin //172.16.0.27/repos/repo.git
- // git push origin master
-
- var repo = processedArgs._[1];
-
- var sequentialTaskShellCommands = [];
- if (!existsSync(`Z:/${repo}.git`)) {
- sequentialTaskShellCommands = [
- // ['net', ['use', 'Z:', defaultRepoServer.replace('/','\\')], {
- // inherit : true, shell: true
- // , env: process.env
- // }]
- ['pwd', { cwd: 'Z:', inherit: true }]
- , ['mkdir', [`${repo}.git`], {
- cwd: `Z:`
- , inherit: true, shell: true
- , env: process.env
- }]
- , ['pwd', { cwd: `Z:/${repo}.git`, inherit: true }]
- , ['git', ['init', '--bare'], {
- cwd: `Z:/${repo}.git`
- , inherit: true, shell: true
- , env: process.env
- }]
- // PB : TODO -- Do this conditionally only...
- , ['git', ['remote', 'rename', 'origin', 'githubclone'], { cwd: `${instanceroot + '/' + repo}` }, (err) => {
- console.log('Ignoring origin rename error : ' + err); return true; //return true to continue.
- }] // PB ; Todo -- new repositories created locally will not have origin. Handle this failure.
- , ['git', ['remote', 'add', 'origin', `${defaultRepoServer}/${repo}.git`], { cwd: `${instanceroot + '/' + repo}` }]
- // PB : TODO -- If threre is a gitbubclone origin
- // Set the master to pull from the local repo.
- ];
- if (!existsSync(`Z:`)) {
- sequentialTaskShellCommands.splice(0, 0, ['net', ['use', 'Z:', defaultRepoServer.replace(/\//gm, '\\')], {
- inherit: true, shell: true
- , env: process.env
- }]);
- console.warn('Adding network drive z: for repo server. ' + sequentialTaskShellCommands[0]);
- // throw 'done'
- }
- }
-
- sequentialTaskShellCommands.push(['git', ['push', 'origin', 'master'], { cwd: `${instanceroot + '/' + repo}` }]);
- // console.dir(sequentialTaskShellCommands);
-
- var tasks = [];
- sequentialTaskShellCommands.forEach(shellcmd => {
- // console.log(shellcmd)
- tasks.push(() => {
-
- var p = nodeShellExec.apply(null, shellcmd.slice(0, 3)).catch((e) => { if (shellcmd[3]) { return shellcmd[3]() } else { console.error(e); } });
- return p;
- });
- });
- any(tasks);
-
- }
- , 'is-git-repo': (dir) => {
- return nodeShellExec('git', ['-C', dir.name, 'rev-parse'], { stdio: 'ignore' })
- }
- , 'set-url': (remotename, url) => {
- var pushable = processedArgs.pushable || false;
- remotename = remotename || processedArgs._[1];
- url = url || processedArgs._[2];
- var serial_perform_git_seturl = (repo) => {
- // console.log(repo)
- if (pushable) {
- return [
- ['git', ['remote', 'set-url', remotename, url + '/' + repo], { cwd: instanceroot + '/' + repo }]
- ]
- }
- else {
- console.error('not supported for non-pushable');
- }
-
- };
-
- var perform_git_seturl = (dir) => {
- op['is-git-repo'](dir).then((code) => {
- any(serial_perform_git_seturl(dir.name).map(x));
- }).catch((e) => {
- // console.log('Failed : ' + dir.name)
- });
- };
-
- const { readdir } = fs__default['default'].promises;
-
- const dirs = async (perform, path) => {
- for (const dir of await readdir(path || process.cwd(), { withFileTypes: true })) {
- if (dir.isDirectory()) perform(dir);
- }
- };
-
- dirs(perform_git_seturl);
- }
- , 'add': (remotename, url, branch) => {
- var pushable = processedArgs.pushable || false;
- remotename = remotename || processedArgs._[1];
- url = url || processedArgs._[2];
- branch = branch || processedArgs._[3];
- var serial_perform_git_add = (repo) => {
- // console.log(repo)
- if (pushable) {
- return [
- ['git', ['remote', 'add', remotename, url + '/' + repo], { cwd: instanceroot + '/' + repo }]
- , ['git', ['pull', remotename, branch], { cwd: instanceroot + '/' + repo }]
- , ['git', ['branch', `--set-upstream-to=${remotename}/${branch}`, branch], { cwd: instanceroot + '/' + repo }]
- ]
- }
- else {
-
- return [
- ['git', ['remote', 'add', remotename, url + '/' + repo], { cwd: instanceroot + '/' + repo }]
- , ['git', ['remote', `set-url`, '--push', remotename, 'no-pushing'], { cwd: instanceroot + '/' + repo }]
- , ['git', ['pull', remotename, branch], { cwd: instanceroot + '/' + repo }]
- , ['git', ['branch', `--set-upstream-to=${remotename}/${branch}`, branch], { cwd: instanceroot + '/' + repo }]
- ]
- }
-
- };
- var x = (args) => {
- return () => {
- // console.log(args)
- return nodeShellExec.apply(null, args)
- }
- // return Promise.resolve(true)
- };
- var perform_git_add = (dir) => {
- op['is-git-repo'](dir).then((code) => {
- // console.log(code)
- if (code) {
- nodeShellExec('git', ['remote', 'get-url', remotename], { cwd: dir.name, stdio: 'ignore' }).then(() => {
- console.log('skipped : ' + dir.name + ', reason : A remote with same name already exists.');
- })
- .catch((e) => {
- any(serial_perform_git_add(dir.name).map(x));
- });
- }
- // else console.log('Skipped : Not a Git Repo : ' + dir.name)
- }).catch((e) => {
- // console.log('Failed : ' + dir.name)
- });
- };
-
- const { readdir } = fs__default['default'].promises;
-
- const dirs = async (perform, path) => {
- for (const dir of await readdir(path || process.cwd(), { withFileTypes: true })) {
- if (dir.isDirectory()) perform(dir);
- }
- };
-
- dirs(perform_git_add);
- }
- , 'remove': (remotename) => {
- remotename = remotename || processedArgs._[1];
- var serial_perform_git_remove = (repo) => {
- // console.log(repo)
- return [
- ['git', ['remote', 'remove', remotename], { cwd: instanceroot + '/' + repo }]
- ]
- };
- var x = (args) => {
- return () => {
- // console.log(args)
- return nodeShellExec.apply(null, args)
- }
- // return Promise.resolve(true)
- };
- var perform_git_remove = (dir) => {
- op['is-git-repo'](dir).then((code) => {
- // console.log(code)
- if (code) {
- nodeShellExec('git', ['remote', 'get-url', remotename], { cwd: dir.name, stdio: 'ignore' }).then(() => {
- any(serial_perform_git_remove(dir.name).map(x));
- })
- .catch((e) => {
- console.log('skipped : ' + dir.name + ', reason : No remote named origin');
- });
- }
- // else console.log('Skipped : Not a Git Repo : ' + dir.name)
- }).catch((e) => {
- // console.log('Failed : ' + dir.name)
- });
- };
-
- const { readdir } = fs__default['default'].promises;
-
- const dirs = async (perform, path) => {
- for (const dir of await readdir(path || process.cwd(), { withFileTypes: true })) {
- if (dir.isDirectory()) perform(dir);
- }
- };
-
- dirs(perform_git_remove);
- }
- , 'init-gitea': (user) => {
- user = user || processedArgs._[1];
- if (!user) throw 'User name required'
- var serial_perform_init_gitea = (repo) => {
- // console.log(repo)
- return [
- ['git', ['remote', 'add', 'chess', `${defaultRepoServer}/${user}/${repo}.git`], { cwd: instanceroot + '/' + repo }]
- , ['git', ['remote', 'set-url', '--push', 'chess', 'no-pushing'], { cwd: instanceroot + '/' + repo }]
- , ['git', ['remote', 'set-url', 'origin', `${defaultRepoServer}/${user}/${repo}.git`], { cwd: instanceroot + '/' + repo }]
- ]
- };
- var x = (args) => {
- return () => {
- // console.log(args)
- return nodeShellExec.apply(null, args)
- }
- // return Promise.resolve(true)
- };
- var perform_init_gitea = (dir) => {
- op['is-git-repo'](dir).then((code) => {
- // console.log(code)
- if (code) {
- nodeShellExec('git', ['remote', 'get-url', 'chess'], { cwd: dir.name, stdio: 'ignore' }).then(() => {
- console.log('skipped : ' + dir.name + ', reason : Already has remote chess ');
- })
- .catch((e) => {
- any(serial_perform_init_gitea(dir.name).map(x));
- });
- }
- // else console.log('Skipped : Not a Git Repo : ' + dir.name)
- }).catch((e) => {
- // console.log('Failed : ' + dir.name)
- });
- };
-
- const { readdir } = fs__default['default'].promises;
-
- const dirs = async (perform, path) => {
- for (const dir of await readdir(path || process.cwd(), { withFileTypes: true })) {
- if (dir.isDirectory()) perform(dir);
- }
- };
-
- dirs(perform_init_gitea);
- }
- , 'syncmaster': (label) => {
- // Usage :
- // elxr pull -- Defaults to run config
-
- Object.assign({}, process.env); // Shallow clone it.
- // console.dir(env)
- console.log('Running exlr pull : ' + path__default['default'].dirname(__dirname));
-
- if (!processedArgs.runas) gitRepos.forEach(performPull);
- if (__isElevated) {
- return any(elevatedRunasRepos.map((repo) => performPull(repo))).then(() => {
- fs.writeFileSync('run.done', 'success');
- }).catch(() => {
- fs.writeFileSync('run.done', 'error');
- })
- }
- else return op['runas']()
- }
-
- , 'pull': (label) => {
- // Usage :
- // elxr pull -- Defaults to run config
-
- Object.assign({}, process.env); // Shallow clone it.
- console.log('Running exlr pull : ' + path__default['default'].dirname(__dirname));
-
- processedArgs.useGitPull || false;
-
- if (__isElevated) {
- return any(elevatedRunasRepos.map((repo) => performPull(repo))).then(() => {
- fs.writeFileSync('run.done', 'success');
- return true;
- }).catch(() => {
- fs.writeFileSync('run.done', 'error');
- })
- }
- else {
- // PB : TODO -- Rename op['runas'] to 'elevate'
- return op['runas']().then(() => { return true; })
- .catch((e) => {
- console.error(e);
- })
- .finally(() => {
- if (!processedArgs.runas) {
- var pendingpulls = [];
- gitRepos.forEach((r) => { pendingpulls.push(performPull(r)); });
- return Promise.all(pendingpulls).then(results => {
- return true;
- }).finally(Traq.finally)
- }
- })
- }
- }
- , 'isInstalled': () => {
- return nodeShellExec('where', [processedArgs._[1]], { inherit: true }).then(() => {
- console.log(processedArgs._[1] + ' exists.');
- return true;
- });
- }
- , 'i': () => {
-
- var tasks = [];
- tasks.push(op['pull']);
- tasks.push(getShellTask.apply(null, ['rm', [instanceroot + '/run.js'], { ignorefailures: true }]));
- tasks.push(op['use']);
- if (!__isElevated) {
- tasks.push(op['npmi']);
- }
-
- // var tasksdefs = [
- // ['elxr', ['pull']]
- // , ['elxr', ['use', 'elixir']]
- // , ['elxr', ['npmi']]
- // ]
-
-
- // tasksdefs.forEach(tasksdef=>{
- // tasks.push( ()=> nodeShellExec.apply(null, tasksdef) )
- // })
-
- return any(tasks);
-
- }
- , 'npmi': () => {
- var tasks = [];
-
-
- var npmbuildrepos = ['loopback-jsonapi-model-serializer'];
- npmbuildrepos.forEach(repo => {
- tasks.push(() => {
- return nodeShellExec('npm', ['i --force'], {
- inherit: true, shell: true
- , cwd: instanceroot + '/' + repo
- , env: process.env
- , title: `npm i for ${repo}`
- }).catch((e) => {
- console.error('Ignoring Benign Error'); console.error(e);
- }).then(() => {
- console.log(`--------------------npm run build for ${repo}--------------------`);
- return nodeShellExec('npm', ['run build'], {
- inherit: true, shell: true
- , cwd: instanceroot + '/' + repo
- , env: process.env
- , title: `npm run build for ${repo}`
- }).then(Tasq.then).catch(Tasq.catch)
- })
- });
- });
-
- any(tasks).then(() => {
-
- gitRepos.push('client/server');
- gitRepos = gitRepos.concat(elevatedRunasRepos);
-
- var rmtasks = [];
- var repotasks = [];
- gitRepos.forEach(repo => {
-
- rmtasks.push(() => {
- console.log(`--------------------rm package-lock.json for ${repo}--------------------`);
- return nodeShellExec('rm', ['package-lock.json'], {
- inherit: true, shell: true
- , cwd: instanceroot + '/' + repo
- , env: process.env
- , title: `rm 'package-lock.json' for ${repo}`
- }).catch((e) => { console.error(e); })
- });
-
- if (npmbuildrepos.indexOf(repo) < 0) {
- repotasks.push(
- () => {
- console.log(`--------------------npm i for ${repo}--------------------`);
- var p = nodeShellExec('npm', ['i --force'], {
- inherit: true, shell: true
- , cwd: instanceroot + '/' + repo
- , env: process.env
- , title: `npm i for ${repo}`
- }).then(Tasq.then).catch(Tasq.catch);
- return p;
- });
- }
- });
-
- var bowerRepos = ['client'];
- bowerRepos.forEach(repo => {
- repotasks.push(() => {
- var p = nodeShellExec('bower', ['install'], {
- inherit: true, shell: true
- , cwd: instanceroot + '/' + repo
- , env: process.env
- , title: `bower i for ${repo}`
- }).then(Tasq.then).catch(Tasq.catch);
- return p;
- });
- });
-
- return Promise.all(rmtasks).then(() => any(repotasks));
- }).catch(e => {
-
- }).finally(statuslog.finally);
-
- }
- , 'start': (label) => {
- console.log('Starting Elixir Server.');
- var env = Object.assign({}, process.env); // Shallow clone it.
- // console.dir(env)
- env.NODE_ENV = process.env.NODE_ENV || 'development';
- env.DEBUG = 'loopback:connector:' + dbForLabel(label);
- var cmd = env.NODE_ENV === 'development' ? 'nodemon' : 'node';
- // cmd = 'node'
- cmd = [cmd, ['--inspect=9228', 'elixir/server.js']];
- var childPromise = nodeShellExec(...cmd, {
- // inherit : true,
- shell: true,
- detached: true,
- stdio: 'ignore',
- cwd: instanceroot + '/' + 'elixir-server'
- , env: env
- });
-
- var child = childPromise.process;
- if (typeof child.pid !== 'undefined') {
- console.log(`started Elixir Server PID(${child.pid}) : NODE_ENV=${process.NODE_ENV} ${cmd}`);
- fs.writeFileSync('.elixir-server.elixir.server.pid', child.pid, {
- encoding: 'utf8'
- });
- }
-
- // nodeShellExec('node', ['--inspect=9226', ' bin/www'], {
- // inherit : true,
- // shell: true, detached: true,
- // cwd : 'qms/server',
- // env: env,
- // shell : true
- // })
-
- // nodeShellExec('ember', ['s'], {
- // // inherit : true,
- // shell: true, detached: true,
- // cwd : 'client/',
- // env: env
- // })
- console.log('Starting Elixir Client Host.');
- var cmd = ['ember', ['s']];
- var childPromise = nodeShellExec(...cmd, {
- // var childPromise = nodeShellExec('node', ['--inspect=9227', './node_modules/.bin/ember', 's'], {
- // PB : TODO -- ember debugging.
- // inherit : true,
- shell: true,
- detached: true,
- stdio: 'ignore',
- cwd: instanceroot + '/' + 'client'
- , env: env
- });
- // .catch(e=>console.error(e))
-
- child = childPromise.process;
- if (typeof child.pid !== 'undefined') {
- console.log(`started Elixir Client Host PID(${child.pid}) : NODE_ENV=${process.NODE_ENV} ${cmd}`);
- fs.writeFileSync('.client.server.pid', child.pid, {
- encoding: 'utf8'
- });
- }
-
- }
- , 'stop': (label) => {
- const kill = treeKill;
-
- var serverPid = fs.readFileSync('.elixir-server.elixir.server.pid', {
- encoding: 'utf8'
- });
- fs.unlinkSync('.elixir-server.elixir.server.pid');
- console.log(serverPid);
- kill(serverPid);
-
- serverPid = fs.readFileSync('.client.server.pid', {
- encoding: 'utf8'
- });
- fs.unlinkSync('.client.server.pid');
- console.log(serverPid);
- kill(serverPid);
- }
- , 'use': () => {
- // use a certain named instance.
- // Eg :
- // 1) elxr use elixir
- // 2) elxr use cihsr
- // If environment is not specified defaults to development.
- // 1) NODE=test elxr use elixir
-
- /*// Steps
- 1) Delete Config and Data symlinks
- 2) Make Links for config ({{name}}-config-{{node_env}}) and data with the NODE_ENV specified or default to dev
- 3) Iterates all repos and pull all. 'git', ['pull', '--all'].
- 4) Iterates all repos and checkout to the ENV specified. 'git', ['checkout', checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV]
- 5) Iterates all repos and merge from source configured in mergeSource. 'git', ['merge', mergeSource],
- */
- var runconfig = { NODE_ENV: repomanifest.node_env };
- try { runconfig = Object.assign(runconfig, commonjsRequire(instanceroot + '/run.js',"/$$rollup_base$$")); } catch (e) { }
- if ((!processedArgs.runas || processedArgs.runas !== 'self') &&
- runconfig.NODE_ENV && runconfig.NODE_ENV === (repomanifest.node_env || runconfig.NODE_ENV) &&
- repomanifest.instanceName && runconfig.use === repomanifest.instanceName) {
-
- console.log(`No change detected. Already using requested specs : ${runconfig.NODE_ENV} ${runconfig.use}`);
- if (processedArgs.runas) { fs.writeFileSync('run.done', 'success'); }
- return
- }
-
- var tasks = [
- () => {
- if (existsSync('config')) {
- var p = nodeShellExec('rmdir', ['config'], { inherit: true, shell: true, env: process.env }
- ).catch((err) => { console.log('Ignoring benign error : ' + err); return true; });
- return p;
- }
- else return Promise.resolve(true);
- },
- () => {
- if (existsSync('data')) {
- var p = nodeShellExec('rmdir', ['data'], { inherit: true, shell: true, env: process.env }
- ).catch((err) => { console.log('Ignoring benign error : ' + err); return true; });
- return p;
- }
- else return Promise.resolve(true);
- },
- ];
- runconfig.NODE_ENV = process.env.NODE_ENV = process.env.NODE_ENV || runconfig.NODE_ENV || 'development';
- if (processedArgs._[1] && runconfig.use !== processedArgs._[1]) runconfig.use = processedArgs._[1];
- if (!runconfig.use) { throw 'unspecifed use not allowed. Please specify chess instance name.' }
- // console.log(process.env.cwd)
- fs.writeFileSync(instanceroot + '/run.js', 'module.exports = ' + JSON.stringify(runconfig));
-
- // Maps an environment to a branch. Not required if the branch is appropriately named.
- var checkoutMap = { 'development': 'master' };
-
- // cant use git checkout -b it fails with branch already exists.
- var performCheckout = (repo, branch) => {
- if (!branch) return Promise.resolve({ 'skipped': true })
- if (excludeCheckouts[repo]) return Promise.resolve({ 'skipped': true })
- return nodeShellExec('git', ['checkout', branch || checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV], {
- // return nodeShellExec('git', ['switch', '-m', '-C', checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV], {
- // inherit : true, shell: true,
- cwd: repoinstanceroot + '/' + repo
- // , stdio : ignore // Use when we want to silcence output completely.
- , runas: processedArgs.runas
- , title: `git checkout ${branch || checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV} for ${repo}`
- }).catch((e) => { console.error(e); return { error: true, message: repo } })
- };
- if (runconfig.NODE_ENV === 'development') performCheckout = () => { return Promise.resolve(true) };
-
- var performPullAll = (repo) => {
- if (excludeCheckouts[repo]) return Promise.resolve({ 'skipped': true })
- return nodeShellExec('git', ['pull', '--all'], {
- // inherit : true, shell: true,
- cwd: instanceroot + '/' + repo
- , runas: processedArgs.runas
- , title: `git pull -all for ${checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV} ${repo}`
- }).catch((e) => { console.error(e); return { error: true, message: repo } })
- };
-
- var mergeSources = {
- 'development': null,
- 'test': 'master',
- 'production': 'master'
- };
- var excludeCheckouts = Object.assign(exludeMergeRepos);
- delete excludeCheckouts[`elixir-config-${runconfig.NODE_ENV}`];
- delete excludeCheckouts[`cihsr-config-${runconfig.NODE_ENV}`];
-
- var mergeSource = mergeSources[checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV];
- var performMerge = (repo) => {
- if (exludeMergeRepos[repo]) return Promise.resolve({ 'skipped': true })
- return nodeShellExec('git', ['merge', mergeSource], {
- inherit: true, shell: true,
- cwd: instanceroot + '/' + repo
- , runas: processedArgs.runas
- }).catch((e) => { console.error(e); })
- };
- if (runconfig.NODE_ENV === 'development') performMerge = () => { return Promise.resolve(true) };
-
- any(tasks).then(() => {
- if (!processedArgs.runas) return op['runas']()
-
- tasks = [
- () => {
- // Use junctions to avoid npm package issues
- var p = nodeShellExec('mklink', ['/J', 'config', runconfig.use + '-config' + '-' + process.env.NODE_ENV], {
- inherit: true, shell: true
- , env: process.env
- }).catch((e) => { console.error(e); });
- return p;
- }
- ];
- if (processedArgs._[1]) {
- tasks = tasks.concat(
- [
- () => {
- var p = nodeShellExec('mklink', ['/J', 'data', runconfig.use + '-data'], {
- inherit: true, shell: true
- , env: process.env
- }).catch((e) => { console.error(e); });
- return p;
- }
- ]
- );
- }
-
- return any(tasks)
- //target is the env is we specify in elxr use command. Default is dev
- .then( //Switch to target branch
- () => any([any(gitRepos.map((repo) => performCheckout(repo, process.env.NODE_ENV || 'development')))
- , any(elevatedRunasRepos.map((repo) => performCheckout(repo, process.env.NODE_ENV || 'development')))]))
- .then( //PULL from target branch
- () => any([any(gitRepos.map((repo) => performPullAll(repo))), any(elevatedRunasRepos.map((repo) => performPullAll(repo)))]))
- .then( //Switch to merge source branch
- () => any([any(gitRepos.map((repo) => performCheckout(repo, mergeSources[process.env.NODE_ENV || 'development'])))
- , any(elevatedRunasRepos.map((repo) => performCheckout(repo, mergeSources[process.env.NODE_ENV || 'development'])))]))
- .then( //Pull on merge source branch
- () => any([any(gitRepos.map((repo) => performPullAll(repo))), any(elevatedRunasRepos.map((repo) => performPullAll(repo)))]))
- .then( //Switch to target branch
- () => any([any(gitRepos.map((repo) => performCheckout(repo, process.env.NODE_ENV || 'development')))
- , any(elevatedRunasRepos.map((repo) => performCheckout(repo, process.env.NODE_ENV || 'development')))]))
- .then( //Merge source branch to target branch
- () => any([any(gitRepos.map((repo) => performMerge(repo))).catch(err => { console.error('error in performMerge ' + err); }),
- any(elevatedRunasRepos.map((repo) => performMerge(repo))).catch(err => { console.error('error in performMerge ' + err); })]))
- .then(() => {
- // Move test config from dev.
- // if(process.env.NODE_ENV === 'test'){
- // var devcfgreponame = runconfig.use + '-config' + '-development';
- // var testcfgreponame = runconfig.use + '-config' + '-test';
-
- // var testcfgdir = path.dirname(__dirname) + '/' + testcfgreponame + '/'
- // var devcfgdir = path.dirname(__dirname) + '/' + devcfgreponame + '/' //eg (elxr/../elixir-config.development)
-
- // return any([
- // ()=>{
- // return nodeShellExec('git', ['checkout', 'test'], {
- // inherit : true, shell: true,
- // cwd : testcfgdir
- // // , env: process.env
- // , runas : processedArgs.runas
- // , title : `git checkout test for ${testcfgreponame}`
- // }).catch((e)=>{ console.error(e) })
- // }
- // , ()=> {
- // return nodeShellExec('git', ['checkout', 'master'], {
- // inherit : true, shell: true,
- // cwd : devcfgdir
- // // , env: process.env
- // , runas : processedArgs.runas
- // , title : `git checkout master for ${devcfgreponame}`
- // }).catch((e)=>{ console.error(e) })
- // }
- // , ()=> {
- // globSync( '**/*.test.js', {cwd : devcfgdir}).map((filename) => {
- // console.log('File found : ' + devcfgdir + filename)
- // fs.copyFileSync(devcfgdir + filename, testcfgdir+ filename);
- // })
- // return nodeShellExec('git', ['checkout', 'test'], {
- // inherit : true, shell: true,
- // cwd : devcfgdir
- // // , env: process.env
- // , runas : processedArgs.runas
- // , title : `git checkout test for ${devcfgreponame}`
- // }).catch((e)=>{ console.error(e) })
- // }
- // ])
- // }
- // else {
- return Promise.resolve(true)
- // }
- })
- .then(() => {
- fs.writeFileSync('run.done', 'success');
- }).catch(() => {
- fs.writeFileSync('run.done', 'error');
- })
- }).catch(() => {
- fs.writeFileSync('run.done', 'error');
- });
-
- // Antibiotic stewardship program.
- // 1st use is fine.
- // Max vials dispense
- // 2nd use Pharmacy needs justification Form.
- // Approval after a certain period of time.
- }
- , 'g': () => {
- if (processedArgs.h) {
-
- console.log('elxr g [modelname] => generate a model named [modelname]');
- console.log('elxr g => regenerate all known models');
- return
- }
- // nodeShellExec('npm', ['init', '-y'], options);
- // nodeShellExec('npm', ['init', '-y'], options);
- // })
-
- var g = {
- 'client': () => {
- console.info('Creating new ember client named : ' + processedArgs._[2]);
- nodeShellExec('cmd', ['/c', 'ember', 'new', processedArgs._[2]], {
- stdio: ['pipe', process.stdout, process.stderr],
- inherit: true,
- shell: true,
- cwd: path__default['default'].dirname(__dirname),
- env: env
- });
- },
-
- 'modelr': () => {
- var tasks = [
- () => {
- var p = nodeShellExec('"ember"', [
- 'g'
- , 'modelr'
- , processedArgs._[2]], {
- inherit: true, shell: true, env: process.env
- }).then(() => {
- console.log('Blueprint generation complete for : ' + processedArgs._[2]);
- return true;
- }).catch((e) => { console.error(e); });
- return p;
- },
- () => {
- var chromePrefsFile = "C:\\chess\\instances\\elixir_01\\data\\Google\\Chrome\\User Data\\chess\\Preferences";
- var chromeprefs = fs.readFileSync(chromePrefsFile, { encoding: 'utf8' });
- chromeprefs = JSON.parse(chromeprefs);
- var previous = chromeprefs.download.default_directory;
- var parentDir = path__default['default'].dirname(__dirname);
- chromeprefs.download.default_directory = parentDir + "\\client\\app\\templates\\components\\resource";
- fs.writeFileSync(chromePrefsFile, JSON.stringify(chromeprefs));
- // PB : TODO -- detect where chrome is installed.
- // PB : TODO -- set the download dir to the place where files are needed.
- var p = nodeShellExec('"C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"', [
- '--user-data-dir="C:\\chess\\instances\\elixir_01\\data\\Google\\Chrome\\User Data"'
- , '--profile-directory="chess"'
- , 'http://localhost:4200/admin/crud/create/' + processedArgs._[2]], {
- inherit: true, shell: true
- , env: process.env
- }).then(() => {
- chromeprefs.download.default_directory = previous;
- fs.writeFileSync(chromePrefsFile, JSON.stringify(chromeprefs));
- return true;
- }).catch((e) => { console.error(e); });
- return p;
- }
- ,
- () => {
- console.log('Browser process should have closed here....');
- return true;
- }
- ];
- any(tasks);
-
- }
-
- };
-
- g[processedArgs._[1]]();
- }
- };
-
-
- var cliname = 'elxr';
- var ver = '1.1';
- var help = `# list of commands... please refer dveloper documentation for ${cliname}
- ${
- // util.inspect(
- [Object.keys(op)]
- // )
- }
- `;
-
- var elxr = {
- help() {
- return source.cyanBright(`
- -------------------------------------------------------------------------------
- *** BBH Elixir ***
- -------------------------------------------------------------------------------
- elxr ${ver}
- A cli tool for chess
- ${help}
- -------------------------------------------------------------------------------
- `)
- }
- , info() {
- return source.cyanBright(`
- -------------------------------------------------------------------------------
- *** BBH Elixir ***
- -------------------------------------------------------------------------------
- elxr ${ver}
- A cli tool for chess
- -------------------------------------------------------------------------------
- `)
- }
- };
-
- // The main elxr cli process
- function elxrworker(hasconfig) {
- // Everything runs after this check is completed. Elevation occurs out of process when needed.
- gitRepos = repomanifest.repos;
-
- // Repositiories that have symlinks that require elevated priviletes in windows to create symlinks
- elevatedRunasRepos = repomanifest.elevated;
- // Repos that should excluded from merge for releases...
- exludeMergeRepos = repomanifest.exludeMergeRepos;
-
- Object.assign({}, process.env); // Shallow clone it.
- var __runcmd = function (label) {
- return op[label] ? op[label]() : null;
- };
-
- // --runas
- if (processedArgs.runas) {
- // Weve been asked to run in priviledged mode. Check if we already are privileged.
- return __runcmd('runas')
- }
- else return __runcmd(processedArgs.label || processedArgs._[0] || 'h');
- }
-
- var getManifest = function () {
- // Once choices are made we need to load config according to those choices.
-
- // No trace of a previous run...
- // Default Config...
- return repomanifest = selectedinstance;
- };
-
- function acquireChoices(selectedinstance) {
- console.warn(source.yellow(`
- -------------------------------------------------------------------------------
- Warning : Cannot locate your preferred configuration since it was not specified
- You should fork the default chess configuration to customize and make it
- your own instance with a named config as
- {{yourowninstancename}}-config-{{yourcurrentenvironment}}
- And then run this tool as follows
- NODE_ENV={{yourenvironment}} elxr i {{yourowninstancename}}
- OR
- Run this tool with the following command to use a quick start default.
- node elxr --default
- OR
- Choose the the option to create a new instance for you interactively.
-
- We will run your choice of default or create your own at the next prompt.
- -------------------------------------------------------------------------------
- `));
- var prompt = cliverse.prompt;
- return prompt.ask(`Choose an option :
- d) Install the default chess instance.
- => elxr i chess node_env=development --default
- n) Create your custom new instance interactively
- => elxr i {{instanceName}} node_env={{environment}}
- i) Choose an instance and environment to install
- => elxr i {{instanceName}} node_env={{environment}}
- c) Choose a command to run ( pull, use, i, npmi ... ) <= pull
- => elxr {{cmd}} {{instanceName}} node_env={{environment}}
- h) Help
- q) Quit
- Default <= d
- : `).then((choice) => {
- prompt.close();
- if (choice && choice === 'd' || !choice) {
- processedArgs._[0] = 'i';
- selectedinstance.instanceName = processedArgs._[1] = processedArgs._[1] || 'chess';
- selectedinstance.node_env = processedArgs.node_env = (process.env.NODE_ENV && process.env.NODE_ENV.trim()) || processedArgs.node_env || 'development';
- defaultRepoServer = 'https://git.bbh.org.in';
- getManifest(); // PB : TODO -- acquire the manifest directly from http url instead of clone before cloning the config. Since
- // This is because the manifest at any server location can redirect to the preferred server..
- }
- else if (choice === 'h') {
- processedArgs._[0] = 'h';
- fs.writeFileSync('run.done', 'noop help');
- console.log(elxr.help()); process.exit();
- }
- else if (choice === 'n' || choice === 'i') {
- var p1 = cliverse.prompt;
- return p1.ask(`Enter Instance Name ( <= ${selectedinstance.instanceName} ) : `).then(function (instanceName) {
- processedArgs._[0] = 'i';
- selectedinstance.instanceName = processedArgs._[1] = instanceName || selectedinstance.instanceName;
- return p1.ask(`Enter Environment ( <= ${selectedinstance.node_env} ) : `).then(function (node_env) {
- selectedinstance.node_env = processedArgs.node_env = node_env || selectedinstance.node_env;
- if (choice === 'n') {
- defaultRepoServer = 'https://git.bbh.org.in';
- console.warn(
- source.magenta('No Option Available. Your account may not have privileges. You can request here http://git.bbh.org.in/chess'));
- process.exit();
- }
-
- return p1.ask(`Enter preferred repo server ( <= ${selectedinstance.reposervers[0]} ) : `).then(function (reposerver) {
- p1.close();
- defaultRepoServer = reposerver || selectedinstance.reposervers[0] || 'https://git.bbh.org.in';
- })
- })
- })
- } else if (choice === 'c') {
- var p1 = cliverse.prompt;
- return p1.ask(`Enter Instance Name ( <= ${selectedinstance.instanceName} ) : `).then(function (instanceName) {
- selectedinstance.instanceName = processedArgs._[1] = instanceName || selectedinstance.instanceName;
- return p1.ask(`Enter Environment ( <= ${selectedinstance.node_env} ) : `).then(function (node_env) {
- selectedinstance.node_env = processedArgs.node_env = node_env || selectedinstance.node_env;
- return p1.ask(`Enter cmd :
- p) pull
- Default <= p
- : `).then(function (cmd) {
- if (!cmd || cmd === 'p') {
- processedArgs._[0] = 'pull';
- }
- else processedArgs._[0] = cmd;
- return p1.ask(`Enter preferred repo server ( <= ${selectedinstance.reposervers[0]} ) : `).then(function (reposerver) {
- defaultRepoServer = reposerver || selectedinstance.reposervers[0] || 'https://git.bbh.org.in';
- p1.close();
- })
- })
- })
- })
- } else {
- console.log(source.gray(`Default option not exercised. Please follow manual instructions to customize your instance here http://git.bbh.org.in/chess and try again.`));
- fs.writeFileSync('run.log', ', ' + JSON.stringify({ success: 'quit without execution' }), { 'flag': 'a+' });
- fs.writeFileSync('run.done', 'noop quit');
- process.exit();
- }
- })
- }
-
- var acquireConfig = function (selected, chessinstances) {
-
- var configrepo = selected.instanceName + '-config-' + selected.node_env;
- return performPull(configrepo).then(() => {
- var manifestpath = path__default['default'].normalize(selected.root + '/' + selected.instanceName + '-config-' + selected.node_env + '/repo-manifest');
- repomanifest = commonjsRequire(manifestpath,"/$$rollup_base$$")();
- chessinstances = chessinstances || {};
- chessinstances[selected.instanceName] = chessinstances[selected.instanceName] || {};
- chessinstances[selected.instanceName][selected.node_env] = chessinstances[selected.instanceName][selected.node_env] || {};
- chessinstances['current_run'] = { instanceName: selected.instanceName, node_env: selected.node_env };
- // Config from server always override merges into selection ecept for the current selection.
- selectedinstance = bbhverse.assign(chessinstances[selected.instanceName][selected.node_env], selected, repomanifest);
- fs.writeFileSync(instanceroot + '/chessinstances.js', 'module.exports = ' + JSON.stringify(chessinstances) + '', { 'flag': 'w' });
- // PB : TODO -- We should probably write the new server config also...
- defaultRepoServer = selectedinstance.reposervers[0]; // PB : TODO -- Attempt first one that is available and online...
- ENV.NODE_ENV = selectedinstance.node_env;
- })
- .catch((e) => {
- console.error(e);
- console.error('Config acquisition failed.');
- })
- };
-
- var launchpath = process.cwd();
- var thisscriptdir = __dirname;
- var instanceroot = launchpath;
- var detectInstance = function () {
- console.log(`launchpath = ${launchpath}`);
- console.log(`thisscriptdir = ${thisscriptdir}`);
-
- var root = launchpath;
-
- // We need a reference to the root director for elxr cli to be properly oriented.
- if ((launchpath + path__default['default'].normalize('/elxr')) === thisscriptdir) {
- // We ran unbuilt from the proper root with elxr subfolder.
- console.log(`Instance Path : ${root}`);
- }
- else {
- if (launchpath === thisscriptdir) {
- // Same directory doesn't mean we are being run from elxr directory or the root directory.
- // It could be a standalone elxr build which may or maynot be in the proper location.
- if (BUILD_VERSION.indexOf('Version: {version} - built on {date}') > -1) {
- // Unbuilt therefore we are in the elxr directory.
- root = path__default['default'].normalize(launchpath + '/..');
- }
- else {
- // Built version.
- // check if we have a elxr subfolder.
- if (fs.existsSync(launchpath + '/..' + path__default['default'].normalize('/elxr'))) {
- // Probably in the right place.
- root = path__default['default'].normalize(launchpath + '/..');
- }
- else {
- // Assume launchpath is meaningless.
- // Figure it out from the input instance name and environment parameters if we are in the right location.
- root = path__default['default'].normalize(launchpath + '/' + processedArgs._[1] + '/' + processedArgs.node_env);
- }
- }
- }
- }
- instanceroot = root;
- var __default = {
-
- // Default is public server only.
- reposervers: ['https://git.bbh.org.in']
-
- // All public repos are by default available.
- , repos: [
- 'setup'
- , 'elxr'
- , 'loopback-connector-mysql'
- , 'loopback-jsonapi-model-serializer'
- , 'loopback-component-jsonapi'
- , 'ember-service-worker'
- , 'ember-service-worker-asset-cache'
- , 'ember-service-worker-cache-fallback'
- , 'ember-service-worker-index'
- , 'ember-sw-client-route'
- ]
-
- , elevated: []
- , exludeMergeRepos: {}
- , instanceName: 'chess'
- // Runas windowshta clobbers and removes the NODE_ENV !!! We therefore pass it in.
- , node_env: 'development'
- };
-
- return Object.assign({ root }, __default);
- };
-
- var gitUser = 'chessdemo';
- var gitEmail = 'chessdemo@bbh.org.in';
- var downloadsdir = '../Downloads';
- var prerequisites = [
- {
- shellcmd: 'git',
- url: 'https://github.com/git-for-windows/git/releases/download/v2.31.0.windows.1/Git-2.31.0-64-bit.exe'
- , installer: 'Git-2.31.0-64-bit.exe'
- , installcmd: ['cmd', ['/c', 'start',
- '/WAIT', path__default['default'].resolve(downloadsdir + '/' + 'Git-2.31.0-64-bit.exe')
- , '/VERYSILENT'
- // , '/MERGETASKS=!runcode' // This is required only for vscode...
- ]]
- , preinstallsteps: () => {
- var prompt = cliverse.prompt;
- var steps = [
- () => {
- if (!existsSync(downloadsdir + '/' + preq.installer)) {
- return nodeShellExec('download.bat', [preq.url, downloadsdir + '/' + preq.installer])
- }
- else return Promise.resolve(true)
- }
- ];
- var prompts = [
- () => prompt.ask(`git user name : ( <= ${gitUser} )`).then((user) => { gitUser = user; })
- , () => prompt.ask(`git user name : ( <= ${gitEmail} )`).then((email) => { gitEmail = email; })
- ];
- return Promise.all([any(steps), any(prompts)]).finally(() => { prompt.close(); })
- }
- , installsteps: function () {
- return any([this.installcmd].map(callsheltask))
- }
- , postinstallsteps: () => {
- var steps = [
- ['git', ['config', '--global', '--add', 'user.name', `${gitUser}`]]
- , ['git', ['config', '--global', '--add', 'user.email', `${gitEmail}`]]
- ];
- return any(steps.map(callsheltask)).then(() => { })
- }
- , install: function () {
- return any([ /*this.preinstallsteps,*/ this.installsteps, this.postinstallsteps])
- }
- }
- ,
- {
- shellcmd: 'node',
- url: 'https://nodejs.org/dist/v14.16.0/node-v14.16.0-x64.msi'
- , installer: 'node-v14.16.0-x64.msi'
- , installcmd: ['MSIEXEC.exe', ['/i'
- , path__default['default'].resolve(downloadsdir + '/' + 'node-v14.16.0-x64.msi')
- , 'ACCEPT=YES', '/passive']]
- }
- ];
-
- function ensureDirectoryExistence(filePath) {
- var dirname = path__default['default'].dirname(filePath);
- if (fs.existsSync(dirname)) {
- return filePath;
- }
- ensureDirectoryExistence(dirname);
- fs.mkdirSync(dirname);
- return filePath;
- }
-
- var mainTasks = [];
- function verifyAndInstallPrerequisites() {
- fs.writeFileSync(ensureDirectoryExistence(path__default['default'].normalize(downloadsdir + '/readme.txt')), `${getVersion()} Your local downloads for this instance`);
- var downloadbatch =
- `::**************************************************************************
- :Download_ <url> <File>
- Powershell.exe ^
- $AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12'; ^
- [System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols; ^
- (New-Object System.Net.WebClient).DownloadFile('%1','%2')
- exit /b
- ::**************************************************************************`;
- fs.writeFileSync('download.bat', downloadbatch);
-
- var downloadtasks = [];
- var installtasks = [];
- prerequisites.forEach(preq => {
- downloadtasks.push(getTaskCheckExists(preq.shellcmd, { ignorefailures: true })().then((exists) => {
- if (exists) console.log(`${preq.shellcmd} exists`);
- else {
- console.log(`${preq.shellcmd} is not installed`);
- return preq.preinstallsteps().then(() => {
- installtasks.push(task.install);
- })
- }
- }));
- });
- return Promise.all(downloadtasks).then(() => { return any(installtasks) })
- }
-
- function initinstances(chessinstances, selected) {
- chessinstances.current_run.instanceName = processedArgs._[1] = processedArgs._[1] || chessinstances.current_run.instanceName || selected.instanceName;
- chessinstances.current_run.node_env = processedArgs.node_env = processedArgs.node_env || chessinstances.current_run.node_env || selected.node_env;
- chessinstances[chessinstances.current_run.instanceName] = chessinstances[chessinstances.current_run.instanceName] || {};
- selectedinstance = Object.assign(selected, chessinstances[chessinstances.current_run.instanceName][chessinstances.current_run.node_env], clioverrides);
- repomanifest = selectedinstance;
- return chessinstances
- }
- function acquirelocalinstances(selected){
- var chessinstances = bbhverse.assign(commonjsRequire(path__default['default'].normalize(selected.root + '/chessinstances.js'),"/$$rollup_base$$"));
- return initinstances(chessinstances, selected)
- }
- var detectedInstance = detectInstance(); // From launch location etc.
- var selectedinstance = detectedInstance;
- var clioverrides = { };
- processedArgs._[1] ? clioverrides.instanceName = processedArgs._[1]: null;
- processedArgs.node_env ? clioverrides.node_env = (process.env.NODE_ENV && process.env.NODE_ENV.trim()) || processedArgs.node_env
- : (process.env.NODE_ENV && process.env.NODE_ENV.trim()) ? clioverrides.node_env = (process.env.NODE_ENV && process.env.NODE_ENV.trim()): null;
-
- var maintask = () => {
- try {
- // Default cmd to run !
- var chessinstances = acquirelocalinstances(selectedinstance);
- processedArgs._[0] === processedArgs._[0] || 'pull';
- // defaultRepoServer = repomanifest.reposervers[0] // PB : TODO -- Attempt first one that is available and online from all that are available...
- return acquireConfig(selectedinstance, chessinstances).catch((e) => {
- console.error('Exisitng config Failed. Fix config and rerun or chose another.');
- console.error(e);
- }).then(() => { return elxrworker(true) })
- }
- catch (e) {
- console.error(e);
- // No local instances config found. We acquire user choices and proceed to reattempt.
- chessinstances = {};
- chessinstances.current_run = {};
- initinstances(chessinstances, selectedinstance);
- return acquireChoices(selectedinstance).then(() => {
- try {
- var chessinstances = acquirelocalinstances(selectedinstance);
- }
- catch (e) {
- console.error(e);
- console.error('No local instances config found in current root = ' + selectedinstance.root);
- console.log('A config will be createed with the instance and environment chosen...');
- }
- finally {
-
- return acquireConfig(selectedinstance, chessinstances).catch((e) => {
- console.error('Chosen cofiguraton failed or not found');
- console.error(e);
- }).then(() => { return elxrworker() })
- .finally(()=>{
- fs.writeFileSync('run.log', ', ' + JSON.stringify({ error: e.message }), { 'flag': 'a+' });
- fs.writeFileSync('run.done', 'error');
- // return process.exit()
- })
- }
- })
- }
- };
-
- acquireElevationState().then(() => {
- if (!__isElevated) mainTasks.push(verifyAndInstallPrerequisites);
- mainTasks.push(maintask);
- return any(mainTasks);
- });
-
- // Sample instances config.
- // var instances = {
- // "elixir": {
- // "production": {
- // "reposervers": ["http://git.bbh", "https://git.bbh.org.in"]
- // , "repos": ["ember-masonry-grid", "client", "elixir-client"]
- // , "exludeMergeRepos": {
- // "elixir-config-development": true, "elixir-config-test": true
- // , "elixir-config-production": true, "elixir-data": true
- // }
- // , "instanceName": "elixir", "node_env": "production"
- // }
- // },
- // "current_run": { "instanceName": "elixir", "node_env": "production" }
- // }
-
- var elxr_1 = {
-
- };
-
- module.exports = elxr_1;
|