index.js 465 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
  3. typeof define === 'function' && define.amd ? define(factory) :
  4. (factory());
  5. }(this, (function () { 'use strict';
  6. function unwrapExports (x) {
  7. return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
  8. }
  9. function createCommonjsModule(fn, module) {
  10. return module = { exports: {} }, fn(module, module.exports), module.exports;
  11. }
  12. var _global = createCommonjsModule(function (module) {
  13. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  14. var global = module.exports = typeof window != 'undefined' && window.Math == Math
  15. ? window : typeof self != 'undefined' && self.Math == Math ? self
  16. // eslint-disable-next-line no-new-func
  17. : Function('return this')();
  18. if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef
  19. });
  20. var _core = createCommonjsModule(function (module) {
  21. var core = module.exports = { version: '2.5.7' };
  22. if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef
  23. });
  24. var _core_1 = _core.version;
  25. var _aFunction = function (it) {
  26. if (typeof it != 'function') throw TypeError(it + ' is not a function!');
  27. return it;
  28. };
  29. // optional / simple context binding
  30. var _ctx = function (fn, that, length) {
  31. _aFunction(fn);
  32. if (that === undefined) return fn;
  33. switch (length) {
  34. case 1: return function (a) {
  35. return fn.call(that, a);
  36. };
  37. case 2: return function (a, b) {
  38. return fn.call(that, a, b);
  39. };
  40. case 3: return function (a, b, c) {
  41. return fn.call(that, a, b, c);
  42. };
  43. }
  44. return function (/* ...args */) {
  45. return fn.apply(that, arguments);
  46. };
  47. };
  48. var _isObject = function (it) {
  49. return typeof it === 'object' ? it !== null : typeof it === 'function';
  50. };
  51. var _anObject = function (it) {
  52. if (!_isObject(it)) throw TypeError(it + ' is not an object!');
  53. return it;
  54. };
  55. var _fails = function (exec) {
  56. try {
  57. return !!exec();
  58. } catch (e) {
  59. return true;
  60. }
  61. };
  62. // Thank's IE8 for his funny defineProperty
  63. var _descriptors = !_fails(function () {
  64. return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
  65. });
  66. var document$1 = _global.document;
  67. // typeof document.createElement is 'object' in old IE
  68. var is = _isObject(document$1) && _isObject(document$1.createElement);
  69. var _domCreate = function (it) {
  70. return is ? document$1.createElement(it) : {};
  71. };
  72. var _ie8DomDefine = !_descriptors && !_fails(function () {
  73. return Object.defineProperty(_domCreate('div'), 'a', { get: function () { return 7; } }).a != 7;
  74. });
  75. // 7.1.1 ToPrimitive(input [, PreferredType])
  76. // instead of the ES6 spec version, we didn't implement @@toPrimitive case
  77. // and the second argument - flag - preferred type is a string
  78. var _toPrimitive = function (it, S) {
  79. if (!_isObject(it)) return it;
  80. var fn, val;
  81. if (S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val;
  82. if (typeof (fn = it.valueOf) == 'function' && !_isObject(val = fn.call(it))) return val;
  83. if (!S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val;
  84. throw TypeError("Can't convert object to primitive value");
  85. };
  86. var dP = Object.defineProperty;
  87. var f = _descriptors ? Object.defineProperty : function defineProperty(O, P, Attributes) {
  88. _anObject(O);
  89. P = _toPrimitive(P, true);
  90. _anObject(Attributes);
  91. if (_ie8DomDefine) try {
  92. return dP(O, P, Attributes);
  93. } catch (e) { /* empty */ }
  94. if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
  95. if ('value' in Attributes) O[P] = Attributes.value;
  96. return O;
  97. };
  98. var _objectDp = {
  99. f: f
  100. };
  101. var _propertyDesc = function (bitmap, value) {
  102. return {
  103. enumerable: !(bitmap & 1),
  104. configurable: !(bitmap & 2),
  105. writable: !(bitmap & 4),
  106. value: value
  107. };
  108. };
  109. var _hide = _descriptors ? function (object, key, value) {
  110. return _objectDp.f(object, key, _propertyDesc(1, value));
  111. } : function (object, key, value) {
  112. object[key] = value;
  113. return object;
  114. };
  115. var hasOwnProperty = {}.hasOwnProperty;
  116. var _has = function (it, key) {
  117. return hasOwnProperty.call(it, key);
  118. };
  119. var PROTOTYPE = 'prototype';
  120. var $export = function (type, name, source) {
  121. var IS_FORCED = type & $export.F;
  122. var IS_GLOBAL = type & $export.G;
  123. var IS_STATIC = type & $export.S;
  124. var IS_PROTO = type & $export.P;
  125. var IS_BIND = type & $export.B;
  126. var IS_WRAP = type & $export.W;
  127. var exports = IS_GLOBAL ? _core : _core[name] || (_core[name] = {});
  128. var expProto = exports[PROTOTYPE];
  129. var target = IS_GLOBAL ? _global : IS_STATIC ? _global[name] : (_global[name] || {})[PROTOTYPE];
  130. var key, own, out;
  131. if (IS_GLOBAL) source = name;
  132. for (key in source) {
  133. // contains in native
  134. own = !IS_FORCED && target && target[key] !== undefined;
  135. if (own && _has(exports, key)) continue;
  136. // export native or passed
  137. out = own ? target[key] : source[key];
  138. // prevent global pollution for namespaces
  139. exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key]
  140. // bind timers to global for call from export context
  141. : IS_BIND && own ? _ctx(out, _global)
  142. // wrap global constructors for prevent change them in library
  143. : IS_WRAP && target[key] == out ? (function (C) {
  144. var F = function (a, b, c) {
  145. if (this instanceof C) {
  146. switch (arguments.length) {
  147. case 0: return new C();
  148. case 1: return new C(a);
  149. case 2: return new C(a, b);
  150. } return new C(a, b, c);
  151. } return C.apply(this, arguments);
  152. };
  153. F[PROTOTYPE] = C[PROTOTYPE];
  154. return F;
  155. // make static versions for prototype methods
  156. })(out) : IS_PROTO && typeof out == 'function' ? _ctx(Function.call, out) : out;
  157. // export proto methods to core.%CONSTRUCTOR%.methods.%NAME%
  158. if (IS_PROTO) {
  159. (exports.virtual || (exports.virtual = {}))[key] = out;
  160. // export proto methods to core.%CONSTRUCTOR%.prototype.%NAME%
  161. if (type & $export.R && expProto && !expProto[key]) _hide(expProto, key, out);
  162. }
  163. }
  164. };
  165. // type bitmap
  166. $export.F = 1; // forced
  167. $export.G = 2; // global
  168. $export.S = 4; // static
  169. $export.P = 8; // proto
  170. $export.B = 16; // bind
  171. $export.W = 32; // wrap
  172. $export.U = 64; // safe
  173. $export.R = 128; // real proto method for `library`
  174. var _export = $export;
  175. var toString$1 = {}.toString;
  176. var _cof = function (it) {
  177. return toString$1.call(it).slice(8, -1);
  178. };
  179. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  180. // eslint-disable-next-line no-prototype-builtins
  181. var _iobject = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
  182. return _cof(it) == 'String' ? it.split('') : Object(it);
  183. };
  184. // 7.2.1 RequireObjectCoercible(argument)
  185. var _defined = function (it) {
  186. if (it == undefined) throw TypeError("Can't call method on " + it);
  187. return it;
  188. };
  189. // to indexed object, toObject with fallback for non-array-like ES3 strings
  190. var _toIobject = function (it) {
  191. return _iobject(_defined(it));
  192. };
  193. // 7.1.4 ToInteger
  194. var ceil = Math.ceil;
  195. var floor = Math.floor;
  196. var _toInteger = function (it) {
  197. return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
  198. };
  199. // 7.1.15 ToLength
  200. var min = Math.min;
  201. var _toLength = function (it) {
  202. return it > 0 ? min(_toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
  203. };
  204. var max = Math.max;
  205. var min$1 = Math.min;
  206. var _toAbsoluteIndex = function (index, length) {
  207. index = _toInteger(index);
  208. return index < 0 ? max(index + length, 0) : min$1(index, length);
  209. };
  210. // false -> Array#indexOf
  211. // true -> Array#includes
  212. var _arrayIncludes = function (IS_INCLUDES) {
  213. return function ($this, el, fromIndex) {
  214. var O = _toIobject($this);
  215. var length = _toLength(O.length);
  216. var index = _toAbsoluteIndex(fromIndex, length);
  217. var value;
  218. // Array#includes uses SameValueZero equality algorithm
  219. // eslint-disable-next-line no-self-compare
  220. if (IS_INCLUDES && el != el) while (length > index) {
  221. value = O[index++];
  222. // eslint-disable-next-line no-self-compare
  223. if (value != value) return true;
  224. // Array#indexOf ignores holes, Array#includes - not
  225. } else for (;length > index; index++) if (IS_INCLUDES || index in O) {
  226. if (O[index] === el) return IS_INCLUDES || index || 0;
  227. } return !IS_INCLUDES && -1;
  228. };
  229. };
  230. var _library = true;
  231. var _shared = createCommonjsModule(function (module) {
  232. var SHARED = '__core-js_shared__';
  233. var store = _global[SHARED] || (_global[SHARED] = {});
  234. (module.exports = function (key, value) {
  235. return store[key] || (store[key] = value !== undefined ? value : {});
  236. })('versions', []).push({
  237. version: _core.version,
  238. mode: _library ? 'pure' : 'global',
  239. copyright: '© 2018 Denis Pushkarev (zloirock.ru)'
  240. });
  241. });
  242. var id = 0;
  243. var px = Math.random();
  244. var _uid = function (key) {
  245. return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
  246. };
  247. var shared = _shared('keys');
  248. var _sharedKey = function (key) {
  249. return shared[key] || (shared[key] = _uid(key));
  250. };
  251. var arrayIndexOf = _arrayIncludes(false);
  252. var IE_PROTO = _sharedKey('IE_PROTO');
  253. var _objectKeysInternal = function (object, names) {
  254. var O = _toIobject(object);
  255. var i = 0;
  256. var result = [];
  257. var key;
  258. for (key in O) if (key != IE_PROTO) _has(O, key) && result.push(key);
  259. // Don't enum bug & hidden keys
  260. while (names.length > i) if (_has(O, key = names[i++])) {
  261. ~arrayIndexOf(result, key) || result.push(key);
  262. }
  263. return result;
  264. };
  265. // IE 8- don't enum bug keys
  266. var _enumBugKeys = (
  267. 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
  268. ).split(',');
  269. // 19.1.2.14 / 15.2.3.14 Object.keys(O)
  270. var _objectKeys = Object.keys || function keys(O) {
  271. return _objectKeysInternal(O, _enumBugKeys);
  272. };
  273. var f$1 = Object.getOwnPropertySymbols;
  274. var _objectGops = {
  275. f: f$1
  276. };
  277. var f$2 = {}.propertyIsEnumerable;
  278. var _objectPie = {
  279. f: f$2
  280. };
  281. // 7.1.13 ToObject(argument)
  282. var _toObject = function (it) {
  283. return Object(_defined(it));
  284. };
  285. // 19.1.2.1 Object.assign(target, source, ...)
  286. var $assign = Object.assign;
  287. // should work with symbols and should have deterministic property order (V8 bug)
  288. var _objectAssign = !$assign || _fails(function () {
  289. var A = {};
  290. var B = {};
  291. // eslint-disable-next-line no-undef
  292. var S = Symbol();
  293. var K = 'abcdefghijklmnopqrst';
  294. A[S] = 7;
  295. K.split('').forEach(function (k) { B[k] = k; });
  296. return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
  297. }) ? function assign(target, source) { // eslint-disable-line no-unused-vars
  298. var T = _toObject(target);
  299. var aLen = arguments.length;
  300. var index = 1;
  301. var getSymbols = _objectGops.f;
  302. var isEnum = _objectPie.f;
  303. while (aLen > index) {
  304. var S = _iobject(arguments[index++]);
  305. var keys = getSymbols ? _objectKeys(S).concat(getSymbols(S)) : _objectKeys(S);
  306. var length = keys.length;
  307. var j = 0;
  308. var key;
  309. while (length > j) if (isEnum.call(S, key = keys[j++])) T[key] = S[key];
  310. } return T;
  311. } : $assign;
  312. // 19.1.3.1 Object.assign(target, source)
  313. _export(_export.S + _export.F, 'Object', { assign: _objectAssign });
  314. var assign = _core.Object.assign;
  315. var assign$1 = createCommonjsModule(function (module) {
  316. module.exports = { "default": assign, __esModule: true };
  317. });
  318. var _Object$assign = unwrapExports(assign$1);
  319. // true -> String#at
  320. // false -> String#codePointAt
  321. var _stringAt = function (TO_STRING) {
  322. return function (that, pos) {
  323. var s = String(_defined(that));
  324. var i = _toInteger(pos);
  325. var l = s.length;
  326. var a, b;
  327. if (i < 0 || i >= l) return TO_STRING ? '' : undefined;
  328. a = s.charCodeAt(i);
  329. return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
  330. ? TO_STRING ? s.charAt(i) : a
  331. : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
  332. };
  333. };
  334. var _redefine = _hide;
  335. var _iterators = {};
  336. var _objectDps = _descriptors ? Object.defineProperties : function defineProperties(O, Properties) {
  337. _anObject(O);
  338. var keys = _objectKeys(Properties);
  339. var length = keys.length;
  340. var i = 0;
  341. var P;
  342. while (length > i) _objectDp.f(O, P = keys[i++], Properties[P]);
  343. return O;
  344. };
  345. var document$2 = _global.document;
  346. var _html = document$2 && document$2.documentElement;
  347. // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
  348. var IE_PROTO$1 = _sharedKey('IE_PROTO');
  349. var Empty = function () { /* empty */ };
  350. var PROTOTYPE$1 = 'prototype';
  351. // Create object with fake `null` prototype: use iframe Object with cleared prototype
  352. var createDict = function () {
  353. // Thrash, waste and sodomy: IE GC bug
  354. var iframe = _domCreate('iframe');
  355. var i = _enumBugKeys.length;
  356. var lt = '<';
  357. var gt = '>';
  358. var iframeDocument;
  359. iframe.style.display = 'none';
  360. _html.appendChild(iframe);
  361. iframe.src = 'javascript:'; // eslint-disable-line no-script-url
  362. // createDict = iframe.contentWindow.Object;
  363. // html.removeChild(iframe);
  364. iframeDocument = iframe.contentWindow.document;
  365. iframeDocument.open();
  366. iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
  367. iframeDocument.close();
  368. createDict = iframeDocument.F;
  369. while (i--) delete createDict[PROTOTYPE$1][_enumBugKeys[i]];
  370. return createDict();
  371. };
  372. var _objectCreate = Object.create || function create(O, Properties) {
  373. var result;
  374. if (O !== null) {
  375. Empty[PROTOTYPE$1] = _anObject(O);
  376. result = new Empty();
  377. Empty[PROTOTYPE$1] = null;
  378. // add "__proto__" for Object.getPrototypeOf polyfill
  379. result[IE_PROTO$1] = O;
  380. } else result = createDict();
  381. return Properties === undefined ? result : _objectDps(result, Properties);
  382. };
  383. var _wks = createCommonjsModule(function (module) {
  384. var store = _shared('wks');
  385. var Symbol = _global.Symbol;
  386. var USE_SYMBOL = typeof Symbol == 'function';
  387. var $exports = module.exports = function (name) {
  388. return store[name] || (store[name] =
  389. USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : _uid)('Symbol.' + name));
  390. };
  391. $exports.store = store;
  392. });
  393. var def = _objectDp.f;
  394. var TAG = _wks('toStringTag');
  395. var _setToStringTag = function (it, tag, stat) {
  396. if (it && !_has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag });
  397. };
  398. var IteratorPrototype = {};
  399. // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
  400. _hide(IteratorPrototype, _wks('iterator'), function () { return this; });
  401. var _iterCreate = function (Constructor, NAME, next) {
  402. Constructor.prototype = _objectCreate(IteratorPrototype, { next: _propertyDesc(1, next) });
  403. _setToStringTag(Constructor, NAME + ' Iterator');
  404. };
  405. // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
  406. var IE_PROTO$2 = _sharedKey('IE_PROTO');
  407. var ObjectProto = Object.prototype;
  408. var _objectGpo = Object.getPrototypeOf || function (O) {
  409. O = _toObject(O);
  410. if (_has(O, IE_PROTO$2)) return O[IE_PROTO$2];
  411. if (typeof O.constructor == 'function' && O instanceof O.constructor) {
  412. return O.constructor.prototype;
  413. } return O instanceof Object ? ObjectProto : null;
  414. };
  415. var ITERATOR = _wks('iterator');
  416. var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next`
  417. var FF_ITERATOR = '@@iterator';
  418. var KEYS = 'keys';
  419. var VALUES = 'values';
  420. var returnThis = function () { return this; };
  421. var _iterDefine = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
  422. _iterCreate(Constructor, NAME, next);
  423. var getMethod = function (kind) {
  424. if (!BUGGY && kind in proto) return proto[kind];
  425. switch (kind) {
  426. case KEYS: return function keys() { return new Constructor(this, kind); };
  427. case VALUES: return function values() { return new Constructor(this, kind); };
  428. } return function entries() { return new Constructor(this, kind); };
  429. };
  430. var TAG = NAME + ' Iterator';
  431. var DEF_VALUES = DEFAULT == VALUES;
  432. var VALUES_BUG = false;
  433. var proto = Base.prototype;
  434. var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
  435. var $default = $native || getMethod(DEFAULT);
  436. var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
  437. var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
  438. var methods, key, IteratorPrototype;
  439. // Fix native
  440. if ($anyNative) {
  441. IteratorPrototype = _objectGpo($anyNative.call(new Base()));
  442. if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
  443. // Set @@toStringTag to native iterators
  444. _setToStringTag(IteratorPrototype, TAG, true);
  445. // fix for some old engines
  446. if (!_library && typeof IteratorPrototype[ITERATOR] != 'function') _hide(IteratorPrototype, ITERATOR, returnThis);
  447. }
  448. }
  449. // fix Array#{values, @@iterator}.name in V8 / FF
  450. if (DEF_VALUES && $native && $native.name !== VALUES) {
  451. VALUES_BUG = true;
  452. $default = function values() { return $native.call(this); };
  453. }
  454. // Define iterator
  455. if ((!_library || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {
  456. _hide(proto, ITERATOR, $default);
  457. }
  458. // Plug for library
  459. _iterators[NAME] = $default;
  460. _iterators[TAG] = returnThis;
  461. if (DEFAULT) {
  462. methods = {
  463. values: DEF_VALUES ? $default : getMethod(VALUES),
  464. keys: IS_SET ? $default : getMethod(KEYS),
  465. entries: $entries
  466. };
  467. if (FORCED) for (key in methods) {
  468. if (!(key in proto)) _redefine(proto, key, methods[key]);
  469. } else _export(_export.P + _export.F * (BUGGY || VALUES_BUG), NAME, methods);
  470. }
  471. return methods;
  472. };
  473. var $at = _stringAt(true);
  474. // 21.1.3.27 String.prototype[@@iterator]()
  475. _iterDefine(String, 'String', function (iterated) {
  476. this._t = String(iterated); // target
  477. this._i = 0; // next index
  478. // 21.1.5.2.1 %StringIteratorPrototype%.next()
  479. }, function () {
  480. var O = this._t;
  481. var index = this._i;
  482. var point;
  483. if (index >= O.length) return { value: undefined, done: true };
  484. point = $at(O, index);
  485. this._i += point.length;
  486. return { value: point, done: false };
  487. });
  488. var _iterStep = function (done, value) {
  489. return { value: value, done: !!done };
  490. };
  491. // 22.1.3.4 Array.prototype.entries()
  492. // 22.1.3.13 Array.prototype.keys()
  493. // 22.1.3.29 Array.prototype.values()
  494. // 22.1.3.30 Array.prototype[@@iterator]()
  495. var es6_array_iterator = _iterDefine(Array, 'Array', function (iterated, kind) {
  496. this._t = _toIobject(iterated); // target
  497. this._i = 0; // next index
  498. this._k = kind; // kind
  499. // 22.1.5.2.1 %ArrayIteratorPrototype%.next()
  500. }, function () {
  501. var O = this._t;
  502. var kind = this._k;
  503. var index = this._i++;
  504. if (!O || index >= O.length) {
  505. this._t = undefined;
  506. return _iterStep(1);
  507. }
  508. if (kind == 'keys') return _iterStep(0, index);
  509. if (kind == 'values') return _iterStep(0, O[index]);
  510. return _iterStep(0, [index, O[index]]);
  511. }, 'values');
  512. // argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
  513. _iterators.Arguments = _iterators.Array;
  514. var TO_STRING_TAG = _wks('toStringTag');
  515. var DOMIterables = ('CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,' +
  516. 'DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,' +
  517. 'MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,' +
  518. 'SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,' +
  519. 'TextTrackList,TouchList').split(',');
  520. for (var i = 0; i < DOMIterables.length; i++) {
  521. var NAME = DOMIterables[i];
  522. var Collection = _global[NAME];
  523. var proto = Collection && Collection.prototype;
  524. if (proto && !proto[TO_STRING_TAG]) _hide(proto, TO_STRING_TAG, NAME);
  525. _iterators[NAME] = _iterators.Array;
  526. }
  527. // getting tag from 19.1.3.6 Object.prototype.toString()
  528. var TAG$1 = _wks('toStringTag');
  529. // ES3 wrong here
  530. var ARG = _cof(function () { return arguments; }()) == 'Arguments';
  531. // fallback for IE11 Script Access Denied error
  532. var tryGet = function (it, key) {
  533. try {
  534. return it[key];
  535. } catch (e) { /* empty */ }
  536. };
  537. var _classof = function (it) {
  538. var O, T, B;
  539. return it === undefined ? 'Undefined' : it === null ? 'Null'
  540. // @@toStringTag case
  541. : typeof (T = tryGet(O = Object(it), TAG$1)) == 'string' ? T
  542. // builtinTag case
  543. : ARG ? _cof(O)
  544. // ES3 arguments fallback
  545. : (B = _cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
  546. };
  547. var _anInstance = function (it, Constructor, name, forbiddenField) {
  548. if (!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)) {
  549. throw TypeError(name + ': incorrect invocation!');
  550. } return it;
  551. };
  552. // call something on iterator step with safe closing on error
  553. var _iterCall = function (iterator, fn, value, entries) {
  554. try {
  555. return entries ? fn(_anObject(value)[0], value[1]) : fn(value);
  556. // 7.4.6 IteratorClose(iterator, completion)
  557. } catch (e) {
  558. var ret = iterator['return'];
  559. if (ret !== undefined) _anObject(ret.call(iterator));
  560. throw e;
  561. }
  562. };
  563. // check on default Array iterator
  564. var ITERATOR$1 = _wks('iterator');
  565. var ArrayProto = Array.prototype;
  566. var _isArrayIter = function (it) {
  567. return it !== undefined && (_iterators.Array === it || ArrayProto[ITERATOR$1] === it);
  568. };
  569. var ITERATOR$2 = _wks('iterator');
  570. var core_getIteratorMethod = _core.getIteratorMethod = function (it) {
  571. if (it != undefined) return it[ITERATOR$2]
  572. || it['@@iterator']
  573. || _iterators[_classof(it)];
  574. };
  575. var _forOf = createCommonjsModule(function (module) {
  576. var BREAK = {};
  577. var RETURN = {};
  578. var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) {
  579. var iterFn = ITERATOR ? function () { return iterable; } : core_getIteratorMethod(iterable);
  580. var f = _ctx(fn, that, entries ? 2 : 1);
  581. var index = 0;
  582. var length, step, iterator, result;
  583. if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!');
  584. // fast case for arrays with default iterator
  585. if (_isArrayIter(iterFn)) for (length = _toLength(iterable.length); length > index; index++) {
  586. result = entries ? f(_anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
  587. if (result === BREAK || result === RETURN) return result;
  588. } else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) {
  589. result = _iterCall(iterator, f, step.value, entries);
  590. if (result === BREAK || result === RETURN) return result;
  591. }
  592. };
  593. exports.BREAK = BREAK;
  594. exports.RETURN = RETURN;
  595. });
  596. // 7.3.20 SpeciesConstructor(O, defaultConstructor)
  597. var SPECIES = _wks('species');
  598. var _speciesConstructor = function (O, D) {
  599. var C = _anObject(O).constructor;
  600. var S;
  601. return C === undefined || (S = _anObject(C)[SPECIES]) == undefined ? D : _aFunction(S);
  602. };
  603. // fast apply, http://jsperf.lnkit.com/fast-apply/5
  604. var _invoke = function (fn, args, that) {
  605. var un = that === undefined;
  606. switch (args.length) {
  607. case 0: return un ? fn()
  608. : fn.call(that);
  609. case 1: return un ? fn(args[0])
  610. : fn.call(that, args[0]);
  611. case 2: return un ? fn(args[0], args[1])
  612. : fn.call(that, args[0], args[1]);
  613. case 3: return un ? fn(args[0], args[1], args[2])
  614. : fn.call(that, args[0], args[1], args[2]);
  615. case 4: return un ? fn(args[0], args[1], args[2], args[3])
  616. : fn.call(that, args[0], args[1], args[2], args[3]);
  617. } return fn.apply(that, args);
  618. };
  619. var process = _global.process;
  620. var setTask = _global.setImmediate;
  621. var clearTask = _global.clearImmediate;
  622. var MessageChannel = _global.MessageChannel;
  623. var Dispatch = _global.Dispatch;
  624. var counter = 0;
  625. var queue = {};
  626. var ONREADYSTATECHANGE = 'onreadystatechange';
  627. var defer, channel, port;
  628. var run = function () {
  629. var id = +this;
  630. // eslint-disable-next-line no-prototype-builtins
  631. if (queue.hasOwnProperty(id)) {
  632. var fn = queue[id];
  633. delete queue[id];
  634. fn();
  635. }
  636. };
  637. var listener = function (event) {
  638. run.call(event.data);
  639. };
  640. // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
  641. if (!setTask || !clearTask) {
  642. setTask = function setImmediate(fn) {
  643. var args = [];
  644. var i = 1;
  645. while (arguments.length > i) args.push(arguments[i++]);
  646. queue[++counter] = function () {
  647. // eslint-disable-next-line no-new-func
  648. _invoke(typeof fn == 'function' ? fn : Function(fn), args);
  649. };
  650. defer(counter);
  651. return counter;
  652. };
  653. clearTask = function clearImmediate(id) {
  654. delete queue[id];
  655. };
  656. // Node.js 0.8-
  657. if (_cof(process) == 'process') {
  658. defer = function (id) {
  659. process.nextTick(_ctx(run, id, 1));
  660. };
  661. // Sphere (JS game engine) Dispatch API
  662. } else if (Dispatch && Dispatch.now) {
  663. defer = function (id) {
  664. Dispatch.now(_ctx(run, id, 1));
  665. };
  666. // Browsers with MessageChannel, includes WebWorkers
  667. } else if (MessageChannel) {
  668. channel = new MessageChannel();
  669. port = channel.port2;
  670. channel.port1.onmessage = listener;
  671. defer = _ctx(port.postMessage, port, 1);
  672. // Browsers with postMessage, skip WebWorkers
  673. // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
  674. } else if (_global.addEventListener && typeof postMessage == 'function' && !_global.importScripts) {
  675. defer = function (id) {
  676. _global.postMessage(id + '', '*');
  677. };
  678. _global.addEventListener('message', listener, false);
  679. // IE8-
  680. } else if (ONREADYSTATECHANGE in _domCreate('script')) {
  681. defer = function (id) {
  682. _html.appendChild(_domCreate('script'))[ONREADYSTATECHANGE] = function () {
  683. _html.removeChild(this);
  684. run.call(id);
  685. };
  686. };
  687. // Rest old browsers
  688. } else {
  689. defer = function (id) {
  690. setTimeout(_ctx(run, id, 1), 0);
  691. };
  692. }
  693. }
  694. var _task = {
  695. set: setTask,
  696. clear: clearTask
  697. };
  698. var macrotask = _task.set;
  699. var Observer = _global.MutationObserver || _global.WebKitMutationObserver;
  700. var process$1 = _global.process;
  701. var Promise = _global.Promise;
  702. var isNode = _cof(process$1) == 'process';
  703. var _microtask = function () {
  704. var head, last, notify;
  705. var flush = function () {
  706. var parent, fn;
  707. if (isNode && (parent = process$1.domain)) parent.exit();
  708. while (head) {
  709. fn = head.fn;
  710. head = head.next;
  711. try {
  712. fn();
  713. } catch (e) {
  714. if (head) notify();
  715. else last = undefined;
  716. throw e;
  717. }
  718. } last = undefined;
  719. if (parent) parent.enter();
  720. };
  721. // Node.js
  722. if (isNode) {
  723. notify = function () {
  724. process$1.nextTick(flush);
  725. };
  726. // browsers with MutationObserver, except iOS Safari - https://github.com/zloirock/core-js/issues/339
  727. } else if (Observer && !(_global.navigator && _global.navigator.standalone)) {
  728. var toggle = true;
  729. var node = document.createTextNode('');
  730. new Observer(flush).observe(node, { characterData: true }); // eslint-disable-line no-new
  731. notify = function () {
  732. node.data = toggle = !toggle;
  733. };
  734. // environments with maybe non-completely correct, but existent Promise
  735. } else if (Promise && Promise.resolve) {
  736. // Promise.resolve without an argument throws an error in LG WebOS 2
  737. var promise = Promise.resolve(undefined);
  738. notify = function () {
  739. promise.then(flush);
  740. };
  741. // for other environments - macrotask based on:
  742. // - setImmediate
  743. // - MessageChannel
  744. // - window.postMessag
  745. // - onreadystatechange
  746. // - setTimeout
  747. } else {
  748. notify = function () {
  749. // strange IE + webpack dev server bug - use .call(global)
  750. macrotask.call(_global, flush);
  751. };
  752. }
  753. return function (fn) {
  754. var task = { fn: fn, next: undefined };
  755. if (last) last.next = task;
  756. if (!head) {
  757. head = task;
  758. notify();
  759. } last = task;
  760. };
  761. };
  762. // 25.4.1.5 NewPromiseCapability(C)
  763. function PromiseCapability(C) {
  764. var resolve, reject;
  765. this.promise = new C(function ($$resolve, $$reject) {
  766. if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');
  767. resolve = $$resolve;
  768. reject = $$reject;
  769. });
  770. this.resolve = _aFunction(resolve);
  771. this.reject = _aFunction(reject);
  772. }
  773. var f$3 = function (C) {
  774. return new PromiseCapability(C);
  775. };
  776. var _newPromiseCapability = {
  777. f: f$3
  778. };
  779. var _perform = function (exec) {
  780. try {
  781. return { e: false, v: exec() };
  782. } catch (e) {
  783. return { e: true, v: e };
  784. }
  785. };
  786. var navigator = _global.navigator;
  787. var _userAgent = navigator && navigator.userAgent || '';
  788. var _promiseResolve = function (C, x) {
  789. _anObject(C);
  790. if (_isObject(x) && x.constructor === C) return x;
  791. var promiseCapability = _newPromiseCapability.f(C);
  792. var resolve = promiseCapability.resolve;
  793. resolve(x);
  794. return promiseCapability.promise;
  795. };
  796. var _redefineAll = function (target, src, safe) {
  797. for (var key in src) {
  798. if (safe && target[key]) target[key] = src[key];
  799. else _hide(target, key, src[key]);
  800. } return target;
  801. };
  802. var SPECIES$1 = _wks('species');
  803. var _setSpecies = function (KEY) {
  804. var C = typeof _core[KEY] == 'function' ? _core[KEY] : _global[KEY];
  805. if (_descriptors && C && !C[SPECIES$1]) _objectDp.f(C, SPECIES$1, {
  806. configurable: true,
  807. get: function () { return this; }
  808. });
  809. };
  810. var ITERATOR$3 = _wks('iterator');
  811. var SAFE_CLOSING = false;
  812. try {
  813. var riter = [7][ITERATOR$3]();
  814. riter['return'] = function () { SAFE_CLOSING = true; };
  815. } catch (e) { /* empty */ }
  816. var _iterDetect = function (exec, skipClosing) {
  817. if (!skipClosing && !SAFE_CLOSING) return false;
  818. var safe = false;
  819. try {
  820. var arr = [7];
  821. var iter = arr[ITERATOR$3]();
  822. iter.next = function () { return { done: safe = true }; };
  823. arr[ITERATOR$3] = function () { return iter; };
  824. exec(arr);
  825. } catch (e) { /* empty */ }
  826. return safe;
  827. };
  828. var task = _task.set;
  829. var microtask = _microtask();
  830. var PROMISE = 'Promise';
  831. var TypeError$1 = _global.TypeError;
  832. var process$2 = _global.process;
  833. var versions = process$2 && process$2.versions;
  834. var v8 = versions && versions.v8 || '';
  835. var $Promise = _global[PROMISE];
  836. var isNode$1 = _classof(process$2) == 'process';
  837. var empty = function () { /* empty */ };
  838. var Internal, newGenericPromiseCapability, OwnPromiseCapability, Wrapper;
  839. var newPromiseCapability = newGenericPromiseCapability = _newPromiseCapability.f;
  840. var USE_NATIVE = !!function () {
  841. try {
  842. // correct subclassing with @@species support
  843. var promise = $Promise.resolve(1);
  844. var FakePromise = (promise.constructor = {})[_wks('species')] = function (exec) {
  845. exec(empty, empty);
  846. };
  847. // unhandled rejections tracking support, NodeJS Promise without it fails @@species test
  848. return (isNode$1 || typeof PromiseRejectionEvent == 'function')
  849. && promise.then(empty) instanceof FakePromise
  850. // v8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
  851. // https://bugs.chromium.org/p/chromium/issues/detail?id=830565
  852. // we can't detect it synchronously, so just check versions
  853. && v8.indexOf('6.6') !== 0
  854. && _userAgent.indexOf('Chrome/66') === -1;
  855. } catch (e) { /* empty */ }
  856. }();
  857. // helpers
  858. var isThenable = function (it) {
  859. var then;
  860. return _isObject(it) && typeof (then = it.then) == 'function' ? then : false;
  861. };
  862. var notify = function (promise, isReject) {
  863. if (promise._n) return;
  864. promise._n = true;
  865. var chain = promise._c;
  866. microtask(function () {
  867. var value = promise._v;
  868. var ok = promise._s == 1;
  869. var i = 0;
  870. var run = function (reaction) {
  871. var handler = ok ? reaction.ok : reaction.fail;
  872. var resolve = reaction.resolve;
  873. var reject = reaction.reject;
  874. var domain = reaction.domain;
  875. var result, then, exited;
  876. try {
  877. if (handler) {
  878. if (!ok) {
  879. if (promise._h == 2) onHandleUnhandled(promise);
  880. promise._h = 1;
  881. }
  882. if (handler === true) result = value;
  883. else {
  884. if (domain) domain.enter();
  885. result = handler(value); // may throw
  886. if (domain) {
  887. domain.exit();
  888. exited = true;
  889. }
  890. }
  891. if (result === reaction.promise) {
  892. reject(TypeError$1('Promise-chain cycle'));
  893. } else if (then = isThenable(result)) {
  894. then.call(result, resolve, reject);
  895. } else resolve(result);
  896. } else reject(value);
  897. } catch (e) {
  898. if (domain && !exited) domain.exit();
  899. reject(e);
  900. }
  901. };
  902. while (chain.length > i) run(chain[i++]); // variable length - can't use forEach
  903. promise._c = [];
  904. promise._n = false;
  905. if (isReject && !promise._h) onUnhandled(promise);
  906. });
  907. };
  908. var onUnhandled = function (promise) {
  909. task.call(_global, function () {
  910. var value = promise._v;
  911. var unhandled = isUnhandled(promise);
  912. var result, handler, console;
  913. if (unhandled) {
  914. result = _perform(function () {
  915. if (isNode$1) {
  916. process$2.emit('unhandledRejection', value, promise);
  917. } else if (handler = _global.onunhandledrejection) {
  918. handler({ promise: promise, reason: value });
  919. } else if ((console = _global.console) && console.error) {
  920. console.error('Unhandled promise rejection', value);
  921. }
  922. });
  923. // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
  924. promise._h = isNode$1 || isUnhandled(promise) ? 2 : 1;
  925. } promise._a = undefined;
  926. if (unhandled && result.e) throw result.v;
  927. });
  928. };
  929. var isUnhandled = function (promise) {
  930. return promise._h !== 1 && (promise._a || promise._c).length === 0;
  931. };
  932. var onHandleUnhandled = function (promise) {
  933. task.call(_global, function () {
  934. var handler;
  935. if (isNode$1) {
  936. process$2.emit('rejectionHandled', promise);
  937. } else if (handler = _global.onrejectionhandled) {
  938. handler({ promise: promise, reason: promise._v });
  939. }
  940. });
  941. };
  942. var $reject = function (value) {
  943. var promise = this;
  944. if (promise._d) return;
  945. promise._d = true;
  946. promise = promise._w || promise; // unwrap
  947. promise._v = value;
  948. promise._s = 2;
  949. if (!promise._a) promise._a = promise._c.slice();
  950. notify(promise, true);
  951. };
  952. var $resolve = function (value) {
  953. var promise = this;
  954. var then;
  955. if (promise._d) return;
  956. promise._d = true;
  957. promise = promise._w || promise; // unwrap
  958. try {
  959. if (promise === value) throw TypeError$1("Promise can't be resolved itself");
  960. if (then = isThenable(value)) {
  961. microtask(function () {
  962. var wrapper = { _w: promise, _d: false }; // wrap
  963. try {
  964. then.call(value, _ctx($resolve, wrapper, 1), _ctx($reject, wrapper, 1));
  965. } catch (e) {
  966. $reject.call(wrapper, e);
  967. }
  968. });
  969. } else {
  970. promise._v = value;
  971. promise._s = 1;
  972. notify(promise, false);
  973. }
  974. } catch (e) {
  975. $reject.call({ _w: promise, _d: false }, e); // wrap
  976. }
  977. };
  978. // constructor polyfill
  979. if (!USE_NATIVE) {
  980. // 25.4.3.1 Promise(executor)
  981. $Promise = function Promise(executor) {
  982. _anInstance(this, $Promise, PROMISE, '_h');
  983. _aFunction(executor);
  984. Internal.call(this);
  985. try {
  986. executor(_ctx($resolve, this, 1), _ctx($reject, this, 1));
  987. } catch (err) {
  988. $reject.call(this, err);
  989. }
  990. };
  991. // eslint-disable-next-line no-unused-vars
  992. Internal = function Promise(executor) {
  993. this._c = []; // <- awaiting reactions
  994. this._a = undefined; // <- checked in isUnhandled reactions
  995. this._s = 0; // <- state
  996. this._d = false; // <- done
  997. this._v = undefined; // <- value
  998. this._h = 0; // <- rejection state, 0 - default, 1 - handled, 2 - unhandled
  999. this._n = false; // <- notify
  1000. };
  1001. Internal.prototype = _redefineAll($Promise.prototype, {
  1002. // 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected)
  1003. then: function then(onFulfilled, onRejected) {
  1004. var reaction = newPromiseCapability(_speciesConstructor(this, $Promise));
  1005. reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
  1006. reaction.fail = typeof onRejected == 'function' && onRejected;
  1007. reaction.domain = isNode$1 ? process$2.domain : undefined;
  1008. this._c.push(reaction);
  1009. if (this._a) this._a.push(reaction);
  1010. if (this._s) notify(this, false);
  1011. return reaction.promise;
  1012. },
  1013. // 25.4.5.1 Promise.prototype.catch(onRejected)
  1014. 'catch': function (onRejected) {
  1015. return this.then(undefined, onRejected);
  1016. }
  1017. });
  1018. OwnPromiseCapability = function () {
  1019. var promise = new Internal();
  1020. this.promise = promise;
  1021. this.resolve = _ctx($resolve, promise, 1);
  1022. this.reject = _ctx($reject, promise, 1);
  1023. };
  1024. _newPromiseCapability.f = newPromiseCapability = function (C) {
  1025. return C === $Promise || C === Wrapper
  1026. ? new OwnPromiseCapability(C)
  1027. : newGenericPromiseCapability(C);
  1028. };
  1029. }
  1030. _export(_export.G + _export.W + _export.F * !USE_NATIVE, { Promise: $Promise });
  1031. _setToStringTag($Promise, PROMISE);
  1032. _setSpecies(PROMISE);
  1033. Wrapper = _core[PROMISE];
  1034. // statics
  1035. _export(_export.S + _export.F * !USE_NATIVE, PROMISE, {
  1036. // 25.4.4.5 Promise.reject(r)
  1037. reject: function reject(r) {
  1038. var capability = newPromiseCapability(this);
  1039. var $$reject = capability.reject;
  1040. $$reject(r);
  1041. return capability.promise;
  1042. }
  1043. });
  1044. _export(_export.S + _export.F * (_library || !USE_NATIVE), PROMISE, {
  1045. // 25.4.4.6 Promise.resolve(x)
  1046. resolve: function resolve(x) {
  1047. return _promiseResolve(_library && this === Wrapper ? $Promise : this, x);
  1048. }
  1049. });
  1050. _export(_export.S + _export.F * !(USE_NATIVE && _iterDetect(function (iter) {
  1051. $Promise.all(iter)['catch'](empty);
  1052. })), PROMISE, {
  1053. // 25.4.4.1 Promise.all(iterable)
  1054. all: function all(iterable) {
  1055. var C = this;
  1056. var capability = newPromiseCapability(C);
  1057. var resolve = capability.resolve;
  1058. var reject = capability.reject;
  1059. var result = _perform(function () {
  1060. var values = [];
  1061. var index = 0;
  1062. var remaining = 1;
  1063. _forOf(iterable, false, function (promise) {
  1064. var $index = index++;
  1065. var alreadyCalled = false;
  1066. values.push(undefined);
  1067. remaining++;
  1068. C.resolve(promise).then(function (value) {
  1069. if (alreadyCalled) return;
  1070. alreadyCalled = true;
  1071. values[$index] = value;
  1072. --remaining || resolve(values);
  1073. }, reject);
  1074. });
  1075. --remaining || resolve(values);
  1076. });
  1077. if (result.e) reject(result.v);
  1078. return capability.promise;
  1079. },
  1080. // 25.4.4.4 Promise.race(iterable)
  1081. race: function race(iterable) {
  1082. var C = this;
  1083. var capability = newPromiseCapability(C);
  1084. var reject = capability.reject;
  1085. var result = _perform(function () {
  1086. _forOf(iterable, false, function (promise) {
  1087. C.resolve(promise).then(capability.resolve, reject);
  1088. });
  1089. });
  1090. if (result.e) reject(result.v);
  1091. return capability.promise;
  1092. }
  1093. });
  1094. _export(_export.P + _export.R, 'Promise', { 'finally': function (onFinally) {
  1095. var C = _speciesConstructor(this, _core.Promise || _global.Promise);
  1096. var isFunction = typeof onFinally == 'function';
  1097. return this.then(
  1098. isFunction ? function (x) {
  1099. return _promiseResolve(C, onFinally()).then(function () { return x; });
  1100. } : onFinally,
  1101. isFunction ? function (e) {
  1102. return _promiseResolve(C, onFinally()).then(function () { throw e; });
  1103. } : onFinally
  1104. );
  1105. } });
  1106. // https://github.com/tc39/proposal-promise-try
  1107. _export(_export.S, 'Promise', { 'try': function (callbackfn) {
  1108. var promiseCapability = _newPromiseCapability.f(this);
  1109. var result = _perform(callbackfn);
  1110. (result.e ? promiseCapability.reject : promiseCapability.resolve)(result.v);
  1111. return promiseCapability.promise;
  1112. } });
  1113. var promise = _core.Promise;
  1114. var promise$1 = createCommonjsModule(function (module) {
  1115. module.exports = { "default": promise, __esModule: true };
  1116. });
  1117. var _Promise = unwrapExports(promise$1);
  1118. // most Object methods by ES6 should accept primitives
  1119. var _objectSap = function (KEY, exec) {
  1120. var fn = (_core.Object || {})[KEY] || Object[KEY];
  1121. var exp = {};
  1122. exp[KEY] = exec(fn);
  1123. _export(_export.S + _export.F * _fails(function () { fn(1); }), 'Object', exp);
  1124. };
  1125. // 19.1.2.14 Object.keys(O)
  1126. _objectSap('keys', function () {
  1127. return function keys(it) {
  1128. return _objectKeys(_toObject(it));
  1129. };
  1130. });
  1131. var keys = _core.Object.keys;
  1132. var keys$1 = createCommonjsModule(function (module) {
  1133. module.exports = { "default": keys, __esModule: true };
  1134. });
  1135. var _Object$keys = unwrapExports(keys$1);
  1136. var f$4 = _wks;
  1137. var _wksExt = {
  1138. f: f$4
  1139. };
  1140. var iterator = _wksExt.f('iterator');
  1141. var iterator$1 = createCommonjsModule(function (module) {
  1142. module.exports = { "default": iterator, __esModule: true };
  1143. });
  1144. var _Symbol$iterator = unwrapExports(iterator$1);
  1145. var _meta = createCommonjsModule(function (module) {
  1146. var META = _uid('meta');
  1147. var setDesc = _objectDp.f;
  1148. var id = 0;
  1149. var isExtensible = Object.isExtensible || function () {
  1150. return true;
  1151. };
  1152. var FREEZE = !_fails(function () {
  1153. return isExtensible(Object.preventExtensions({}));
  1154. });
  1155. var setMeta = function (it) {
  1156. setDesc(it, META, { value: {
  1157. i: 'O' + ++id, // object ID
  1158. w: {} // weak collections IDs
  1159. } });
  1160. };
  1161. var fastKey = function (it, create) {
  1162. // return primitive with prefix
  1163. if (!_isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
  1164. if (!_has(it, META)) {
  1165. // can't set metadata to uncaught frozen object
  1166. if (!isExtensible(it)) return 'F';
  1167. // not necessary to add metadata
  1168. if (!create) return 'E';
  1169. // add missing metadata
  1170. setMeta(it);
  1171. // return object ID
  1172. } return it[META].i;
  1173. };
  1174. var getWeak = function (it, create) {
  1175. if (!_has(it, META)) {
  1176. // can't set metadata to uncaught frozen object
  1177. if (!isExtensible(it)) return true;
  1178. // not necessary to add metadata
  1179. if (!create) return false;
  1180. // add missing metadata
  1181. setMeta(it);
  1182. // return hash weak collections IDs
  1183. } return it[META].w;
  1184. };
  1185. // add metadata on freeze-family methods calling
  1186. var onFreeze = function (it) {
  1187. if (FREEZE && meta.NEED && isExtensible(it) && !_has(it, META)) setMeta(it);
  1188. return it;
  1189. };
  1190. var meta = module.exports = {
  1191. KEY: META,
  1192. NEED: false,
  1193. fastKey: fastKey,
  1194. getWeak: getWeak,
  1195. onFreeze: onFreeze
  1196. };
  1197. });
  1198. var _meta_1 = _meta.KEY;
  1199. var _meta_2 = _meta.NEED;
  1200. var _meta_3 = _meta.fastKey;
  1201. var _meta_4 = _meta.getWeak;
  1202. var _meta_5 = _meta.onFreeze;
  1203. var defineProperty = _objectDp.f;
  1204. var _wksDefine = function (name) {
  1205. var $Symbol = _core.Symbol || (_core.Symbol = _library ? {} : _global.Symbol || {});
  1206. if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, { value: _wksExt.f(name) });
  1207. };
  1208. // all enumerable object keys, includes symbols
  1209. var _enumKeys = function (it) {
  1210. var result = _objectKeys(it);
  1211. var getSymbols = _objectGops.f;
  1212. if (getSymbols) {
  1213. var symbols = getSymbols(it);
  1214. var isEnum = _objectPie.f;
  1215. var i = 0;
  1216. var key;
  1217. while (symbols.length > i) if (isEnum.call(it, key = symbols[i++])) result.push(key);
  1218. } return result;
  1219. };
  1220. // 7.2.2 IsArray(argument)
  1221. var _isArray = Array.isArray || function isArray(arg) {
  1222. return _cof(arg) == 'Array';
  1223. };
  1224. // 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)
  1225. var hiddenKeys = _enumBugKeys.concat('length', 'prototype');
  1226. var f$5 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  1227. return _objectKeysInternal(O, hiddenKeys);
  1228. };
  1229. var _objectGopn = {
  1230. f: f$5
  1231. };
  1232. // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
  1233. var gOPN = _objectGopn.f;
  1234. var toString$2 = {}.toString;
  1235. var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
  1236. ? Object.getOwnPropertyNames(window) : [];
  1237. var getWindowNames = function (it) {
  1238. try {
  1239. return gOPN(it);
  1240. } catch (e) {
  1241. return windowNames.slice();
  1242. }
  1243. };
  1244. var f$6 = function getOwnPropertyNames(it) {
  1245. return windowNames && toString$2.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(_toIobject(it));
  1246. };
  1247. var _objectGopnExt = {
  1248. f: f$6
  1249. };
  1250. var gOPD = Object.getOwnPropertyDescriptor;
  1251. var f$7 = _descriptors ? gOPD : function getOwnPropertyDescriptor(O, P) {
  1252. O = _toIobject(O);
  1253. P = _toPrimitive(P, true);
  1254. if (_ie8DomDefine) try {
  1255. return gOPD(O, P);
  1256. } catch (e) { /* empty */ }
  1257. if (_has(O, P)) return _propertyDesc(!_objectPie.f.call(O, P), O[P]);
  1258. };
  1259. var _objectGopd = {
  1260. f: f$7
  1261. };
  1262. // ECMAScript 6 symbols shim
  1263. var META = _meta.KEY;
  1264. var gOPD$1 = _objectGopd.f;
  1265. var dP$1 = _objectDp.f;
  1266. var gOPN$1 = _objectGopnExt.f;
  1267. var $Symbol = _global.Symbol;
  1268. var $JSON = _global.JSON;
  1269. var _stringify = $JSON && $JSON.stringify;
  1270. var PROTOTYPE$2 = 'prototype';
  1271. var HIDDEN = _wks('_hidden');
  1272. var TO_PRIMITIVE = _wks('toPrimitive');
  1273. var isEnum = {}.propertyIsEnumerable;
  1274. var SymbolRegistry = _shared('symbol-registry');
  1275. var AllSymbols = _shared('symbols');
  1276. var OPSymbols = _shared('op-symbols');
  1277. var ObjectProto$1 = Object[PROTOTYPE$2];
  1278. var USE_NATIVE$1 = typeof $Symbol == 'function';
  1279. var QObject = _global.QObject;
  1280. // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
  1281. var setter = !QObject || !QObject[PROTOTYPE$2] || !QObject[PROTOTYPE$2].findChild;
  1282. // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
  1283. var setSymbolDesc = _descriptors && _fails(function () {
  1284. return _objectCreate(dP$1({}, 'a', {
  1285. get: function () { return dP$1(this, 'a', { value: 7 }).a; }
  1286. })).a != 7;
  1287. }) ? function (it, key, D) {
  1288. var protoDesc = gOPD$1(ObjectProto$1, key);
  1289. if (protoDesc) delete ObjectProto$1[key];
  1290. dP$1(it, key, D);
  1291. if (protoDesc && it !== ObjectProto$1) dP$1(ObjectProto$1, key, protoDesc);
  1292. } : dP$1;
  1293. var wrap = function (tag) {
  1294. var sym = AllSymbols[tag] = _objectCreate($Symbol[PROTOTYPE$2]);
  1295. sym._k = tag;
  1296. return sym;
  1297. };
  1298. var isSymbol = USE_NATIVE$1 && typeof $Symbol.iterator == 'symbol' ? function (it) {
  1299. return typeof it == 'symbol';
  1300. } : function (it) {
  1301. return it instanceof $Symbol;
  1302. };
  1303. var $defineProperty = function defineProperty(it, key, D) {
  1304. if (it === ObjectProto$1) $defineProperty(OPSymbols, key, D);
  1305. _anObject(it);
  1306. key = _toPrimitive(key, true);
  1307. _anObject(D);
  1308. if (_has(AllSymbols, key)) {
  1309. if (!D.enumerable) {
  1310. if (!_has(it, HIDDEN)) dP$1(it, HIDDEN, _propertyDesc(1, {}));
  1311. it[HIDDEN][key] = true;
  1312. } else {
  1313. if (_has(it, HIDDEN) && it[HIDDEN][key]) it[HIDDEN][key] = false;
  1314. D = _objectCreate(D, { enumerable: _propertyDesc(0, false) });
  1315. } return setSymbolDesc(it, key, D);
  1316. } return dP$1(it, key, D);
  1317. };
  1318. var $defineProperties = function defineProperties(it, P) {
  1319. _anObject(it);
  1320. var keys = _enumKeys(P = _toIobject(P));
  1321. var i = 0;
  1322. var l = keys.length;
  1323. var key;
  1324. while (l > i) $defineProperty(it, key = keys[i++], P[key]);
  1325. return it;
  1326. };
  1327. var $create = function create(it, P) {
  1328. return P === undefined ? _objectCreate(it) : $defineProperties(_objectCreate(it), P);
  1329. };
  1330. var $propertyIsEnumerable = function propertyIsEnumerable(key) {
  1331. var E = isEnum.call(this, key = _toPrimitive(key, true));
  1332. if (this === ObjectProto$1 && _has(AllSymbols, key) && !_has(OPSymbols, key)) return false;
  1333. return E || !_has(this, key) || !_has(AllSymbols, key) || _has(this, HIDDEN) && this[HIDDEN][key] ? E : true;
  1334. };
  1335. var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key) {
  1336. it = _toIobject(it);
  1337. key = _toPrimitive(key, true);
  1338. if (it === ObjectProto$1 && _has(AllSymbols, key) && !_has(OPSymbols, key)) return;
  1339. var D = gOPD$1(it, key);
  1340. if (D && _has(AllSymbols, key) && !(_has(it, HIDDEN) && it[HIDDEN][key])) D.enumerable = true;
  1341. return D;
  1342. };
  1343. var $getOwnPropertyNames = function getOwnPropertyNames(it) {
  1344. var names = gOPN$1(_toIobject(it));
  1345. var result = [];
  1346. var i = 0;
  1347. var key;
  1348. while (names.length > i) {
  1349. if (!_has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META) result.push(key);
  1350. } return result;
  1351. };
  1352. var $getOwnPropertySymbols = function getOwnPropertySymbols(it) {
  1353. var IS_OP = it === ObjectProto$1;
  1354. var names = gOPN$1(IS_OP ? OPSymbols : _toIobject(it));
  1355. var result = [];
  1356. var i = 0;
  1357. var key;
  1358. while (names.length > i) {
  1359. if (_has(AllSymbols, key = names[i++]) && (IS_OP ? _has(ObjectProto$1, key) : true)) result.push(AllSymbols[key]);
  1360. } return result;
  1361. };
  1362. // 19.4.1.1 Symbol([description])
  1363. if (!USE_NATIVE$1) {
  1364. $Symbol = function Symbol() {
  1365. if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor!');
  1366. var tag = _uid(arguments.length > 0 ? arguments[0] : undefined);
  1367. var $set = function (value) {
  1368. if (this === ObjectProto$1) $set.call(OPSymbols, value);
  1369. if (_has(this, HIDDEN) && _has(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
  1370. setSymbolDesc(this, tag, _propertyDesc(1, value));
  1371. };
  1372. if (_descriptors && setter) setSymbolDesc(ObjectProto$1, tag, { configurable: true, set: $set });
  1373. return wrap(tag);
  1374. };
  1375. _redefine($Symbol[PROTOTYPE$2], 'toString', function toString() {
  1376. return this._k;
  1377. });
  1378. _objectGopd.f = $getOwnPropertyDescriptor;
  1379. _objectDp.f = $defineProperty;
  1380. _objectGopn.f = _objectGopnExt.f = $getOwnPropertyNames;
  1381. _objectPie.f = $propertyIsEnumerable;
  1382. _objectGops.f = $getOwnPropertySymbols;
  1383. if (_descriptors && !_library) {
  1384. _redefine(ObjectProto$1, 'propertyIsEnumerable', $propertyIsEnumerable, true);
  1385. }
  1386. _wksExt.f = function (name) {
  1387. return wrap(_wks(name));
  1388. };
  1389. }
  1390. _export(_export.G + _export.W + _export.F * !USE_NATIVE$1, { Symbol: $Symbol });
  1391. for (var es6Symbols = (
  1392. // 19.4.2.2, 19.4.2.3, 19.4.2.4, 19.4.2.6, 19.4.2.8, 19.4.2.9, 19.4.2.10, 19.4.2.11, 19.4.2.12, 19.4.2.13, 19.4.2.14
  1393. 'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables'
  1394. ).split(','), j = 0; es6Symbols.length > j;)_wks(es6Symbols[j++]);
  1395. for (var wellKnownSymbols = _objectKeys(_wks.store), k = 0; wellKnownSymbols.length > k;) _wksDefine(wellKnownSymbols[k++]);
  1396. _export(_export.S + _export.F * !USE_NATIVE$1, 'Symbol', {
  1397. // 19.4.2.1 Symbol.for(key)
  1398. 'for': function (key) {
  1399. return _has(SymbolRegistry, key += '')
  1400. ? SymbolRegistry[key]
  1401. : SymbolRegistry[key] = $Symbol(key);
  1402. },
  1403. // 19.4.2.5 Symbol.keyFor(sym)
  1404. keyFor: function keyFor(sym) {
  1405. if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol!');
  1406. for (var key in SymbolRegistry) if (SymbolRegistry[key] === sym) return key;
  1407. },
  1408. useSetter: function () { setter = true; },
  1409. useSimple: function () { setter = false; }
  1410. });
  1411. _export(_export.S + _export.F * !USE_NATIVE$1, 'Object', {
  1412. // 19.1.2.2 Object.create(O [, Properties])
  1413. create: $create,
  1414. // 19.1.2.4 Object.defineProperty(O, P, Attributes)
  1415. defineProperty: $defineProperty,
  1416. // 19.1.2.3 Object.defineProperties(O, Properties)
  1417. defineProperties: $defineProperties,
  1418. // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
  1419. getOwnPropertyDescriptor: $getOwnPropertyDescriptor,
  1420. // 19.1.2.7 Object.getOwnPropertyNames(O)
  1421. getOwnPropertyNames: $getOwnPropertyNames,
  1422. // 19.1.2.8 Object.getOwnPropertySymbols(O)
  1423. getOwnPropertySymbols: $getOwnPropertySymbols
  1424. });
  1425. // 24.3.2 JSON.stringify(value [, replacer [, space]])
  1426. $JSON && _export(_export.S + _export.F * (!USE_NATIVE$1 || _fails(function () {
  1427. var S = $Symbol();
  1428. // MS Edge converts symbol values to JSON as {}
  1429. // WebKit converts symbol values to JSON as null
  1430. // V8 throws on boxed symbols
  1431. return _stringify([S]) != '[null]' || _stringify({ a: S }) != '{}' || _stringify(Object(S)) != '{}';
  1432. })), 'JSON', {
  1433. stringify: function stringify(it) {
  1434. var args = [it];
  1435. var i = 1;
  1436. var replacer, $replacer;
  1437. while (arguments.length > i) args.push(arguments[i++]);
  1438. $replacer = replacer = args[1];
  1439. if (!_isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined
  1440. if (!_isArray(replacer)) replacer = function (key, value) {
  1441. if (typeof $replacer == 'function') value = $replacer.call(this, key, value);
  1442. if (!isSymbol(value)) return value;
  1443. };
  1444. args[1] = replacer;
  1445. return _stringify.apply($JSON, args);
  1446. }
  1447. });
  1448. // 19.4.3.4 Symbol.prototype[@@toPrimitive](hint)
  1449. $Symbol[PROTOTYPE$2][TO_PRIMITIVE] || _hide($Symbol[PROTOTYPE$2], TO_PRIMITIVE, $Symbol[PROTOTYPE$2].valueOf);
  1450. // 19.4.3.5 Symbol.prototype[@@toStringTag]
  1451. _setToStringTag($Symbol, 'Symbol');
  1452. // 20.2.1.9 Math[@@toStringTag]
  1453. _setToStringTag(Math, 'Math', true);
  1454. // 24.3.3 JSON[@@toStringTag]
  1455. _setToStringTag(_global.JSON, 'JSON', true);
  1456. _wksDefine('asyncIterator');
  1457. _wksDefine('observable');
  1458. var symbol = _core.Symbol;
  1459. var symbol$1 = createCommonjsModule(function (module) {
  1460. module.exports = { "default": symbol, __esModule: true };
  1461. });
  1462. var _Symbol = unwrapExports(symbol$1);
  1463. var _typeof_1 = createCommonjsModule(function (module, exports) {
  1464. exports.__esModule = true;
  1465. var _iterator2 = _interopRequireDefault(iterator$1);
  1466. var _symbol2 = _interopRequireDefault(symbol$1);
  1467. var _typeof = typeof _symbol2.default === "function" && typeof _iterator2.default === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj; };
  1468. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1469. exports.default = typeof _symbol2.default === "function" && _typeof(_iterator2.default) === "symbol" ? function (obj) {
  1470. return typeof obj === "undefined" ? "undefined" : _typeof(obj);
  1471. } : function (obj) {
  1472. return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof(obj);
  1473. };
  1474. });
  1475. var _typeof = unwrapExports(_typeof_1);
  1476. // 19.1.2.9 Object.getPrototypeOf(O)
  1477. _objectSap('getPrototypeOf', function () {
  1478. return function getPrototypeOf(it) {
  1479. return _objectGpo(_toObject(it));
  1480. };
  1481. });
  1482. var getPrototypeOf = _core.Object.getPrototypeOf;
  1483. var getPrototypeOf$1 = createCommonjsModule(function (module) {
  1484. module.exports = { "default": getPrototypeOf, __esModule: true };
  1485. });
  1486. var _Object$getPrototypeOf = unwrapExports(getPrototypeOf$1);
  1487. var classCallCheck = createCommonjsModule(function (module, exports) {
  1488. exports.__esModule = true;
  1489. exports.default = function (instance, Constructor) {
  1490. if (!(instance instanceof Constructor)) {
  1491. throw new TypeError("Cannot call a class as a function");
  1492. }
  1493. };
  1494. });
  1495. var _classCallCheck = unwrapExports(classCallCheck);
  1496. var possibleConstructorReturn = createCommonjsModule(function (module, exports) {
  1497. exports.__esModule = true;
  1498. var _typeof3 = _interopRequireDefault(_typeof_1);
  1499. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1500. exports.default = function (self, call) {
  1501. if (!self) {
  1502. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  1503. }
  1504. return call && ((typeof call === "undefined" ? "undefined" : (0, _typeof3.default)(call)) === "object" || typeof call === "function") ? call : self;
  1505. };
  1506. });
  1507. var _possibleConstructorReturn = unwrapExports(possibleConstructorReturn);
  1508. // Works with __proto__ only. Old v8 can't work with null proto objects.
  1509. /* eslint-disable no-proto */
  1510. var check = function (O, proto) {
  1511. _anObject(O);
  1512. if (!_isObject(proto) && proto !== null) throw TypeError(proto + ": can't set as prototype!");
  1513. };
  1514. var _setProto = {
  1515. set: Object.setPrototypeOf || ('__proto__' in {} ? // eslint-disable-line
  1516. function (test, buggy, set) {
  1517. try {
  1518. set = _ctx(Function.call, _objectGopd.f(Object.prototype, '__proto__').set, 2);
  1519. set(test, []);
  1520. buggy = !(test instanceof Array);
  1521. } catch (e) { buggy = true; }
  1522. return function setPrototypeOf(O, proto) {
  1523. check(O, proto);
  1524. if (buggy) O.__proto__ = proto;
  1525. else set(O, proto);
  1526. return O;
  1527. };
  1528. }({}, false) : undefined),
  1529. check: check
  1530. };
  1531. // 19.1.3.19 Object.setPrototypeOf(O, proto)
  1532. _export(_export.S, 'Object', { setPrototypeOf: _setProto.set });
  1533. var setPrototypeOf = _core.Object.setPrototypeOf;
  1534. var setPrototypeOf$1 = createCommonjsModule(function (module) {
  1535. module.exports = { "default": setPrototypeOf, __esModule: true };
  1536. });
  1537. unwrapExports(setPrototypeOf$1);
  1538. // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
  1539. _export(_export.S, 'Object', { create: _objectCreate });
  1540. var $Object = _core.Object;
  1541. var create = function create(P, D) {
  1542. return $Object.create(P, D);
  1543. };
  1544. var create$1 = createCommonjsModule(function (module) {
  1545. module.exports = { "default": create, __esModule: true };
  1546. });
  1547. var _Object$create = unwrapExports(create$1);
  1548. var inherits = createCommonjsModule(function (module, exports) {
  1549. exports.__esModule = true;
  1550. var _setPrototypeOf2 = _interopRequireDefault(setPrototypeOf$1);
  1551. var _create2 = _interopRequireDefault(create$1);
  1552. var _typeof3 = _interopRequireDefault(_typeof_1);
  1553. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1554. exports.default = function (subClass, superClass) {
  1555. if (typeof superClass !== "function" && superClass !== null) {
  1556. throw new TypeError("Super expression must either be null or a function, not " + (typeof superClass === "undefined" ? "undefined" : (0, _typeof3.default)(superClass)));
  1557. }
  1558. subClass.prototype = (0, _create2.default)(superClass && superClass.prototype, {
  1559. constructor: {
  1560. value: subClass,
  1561. enumerable: false,
  1562. writable: true,
  1563. configurable: true
  1564. }
  1565. });
  1566. if (superClass) _setPrototypeOf2.default ? (0, _setPrototypeOf2.default)(subClass, superClass) : subClass.__proto__ = superClass;
  1567. };
  1568. });
  1569. var _inherits = unwrapExports(inherits);
  1570. // 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes)
  1571. _export(_export.S + _export.F * !_descriptors, 'Object', { defineProperty: _objectDp.f });
  1572. var $Object$1 = _core.Object;
  1573. var defineProperty$1 = function defineProperty(it, key, desc) {
  1574. return $Object$1.defineProperty(it, key, desc);
  1575. };
  1576. var defineProperty$2 = createCommonjsModule(function (module) {
  1577. module.exports = { "default": defineProperty$1, __esModule: true };
  1578. });
  1579. var _Object$defineProperty = unwrapExports(defineProperty$2);
  1580. var defineProperty$3 = createCommonjsModule(function (module, exports) {
  1581. exports.__esModule = true;
  1582. var _defineProperty2 = _interopRequireDefault(defineProperty$2);
  1583. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1584. exports.default = function (obj, key, value) {
  1585. if (key in obj) {
  1586. (0, _defineProperty2.default)(obj, key, {
  1587. value: value,
  1588. enumerable: true,
  1589. configurable: true,
  1590. writable: true
  1591. });
  1592. } else {
  1593. obj[key] = value;
  1594. }
  1595. return obj;
  1596. };
  1597. });
  1598. var _defineProperty = unwrapExports(defineProperty$3);
  1599. var core_getIterator = _core.getIterator = function (it) {
  1600. var iterFn = core_getIteratorMethod(it);
  1601. if (typeof iterFn != 'function') throw TypeError(it + ' is not iterable!');
  1602. return _anObject(iterFn.call(it));
  1603. };
  1604. var getIterator = core_getIterator;
  1605. var getIterator$1 = createCommonjsModule(function (module) {
  1606. module.exports = { "default": getIterator, __esModule: true };
  1607. });
  1608. var _getIterator = unwrapExports(getIterator$1);
  1609. var _validateCollection = function (it, TYPE) {
  1610. if (!_isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!');
  1611. return it;
  1612. };
  1613. var dP$2 = _objectDp.f;
  1614. var fastKey = _meta.fastKey;
  1615. var SIZE = _descriptors ? '_s' : 'size';
  1616. var getEntry = function (that, key) {
  1617. // fast case
  1618. var index = fastKey(key);
  1619. var entry;
  1620. if (index !== 'F') return that._i[index];
  1621. // frozen object case
  1622. for (entry = that._f; entry; entry = entry.n) {
  1623. if (entry.k == key) return entry;
  1624. }
  1625. };
  1626. var _collectionStrong = {
  1627. getConstructor: function (wrapper, NAME, IS_MAP, ADDER) {
  1628. var C = wrapper(function (that, iterable) {
  1629. _anInstance(that, C, NAME, '_i');
  1630. that._t = NAME; // collection type
  1631. that._i = _objectCreate(null); // index
  1632. that._f = undefined; // first entry
  1633. that._l = undefined; // last entry
  1634. that[SIZE] = 0; // size
  1635. if (iterable != undefined) _forOf(iterable, IS_MAP, that[ADDER], that);
  1636. });
  1637. _redefineAll(C.prototype, {
  1638. // 23.1.3.1 Map.prototype.clear()
  1639. // 23.2.3.2 Set.prototype.clear()
  1640. clear: function clear() {
  1641. for (var that = _validateCollection(this, NAME), data = that._i, entry = that._f; entry; entry = entry.n) {
  1642. entry.r = true;
  1643. if (entry.p) entry.p = entry.p.n = undefined;
  1644. delete data[entry.i];
  1645. }
  1646. that._f = that._l = undefined;
  1647. that[SIZE] = 0;
  1648. },
  1649. // 23.1.3.3 Map.prototype.delete(key)
  1650. // 23.2.3.4 Set.prototype.delete(value)
  1651. 'delete': function (key) {
  1652. var that = _validateCollection(this, NAME);
  1653. var entry = getEntry(that, key);
  1654. if (entry) {
  1655. var next = entry.n;
  1656. var prev = entry.p;
  1657. delete that._i[entry.i];
  1658. entry.r = true;
  1659. if (prev) prev.n = next;
  1660. if (next) next.p = prev;
  1661. if (that._f == entry) that._f = next;
  1662. if (that._l == entry) that._l = prev;
  1663. that[SIZE]--;
  1664. } return !!entry;
  1665. },
  1666. // 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined)
  1667. // 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined)
  1668. forEach: function forEach(callbackfn /* , that = undefined */) {
  1669. _validateCollection(this, NAME);
  1670. var f = _ctx(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3);
  1671. var entry;
  1672. while (entry = entry ? entry.n : this._f) {
  1673. f(entry.v, entry.k, this);
  1674. // revert to the last existing entry
  1675. while (entry && entry.r) entry = entry.p;
  1676. }
  1677. },
  1678. // 23.1.3.7 Map.prototype.has(key)
  1679. // 23.2.3.7 Set.prototype.has(value)
  1680. has: function has(key) {
  1681. return !!getEntry(_validateCollection(this, NAME), key);
  1682. }
  1683. });
  1684. if (_descriptors) dP$2(C.prototype, 'size', {
  1685. get: function () {
  1686. return _validateCollection(this, NAME)[SIZE];
  1687. }
  1688. });
  1689. return C;
  1690. },
  1691. def: function (that, key, value) {
  1692. var entry = getEntry(that, key);
  1693. var prev, index;
  1694. // change existing entry
  1695. if (entry) {
  1696. entry.v = value;
  1697. // create new entry
  1698. } else {
  1699. that._l = entry = {
  1700. i: index = fastKey(key, true), // <- index
  1701. k: key, // <- key
  1702. v: value, // <- value
  1703. p: prev = that._l, // <- previous entry
  1704. n: undefined, // <- next entry
  1705. r: false // <- removed
  1706. };
  1707. if (!that._f) that._f = entry;
  1708. if (prev) prev.n = entry;
  1709. that[SIZE]++;
  1710. // add to index
  1711. if (index !== 'F') that._i[index] = entry;
  1712. } return that;
  1713. },
  1714. getEntry: getEntry,
  1715. setStrong: function (C, NAME, IS_MAP) {
  1716. // add .keys, .values, .entries, [@@iterator]
  1717. // 23.1.3.4, 23.1.3.8, 23.1.3.11, 23.1.3.12, 23.2.3.5, 23.2.3.8, 23.2.3.10, 23.2.3.11
  1718. _iterDefine(C, NAME, function (iterated, kind) {
  1719. this._t = _validateCollection(iterated, NAME); // target
  1720. this._k = kind; // kind
  1721. this._l = undefined; // previous
  1722. }, function () {
  1723. var that = this;
  1724. var kind = that._k;
  1725. var entry = that._l;
  1726. // revert to the last existing entry
  1727. while (entry && entry.r) entry = entry.p;
  1728. // get next entry
  1729. if (!that._t || !(that._l = entry = entry ? entry.n : that._t._f)) {
  1730. // or finish the iteration
  1731. that._t = undefined;
  1732. return _iterStep(1);
  1733. }
  1734. // return step by kind
  1735. if (kind == 'keys') return _iterStep(0, entry.k);
  1736. if (kind == 'values') return _iterStep(0, entry.v);
  1737. return _iterStep(0, [entry.k, entry.v]);
  1738. }, IS_MAP ? 'entries' : 'values', !IS_MAP, true);
  1739. // add [@@species], 23.1.2.2, 23.2.2.2
  1740. _setSpecies(NAME);
  1741. }
  1742. };
  1743. var SPECIES$2 = _wks('species');
  1744. var _arraySpeciesConstructor = function (original) {
  1745. var C;
  1746. if (_isArray(original)) {
  1747. C = original.constructor;
  1748. // cross-realm fallback
  1749. if (typeof C == 'function' && (C === Array || _isArray(C.prototype))) C = undefined;
  1750. if (_isObject(C)) {
  1751. C = C[SPECIES$2];
  1752. if (C === null) C = undefined;
  1753. }
  1754. } return C === undefined ? Array : C;
  1755. };
  1756. // 9.4.2.3 ArraySpeciesCreate(originalArray, length)
  1757. var _arraySpeciesCreate = function (original, length) {
  1758. return new (_arraySpeciesConstructor(original))(length);
  1759. };
  1760. // 0 -> Array#forEach
  1761. // 1 -> Array#map
  1762. // 2 -> Array#filter
  1763. // 3 -> Array#some
  1764. // 4 -> Array#every
  1765. // 5 -> Array#find
  1766. // 6 -> Array#findIndex
  1767. var _arrayMethods = function (TYPE, $create) {
  1768. var IS_MAP = TYPE == 1;
  1769. var IS_FILTER = TYPE == 2;
  1770. var IS_SOME = TYPE == 3;
  1771. var IS_EVERY = TYPE == 4;
  1772. var IS_FIND_INDEX = TYPE == 6;
  1773. var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
  1774. var create = $create || _arraySpeciesCreate;
  1775. return function ($this, callbackfn, that) {
  1776. var O = _toObject($this);
  1777. var self = _iobject(O);
  1778. var f = _ctx(callbackfn, that, 3);
  1779. var length = _toLength(self.length);
  1780. var index = 0;
  1781. var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
  1782. var val, res;
  1783. for (;length > index; index++) if (NO_HOLES || index in self) {
  1784. val = self[index];
  1785. res = f(val, index, O);
  1786. if (TYPE) {
  1787. if (IS_MAP) result[index] = res; // map
  1788. else if (res) switch (TYPE) {
  1789. case 3: return true; // some
  1790. case 5: return val; // find
  1791. case 6: return index; // findIndex
  1792. case 2: result.push(val); // filter
  1793. } else if (IS_EVERY) return false; // every
  1794. }
  1795. }
  1796. return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
  1797. };
  1798. };
  1799. var dP$3 = _objectDp.f;
  1800. var each = _arrayMethods(0);
  1801. var _collection = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) {
  1802. var Base = _global[NAME];
  1803. var C = Base;
  1804. var ADDER = IS_MAP ? 'set' : 'add';
  1805. var proto = C && C.prototype;
  1806. var O = {};
  1807. if (!_descriptors || typeof C != 'function' || !(IS_WEAK || proto.forEach && !_fails(function () {
  1808. new C().entries().next();
  1809. }))) {
  1810. // create collection constructor
  1811. C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER);
  1812. _redefineAll(C.prototype, methods);
  1813. _meta.NEED = true;
  1814. } else {
  1815. C = wrapper(function (target, iterable) {
  1816. _anInstance(target, C, NAME, '_c');
  1817. target._c = new Base();
  1818. if (iterable != undefined) _forOf(iterable, IS_MAP, target[ADDER], target);
  1819. });
  1820. each('add,clear,delete,forEach,get,has,set,keys,values,entries,toJSON'.split(','), function (KEY) {
  1821. var IS_ADDER = KEY == 'add' || KEY == 'set';
  1822. if (KEY in proto && !(IS_WEAK && KEY == 'clear')) _hide(C.prototype, KEY, function (a, b) {
  1823. _anInstance(this, C, KEY);
  1824. if (!IS_ADDER && IS_WEAK && !_isObject(a)) return KEY == 'get' ? undefined : false;
  1825. var result = this._c[KEY](a === 0 ? 0 : a, b);
  1826. return IS_ADDER ? this : result;
  1827. });
  1828. });
  1829. IS_WEAK || dP$3(C.prototype, 'size', {
  1830. get: function () {
  1831. return this._c.size;
  1832. }
  1833. });
  1834. }
  1835. _setToStringTag(C, NAME);
  1836. O[NAME] = C;
  1837. _export(_export.G + _export.W + _export.F, O);
  1838. if (!IS_WEAK) common.setStrong(C, NAME, IS_MAP);
  1839. return C;
  1840. };
  1841. var MAP = 'Map';
  1842. // 23.1 Map Objects
  1843. var es6_map = _collection(MAP, function (get) {
  1844. return function Map() { return get(this, arguments.length > 0 ? arguments[0] : undefined); };
  1845. }, {
  1846. // 23.1.3.6 Map.prototype.get(key)
  1847. get: function get(key) {
  1848. var entry = _collectionStrong.getEntry(_validateCollection(this, MAP), key);
  1849. return entry && entry.v;
  1850. },
  1851. // 23.1.3.9 Map.prototype.set(key, value)
  1852. set: function set(key, value) {
  1853. return _collectionStrong.def(_validateCollection(this, MAP), key === 0 ? 0 : key, value);
  1854. }
  1855. }, _collectionStrong, true);
  1856. var _arrayFromIterable = function (iter, ITERATOR) {
  1857. var result = [];
  1858. _forOf(iter, false, result.push, result, ITERATOR);
  1859. return result;
  1860. };
  1861. // https://github.com/DavidBruant/Map-Set.prototype.toJSON
  1862. var _collectionToJson = function (NAME) {
  1863. return function toJSON() {
  1864. if (_classof(this) != NAME) throw TypeError(NAME + "#toJSON isn't generic");
  1865. return _arrayFromIterable(this);
  1866. };
  1867. };
  1868. // https://github.com/DavidBruant/Map-Set.prototype.toJSON
  1869. _export(_export.P + _export.R, 'Map', { toJSON: _collectionToJson('Map') });
  1870. // https://tc39.github.io/proposal-setmap-offrom/
  1871. var _setCollectionOf = function (COLLECTION) {
  1872. _export(_export.S, COLLECTION, { of: function of() {
  1873. var length = arguments.length;
  1874. var A = new Array(length);
  1875. while (length--) A[length] = arguments[length];
  1876. return new this(A);
  1877. } });
  1878. };
  1879. // https://tc39.github.io/proposal-setmap-offrom/#sec-map.of
  1880. _setCollectionOf('Map');
  1881. // https://tc39.github.io/proposal-setmap-offrom/
  1882. var _setCollectionFrom = function (COLLECTION) {
  1883. _export(_export.S, COLLECTION, { from: function from(source /* , mapFn, thisArg */) {
  1884. var mapFn = arguments[1];
  1885. var mapping, A, n, cb;
  1886. _aFunction(this);
  1887. mapping = mapFn !== undefined;
  1888. if (mapping) _aFunction(mapFn);
  1889. if (source == undefined) return new this();
  1890. A = [];
  1891. if (mapping) {
  1892. n = 0;
  1893. cb = _ctx(mapFn, arguments[2], 2);
  1894. _forOf(source, false, function (nextItem) {
  1895. A.push(cb(nextItem, n++));
  1896. });
  1897. } else {
  1898. _forOf(source, false, A.push, A);
  1899. }
  1900. return new this(A);
  1901. } });
  1902. };
  1903. // https://tc39.github.io/proposal-setmap-offrom/#sec-map.from
  1904. _setCollectionFrom('Map');
  1905. var map = _core.Map;
  1906. var map$1 = createCommonjsModule(function (module) {
  1907. module.exports = { "default": map, __esModule: true };
  1908. });
  1909. var _Map = unwrapExports(map$1);
  1910. var colorName = {
  1911. "aliceblue": [240, 248, 255],
  1912. "antiquewhite": [250, 235, 215],
  1913. "aqua": [0, 255, 255],
  1914. "aquamarine": [127, 255, 212],
  1915. "azure": [240, 255, 255],
  1916. "beige": [245, 245, 220],
  1917. "bisque": [255, 228, 196],
  1918. "black": [0, 0, 0],
  1919. "blanchedalmond": [255, 235, 205],
  1920. "blue": [0, 0, 255],
  1921. "blueviolet": [138, 43, 226],
  1922. "brown": [165, 42, 42],
  1923. "burlywood": [222, 184, 135],
  1924. "cadetblue": [95, 158, 160],
  1925. "chartreuse": [127, 255, 0],
  1926. "chocolate": [210, 105, 30],
  1927. "coral": [255, 127, 80],
  1928. "cornflowerblue": [100, 149, 237],
  1929. "cornsilk": [255, 248, 220],
  1930. "crimson": [220, 20, 60],
  1931. "cyan": [0, 255, 255],
  1932. "darkblue": [0, 0, 139],
  1933. "darkcyan": [0, 139, 139],
  1934. "darkgoldenrod": [184, 134, 11],
  1935. "darkgray": [169, 169, 169],
  1936. "darkgreen": [0, 100, 0],
  1937. "darkgrey": [169, 169, 169],
  1938. "darkkhaki": [189, 183, 107],
  1939. "darkmagenta": [139, 0, 139],
  1940. "darkolivegreen": [85, 107, 47],
  1941. "darkorange": [255, 140, 0],
  1942. "darkorchid": [153, 50, 204],
  1943. "darkred": [139, 0, 0],
  1944. "darksalmon": [233, 150, 122],
  1945. "darkseagreen": [143, 188, 143],
  1946. "darkslateblue": [72, 61, 139],
  1947. "darkslategray": [47, 79, 79],
  1948. "darkslategrey": [47, 79, 79],
  1949. "darkturquoise": [0, 206, 209],
  1950. "darkviolet": [148, 0, 211],
  1951. "deeppink": [255, 20, 147],
  1952. "deepskyblue": [0, 191, 255],
  1953. "dimgray": [105, 105, 105],
  1954. "dimgrey": [105, 105, 105],
  1955. "dodgerblue": [30, 144, 255],
  1956. "firebrick": [178, 34, 34],
  1957. "floralwhite": [255, 250, 240],
  1958. "forestgreen": [34, 139, 34],
  1959. "fuchsia": [255, 0, 255],
  1960. "gainsboro": [220, 220, 220],
  1961. "ghostwhite": [248, 248, 255],
  1962. "gold": [255, 215, 0],
  1963. "goldenrod": [218, 165, 32],
  1964. "gray": [128, 128, 128],
  1965. "green": [0, 128, 0],
  1966. "greenyellow": [173, 255, 47],
  1967. "grey": [128, 128, 128],
  1968. "honeydew": [240, 255, 240],
  1969. "hotpink": [255, 105, 180],
  1970. "indianred": [205, 92, 92],
  1971. "indigo": [75, 0, 130],
  1972. "ivory": [255, 255, 240],
  1973. "khaki": [240, 230, 140],
  1974. "lavender": [230, 230, 250],
  1975. "lavenderblush": [255, 240, 245],
  1976. "lawngreen": [124, 252, 0],
  1977. "lemonchiffon": [255, 250, 205],
  1978. "lightblue": [173, 216, 230],
  1979. "lightcoral": [240, 128, 128],
  1980. "lightcyan": [224, 255, 255],
  1981. "lightgoldenrodyellow": [250, 250, 210],
  1982. "lightgray": [211, 211, 211],
  1983. "lightgreen": [144, 238, 144],
  1984. "lightgrey": [211, 211, 211],
  1985. "lightpink": [255, 182, 193],
  1986. "lightsalmon": [255, 160, 122],
  1987. "lightseagreen": [32, 178, 170],
  1988. "lightskyblue": [135, 206, 250],
  1989. "lightslategray": [119, 136, 153],
  1990. "lightslategrey": [119, 136, 153],
  1991. "lightsteelblue": [176, 196, 222],
  1992. "lightyellow": [255, 255, 224],
  1993. "lime": [0, 255, 0],
  1994. "limegreen": [50, 205, 50],
  1995. "linen": [250, 240, 230],
  1996. "magenta": [255, 0, 255],
  1997. "maroon": [128, 0, 0],
  1998. "mediumaquamarine": [102, 205, 170],
  1999. "mediumblue": [0, 0, 205],
  2000. "mediumorchid": [186, 85, 211],
  2001. "mediumpurple": [147, 112, 219],
  2002. "mediumseagreen": [60, 179, 113],
  2003. "mediumslateblue": [123, 104, 238],
  2004. "mediumspringgreen": [0, 250, 154],
  2005. "mediumturquoise": [72, 209, 204],
  2006. "mediumvioletred": [199, 21, 133],
  2007. "midnightblue": [25, 25, 112],
  2008. "mintcream": [245, 255, 250],
  2009. "mistyrose": [255, 228, 225],
  2010. "moccasin": [255, 228, 181],
  2011. "navajowhite": [255, 222, 173],
  2012. "navy": [0, 0, 128],
  2013. "oldlace": [253, 245, 230],
  2014. "olive": [128, 128, 0],
  2015. "olivedrab": [107, 142, 35],
  2016. "orange": [255, 165, 0],
  2017. "orangered": [255, 69, 0],
  2018. "orchid": [218, 112, 214],
  2019. "palegoldenrod": [238, 232, 170],
  2020. "palegreen": [152, 251, 152],
  2021. "paleturquoise": [175, 238, 238],
  2022. "palevioletred": [219, 112, 147],
  2023. "papayawhip": [255, 239, 213],
  2024. "peachpuff": [255, 218, 185],
  2025. "peru": [205, 133, 63],
  2026. "pink": [255, 192, 203],
  2027. "plum": [221, 160, 221],
  2028. "powderblue": [176, 224, 230],
  2029. "purple": [128, 0, 128],
  2030. "rebeccapurple": [102, 51, 153],
  2031. "red": [255, 0, 0],
  2032. "rosybrown": [188, 143, 143],
  2033. "royalblue": [65, 105, 225],
  2034. "saddlebrown": [139, 69, 19],
  2035. "salmon": [250, 128, 114],
  2036. "sandybrown": [244, 164, 96],
  2037. "seagreen": [46, 139, 87],
  2038. "seashell": [255, 245, 238],
  2039. "sienna": [160, 82, 45],
  2040. "silver": [192, 192, 192],
  2041. "skyblue": [135, 206, 235],
  2042. "slateblue": [106, 90, 205],
  2043. "slategray": [112, 128, 144],
  2044. "slategrey": [112, 128, 144],
  2045. "snow": [255, 250, 250],
  2046. "springgreen": [0, 255, 127],
  2047. "steelblue": [70, 130, 180],
  2048. "tan": [210, 180, 140],
  2049. "teal": [0, 128, 128],
  2050. "thistle": [216, 191, 216],
  2051. "tomato": [255, 99, 71],
  2052. "turquoise": [64, 224, 208],
  2053. "violet": [238, 130, 238],
  2054. "wheat": [245, 222, 179],
  2055. "white": [255, 255, 255],
  2056. "whitesmoke": [245, 245, 245],
  2057. "yellow": [255, 255, 0],
  2058. "yellowgreen": [154, 205, 50]
  2059. };
  2060. var conversions = createCommonjsModule(function (module) {
  2061. /* MIT license */
  2062. // NOTE: conversions should only return primitive values (i.e. arrays, or
  2063. // values that give correct `typeof` results).
  2064. // do not use box values types (i.e. Number(), String(), etc.)
  2065. var reverseKeywords = {};
  2066. for (var key in colorName) {
  2067. if (colorName.hasOwnProperty(key)) {
  2068. reverseKeywords[colorName[key]] = key;
  2069. }
  2070. }
  2071. var convert = module.exports = {
  2072. rgb: {channels: 3, labels: 'rgb'},
  2073. hsl: {channels: 3, labels: 'hsl'},
  2074. hsv: {channels: 3, labels: 'hsv'},
  2075. hwb: {channels: 3, labels: 'hwb'},
  2076. cmyk: {channels: 4, labels: 'cmyk'},
  2077. xyz: {channels: 3, labels: 'xyz'},
  2078. lab: {channels: 3, labels: 'lab'},
  2079. lch: {channels: 3, labels: 'lch'},
  2080. hex: {channels: 1, labels: ['hex']},
  2081. keyword: {channels: 1, labels: ['keyword']},
  2082. ansi16: {channels: 1, labels: ['ansi16']},
  2083. ansi256: {channels: 1, labels: ['ansi256']},
  2084. hcg: {channels: 3, labels: ['h', 'c', 'g']},
  2085. apple: {channels: 3, labels: ['r16', 'g16', 'b16']},
  2086. gray: {channels: 1, labels: ['gray']}
  2087. };
  2088. // hide .channels and .labels properties
  2089. for (var model in convert) {
  2090. if (convert.hasOwnProperty(model)) {
  2091. if (!('channels' in convert[model])) {
  2092. throw new Error('missing channels property: ' + model);
  2093. }
  2094. if (!('labels' in convert[model])) {
  2095. throw new Error('missing channel labels property: ' + model);
  2096. }
  2097. if (convert[model].labels.length !== convert[model].channels) {
  2098. throw new Error('channel and label counts mismatch: ' + model);
  2099. }
  2100. var channels = convert[model].channels;
  2101. var labels = convert[model].labels;
  2102. delete convert[model].channels;
  2103. delete convert[model].labels;
  2104. Object.defineProperty(convert[model], 'channels', {value: channels});
  2105. Object.defineProperty(convert[model], 'labels', {value: labels});
  2106. }
  2107. }
  2108. convert.rgb.hsl = function (rgb) {
  2109. var r = rgb[0] / 255;
  2110. var g = rgb[1] / 255;
  2111. var b = rgb[2] / 255;
  2112. var min = Math.min(r, g, b);
  2113. var max = Math.max(r, g, b);
  2114. var delta = max - min;
  2115. var h;
  2116. var s;
  2117. var l;
  2118. if (max === min) {
  2119. h = 0;
  2120. } else if (r === max) {
  2121. h = (g - b) / delta;
  2122. } else if (g === max) {
  2123. h = 2 + (b - r) / delta;
  2124. } else if (b === max) {
  2125. h = 4 + (r - g) / delta;
  2126. }
  2127. h = Math.min(h * 60, 360);
  2128. if (h < 0) {
  2129. h += 360;
  2130. }
  2131. l = (min + max) / 2;
  2132. if (max === min) {
  2133. s = 0;
  2134. } else if (l <= 0.5) {
  2135. s = delta / (max + min);
  2136. } else {
  2137. s = delta / (2 - max - min);
  2138. }
  2139. return [h, s * 100, l * 100];
  2140. };
  2141. convert.rgb.hsv = function (rgb) {
  2142. var rdif;
  2143. var gdif;
  2144. var bdif;
  2145. var h;
  2146. var s;
  2147. var r = rgb[0] / 255;
  2148. var g = rgb[1] / 255;
  2149. var b = rgb[2] / 255;
  2150. var v = Math.max(r, g, b);
  2151. var diff = v - Math.min(r, g, b);
  2152. var diffc = function (c) {
  2153. return (v - c) / 6 / diff + 1 / 2;
  2154. };
  2155. if (diff === 0) {
  2156. h = s = 0;
  2157. } else {
  2158. s = diff / v;
  2159. rdif = diffc(r);
  2160. gdif = diffc(g);
  2161. bdif = diffc(b);
  2162. if (r === v) {
  2163. h = bdif - gdif;
  2164. } else if (g === v) {
  2165. h = (1 / 3) + rdif - bdif;
  2166. } else if (b === v) {
  2167. h = (2 / 3) + gdif - rdif;
  2168. }
  2169. if (h < 0) {
  2170. h += 1;
  2171. } else if (h > 1) {
  2172. h -= 1;
  2173. }
  2174. }
  2175. return [
  2176. h * 360,
  2177. s * 100,
  2178. v * 100
  2179. ];
  2180. };
  2181. convert.rgb.hwb = function (rgb) {
  2182. var r = rgb[0];
  2183. var g = rgb[1];
  2184. var b = rgb[2];
  2185. var h = convert.rgb.hsl(rgb)[0];
  2186. var w = 1 / 255 * Math.min(r, Math.min(g, b));
  2187. b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
  2188. return [h, w * 100, b * 100];
  2189. };
  2190. convert.rgb.cmyk = function (rgb) {
  2191. var r = rgb[0] / 255;
  2192. var g = rgb[1] / 255;
  2193. var b = rgb[2] / 255;
  2194. var c;
  2195. var m;
  2196. var y;
  2197. var k;
  2198. k = Math.min(1 - r, 1 - g, 1 - b);
  2199. c = (1 - r - k) / (1 - k) || 0;
  2200. m = (1 - g - k) / (1 - k) || 0;
  2201. y = (1 - b - k) / (1 - k) || 0;
  2202. return [c * 100, m * 100, y * 100, k * 100];
  2203. };
  2204. /**
  2205. * See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
  2206. * */
  2207. function comparativeDistance(x, y) {
  2208. return (
  2209. Math.pow(x[0] - y[0], 2) +
  2210. Math.pow(x[1] - y[1], 2) +
  2211. Math.pow(x[2] - y[2], 2)
  2212. );
  2213. }
  2214. convert.rgb.keyword = function (rgb) {
  2215. var reversed = reverseKeywords[rgb];
  2216. if (reversed) {
  2217. return reversed;
  2218. }
  2219. var currentClosestDistance = Infinity;
  2220. var currentClosestKeyword;
  2221. for (var keyword in colorName) {
  2222. if (colorName.hasOwnProperty(keyword)) {
  2223. var value = colorName[keyword];
  2224. // Compute comparative distance
  2225. var distance = comparativeDistance(rgb, value);
  2226. // Check if its less, if so set as closest
  2227. if (distance < currentClosestDistance) {
  2228. currentClosestDistance = distance;
  2229. currentClosestKeyword = keyword;
  2230. }
  2231. }
  2232. }
  2233. return currentClosestKeyword;
  2234. };
  2235. convert.keyword.rgb = function (keyword) {
  2236. return colorName[keyword];
  2237. };
  2238. convert.rgb.xyz = function (rgb) {
  2239. var r = rgb[0] / 255;
  2240. var g = rgb[1] / 255;
  2241. var b = rgb[2] / 255;
  2242. // assume sRGB
  2243. r = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92);
  2244. g = g > 0.04045 ? Math.pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92);
  2245. b = b > 0.04045 ? Math.pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92);
  2246. var x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);
  2247. var y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);
  2248. var z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);
  2249. return [x * 100, y * 100, z * 100];
  2250. };
  2251. convert.rgb.lab = function (rgb) {
  2252. var xyz = convert.rgb.xyz(rgb);
  2253. var x = xyz[0];
  2254. var y = xyz[1];
  2255. var z = xyz[2];
  2256. var l;
  2257. var a;
  2258. var b;
  2259. x /= 95.047;
  2260. y /= 100;
  2261. z /= 108.883;
  2262. x = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116);
  2263. y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116);
  2264. z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116);
  2265. l = (116 * y) - 16;
  2266. a = 500 * (x - y);
  2267. b = 200 * (y - z);
  2268. return [l, a, b];
  2269. };
  2270. convert.hsl.rgb = function (hsl) {
  2271. var h = hsl[0] / 360;
  2272. var s = hsl[1] / 100;
  2273. var l = hsl[2] / 100;
  2274. var t1;
  2275. var t2;
  2276. var t3;
  2277. var rgb;
  2278. var val;
  2279. if (s === 0) {
  2280. val = l * 255;
  2281. return [val, val, val];
  2282. }
  2283. if (l < 0.5) {
  2284. t2 = l * (1 + s);
  2285. } else {
  2286. t2 = l + s - l * s;
  2287. }
  2288. t1 = 2 * l - t2;
  2289. rgb = [0, 0, 0];
  2290. for (var i = 0; i < 3; i++) {
  2291. t3 = h + 1 / 3 * -(i - 1);
  2292. if (t3 < 0) {
  2293. t3++;
  2294. }
  2295. if (t3 > 1) {
  2296. t3--;
  2297. }
  2298. if (6 * t3 < 1) {
  2299. val = t1 + (t2 - t1) * 6 * t3;
  2300. } else if (2 * t3 < 1) {
  2301. val = t2;
  2302. } else if (3 * t3 < 2) {
  2303. val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
  2304. } else {
  2305. val = t1;
  2306. }
  2307. rgb[i] = val * 255;
  2308. }
  2309. return rgb;
  2310. };
  2311. convert.hsl.hsv = function (hsl) {
  2312. var h = hsl[0];
  2313. var s = hsl[1] / 100;
  2314. var l = hsl[2] / 100;
  2315. var smin = s;
  2316. var lmin = Math.max(l, 0.01);
  2317. var sv;
  2318. var v;
  2319. l *= 2;
  2320. s *= (l <= 1) ? l : 2 - l;
  2321. smin *= lmin <= 1 ? lmin : 2 - lmin;
  2322. v = (l + s) / 2;
  2323. sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s);
  2324. return [h, sv * 100, v * 100];
  2325. };
  2326. convert.hsv.rgb = function (hsv) {
  2327. var h = hsv[0] / 60;
  2328. var s = hsv[1] / 100;
  2329. var v = hsv[2] / 100;
  2330. var hi = Math.floor(h) % 6;
  2331. var f = h - Math.floor(h);
  2332. var p = 255 * v * (1 - s);
  2333. var q = 255 * v * (1 - (s * f));
  2334. var t = 255 * v * (1 - (s * (1 - f)));
  2335. v *= 255;
  2336. switch (hi) {
  2337. case 0:
  2338. return [v, t, p];
  2339. case 1:
  2340. return [q, v, p];
  2341. case 2:
  2342. return [p, v, t];
  2343. case 3:
  2344. return [p, q, v];
  2345. case 4:
  2346. return [t, p, v];
  2347. case 5:
  2348. return [v, p, q];
  2349. }
  2350. };
  2351. convert.hsv.hsl = function (hsv) {
  2352. var h = hsv[0];
  2353. var s = hsv[1] / 100;
  2354. var v = hsv[2] / 100;
  2355. var vmin = Math.max(v, 0.01);
  2356. var lmin;
  2357. var sl;
  2358. var l;
  2359. l = (2 - s) * v;
  2360. lmin = (2 - s) * vmin;
  2361. sl = s * vmin;
  2362. sl /= (lmin <= 1) ? lmin : 2 - lmin;
  2363. sl = sl || 0;
  2364. l /= 2;
  2365. return [h, sl * 100, l * 100];
  2366. };
  2367. // http://dev.w3.org/csswg/css-color/#hwb-to-rgb
  2368. convert.hwb.rgb = function (hwb) {
  2369. var h = hwb[0] / 360;
  2370. var wh = hwb[1] / 100;
  2371. var bl = hwb[2] / 100;
  2372. var ratio = wh + bl;
  2373. var i;
  2374. var v;
  2375. var f;
  2376. var n;
  2377. // wh + bl cant be > 1
  2378. if (ratio > 1) {
  2379. wh /= ratio;
  2380. bl /= ratio;
  2381. }
  2382. i = Math.floor(6 * h);
  2383. v = 1 - bl;
  2384. f = 6 * h - i;
  2385. if ((i & 0x01) !== 0) {
  2386. f = 1 - f;
  2387. }
  2388. n = wh + f * (v - wh); // linear interpolation
  2389. var r;
  2390. var g;
  2391. var b;
  2392. switch (i) {
  2393. default:
  2394. case 6:
  2395. case 0: r = v; g = n; b = wh; break;
  2396. case 1: r = n; g = v; b = wh; break;
  2397. case 2: r = wh; g = v; b = n; break;
  2398. case 3: r = wh; g = n; b = v; break;
  2399. case 4: r = n; g = wh; b = v; break;
  2400. case 5: r = v; g = wh; b = n; break;
  2401. }
  2402. return [r * 255, g * 255, b * 255];
  2403. };
  2404. convert.cmyk.rgb = function (cmyk) {
  2405. var c = cmyk[0] / 100;
  2406. var m = cmyk[1] / 100;
  2407. var y = cmyk[2] / 100;
  2408. var k = cmyk[3] / 100;
  2409. var r;
  2410. var g;
  2411. var b;
  2412. r = 1 - Math.min(1, c * (1 - k) + k);
  2413. g = 1 - Math.min(1, m * (1 - k) + k);
  2414. b = 1 - Math.min(1, y * (1 - k) + k);
  2415. return [r * 255, g * 255, b * 255];
  2416. };
  2417. convert.xyz.rgb = function (xyz) {
  2418. var x = xyz[0] / 100;
  2419. var y = xyz[1] / 100;
  2420. var z = xyz[2] / 100;
  2421. var r;
  2422. var g;
  2423. var b;
  2424. r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);
  2425. g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);
  2426. b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);
  2427. // assume sRGB
  2428. r = r > 0.0031308
  2429. ? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055)
  2430. : r * 12.92;
  2431. g = g > 0.0031308
  2432. ? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055)
  2433. : g * 12.92;
  2434. b = b > 0.0031308
  2435. ? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055)
  2436. : b * 12.92;
  2437. r = Math.min(Math.max(0, r), 1);
  2438. g = Math.min(Math.max(0, g), 1);
  2439. b = Math.min(Math.max(0, b), 1);
  2440. return [r * 255, g * 255, b * 255];
  2441. };
  2442. convert.xyz.lab = function (xyz) {
  2443. var x = xyz[0];
  2444. var y = xyz[1];
  2445. var z = xyz[2];
  2446. var l;
  2447. var a;
  2448. var b;
  2449. x /= 95.047;
  2450. y /= 100;
  2451. z /= 108.883;
  2452. x = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116);
  2453. y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116);
  2454. z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116);
  2455. l = (116 * y) - 16;
  2456. a = 500 * (x - y);
  2457. b = 200 * (y - z);
  2458. return [l, a, b];
  2459. };
  2460. convert.lab.xyz = function (lab) {
  2461. var l = lab[0];
  2462. var a = lab[1];
  2463. var b = lab[2];
  2464. var x;
  2465. var y;
  2466. var z;
  2467. y = (l + 16) / 116;
  2468. x = a / 500 + y;
  2469. z = y - b / 200;
  2470. var y2 = Math.pow(y, 3);
  2471. var x2 = Math.pow(x, 3);
  2472. var z2 = Math.pow(z, 3);
  2473. y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
  2474. x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
  2475. z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
  2476. x *= 95.047;
  2477. y *= 100;
  2478. z *= 108.883;
  2479. return [x, y, z];
  2480. };
  2481. convert.lab.lch = function (lab) {
  2482. var l = lab[0];
  2483. var a = lab[1];
  2484. var b = lab[2];
  2485. var hr;
  2486. var h;
  2487. var c;
  2488. hr = Math.atan2(b, a);
  2489. h = hr * 360 / 2 / Math.PI;
  2490. if (h < 0) {
  2491. h += 360;
  2492. }
  2493. c = Math.sqrt(a * a + b * b);
  2494. return [l, c, h];
  2495. };
  2496. convert.lch.lab = function (lch) {
  2497. var l = lch[0];
  2498. var c = lch[1];
  2499. var h = lch[2];
  2500. var a;
  2501. var b;
  2502. var hr;
  2503. hr = h / 360 * 2 * Math.PI;
  2504. a = c * Math.cos(hr);
  2505. b = c * Math.sin(hr);
  2506. return [l, a, b];
  2507. };
  2508. convert.rgb.ansi16 = function (args) {
  2509. var r = args[0];
  2510. var g = args[1];
  2511. var b = args[2];
  2512. var value = 1 in arguments ? arguments[1] : convert.rgb.hsv(args)[2]; // hsv -> ansi16 optimization
  2513. value = Math.round(value / 50);
  2514. if (value === 0) {
  2515. return 30;
  2516. }
  2517. var ansi = 30
  2518. + ((Math.round(b / 255) << 2)
  2519. | (Math.round(g / 255) << 1)
  2520. | Math.round(r / 255));
  2521. if (value === 2) {
  2522. ansi += 60;
  2523. }
  2524. return ansi;
  2525. };
  2526. convert.hsv.ansi16 = function (args) {
  2527. // optimization here; we already know the value and don't need to get
  2528. // it converted for us.
  2529. return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
  2530. };
  2531. convert.rgb.ansi256 = function (args) {
  2532. var r = args[0];
  2533. var g = args[1];
  2534. var b = args[2];
  2535. // we use the extended greyscale palette here, with the exception of
  2536. // black and white. normal palette only has 4 greyscale shades.
  2537. if (r === g && g === b) {
  2538. if (r < 8) {
  2539. return 16;
  2540. }
  2541. if (r > 248) {
  2542. return 231;
  2543. }
  2544. return Math.round(((r - 8) / 247) * 24) + 232;
  2545. }
  2546. var ansi = 16
  2547. + (36 * Math.round(r / 255 * 5))
  2548. + (6 * Math.round(g / 255 * 5))
  2549. + Math.round(b / 255 * 5);
  2550. return ansi;
  2551. };
  2552. convert.ansi16.rgb = function (args) {
  2553. var color = args % 10;
  2554. // handle greyscale
  2555. if (color === 0 || color === 7) {
  2556. if (args > 50) {
  2557. color += 3.5;
  2558. }
  2559. color = color / 10.5 * 255;
  2560. return [color, color, color];
  2561. }
  2562. var mult = (~~(args > 50) + 1) * 0.5;
  2563. var r = ((color & 1) * mult) * 255;
  2564. var g = (((color >> 1) & 1) * mult) * 255;
  2565. var b = (((color >> 2) & 1) * mult) * 255;
  2566. return [r, g, b];
  2567. };
  2568. convert.ansi256.rgb = function (args) {
  2569. // handle greyscale
  2570. if (args >= 232) {
  2571. var c = (args - 232) * 10 + 8;
  2572. return [c, c, c];
  2573. }
  2574. args -= 16;
  2575. var rem;
  2576. var r = Math.floor(args / 36) / 5 * 255;
  2577. var g = Math.floor((rem = args % 36) / 6) / 5 * 255;
  2578. var b = (rem % 6) / 5 * 255;
  2579. return [r, g, b];
  2580. };
  2581. convert.rgb.hex = function (args) {
  2582. var integer = ((Math.round(args[0]) & 0xFF) << 16)
  2583. + ((Math.round(args[1]) & 0xFF) << 8)
  2584. + (Math.round(args[2]) & 0xFF);
  2585. var string = integer.toString(16).toUpperCase();
  2586. return '000000'.substring(string.length) + string;
  2587. };
  2588. convert.hex.rgb = function (args) {
  2589. var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
  2590. if (!match) {
  2591. return [0, 0, 0];
  2592. }
  2593. var colorString = match[0];
  2594. if (match[0].length === 3) {
  2595. colorString = colorString.split('').map(function (char) {
  2596. return char + char;
  2597. }).join('');
  2598. }
  2599. var integer = parseInt(colorString, 16);
  2600. var r = (integer >> 16) & 0xFF;
  2601. var g = (integer >> 8) & 0xFF;
  2602. var b = integer & 0xFF;
  2603. return [r, g, b];
  2604. };
  2605. convert.rgb.hcg = function (rgb) {
  2606. var r = rgb[0] / 255;
  2607. var g = rgb[1] / 255;
  2608. var b = rgb[2] / 255;
  2609. var max = Math.max(Math.max(r, g), b);
  2610. var min = Math.min(Math.min(r, g), b);
  2611. var chroma = (max - min);
  2612. var grayscale;
  2613. var hue;
  2614. if (chroma < 1) {
  2615. grayscale = min / (1 - chroma);
  2616. } else {
  2617. grayscale = 0;
  2618. }
  2619. if (chroma <= 0) {
  2620. hue = 0;
  2621. } else
  2622. if (max === r) {
  2623. hue = ((g - b) / chroma) % 6;
  2624. } else
  2625. if (max === g) {
  2626. hue = 2 + (b - r) / chroma;
  2627. } else {
  2628. hue = 4 + (r - g) / chroma + 4;
  2629. }
  2630. hue /= 6;
  2631. hue %= 1;
  2632. return [hue * 360, chroma * 100, grayscale * 100];
  2633. };
  2634. convert.hsl.hcg = function (hsl) {
  2635. var s = hsl[1] / 100;
  2636. var l = hsl[2] / 100;
  2637. var c = 1;
  2638. var f = 0;
  2639. if (l < 0.5) {
  2640. c = 2.0 * s * l;
  2641. } else {
  2642. c = 2.0 * s * (1.0 - l);
  2643. }
  2644. if (c < 1.0) {
  2645. f = (l - 0.5 * c) / (1.0 - c);
  2646. }
  2647. return [hsl[0], c * 100, f * 100];
  2648. };
  2649. convert.hsv.hcg = function (hsv) {
  2650. var s = hsv[1] / 100;
  2651. var v = hsv[2] / 100;
  2652. var c = s * v;
  2653. var f = 0;
  2654. if (c < 1.0) {
  2655. f = (v - c) / (1 - c);
  2656. }
  2657. return [hsv[0], c * 100, f * 100];
  2658. };
  2659. convert.hcg.rgb = function (hcg) {
  2660. var h = hcg[0] / 360;
  2661. var c = hcg[1] / 100;
  2662. var g = hcg[2] / 100;
  2663. if (c === 0.0) {
  2664. return [g * 255, g * 255, g * 255];
  2665. }
  2666. var pure = [0, 0, 0];
  2667. var hi = (h % 1) * 6;
  2668. var v = hi % 1;
  2669. var w = 1 - v;
  2670. var mg = 0;
  2671. switch (Math.floor(hi)) {
  2672. case 0:
  2673. pure[0] = 1; pure[1] = v; pure[2] = 0; break;
  2674. case 1:
  2675. pure[0] = w; pure[1] = 1; pure[2] = 0; break;
  2676. case 2:
  2677. pure[0] = 0; pure[1] = 1; pure[2] = v; break;
  2678. case 3:
  2679. pure[0] = 0; pure[1] = w; pure[2] = 1; break;
  2680. case 4:
  2681. pure[0] = v; pure[1] = 0; pure[2] = 1; break;
  2682. default:
  2683. pure[0] = 1; pure[1] = 0; pure[2] = w;
  2684. }
  2685. mg = (1.0 - c) * g;
  2686. return [
  2687. (c * pure[0] + mg) * 255,
  2688. (c * pure[1] + mg) * 255,
  2689. (c * pure[2] + mg) * 255
  2690. ];
  2691. };
  2692. convert.hcg.hsv = function (hcg) {
  2693. var c = hcg[1] / 100;
  2694. var g = hcg[2] / 100;
  2695. var v = c + g * (1.0 - c);
  2696. var f = 0;
  2697. if (v > 0.0) {
  2698. f = c / v;
  2699. }
  2700. return [hcg[0], f * 100, v * 100];
  2701. };
  2702. convert.hcg.hsl = function (hcg) {
  2703. var c = hcg[1] / 100;
  2704. var g = hcg[2] / 100;
  2705. var l = g * (1.0 - c) + 0.5 * c;
  2706. var s = 0;
  2707. if (l > 0.0 && l < 0.5) {
  2708. s = c / (2 * l);
  2709. } else
  2710. if (l >= 0.5 && l < 1.0) {
  2711. s = c / (2 * (1 - l));
  2712. }
  2713. return [hcg[0], s * 100, l * 100];
  2714. };
  2715. convert.hcg.hwb = function (hcg) {
  2716. var c = hcg[1] / 100;
  2717. var g = hcg[2] / 100;
  2718. var v = c + g * (1.0 - c);
  2719. return [hcg[0], (v - c) * 100, (1 - v) * 100];
  2720. };
  2721. convert.hwb.hcg = function (hwb) {
  2722. var w = hwb[1] / 100;
  2723. var b = hwb[2] / 100;
  2724. var v = 1 - b;
  2725. var c = v - w;
  2726. var g = 0;
  2727. if (c < 1) {
  2728. g = (v - c) / (1 - c);
  2729. }
  2730. return [hwb[0], c * 100, g * 100];
  2731. };
  2732. convert.apple.rgb = function (apple) {
  2733. return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255];
  2734. };
  2735. convert.rgb.apple = function (rgb) {
  2736. return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535];
  2737. };
  2738. convert.gray.rgb = function (args) {
  2739. return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
  2740. };
  2741. convert.gray.hsl = convert.gray.hsv = function (args) {
  2742. return [0, 0, args[0]];
  2743. };
  2744. convert.gray.hwb = function (gray) {
  2745. return [0, 100, gray[0]];
  2746. };
  2747. convert.gray.cmyk = function (gray) {
  2748. return [0, 0, 0, gray[0]];
  2749. };
  2750. convert.gray.lab = function (gray) {
  2751. return [gray[0], 0, 0];
  2752. };
  2753. convert.gray.hex = function (gray) {
  2754. var val = Math.round(gray[0] / 100 * 255) & 0xFF;
  2755. var integer = (val << 16) + (val << 8) + val;
  2756. var string = integer.toString(16).toUpperCase();
  2757. return '000000'.substring(string.length) + string;
  2758. };
  2759. convert.rgb.gray = function (rgb) {
  2760. var val = (rgb[0] + rgb[1] + rgb[2]) / 3;
  2761. return [val / 255 * 100];
  2762. };
  2763. });
  2764. var conversions_1 = conversions.rgb;
  2765. var conversions_2 = conversions.hsl;
  2766. var conversions_3 = conversions.hsv;
  2767. var conversions_4 = conversions.hwb;
  2768. var conversions_5 = conversions.cmyk;
  2769. var conversions_6 = conversions.xyz;
  2770. var conversions_7 = conversions.lab;
  2771. var conversions_8 = conversions.lch;
  2772. var conversions_9 = conversions.hex;
  2773. var conversions_10 = conversions.keyword;
  2774. var conversions_11 = conversions.ansi16;
  2775. var conversions_12 = conversions.ansi256;
  2776. var conversions_13 = conversions.hcg;
  2777. var conversions_14 = conversions.apple;
  2778. var conversions_15 = conversions.gray;
  2779. /*
  2780. this function routes a model to all other models.
  2781. all functions that are routed have a property `.conversion` attached
  2782. to the returned synthetic function. This property is an array
  2783. of strings, each with the steps in between the 'from' and 'to'
  2784. color models (inclusive).
  2785. conversions that are not possible simply are not included.
  2786. */
  2787. function buildGraph() {
  2788. var graph = {};
  2789. // https://jsperf.com/object-keys-vs-for-in-with-closure/3
  2790. var models = Object.keys(conversions);
  2791. for (var len = models.length, i = 0; i < len; i++) {
  2792. graph[models[i]] = {
  2793. // http://jsperf.com/1-vs-infinity
  2794. // micro-opt, but this is simple.
  2795. distance: -1,
  2796. parent: null
  2797. };
  2798. }
  2799. return graph;
  2800. }
  2801. // https://en.wikipedia.org/wiki/Breadth-first_search
  2802. function deriveBFS(fromModel) {
  2803. var graph = buildGraph();
  2804. var queue = [fromModel]; // unshift -> queue -> pop
  2805. graph[fromModel].distance = 0;
  2806. while (queue.length) {
  2807. var current = queue.pop();
  2808. var adjacents = Object.keys(conversions[current]);
  2809. for (var len = adjacents.length, i = 0; i < len; i++) {
  2810. var adjacent = adjacents[i];
  2811. var node = graph[adjacent];
  2812. if (node.distance === -1) {
  2813. node.distance = graph[current].distance + 1;
  2814. node.parent = current;
  2815. queue.unshift(adjacent);
  2816. }
  2817. }
  2818. }
  2819. return graph;
  2820. }
  2821. function link(from, to) {
  2822. return function (args) {
  2823. return to(from(args));
  2824. };
  2825. }
  2826. function wrapConversion(toModel, graph) {
  2827. var path = [graph[toModel].parent, toModel];
  2828. var fn = conversions[graph[toModel].parent][toModel];
  2829. var cur = graph[toModel].parent;
  2830. while (graph[cur].parent) {
  2831. path.unshift(graph[cur].parent);
  2832. fn = link(conversions[graph[cur].parent][cur], fn);
  2833. cur = graph[cur].parent;
  2834. }
  2835. fn.conversion = path;
  2836. return fn;
  2837. }
  2838. var route = function (fromModel) {
  2839. var graph = deriveBFS(fromModel);
  2840. var conversion = {};
  2841. var models = Object.keys(graph);
  2842. for (var len = models.length, i = 0; i < len; i++) {
  2843. var toModel = models[i];
  2844. var node = graph[toModel];
  2845. if (node.parent === null) {
  2846. // no possible conversion, or this node is the source model.
  2847. continue;
  2848. }
  2849. conversion[toModel] = wrapConversion(toModel, graph);
  2850. }
  2851. return conversion;
  2852. };
  2853. var convert = {};
  2854. var models = Object.keys(conversions);
  2855. function wrapRaw(fn) {
  2856. var wrappedFn = function (args) {
  2857. if (args === undefined || args === null) {
  2858. return args;
  2859. }
  2860. if (arguments.length > 1) {
  2861. args = Array.prototype.slice.call(arguments);
  2862. }
  2863. return fn(args);
  2864. };
  2865. // preserve .conversion property if there is one
  2866. if ('conversion' in fn) {
  2867. wrappedFn.conversion = fn.conversion;
  2868. }
  2869. return wrappedFn;
  2870. }
  2871. function wrapRounded(fn) {
  2872. var wrappedFn = function (args) {
  2873. if (args === undefined || args === null) {
  2874. return args;
  2875. }
  2876. if (arguments.length > 1) {
  2877. args = Array.prototype.slice.call(arguments);
  2878. }
  2879. var result = fn(args);
  2880. // we're assuming the result is an array here.
  2881. // see notice in conversions.js; don't use box types
  2882. // in conversion functions.
  2883. if (typeof result === 'object') {
  2884. for (var len = result.length, i = 0; i < len; i++) {
  2885. result[i] = Math.round(result[i]);
  2886. }
  2887. }
  2888. return result;
  2889. };
  2890. // preserve .conversion property if there is one
  2891. if ('conversion' in fn) {
  2892. wrappedFn.conversion = fn.conversion;
  2893. }
  2894. return wrappedFn;
  2895. }
  2896. models.forEach(function (fromModel) {
  2897. convert[fromModel] = {};
  2898. Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels});
  2899. Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels});
  2900. var routes = route(fromModel);
  2901. var routeModels = Object.keys(routes);
  2902. routeModels.forEach(function (toModel) {
  2903. var fn = routes[toModel];
  2904. convert[fromModel][toModel] = wrapRounded(fn);
  2905. convert[fromModel][toModel].raw = wrapRaw(fn);
  2906. });
  2907. });
  2908. var colorConvert = convert;
  2909. var ansiStyles = createCommonjsModule(function (module) {
  2910. var wrapAnsi16 = function wrapAnsi16(fn, offset) {
  2911. return function () {
  2912. var code = fn.apply(colorConvert, arguments);
  2913. return '\x1B[' + (code + offset) + 'm';
  2914. };
  2915. };
  2916. var wrapAnsi256 = function wrapAnsi256(fn, offset) {
  2917. return function () {
  2918. var code = fn.apply(colorConvert, arguments);
  2919. return '\x1B[' + (38 + offset) + ';5;' + code + 'm';
  2920. };
  2921. };
  2922. var wrapAnsi16m = function wrapAnsi16m(fn, offset) {
  2923. return function () {
  2924. var rgb = fn.apply(colorConvert, arguments);
  2925. return '\x1B[' + (38 + offset) + ';2;' + rgb[0] + ';' + rgb[1] + ';' + rgb[2] + 'm';
  2926. };
  2927. };
  2928. function assembleStyles() {
  2929. var codes = new _Map();
  2930. var styles = {
  2931. modifier: {
  2932. reset: [0, 0],
  2933. // 21 isn't widely supported and 22 does the same thing
  2934. bold: [1, 22],
  2935. dim: [2, 22],
  2936. italic: [3, 23],
  2937. underline: [4, 24],
  2938. inverse: [7, 27],
  2939. hidden: [8, 28],
  2940. strikethrough: [9, 29]
  2941. },
  2942. color: {
  2943. black: [30, 39],
  2944. red: [31, 39],
  2945. green: [32, 39],
  2946. yellow: [33, 39],
  2947. blue: [34, 39],
  2948. magenta: [35, 39],
  2949. cyan: [36, 39],
  2950. white: [37, 39],
  2951. gray: [90, 39],
  2952. // Bright color
  2953. redBright: [91, 39],
  2954. greenBright: [92, 39],
  2955. yellowBright: [93, 39],
  2956. blueBright: [94, 39],
  2957. magentaBright: [95, 39],
  2958. cyanBright: [96, 39],
  2959. whiteBright: [97, 39]
  2960. },
  2961. bgColor: {
  2962. bgBlack: [40, 49],
  2963. bgRed: [41, 49],
  2964. bgGreen: [42, 49],
  2965. bgYellow: [43, 49],
  2966. bgBlue: [44, 49],
  2967. bgMagenta: [45, 49],
  2968. bgCyan: [46, 49],
  2969. bgWhite: [47, 49],
  2970. // Bright color
  2971. bgBlackBright: [100, 49],
  2972. bgRedBright: [101, 49],
  2973. bgGreenBright: [102, 49],
  2974. bgYellowBright: [103, 49],
  2975. bgBlueBright: [104, 49],
  2976. bgMagentaBright: [105, 49],
  2977. bgCyanBright: [106, 49],
  2978. bgWhiteBright: [107, 49]
  2979. }
  2980. };
  2981. // Fix humans
  2982. styles.color.grey = styles.color.gray;
  2983. var _iteratorNormalCompletion = true;
  2984. var _didIteratorError = false;
  2985. var _iteratorError = undefined;
  2986. try {
  2987. for (var _iterator = _getIterator(_Object$keys(styles)), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  2988. var groupName = _step.value;
  2989. var group = styles[groupName];
  2990. var _iteratorNormalCompletion3 = true;
  2991. var _didIteratorError3 = false;
  2992. var _iteratorError3 = undefined;
  2993. try {
  2994. for (var _iterator3 = _getIterator(_Object$keys(group)), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  2995. var styleName = _step3.value;
  2996. var style = group[styleName];
  2997. styles[styleName] = {
  2998. open: '\x1B[' + style[0] + 'm',
  2999. close: '\x1B[' + style[1] + 'm'
  3000. };
  3001. group[styleName] = styles[styleName];
  3002. codes.set(style[0], style[1]);
  3003. }
  3004. } catch (err) {
  3005. _didIteratorError3 = true;
  3006. _iteratorError3 = err;
  3007. } finally {
  3008. try {
  3009. if (!_iteratorNormalCompletion3 && _iterator3.return) {
  3010. _iterator3.return();
  3011. }
  3012. } finally {
  3013. if (_didIteratorError3) {
  3014. throw _iteratorError3;
  3015. }
  3016. }
  3017. }
  3018. _Object$defineProperty(styles, groupName, {
  3019. value: group,
  3020. enumerable: false
  3021. });
  3022. Object.defineProperty(styles, 'codes', {
  3023. value: codes,
  3024. enumerable: false
  3025. });
  3026. }
  3027. } catch (err) {
  3028. _didIteratorError = true;
  3029. _iteratorError = err;
  3030. } finally {
  3031. try {
  3032. if (!_iteratorNormalCompletion && _iterator.return) {
  3033. _iterator.return();
  3034. }
  3035. } finally {
  3036. if (_didIteratorError) {
  3037. throw _iteratorError;
  3038. }
  3039. }
  3040. }
  3041. var ansi2ansi = function ansi2ansi(n) {
  3042. return n;
  3043. };
  3044. var rgb2rgb = function rgb2rgb(r, g, b) {
  3045. return [r, g, b];
  3046. };
  3047. styles.color.close = '\x1B[39m';
  3048. styles.bgColor.close = '\x1B[49m';
  3049. styles.color.ansi = {
  3050. ansi: wrapAnsi16(ansi2ansi, 0)
  3051. };
  3052. styles.color.ansi256 = {
  3053. ansi256: wrapAnsi256(ansi2ansi, 0)
  3054. };
  3055. styles.color.ansi16m = {
  3056. rgb: wrapAnsi16m(rgb2rgb, 0)
  3057. };
  3058. styles.bgColor.ansi = {
  3059. ansi: wrapAnsi16(ansi2ansi, 10)
  3060. };
  3061. styles.bgColor.ansi256 = {
  3062. ansi256: wrapAnsi256(ansi2ansi, 10)
  3063. };
  3064. styles.bgColor.ansi16m = {
  3065. rgb: wrapAnsi16m(rgb2rgb, 10)
  3066. };
  3067. var _iteratorNormalCompletion2 = true;
  3068. var _didIteratorError2 = false;
  3069. var _iteratorError2 = undefined;
  3070. try {
  3071. for (var _iterator2 = _getIterator(_Object$keys(colorConvert)), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  3072. var key = _step2.value;
  3073. if (_typeof(colorConvert[key]) !== 'object') {
  3074. continue;
  3075. }
  3076. var suite = colorConvert[key];
  3077. if (key === 'ansi16') {
  3078. key = 'ansi';
  3079. }
  3080. if ('ansi16' in suite) {
  3081. styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0);
  3082. styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10);
  3083. }
  3084. if ('ansi256' in suite) {
  3085. styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0);
  3086. styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10);
  3087. }
  3088. if ('rgb' in suite) {
  3089. styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0);
  3090. styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10);
  3091. }
  3092. }
  3093. } catch (err) {
  3094. _didIteratorError2 = true;
  3095. _iteratorError2 = err;
  3096. } finally {
  3097. try {
  3098. if (!_iteratorNormalCompletion2 && _iterator2.return) {
  3099. _iterator2.return();
  3100. }
  3101. } finally {
  3102. if (_didIteratorError2) {
  3103. throw _iteratorError2;
  3104. }
  3105. }
  3106. }
  3107. return styles;
  3108. }
  3109. // Make the export immutable
  3110. Object.defineProperty(module, 'exports', {
  3111. enumerable: true,
  3112. get: assembleStyles
  3113. });
  3114. });
  3115. var fake_chalk = createCommonjsModule(function (module) {
  3116. var _ansiStyles2 = _interopRequireDefault(ansiStyles);
  3117. function _interopRequireDefault(obj) {
  3118. return obj && obj.__esModule ? obj : { default: obj };
  3119. }
  3120. var returnInput = function returnInput(str) {
  3121. return str;
  3122. };
  3123. /**
  3124. * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
  3125. *
  3126. * This source code is licensed under the MIT license found in the
  3127. * LICENSE file in the root directory of this source tree.
  3128. *
  3129. */
  3130. var allColorsAsFunc = _Object$keys(_ansiStyles2.default).map(function (style) {
  3131. return _defineProperty({}, style, returnInput);
  3132. }).reduce(function (acc, cur) {
  3133. return _Object$assign(acc, cur);
  3134. });
  3135. _Object$keys(allColorsAsFunc).map(function (color) {
  3136. return allColorsAsFunc[color];
  3137. }).forEach(function (style) {
  3138. _Object$assign(style, allColorsAsFunc);
  3139. _Object$assign(returnInput, style);
  3140. });
  3141. module.exports = allColorsAsFunc;
  3142. });
  3143. unwrapExports(fake_chalk);
  3144. var SET = 'Set';
  3145. // 23.2 Set Objects
  3146. var es6_set = _collection(SET, function (get) {
  3147. return function Set() { return get(this, arguments.length > 0 ? arguments[0] : undefined); };
  3148. }, {
  3149. // 23.2.3.1 Set.prototype.add(value)
  3150. add: function add(value) {
  3151. return _collectionStrong.def(_validateCollection(this, SET), value = value === 0 ? 0 : value, value);
  3152. }
  3153. }, _collectionStrong);
  3154. // https://github.com/DavidBruant/Map-Set.prototype.toJSON
  3155. _export(_export.P + _export.R, 'Set', { toJSON: _collectionToJson('Set') });
  3156. // https://tc39.github.io/proposal-setmap-offrom/#sec-set.of
  3157. _setCollectionOf('Set');
  3158. // https://tc39.github.io/proposal-setmap-offrom/#sec-set.from
  3159. _setCollectionFrom('Set');
  3160. var set = _core.Set;
  3161. var set$1 = createCommonjsModule(function (module) {
  3162. module.exports = { "default": set, __esModule: true };
  3163. });
  3164. var _Set = unwrapExports(set$1);
  3165. var build = createCommonjsModule(function (module) {
  3166. // get the type of a value with handling the edge cases like `typeof []`
  3167. // and `typeof null`
  3168. var getType = function getType(value) {
  3169. if (value === undefined) {
  3170. return 'undefined';
  3171. } else if (value === null) {
  3172. return 'null';
  3173. } else if (Array.isArray(value)) {
  3174. return 'array';
  3175. } else if (typeof value === 'boolean') {
  3176. return 'boolean';
  3177. } else if (typeof value === 'function') {
  3178. return 'function';
  3179. } else if (typeof value === 'number') {
  3180. return 'number';
  3181. } else if (typeof value === 'string') {
  3182. return 'string';
  3183. } else if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') {
  3184. if (value.constructor === RegExp) {
  3185. return 'regexp';
  3186. } else if (value.constructor === _Map) {
  3187. return 'map';
  3188. } else if (value.constructor === _Set) {
  3189. return 'set';
  3190. } else if (value.constructor === Date) {
  3191. return 'date';
  3192. }
  3193. return 'object';
  3194. // $FlowFixMe https://github.com/facebook/flow/issues/1015
  3195. } else if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'symbol') {
  3196. return 'symbol';
  3197. }
  3198. throw new Error('value of unknown type: ' + value);
  3199. };
  3200. module.exports = getType;
  3201. });
  3202. // 7.2.9 SameValue(x, y)
  3203. var _sameValue = Object.is || function is(x, y) {
  3204. // eslint-disable-next-line no-self-compare
  3205. return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y;
  3206. };
  3207. // 19.1.3.10 Object.is(value1, value2)
  3208. _export(_export.S, 'Object', { is: _sameValue });
  3209. var is$1 = _core.Object.is;
  3210. var is$2 = createCommonjsModule(function (module) {
  3211. module.exports = { "default": is$1, __esModule: true };
  3212. });
  3213. var _Object$is = unwrapExports(is$2);
  3214. var getOwnPropertySymbols = _core.Object.getOwnPropertySymbols;
  3215. var getOwnPropertySymbols$1 = createCommonjsModule(function (module) {
  3216. module.exports = { "default": getOwnPropertySymbols, __esModule: true };
  3217. });
  3218. var _Object$getOwnPropertySymbols = unwrapExports(getOwnPropertySymbols$1);
  3219. var collections = createCommonjsModule(function (module, exports) {
  3220. Object.defineProperty(exports, '__esModule', {
  3221. value: true
  3222. });
  3223. exports.printIteratorEntries = printIteratorEntries;
  3224. exports.printIteratorValues = printIteratorValues;
  3225. exports.printListItems = printListItems;
  3226. exports.printObjectProperties = printObjectProperties;
  3227. var getSymbols = _Object$getOwnPropertySymbols || function (obj) {
  3228. return [];
  3229. };
  3230. /**
  3231. * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
  3232. *
  3233. * This source code is licensed under the MIT license found in the
  3234. * LICENSE file in the root directory of this source tree.
  3235. *
  3236. *
  3237. */
  3238. var isSymbol = function isSymbol(key) {
  3239. return (
  3240. // $FlowFixMe string literal `symbol`. This value is not a valid `typeof` return value
  3241. (typeof key === 'undefined' ? 'undefined' : _typeof(key)) === 'symbol' || toString.call(key) === '[object Symbol]'
  3242. );
  3243. };
  3244. // Return entries (for example, of a map)
  3245. // with spacing, indentation, and comma
  3246. // without surrounding punctuation (for example, braces)
  3247. function printIteratorEntries(
  3248. // Flow 0.51.0: property `@@iterator` of $Iterator not found in Object
  3249. iterator, config, indentation, depth, refs, printer) {
  3250. var separator = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : ': ';
  3251. var result = '';
  3252. var current = iterator.next();
  3253. if (!current.done) {
  3254. result += config.spacingOuter;
  3255. var indentationNext = indentation + config.indent;
  3256. while (!current.done) {
  3257. var name = printer(current.value[0], config, indentationNext, depth, refs);
  3258. var value = printer(current.value[1], config, indentationNext, depth, refs);
  3259. result += indentationNext + name + separator + value;
  3260. current = iterator.next();
  3261. if (!current.done) {
  3262. result += ',' + config.spacingInner;
  3263. } else if (!config.min) {
  3264. result += ',';
  3265. }
  3266. }
  3267. result += config.spacingOuter + indentation;
  3268. }
  3269. return result;
  3270. }
  3271. // Return values (for example, of a set)
  3272. // with spacing, indentation, and comma
  3273. // without surrounding punctuation (braces or brackets)
  3274. function printIteratorValues(iterator, config, indentation, depth, refs, printer) {
  3275. var result = '';
  3276. var current = iterator.next();
  3277. if (!current.done) {
  3278. result += config.spacingOuter;
  3279. var indentationNext = indentation + config.indent;
  3280. while (!current.done) {
  3281. result += indentationNext + printer(current.value, config, indentationNext, depth, refs);
  3282. current = iterator.next();
  3283. if (!current.done) {
  3284. result += ',' + config.spacingInner;
  3285. } else if (!config.min) {
  3286. result += ',';
  3287. }
  3288. }
  3289. result += config.spacingOuter + indentation;
  3290. }
  3291. return result;
  3292. }
  3293. // Return items (for example, of an array)
  3294. // with spacing, indentation, and comma
  3295. // without surrounding punctuation (for example, brackets)
  3296. function printListItems(list, config, indentation, depth, refs, printer) {
  3297. var result = '';
  3298. if (list.length) {
  3299. result += config.spacingOuter;
  3300. var indentationNext = indentation + config.indent;
  3301. for (var i = 0; i < list.length; i++) {
  3302. result += indentationNext + printer(list[i], config, indentationNext, depth, refs);
  3303. if (i < list.length - 1) {
  3304. result += ',' + config.spacingInner;
  3305. } else if (!config.min) {
  3306. result += ',';
  3307. }
  3308. }
  3309. result += config.spacingOuter + indentation;
  3310. }
  3311. return result;
  3312. }
  3313. // Return properties of an object
  3314. // with spacing, indentation, and comma
  3315. // without surrounding punctuation (for example, braces)
  3316. function printObjectProperties(val, config, indentation, depth, refs, printer) {
  3317. var result = '';
  3318. var keys = _Object$keys(val).sort();
  3319. var symbols = getSymbols(val);
  3320. if (symbols.length) {
  3321. keys = keys.filter(function (key) {
  3322. return !isSymbol(key);
  3323. }).concat(symbols);
  3324. }
  3325. if (keys.length) {
  3326. result += config.spacingOuter;
  3327. var indentationNext = indentation + config.indent;
  3328. for (var i = 0; i < keys.length; i++) {
  3329. var key = keys[i];
  3330. var name = printer(key, config, indentationNext, depth, refs);
  3331. var value = printer(val[key], config, indentationNext, depth, refs);
  3332. result += indentationNext + name + ': ' + value;
  3333. if (i < keys.length - 1) {
  3334. result += ',' + config.spacingInner;
  3335. } else if (!config.min) {
  3336. result += ',';
  3337. }
  3338. }
  3339. result += config.spacingOuter + indentation;
  3340. }
  3341. return result;
  3342. }
  3343. });
  3344. unwrapExports(collections);
  3345. var collections_1 = collections.printIteratorEntries;
  3346. var collections_2 = collections.printIteratorValues;
  3347. var collections_3 = collections.printListItems;
  3348. var collections_4 = collections.printObjectProperties;
  3349. var _for = _core.Symbol['for'];
  3350. var _for$1 = createCommonjsModule(function (module) {
  3351. module.exports = { "default": _for, __esModule: true };
  3352. });
  3353. var _Symbol$for = unwrapExports(_for$1);
  3354. var asymmetric_matcher = createCommonjsModule(function (module, exports) {
  3355. Object.defineProperty(exports, '__esModule', {
  3356. value: true
  3357. });
  3358. exports.test = exports.serialize = undefined;
  3359. /**
  3360. * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
  3361. *
  3362. * This source code is licensed under the MIT license found in the
  3363. * LICENSE file in the root directory of this source tree.
  3364. *
  3365. *
  3366. */
  3367. var asymmetricMatcher = _Symbol$for('jest.asymmetricMatcher');
  3368. var SPACE = ' ';
  3369. var serialize = exports.serialize = function (val, config, indentation, depth, refs, printer) {
  3370. var stringedValue = val.toString();
  3371. if (stringedValue === 'ArrayContaining' || stringedValue === 'ArrayNotContaining') {
  3372. if (++depth > config.maxDepth) {
  3373. return '[' + stringedValue + ']';
  3374. }
  3375. return stringedValue + SPACE + '[' + (0, collections.printListItems)(val.sample, config, indentation, depth, refs, printer) + ']';
  3376. }
  3377. if (stringedValue === 'ObjectContaining' || stringedValue === 'ObjectNotContaining') {
  3378. if (++depth > config.maxDepth) {
  3379. return '[' + stringedValue + ']';
  3380. }
  3381. return stringedValue + SPACE + '{' + (0, collections.printObjectProperties)(val.sample, config, indentation, depth, refs, printer) + '}';
  3382. }
  3383. if (stringedValue === 'StringMatching' || stringedValue === 'StringNotMatching') {
  3384. return stringedValue + SPACE + printer(val.sample, config, indentation, depth, refs);
  3385. }
  3386. if (stringedValue === 'StringContaining' || stringedValue === 'StringNotContaining') {
  3387. return stringedValue + SPACE + printer(val.sample, config, indentation, depth, refs);
  3388. }
  3389. return val.toAsymmetricMatcher();
  3390. };
  3391. var test = exports.test = function (val) {
  3392. return val && val.$$typeof === asymmetricMatcher;
  3393. };
  3394. exports.default = { serialize: serialize, test: test };
  3395. });
  3396. unwrapExports(asymmetric_matcher);
  3397. var asymmetric_matcher_1 = asymmetric_matcher.test;
  3398. var asymmetric_matcher_2 = asymmetric_matcher.serialize;
  3399. var ansiRegex = createCommonjsModule(function (module) {
  3400. module.exports = function () {
  3401. var pattern = ['[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)', '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))'].join('|');
  3402. return new RegExp(pattern, 'g');
  3403. };
  3404. });
  3405. var convert_ansi = createCommonjsModule(function (module, exports) {
  3406. Object.defineProperty(exports, '__esModule', {
  3407. value: true
  3408. });
  3409. exports.serialize = exports.test = undefined;
  3410. var _ansiRegex2 = _interopRequireDefault(ansiRegex);
  3411. var _ansiStyles2 = _interopRequireDefault(ansiStyles);
  3412. function _interopRequireDefault(obj) {
  3413. return obj && obj.__esModule ? obj : { default: obj };
  3414. }
  3415. var toHumanReadableAnsi = function toHumanReadableAnsi(text) {
  3416. return text.replace((0, _ansiRegex2.default)(), function (match, offset, string) {
  3417. switch (match) {
  3418. case _ansiStyles2.default.red.close:
  3419. case _ansiStyles2.default.green.close:
  3420. case _ansiStyles2.default.cyan.close:
  3421. case _ansiStyles2.default.gray.close:
  3422. case _ansiStyles2.default.white.close:
  3423. case _ansiStyles2.default.yellow.close:
  3424. case _ansiStyles2.default.bgRed.close:
  3425. case _ansiStyles2.default.bgGreen.close:
  3426. case _ansiStyles2.default.bgYellow.close:
  3427. case _ansiStyles2.default.inverse.close:
  3428. case _ansiStyles2.default.dim.close:
  3429. case _ansiStyles2.default.bold.close:
  3430. case _ansiStyles2.default.reset.open:
  3431. case _ansiStyles2.default.reset.close:
  3432. return '</>';
  3433. case _ansiStyles2.default.red.open:
  3434. return '<red>';
  3435. case _ansiStyles2.default.green.open:
  3436. return '<green>';
  3437. case _ansiStyles2.default.cyan.open:
  3438. return '<cyan>';
  3439. case _ansiStyles2.default.gray.open:
  3440. return '<gray>';
  3441. case _ansiStyles2.default.white.open:
  3442. return '<white>';
  3443. case _ansiStyles2.default.yellow.open:
  3444. return '<yellow>';
  3445. case _ansiStyles2.default.bgRed.open:
  3446. return '<bgRed>';
  3447. case _ansiStyles2.default.bgGreen.open:
  3448. return '<bgGreen>';
  3449. case _ansiStyles2.default.bgYellow.open:
  3450. return '<bgYellow>';
  3451. case _ansiStyles2.default.inverse.open:
  3452. return '<inverse>';
  3453. case _ansiStyles2.default.dim.open:
  3454. return '<dim>';
  3455. case _ansiStyles2.default.bold.open:
  3456. return '<bold>';
  3457. default:
  3458. return '';
  3459. }
  3460. });
  3461. };
  3462. /**
  3463. * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
  3464. *
  3465. * This source code is licensed under the MIT license found in the
  3466. * LICENSE file in the root directory of this source tree.
  3467. *
  3468. *
  3469. */
  3470. var test = exports.test = function (val) {
  3471. return typeof val === 'string' && val.match((0, _ansiRegex2.default)());
  3472. };
  3473. var serialize = exports.serialize = function (val, config, indentation, depth, refs, printer) {
  3474. return printer(toHumanReadableAnsi(val), config, indentation, depth, refs);
  3475. };
  3476. exports.default = { serialize: serialize, test: test };
  3477. });
  3478. unwrapExports(convert_ansi);
  3479. var convert_ansi_1 = convert_ansi.serialize;
  3480. var convert_ansi_2 = convert_ansi.test;
  3481. var dom_collection = createCommonjsModule(function (module, exports) {
  3482. Object.defineProperty(exports, '__esModule', {
  3483. value: true
  3484. });
  3485. exports.serialize = exports.test = undefined;
  3486. /**
  3487. * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
  3488. *
  3489. * This source code is licensed under the MIT license found in the
  3490. * LICENSE file in the root directory of this source tree.
  3491. *
  3492. *
  3493. */
  3494. var SPACE = ' ';
  3495. var COLLECTION_NAMES = ['DOMStringMap', 'NamedNodeMap'];
  3496. var test = exports.test = function (val) {
  3497. return val && val.constructor && COLLECTION_NAMES.indexOf(val.constructor.name) !== -1;
  3498. };
  3499. var convertCollectionToObject = function convertCollectionToObject(collection) {
  3500. var result = {};
  3501. if (collection.constructor.name === 'NamedNodeMap') {
  3502. for (var i = 0; i < collection.length; i++) {
  3503. result[collection[i].name] = collection[i].value;
  3504. }
  3505. } else {
  3506. result = _Object$assign({}, collection);
  3507. }
  3508. return result;
  3509. };
  3510. var serialize = exports.serialize = function (collection, config, indentation, depth, refs, printer) {
  3511. if (++depth > config.maxDepth) {
  3512. return '[' + collection.constructor.name + ']';
  3513. }
  3514. return collection.constructor.name + SPACE + '{' + (0, collections.printObjectProperties)(convertCollectionToObject(collection), config, indentation, depth, refs, printer) + '}';
  3515. };
  3516. exports.default = { serialize: serialize, test: test };
  3517. });
  3518. unwrapExports(dom_collection);
  3519. var dom_collection_1 = dom_collection.serialize;
  3520. var dom_collection_2 = dom_collection.test;
  3521. var escape_html = createCommonjsModule(function (module, exports) {
  3522. Object.defineProperty(exports, '__esModule', {
  3523. value: true
  3524. });
  3525. exports.default = escapeHTML;
  3526. /**
  3527. * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
  3528. *
  3529. * This source code is licensed under the MIT license found in the
  3530. * LICENSE file in the root directory of this source tree.
  3531. *
  3532. *
  3533. */
  3534. function escapeHTML(str) {
  3535. return str.replace(/</g, '&lt;').replace(/>/g, '&gt;');
  3536. }
  3537. });
  3538. unwrapExports(escape_html);
  3539. var markup = createCommonjsModule(function (module, exports) {
  3540. Object.defineProperty(exports, '__esModule', {
  3541. value: true
  3542. });
  3543. exports.printElementAsLeaf = exports.printElement = exports.printComment = exports.printText = exports.printChildren = exports.printProps = undefined;
  3544. var _escape_html2 = _interopRequireDefault(escape_html);
  3545. function _interopRequireDefault(obj) {
  3546. return obj && obj.__esModule ? obj : { default: obj };
  3547. }
  3548. // Return empty string if keys is empty.
  3549. /**
  3550. * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
  3551. *
  3552. * This source code is licensed under the MIT license found in the
  3553. * LICENSE file in the root directory of this source tree.
  3554. *
  3555. *
  3556. */
  3557. var printProps = exports.printProps = function (keys, props, config, indentation, depth, refs, printer) {
  3558. var indentationNext = indentation + config.indent;
  3559. var colors = config.colors;
  3560. return keys.map(function (key) {
  3561. var value = props[key];
  3562. var printed = printer(value, config, indentationNext, depth, refs);
  3563. if (typeof value !== 'string') {
  3564. if (printed.indexOf('\n') !== -1) {
  3565. printed = config.spacingOuter + indentationNext + printed + config.spacingOuter + indentation;
  3566. }
  3567. printed = '{' + printed + '}';
  3568. }
  3569. return config.spacingInner + indentation + colors.prop.open + key + colors.prop.close + '=' + colors.value.open + printed + colors.value.close;
  3570. }).join('');
  3571. };
  3572. // Return empty string if children is empty.
  3573. var printChildren = exports.printChildren = function (children, config, indentation, depth, refs, printer) {
  3574. return children.map(function (child) {
  3575. return config.spacingOuter + indentation + (typeof child === 'string' ? printText(child, config) : printer(child, config, indentation, depth, refs));
  3576. }).join('');
  3577. };
  3578. var printText = exports.printText = function (text, config) {
  3579. var contentColor = config.colors.content;
  3580. return contentColor.open + (0, _escape_html2.default)(text) + contentColor.close;
  3581. };
  3582. var printComment = exports.printComment = function (comment, config) {
  3583. var commentColor = config.colors.comment;
  3584. return commentColor.open + '<!--' + (0, _escape_html2.default)(comment) + '-->' + commentColor.close;
  3585. };
  3586. // Separate the functions to format props, children, and element,
  3587. // so a plugin could override a particular function, if needed.
  3588. // Too bad, so sad: the traditional (but unnecessary) space
  3589. // in a self-closing tagColor requires a second test of printedProps.
  3590. var printElement = exports.printElement = function (type, printedProps, printedChildren, config, indentation) {
  3591. var tagColor = config.colors.tag;
  3592. return tagColor.open + '<' + type + (printedProps && tagColor.close + printedProps + config.spacingOuter + indentation + tagColor.open) + (printedChildren ? '>' + tagColor.close + printedChildren + config.spacingOuter + indentation + tagColor.open + '</' + type : (printedProps && !config.min ? '' : ' ') + '/') + '>' + tagColor.close;
  3593. };
  3594. var printElementAsLeaf = exports.printElementAsLeaf = function (type, config) {
  3595. var tagColor = config.colors.tag;
  3596. return tagColor.open + '<' + type + tagColor.close + ' …' + tagColor.open + ' />' + tagColor.close;
  3597. };
  3598. });
  3599. unwrapExports(markup);
  3600. var markup_1 = markup.printElementAsLeaf;
  3601. var markup_2 = markup.printElement;
  3602. var markup_3 = markup.printComment;
  3603. var markup_4 = markup.printText;
  3604. var markup_5 = markup.printChildren;
  3605. var markup_6 = markup.printProps;
  3606. var dom_element = createCommonjsModule(function (module, exports) {
  3607. Object.defineProperty(exports, '__esModule', {
  3608. value: true
  3609. });
  3610. exports.serialize = exports.test = undefined;
  3611. /**
  3612. * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
  3613. *
  3614. * This source code is licensed under the MIT license found in the
  3615. * LICENSE file in the root directory of this source tree.
  3616. *
  3617. *
  3618. */
  3619. var ELEMENT_NODE = 1;
  3620. var TEXT_NODE = 3;
  3621. var COMMENT_NODE = 8;
  3622. var FRAGMENT_NODE = 11;
  3623. var ELEMENT_REGEXP = /^((HTML|SVG)\w*)?Element$/;
  3624. var testNode = function testNode(nodeType, name) {
  3625. return nodeType === ELEMENT_NODE && ELEMENT_REGEXP.test(name) || nodeType === TEXT_NODE && name === 'Text' || nodeType === COMMENT_NODE && name === 'Comment' || nodeType === FRAGMENT_NODE && name === 'DocumentFragment';
  3626. };
  3627. var test = exports.test = function (val) {
  3628. return val && val.constructor && val.constructor.name && testNode(val.nodeType, val.constructor.name);
  3629. };
  3630. // Convert array of attribute objects to keys array and props object.
  3631. var keysMapper = function keysMapper(attribute) {
  3632. return attribute.name;
  3633. };
  3634. var propsReducer = function propsReducer(props, attribute) {
  3635. props[attribute.name] = attribute.value;
  3636. return props;
  3637. };
  3638. var serialize = exports.serialize = function (node, config, indentation, depth, refs, printer) {
  3639. if (node.nodeType === TEXT_NODE) {
  3640. return (0, markup.printText)(node.data, config);
  3641. }
  3642. if (node.nodeType === COMMENT_NODE) {
  3643. return (0, markup.printComment)(node.data, config);
  3644. }
  3645. var type = node.nodeType === FRAGMENT_NODE ? 'DocumentFragment' : node.tagName.toLowerCase();
  3646. if (++depth > config.maxDepth) {
  3647. return (0, markup.printElementAsLeaf)(type, config);
  3648. }
  3649. return (0, markup.printElement)(type, (0, markup.printProps)(Array.prototype.map.call(node.attributes || [], keysMapper).sort(), Array.prototype.reduce.call(node.attributes || [], propsReducer, {}), config, indentation + config.indent, depth, refs, printer), (0, markup.printChildren)(Array.prototype.slice.call(node.childNodes || node.children), config, indentation + config.indent, depth, refs, printer), config, indentation);
  3650. };
  3651. exports.default = { serialize: serialize, test: test };
  3652. });
  3653. unwrapExports(dom_element);
  3654. var dom_element_1 = dom_element.serialize;
  3655. var dom_element_2 = dom_element.test;
  3656. var immutable = createCommonjsModule(function (module, exports) {
  3657. Object.defineProperty(exports, '__esModule', {
  3658. value: true
  3659. });
  3660. exports.test = exports.serialize = undefined;
  3661. // SENTINEL constants are from https://github.com/facebook/immutable-js
  3662. /**
  3663. * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
  3664. *
  3665. * This source code is licensed under the MIT license found in the
  3666. * LICENSE file in the root directory of this source tree.
  3667. *
  3668. *
  3669. */
  3670. var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
  3671. var IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
  3672. var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
  3673. var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';
  3674. var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
  3675. var IS_RECORD_SENTINEL = '@@__IMMUTABLE_RECORD__@@'; // immutable v4
  3676. var IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@';
  3677. var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
  3678. var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
  3679. var getImmutableName = function getImmutableName(name) {
  3680. return 'Immutable.' + name;
  3681. };
  3682. var printAsLeaf = function printAsLeaf(name) {
  3683. return '[' + name + ']';
  3684. };
  3685. var SPACE = ' ';
  3686. var LAZY = '…'; // Seq is lazy if it calls a method like filter
  3687. var printImmutableEntries = function printImmutableEntries(val, config, indentation, depth, refs, printer, type) {
  3688. return ++depth > config.maxDepth ? printAsLeaf(getImmutableName(type)) : getImmutableName(type) + SPACE + '{' + (0, collections.printIteratorEntries)(val.entries(), config, indentation, depth, refs, printer) + '}';
  3689. };
  3690. // Record has an entries method because it is a collection in immutable v3.
  3691. // Return an iterator for Immutable Record from version v3 or v4.
  3692. var getRecordEntries = function getRecordEntries(val) {
  3693. var i = 0;
  3694. return {
  3695. next: function next() {
  3696. if (i < val._keys.length) {
  3697. var key = val._keys[i++];
  3698. return { done: false, value: [key, val.get(key)] };
  3699. }
  3700. return { done: true };
  3701. }
  3702. };
  3703. };
  3704. var printImmutableRecord = function printImmutableRecord(val, config, indentation, depth, refs, printer) {
  3705. // _name property is defined only for an Immutable Record instance
  3706. // which was constructed with a second optional descriptive name arg
  3707. var name = getImmutableName(val._name || 'Record');
  3708. return ++depth > config.maxDepth ? printAsLeaf(name) : name + SPACE + '{' + (0, collections.printIteratorEntries)(getRecordEntries(val), config, indentation, depth, refs, printer) + '}';
  3709. };
  3710. var printImmutableSeq = function printImmutableSeq(val, config, indentation, depth, refs, printer) {
  3711. var name = getImmutableName('Seq');
  3712. if (++depth > config.maxDepth) {
  3713. return printAsLeaf(name);
  3714. }
  3715. if (val[IS_KEYED_SENTINEL]) {
  3716. return name + SPACE + '{' + (
  3717. // from Immutable collection of entries or from ECMAScript object
  3718. val._iter || val._object ? (0, collections.printIteratorEntries)(val.entries(), config, indentation, depth, refs, printer) : LAZY) + '}';
  3719. }
  3720. return name + SPACE + '[' + (val._iter || // from Immutable collection of values
  3721. val._array || // from ECMAScript array
  3722. val._collection || // from ECMAScript collection in immutable v4
  3723. val._iterable // from ECMAScript collection in immutable v3
  3724. ? (0, collections.printIteratorValues)(val.values(), config, indentation, depth, refs, printer) : LAZY) + ']';
  3725. };
  3726. var printImmutableValues = function printImmutableValues(val, config, indentation, depth, refs, printer, type) {
  3727. return ++depth > config.maxDepth ? printAsLeaf(getImmutableName(type)) : getImmutableName(type) + SPACE + '[' + (0, collections.printIteratorValues)(val.values(), config, indentation, depth, refs, printer) + ']';
  3728. };
  3729. var serialize = exports.serialize = function (val, config, indentation, depth, refs, printer) {
  3730. if (val[IS_MAP_SENTINEL]) {
  3731. return printImmutableEntries(val, config, indentation, depth, refs, printer, val[IS_ORDERED_SENTINEL] ? 'OrderedMap' : 'Map');
  3732. }
  3733. if (val[IS_LIST_SENTINEL]) {
  3734. return printImmutableValues(val, config, indentation, depth, refs, printer, 'List');
  3735. }
  3736. if (val[IS_SET_SENTINEL]) {
  3737. return printImmutableValues(val, config, indentation, depth, refs, printer, val[IS_ORDERED_SENTINEL] ? 'OrderedSet' : 'Set');
  3738. }
  3739. if (val[IS_STACK_SENTINEL]) {
  3740. return printImmutableValues(val, config, indentation, depth, refs, printer, 'Stack');
  3741. }
  3742. if (val[IS_SEQ_SENTINEL]) {
  3743. return printImmutableSeq(val, config, indentation, depth, refs, printer);
  3744. }
  3745. // For compatibility with immutable v3 and v4, let record be the default.
  3746. return printImmutableRecord(val, config, indentation, depth, refs, printer);
  3747. };
  3748. // Explicitly comparing sentinel properties to true avoids false positive
  3749. // when mock identity-obj-proxy returns the key as the value for any key.
  3750. var test = exports.test = function (val) {
  3751. return val && (val[IS_ITERABLE_SENTINEL] === true || val[IS_RECORD_SENTINEL] === true);
  3752. };
  3753. exports.default = { serialize: serialize, test: test };
  3754. });
  3755. unwrapExports(immutable);
  3756. var immutable_1 = immutable.test;
  3757. var immutable_2 = immutable.serialize;
  3758. var react_element = createCommonjsModule(function (module, exports) {
  3759. Object.defineProperty(exports, '__esModule', {
  3760. value: true
  3761. });
  3762. exports.test = exports.serialize = undefined;
  3763. /**
  3764. * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
  3765. *
  3766. * This source code is licensed under the MIT license found in the
  3767. * LICENSE file in the root directory of this source tree.
  3768. *
  3769. *
  3770. */
  3771. var elementSymbol = _Symbol$for('react.element');
  3772. var fragmentSymbol = _Symbol$for('react.fragment');
  3773. var forwardRefSymbol = _Symbol$for('react.forward_ref');
  3774. var providerSymbol = _Symbol$for('react.provider');
  3775. var contextSymbol = _Symbol$for('react.context');
  3776. // Given element.props.children, or subtree during recursive traversal,
  3777. // return flattened array of children.
  3778. var getChildren = function getChildren(arg) {
  3779. var children = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  3780. if (Array.isArray(arg)) {
  3781. arg.forEach(function (item) {
  3782. getChildren(item, children);
  3783. });
  3784. } else if (arg != null && arg !== false) {
  3785. children.push(arg);
  3786. }
  3787. return children;
  3788. };
  3789. var getType = function getType(element) {
  3790. var type = element.type;
  3791. if (typeof type === 'string') {
  3792. return type;
  3793. }
  3794. if (typeof type === 'function') {
  3795. return type.displayName || type.name || 'Unknown';
  3796. }
  3797. if (type === fragmentSymbol) {
  3798. return 'React.Fragment';
  3799. }
  3800. if ((typeof type === 'undefined' ? 'undefined' : _typeof(type)) === 'object' && type !== null) {
  3801. if (type.$$typeof === providerSymbol) {
  3802. return 'Context.Provider';
  3803. }
  3804. if (type.$$typeof === contextSymbol) {
  3805. return 'Context.Consumer';
  3806. }
  3807. if (type.$$typeof === forwardRefSymbol) {
  3808. var functionName = type.render.displayName || type.render.name || '';
  3809. return functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef';
  3810. }
  3811. }
  3812. return 'UNDEFINED';
  3813. };
  3814. var getPropKeys = function getPropKeys(element) {
  3815. var props = element.props;
  3816. return _Object$keys(props).filter(function (key) {
  3817. return key !== 'children' && props[key] !== undefined;
  3818. }).sort();
  3819. };
  3820. var serialize = exports.serialize = function (element, config, indentation, depth, refs, printer) {
  3821. return ++depth > config.maxDepth ? (0, markup.printElementAsLeaf)(getType(element), config) : (0, markup.printElement)(getType(element), (0, markup.printProps)(getPropKeys(element), element.props, config, indentation + config.indent, depth, refs, printer), (0, markup.printChildren)(getChildren(element.props.children), config, indentation + config.indent, depth, refs, printer), config, indentation);
  3822. };
  3823. var test = exports.test = function (val) {
  3824. return val && val.$$typeof === elementSymbol;
  3825. };
  3826. exports.default = { serialize: serialize, test: test };
  3827. });
  3828. unwrapExports(react_element);
  3829. var react_element_1 = react_element.test;
  3830. var react_element_2 = react_element.serialize;
  3831. var react_test_component = createCommonjsModule(function (module, exports) {
  3832. Object.defineProperty(exports, '__esModule', {
  3833. value: true
  3834. });
  3835. exports.test = exports.serialize = undefined;
  3836. /**
  3837. * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
  3838. *
  3839. * This source code is licensed under the MIT license found in the
  3840. * LICENSE file in the root directory of this source tree.
  3841. *
  3842. *
  3843. */
  3844. var testSymbol = _Symbol$for('react.test.json');
  3845. var getPropKeys = function getPropKeys(object) {
  3846. var props = object.props;
  3847. return props ? _Object$keys(props).filter(function (key) {
  3848. return props[key] !== undefined;
  3849. }).sort() : [];
  3850. };
  3851. var serialize = exports.serialize = function (object, config, indentation, depth, refs, printer) {
  3852. return ++depth > config.maxDepth ? (0, markup.printElementAsLeaf)(object.type, config) : (0, markup.printElement)(object.type, object.props ? (0, markup.printProps)(getPropKeys(object),
  3853. // Despite ternary expression, Flow 0.51.0 found incorrect error:
  3854. // undefined is incompatible with the expected param type of Object
  3855. // $FlowFixMe
  3856. object.props, config, indentation + config.indent, depth, refs, printer) : '', object.children ? (0, markup.printChildren)(object.children, config, indentation + config.indent, depth, refs, printer) : '', config, indentation);
  3857. };
  3858. var test = exports.test = function (val) {
  3859. return val && val.$$typeof === testSymbol;
  3860. };
  3861. exports.default = { serialize: serialize, test: test };
  3862. });
  3863. unwrapExports(react_test_component);
  3864. var react_test_component_1 = react_test_component.test;
  3865. var react_test_component_2 = react_test_component.serialize;
  3866. var build$1 = createCommonjsModule(function (module) {
  3867. var _ansiStyles2 = _interopRequireDefault(ansiStyles);
  3868. var _asymmetric_matcher2 = _interopRequireDefault(asymmetric_matcher);
  3869. var _convert_ansi2 = _interopRequireDefault(convert_ansi);
  3870. var _dom_collection2 = _interopRequireDefault(dom_collection);
  3871. var _dom_element2 = _interopRequireDefault(dom_element);
  3872. var _immutable2 = _interopRequireDefault(immutable);
  3873. var _react_element2 = _interopRequireDefault(react_element);
  3874. var _react_test_component2 = _interopRequireDefault(react_test_component);
  3875. function _interopRequireDefault(obj) {
  3876. return obj && obj.__esModule ? obj : { default: obj };
  3877. }
  3878. /**
  3879. * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
  3880. *
  3881. * This source code is licensed under the MIT license found in the
  3882. * LICENSE file in the root directory of this source tree.
  3883. *
  3884. *
  3885. */
  3886. var toString = Object.prototype.toString;
  3887. var toISOString = Date.prototype.toISOString;
  3888. var errorToString = Error.prototype.toString;
  3889. var regExpToString = RegExp.prototype.toString;
  3890. var symbolToString = _Symbol.prototype.toString;
  3891. // Explicitly comparing typeof constructor to function avoids undefined as name
  3892. // when mock identity-obj-proxy returns the key as the value for any key.
  3893. var getConstructorName = function getConstructorName(val) {
  3894. return typeof val.constructor === 'function' && val.constructor.name || 'Object';
  3895. };
  3896. // Is val is equal to global window object? Works even if it does not exist :)
  3897. /* global window */
  3898. var isWindow = function isWindow(val) {
  3899. return typeof window !== 'undefined' && val === window;
  3900. };
  3901. var SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/;
  3902. var NEWLINE_REGEXP = /\n/gi;
  3903. var PrettyFormatPluginError = function (_Error) {
  3904. _inherits(PrettyFormatPluginError, _Error);
  3905. function PrettyFormatPluginError(message, stack) {
  3906. _classCallCheck(this, PrettyFormatPluginError);
  3907. var _this = _possibleConstructorReturn(this, (PrettyFormatPluginError.__proto__ || _Object$getPrototypeOf(PrettyFormatPluginError)).call(this, message));
  3908. _this.stack = stack;
  3909. _this.name = _this.constructor.name;
  3910. return _this;
  3911. }
  3912. return PrettyFormatPluginError;
  3913. }(Error);
  3914. function isToStringedArrayType(toStringed) {
  3915. return toStringed === '[object Array]' || toStringed === '[object ArrayBuffer]' || toStringed === '[object DataView]' || toStringed === '[object Float32Array]' || toStringed === '[object Float64Array]' || toStringed === '[object Int8Array]' || toStringed === '[object Int16Array]' || toStringed === '[object Int32Array]' || toStringed === '[object Uint8Array]' || toStringed === '[object Uint8ClampedArray]' || toStringed === '[object Uint16Array]' || toStringed === '[object Uint32Array]';
  3916. }
  3917. function printNumber(val) {
  3918. return _Object$is(val, -0) ? '-0' : String(val);
  3919. }
  3920. function printFunction(val, printFunctionName) {
  3921. if (!printFunctionName) {
  3922. return '[Function]';
  3923. }
  3924. return '[Function ' + (val.name || 'anonymous') + ']';
  3925. }
  3926. function printSymbol(val) {
  3927. return symbolToString.call(val).replace(SYMBOL_REGEXP, 'Symbol($1)');
  3928. }
  3929. function printError(val) {
  3930. return '[' + errorToString.call(val) + ']';
  3931. }
  3932. function printBasicValue(val, printFunctionName, escapeRegex) {
  3933. if (val === true || val === false) {
  3934. return '' + val;
  3935. }
  3936. if (val === undefined) {
  3937. return 'undefined';
  3938. }
  3939. if (val === null) {
  3940. return 'null';
  3941. }
  3942. var typeOf = typeof val === 'undefined' ? 'undefined' : _typeof(val);
  3943. if (typeOf === 'number') {
  3944. return printNumber(val);
  3945. }
  3946. if (typeOf === 'string') {
  3947. return '"' + val.replace(/"|\\/g, '\\$&') + '"';
  3948. }
  3949. if (typeOf === 'function') {
  3950. return printFunction(val, printFunctionName);
  3951. }
  3952. if (typeOf === 'symbol') {
  3953. return printSymbol(val);
  3954. }
  3955. var toStringed = toString.call(val);
  3956. if (toStringed === '[object WeakMap]') {
  3957. return 'WeakMap {}';
  3958. }
  3959. if (toStringed === '[object WeakSet]') {
  3960. return 'WeakSet {}';
  3961. }
  3962. if (toStringed === '[object Function]' || toStringed === '[object GeneratorFunction]') {
  3963. return printFunction(val, printFunctionName);
  3964. }
  3965. if (toStringed === '[object Symbol]') {
  3966. return printSymbol(val);
  3967. }
  3968. if (toStringed === '[object Date]') {
  3969. return isNaN(+val) ? 'Date { NaN }' : toISOString.call(val);
  3970. }
  3971. if (toStringed === '[object Error]') {
  3972. return printError(val);
  3973. }
  3974. if (toStringed === '[object RegExp]') {
  3975. if (escapeRegex) {
  3976. // https://github.com/benjamingr/RegExp.escape/blob/master/polyfill.js
  3977. return regExpToString.call(val).replace(/[\\^$*+?.()|[\]{}]/g, '\\$&');
  3978. }
  3979. return regExpToString.call(val);
  3980. }
  3981. if (val instanceof Error) {
  3982. return printError(val);
  3983. }
  3984. return null;
  3985. }
  3986. function printComplexValue(val, config, indentation, depth, refs, hasCalledToJSON) {
  3987. if (refs.indexOf(val) !== -1) {
  3988. return '[Circular]';
  3989. }
  3990. refs = refs.slice();
  3991. refs.push(val);
  3992. var hitMaxDepth = ++depth > config.maxDepth;
  3993. var min = config.min;
  3994. if (config.callToJSON && !hitMaxDepth && val.toJSON && typeof val.toJSON === 'function' && !hasCalledToJSON) {
  3995. return printer(val.toJSON(), config, indentation, depth, refs, true);
  3996. }
  3997. var toStringed = toString.call(val);
  3998. if (toStringed === '[object Arguments]') {
  3999. return hitMaxDepth ? '[Arguments]' : (min ? '' : 'Arguments ') + '[' + (0, collections.printListItems)(val, config, indentation, depth, refs, printer) + ']';
  4000. }
  4001. if (isToStringedArrayType(toStringed)) {
  4002. return hitMaxDepth ? '[' + val.constructor.name + ']' : (min ? '' : val.constructor.name + ' ') + '[' + (0, collections.printListItems)(val, config, indentation, depth, refs, printer) + ']';
  4003. }
  4004. if (toStringed === '[object Map]') {
  4005. return hitMaxDepth ? '[Map]' : 'Map {' + (0, collections.printIteratorEntries)(val.entries(), config, indentation, depth, refs, printer, ' => ') + '}';
  4006. }
  4007. if (toStringed === '[object Set]') {
  4008. return hitMaxDepth ? '[Set]' : 'Set {' + (0, collections.printIteratorValues)(val.values(), config, indentation, depth, refs, printer) + '}';
  4009. }
  4010. // Avoid failure to serialize global window object in jsdom test environment.
  4011. // For example, not even relevant if window is prop of React element.
  4012. return hitMaxDepth || isWindow(val) ? '[' + getConstructorName(val) + ']' : (min ? '' : getConstructorName(val) + ' ') + '{' + (0, collections.printObjectProperties)(val, config, indentation, depth, refs, printer) + '}';
  4013. }
  4014. function printPlugin(plugin, val, config, indentation, depth, refs) {
  4015. var printed = void 0;
  4016. try {
  4017. printed = plugin.serialize ? plugin.serialize(val, config, indentation, depth, refs, printer) : plugin.print(val, function (valChild) {
  4018. return printer(valChild, config, indentation, depth, refs);
  4019. }, function (str) {
  4020. var indentationNext = indentation + config.indent;
  4021. return indentationNext + str.replace(NEWLINE_REGEXP, '\n' + indentationNext);
  4022. }, {
  4023. edgeSpacing: config.spacingOuter,
  4024. min: config.min,
  4025. spacing: config.spacingInner
  4026. }, config.colors);
  4027. } catch (error) {
  4028. throw new PrettyFormatPluginError(error.message, error.stack);
  4029. }
  4030. if (typeof printed !== 'string') {
  4031. throw new Error('pretty-format: Plugin must return type "string" but instead returned "' + (typeof printed === 'undefined' ? 'undefined' : _typeof(printed)) + '".');
  4032. }
  4033. return printed;
  4034. }
  4035. function findPlugin(plugins, val) {
  4036. for (var p = 0; p < plugins.length; p++) {
  4037. try {
  4038. if (plugins[p].test(val)) {
  4039. return plugins[p];
  4040. }
  4041. } catch (error) {
  4042. throw new PrettyFormatPluginError(error.message, error.stack);
  4043. }
  4044. }
  4045. return null;
  4046. }
  4047. function printer(val, config, indentation, depth, refs, hasCalledToJSON) {
  4048. var plugin = findPlugin(config.plugins, val);
  4049. if (plugin !== null) {
  4050. return printPlugin(plugin, val, config, indentation, depth, refs);
  4051. }
  4052. var basicResult = printBasicValue(val, config.printFunctionName, config.escapeRegex);
  4053. if (basicResult !== null) {
  4054. return basicResult;
  4055. }
  4056. return printComplexValue(val, config, indentation, depth, refs, hasCalledToJSON);
  4057. }
  4058. var DEFAULT_THEME = {
  4059. comment: 'gray',
  4060. content: 'reset',
  4061. prop: 'yellow',
  4062. tag: 'cyan',
  4063. value: 'green'
  4064. };
  4065. var DEFAULT_THEME_KEYS = _Object$keys(DEFAULT_THEME);
  4066. var DEFAULT_OPTIONS = {
  4067. callToJSON: true,
  4068. escapeRegex: false,
  4069. highlight: false,
  4070. indent: 2,
  4071. maxDepth: Infinity,
  4072. min: false,
  4073. plugins: [],
  4074. printFunctionName: true,
  4075. theme: DEFAULT_THEME
  4076. };
  4077. function validateOptions(options) {
  4078. _Object$keys(options).forEach(function (key) {
  4079. if (!DEFAULT_OPTIONS.hasOwnProperty(key)) {
  4080. throw new Error('pretty-format: Unknown option "' + key + '".');
  4081. }
  4082. });
  4083. if (options.min && options.indent !== undefined && options.indent !== 0) {
  4084. throw new Error('pretty-format: Options "min" and "indent" cannot be used together.');
  4085. }
  4086. if (options.theme !== undefined) {
  4087. if (options.theme === null) {
  4088. throw new Error('pretty-format: Option "theme" must not be null.');
  4089. }
  4090. if (_typeof(options.theme) !== 'object') {
  4091. throw new Error('pretty-format: Option "theme" must be of type "object" but instead received "' + _typeof(options.theme) + '".');
  4092. }
  4093. }
  4094. }
  4095. var getColorsHighlight = function getColorsHighlight(options
  4096. // $FlowFixMe: Flow thinks keys from `Colors` are missing from `DEFAULT_THEME_KEYS`
  4097. ) {
  4098. return DEFAULT_THEME_KEYS.reduce(function (colors, key) {
  4099. var value = options.theme && options.theme[key] !== undefined ? options.theme[key] : DEFAULT_THEME[key];
  4100. var color = _ansiStyles2.default[value];
  4101. if (color && typeof color.close === 'string' && typeof color.open === 'string') {
  4102. colors[key] = color;
  4103. } else {
  4104. throw new Error('pretty-format: Option "theme" has a key "' + key + '" whose value "' + value + '" is undefined in ansi-styles.');
  4105. }
  4106. return colors;
  4107. }, _Object$create(null));
  4108. };
  4109. var getColorsEmpty = function getColorsEmpty() {
  4110. return (
  4111. // $FlowFixMe: Flow thinks keys from `Colors` are missing from `DEFAULT_THEME_KEYS`
  4112. DEFAULT_THEME_KEYS.reduce(function (colors, key) {
  4113. colors[key] = { close: '', open: '' };
  4114. return colors;
  4115. }, _Object$create(null))
  4116. );
  4117. };
  4118. var getPrintFunctionName = function getPrintFunctionName(options) {
  4119. return options && options.printFunctionName !== undefined ? options.printFunctionName : DEFAULT_OPTIONS.printFunctionName;
  4120. };
  4121. var getEscapeRegex = function getEscapeRegex(options) {
  4122. return options && options.escapeRegex !== undefined ? options.escapeRegex : DEFAULT_OPTIONS.escapeRegex;
  4123. };
  4124. var getConfig = function getConfig(options) {
  4125. return {
  4126. callToJSON: options && options.callToJSON !== undefined ? options.callToJSON : DEFAULT_OPTIONS.callToJSON,
  4127. colors: options && options.highlight ? getColorsHighlight(options) : getColorsEmpty(),
  4128. escapeRegex: getEscapeRegex(options),
  4129. indent: options && options.min ? '' : createIndent(options && options.indent !== undefined ? options.indent : DEFAULT_OPTIONS.indent),
  4130. maxDepth: options && options.maxDepth !== undefined ? options.maxDepth : DEFAULT_OPTIONS.maxDepth,
  4131. min: options && options.min !== undefined ? options.min : DEFAULT_OPTIONS.min,
  4132. plugins: options && options.plugins !== undefined ? options.plugins : DEFAULT_OPTIONS.plugins,
  4133. printFunctionName: getPrintFunctionName(options),
  4134. spacingInner: options && options.min ? ' ' : '\n',
  4135. spacingOuter: options && options.min ? '' : '\n'
  4136. };
  4137. };
  4138. function createIndent(indent) {
  4139. return new Array(indent + 1).join(' ');
  4140. }
  4141. function prettyFormat(val, options) {
  4142. if (options) {
  4143. validateOptions(options);
  4144. if (options.plugins) {
  4145. var plugin = findPlugin(options.plugins, val);
  4146. if (plugin !== null) {
  4147. return printPlugin(plugin, val, getConfig(options), '', 0, []);
  4148. }
  4149. }
  4150. }
  4151. var basicResult = printBasicValue(val, getPrintFunctionName(options), getEscapeRegex(options));
  4152. if (basicResult !== null) {
  4153. return basicResult;
  4154. }
  4155. return printComplexValue(val, getConfig(options), '', 0, []);
  4156. }
  4157. prettyFormat.plugins = {
  4158. AsymmetricMatcher: _asymmetric_matcher2.default,
  4159. ConvertAnsi: _convert_ansi2.default,
  4160. DOMCollection: _dom_collection2.default,
  4161. DOMElement: _dom_element2.default,
  4162. Immutable: _immutable2.default,
  4163. ReactElement: _react_element2.default,
  4164. ReactTestComponent: _react_test_component2.default
  4165. };
  4166. module.exports = prettyFormat;
  4167. });
  4168. unwrapExports(build$1);
  4169. var build$2 = createCommonjsModule(function (module, exports) {
  4170. Object.defineProperty(exports, '__esModule', {
  4171. value: true
  4172. });
  4173. exports.matcherHint = exports.pluralize = exports.ensureNumbers = exports.ensureExpectedIsNumber = exports.ensureActualIsNumber = exports.ensureNoExpected = exports.printWithType = exports.printExpected = exports.printReceived = exports.highlightTrailingWhitespace = exports.stringify = exports.SUGGEST_TO_CONTAIN_EQUAL = exports.SUGGEST_TO_EQUAL = exports.RECEIVED_COLOR = exports.EXPECTED_COLOR = undefined;
  4174. var _chalk2 = _interopRequireDefault(fake_chalk);
  4175. var _jestGetType2 = _interopRequireDefault(build);
  4176. var _prettyFormat2 = _interopRequireDefault(build$1);
  4177. function _interopRequireDefault(obj) {
  4178. return obj && obj.__esModule ? obj : { default: obj };
  4179. }
  4180. var _prettyFormat$plugins = _prettyFormat2.default.plugins;
  4181. /**
  4182. * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
  4183. *
  4184. * This source code is licensed under the MIT license found in the
  4185. * LICENSE file in the root directory of this source tree.
  4186. *
  4187. *
  4188. */
  4189. var AsymmetricMatcher = _prettyFormat$plugins.AsymmetricMatcher,
  4190. DOMCollection = _prettyFormat$plugins.DOMCollection,
  4191. DOMElement = _prettyFormat$plugins.DOMElement,
  4192. Immutable = _prettyFormat$plugins.Immutable,
  4193. ReactElement = _prettyFormat$plugins.ReactElement,
  4194. ReactTestComponent = _prettyFormat$plugins.ReactTestComponent;
  4195. var PLUGINS = [ReactTestComponent, ReactElement, DOMElement, DOMCollection, Immutable, AsymmetricMatcher];
  4196. var EXPECTED_COLOR = exports.EXPECTED_COLOR = _chalk2.default.green;
  4197. var RECEIVED_COLOR = exports.RECEIVED_COLOR = _chalk2.default.red;
  4198. var NUMBERS = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen'];
  4199. var SUGGEST_TO_EQUAL = exports.SUGGEST_TO_EQUAL = _chalk2.default.dim('Note that you are testing for equality with the stricter `toBe` matcher using `Object.is`. For deep equality only, use `toEqual` instead.');
  4200. var SUGGEST_TO_CONTAIN_EQUAL = exports.SUGGEST_TO_CONTAIN_EQUAL = _chalk2.default.dim('Looks like you wanted to test for object/array equality with the stricter `toContain` matcher. You probably need to use `toContainEqual` instead.');
  4201. var stringify = exports.stringify = function (object) {
  4202. var maxDepth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
  4203. var MAX_LENGTH = 10000;
  4204. var result = void 0;
  4205. try {
  4206. result = (0, _prettyFormat2.default)(object, {
  4207. maxDepth: maxDepth,
  4208. min: true,
  4209. plugins: PLUGINS
  4210. });
  4211. } catch (e) {
  4212. result = (0, _prettyFormat2.default)(object, {
  4213. callToJSON: false,
  4214. maxDepth: maxDepth,
  4215. min: true,
  4216. plugins: PLUGINS
  4217. });
  4218. }
  4219. return result.length >= MAX_LENGTH && maxDepth > 1 ? stringify(object, Math.floor(maxDepth / 2)) : result;
  4220. };
  4221. var highlightTrailingWhitespace = exports.highlightTrailingWhitespace = function (text) {
  4222. return text.replace(/\s+$/gm, _chalk2.default.inverse('$&'));
  4223. };
  4224. var printReceived = exports.printReceived = function (object) {
  4225. return RECEIVED_COLOR(highlightTrailingWhitespace(stringify(object)));
  4226. };
  4227. var printExpected = exports.printExpected = function (value) {
  4228. return EXPECTED_COLOR(highlightTrailingWhitespace(stringify(value)));
  4229. };
  4230. var printWithType = exports.printWithType = function (name, received, print) {
  4231. var type = (0, _jestGetType2.default)(received);
  4232. return name + ':' + (type !== 'null' && type !== 'undefined' ? '\n ' + type + ': ' : ' ') + print(received);
  4233. };
  4234. var ensureNoExpected = exports.ensureNoExpected = function (expected, matcherName) {
  4235. matcherName || (matcherName = 'This');
  4236. if (typeof expected !== 'undefined') {
  4237. throw new Error(matcherHint('[.not]' + matcherName, undefined, '') + '\n\n' + 'Matcher does not accept any arguments.\n' + printWithType('Got', expected, printExpected));
  4238. }
  4239. };
  4240. var ensureActualIsNumber = exports.ensureActualIsNumber = function (actual, matcherName) {
  4241. matcherName || (matcherName = 'This matcher');
  4242. if (typeof actual !== 'number') {
  4243. throw new Error(matcherHint('[.not]' + matcherName) + '\n\n' + 'Received value must be a number.\n' + printWithType('Received', actual, printReceived));
  4244. }
  4245. };
  4246. var ensureExpectedIsNumber = exports.ensureExpectedIsNumber = function (expected, matcherName) {
  4247. matcherName || (matcherName = 'This matcher');
  4248. if (typeof expected !== 'number') {
  4249. throw new Error(matcherHint('[.not]' + matcherName) + '\n\n' + 'Expected value must be a number.\n' + printWithType('Got', expected, printExpected));
  4250. }
  4251. };
  4252. var ensureNumbers = exports.ensureNumbers = function (actual, expected, matcherName) {
  4253. ensureActualIsNumber(actual, matcherName);
  4254. ensureExpectedIsNumber(expected, matcherName);
  4255. };
  4256. var pluralize = exports.pluralize = function (word, count) {
  4257. return (NUMBERS[count] || count) + ' ' + word + (count === 1 ? '' : 's');
  4258. };
  4259. var matcherHint = exports.matcherHint = function (matcherName) {
  4260. var received = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'received';
  4261. var expected = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'expected';
  4262. var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
  4263. var comment = options.comment,
  4264. isDirectExpectCall = options.isDirectExpectCall,
  4265. isNot = options.isNot,
  4266. secondArgument = options.secondArgument;
  4267. return _chalk2.default.dim('expect' + (isDirectExpectCall ? '' : '(')) + RECEIVED_COLOR(received) + (isNot ? _chalk2.default.dim(').') + 'not' + _chalk2.default.dim(matcherName + '(') : _chalk2.default.dim((isDirectExpectCall ? '' : ')') + matcherName + '(')) + EXPECTED_COLOR(expected) + (secondArgument ? '' + _chalk2.default.dim(', ') + EXPECTED_COLOR(secondArgument) : '') + _chalk2.default.dim(')' + (comment ? ' // ' + comment : ''));
  4268. };
  4269. });
  4270. var index$1 = unwrapExports(build$2);
  4271. var build_1 = build$2.matcherHint;
  4272. var build_2 = build$2.pluralize;
  4273. var build_3 = build$2.ensureNumbers;
  4274. var build_4 = build$2.ensureExpectedIsNumber;
  4275. var build_5 = build$2.ensureActualIsNumber;
  4276. var build_6 = build$2.ensureNoExpected;
  4277. var build_7 = build$2.printWithType;
  4278. var build_8 = build$2.printExpected;
  4279. var build_9 = build$2.printReceived;
  4280. var build_10 = build$2.highlightTrailingWhitespace;
  4281. var build_11 = build$2.stringify;
  4282. var build_12 = build$2.SUGGEST_TO_CONTAIN_EQUAL;
  4283. var build_13 = build$2.SUGGEST_TO_EQUAL;
  4284. var build_14 = build$2.RECEIVED_COLOR;
  4285. var build_15 = build$2.EXPECTED_COLOR;
  4286. var matcherUtils = Object.freeze({
  4287. default: index$1,
  4288. __moduleExports: build$2,
  4289. matcherHint: build_1,
  4290. pluralize: build_2,
  4291. ensureNumbers: build_3,
  4292. ensureExpectedIsNumber: build_4,
  4293. ensureActualIsNumber: build_5,
  4294. ensureNoExpected: build_6,
  4295. printWithType: build_7,
  4296. printExpected: build_8,
  4297. printReceived: build_9,
  4298. highlightTrailingWhitespace: build_10,
  4299. stringify: build_11,
  4300. SUGGEST_TO_CONTAIN_EQUAL: build_12,
  4301. SUGGEST_TO_EQUAL: build_13,
  4302. RECEIVED_COLOR: build_14,
  4303. EXPECTED_COLOR: build_15
  4304. });
  4305. // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
  4306. var $getOwnPropertyDescriptor$1 = _objectGopd.f;
  4307. _objectSap('getOwnPropertyDescriptor', function () {
  4308. return function getOwnPropertyDescriptor(it, key) {
  4309. return $getOwnPropertyDescriptor$1(_toIobject(it), key);
  4310. };
  4311. });
  4312. var $Object$2 = _core.Object;
  4313. var getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key) {
  4314. return $Object$2.getOwnPropertyDescriptor(it, key);
  4315. };
  4316. var getOwnPropertyDescriptor$1 = createCommonjsModule(function (module) {
  4317. module.exports = { "default": getOwnPropertyDescriptor, __esModule: true };
  4318. });
  4319. var _Object$getOwnPropertyDescriptor = unwrapExports(getOwnPropertyDescriptor$1);
  4320. /*
  4321. Copyright (c) 2008-2016 Pivotal Labs
  4322. Permission is hereby granted, free of charge, to any person obtaining
  4323. a copy of this software and associated documentation files (the
  4324. "Software"), to deal in the Software without restriction, including
  4325. without limitation the rights to use, copy, modify, merge, publish,
  4326. distribute, sublicense, and/or sell copies of the Software, and to
  4327. permit persons to whom the Software is furnished to do so, subject to
  4328. the following conditions:
  4329. The above copyright notice and this permission notice shall be
  4330. included in all copies or substantial portions of the Software.
  4331. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  4332. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  4333. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  4334. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  4335. LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  4336. OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  4337. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  4338. */
  4339. /* eslint-disable */
  4340. // Extracted out of jasmine 2.5.2
  4341. function equals(a, b, customTesters, strictCheck) {
  4342. customTesters = customTesters || [];
  4343. return eq(a, b, [], [], customTesters, strictCheck ? hasKey : hasDefinedKey);
  4344. }
  4345. function isAsymmetric(obj) {
  4346. return obj && isA('Function', obj.asymmetricMatch);
  4347. }
  4348. function asymmetricMatch(a, b) {
  4349. var asymmetricA = isAsymmetric(a),
  4350. asymmetricB = isAsymmetric(b);
  4351. if (asymmetricA && asymmetricB) {
  4352. return undefined;
  4353. }
  4354. if (asymmetricA) {
  4355. return a.asymmetricMatch(b);
  4356. }
  4357. if (asymmetricB) {
  4358. return b.asymmetricMatch(a);
  4359. }
  4360. }
  4361. // Equality function lovingly adapted from isEqual in
  4362. // [Underscore](http://underscorejs.org)
  4363. function eq(a, b, aStack, bStack, customTesters, hasKey) {
  4364. var result = true;
  4365. var asymmetricResult = asymmetricMatch(a, b);
  4366. if (asymmetricResult !== undefined) {
  4367. return asymmetricResult;
  4368. }
  4369. for (var i = 0; i < customTesters.length; i++) {
  4370. var customTesterResult = customTesters[i](a, b);
  4371. if (customTesterResult !== undefined) {
  4372. return customTesterResult;
  4373. }
  4374. }
  4375. if (a instanceof Error && b instanceof Error) {
  4376. return a.message == b.message;
  4377. }
  4378. if (_Object$is(a, b)) {
  4379. return true;
  4380. }
  4381. // A strict comparison is necessary because `null == undefined`.
  4382. if (a === null || b === null) {
  4383. return a === b;
  4384. }
  4385. var className = Object.prototype.toString.call(a);
  4386. if (className != Object.prototype.toString.call(b)) {
  4387. return false;
  4388. }
  4389. switch (className) {
  4390. // Strings, numbers, dates, and booleans are compared by value.
  4391. case '[object String]':
  4392. // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
  4393. // equivalent to `new String("5")`.
  4394. return a == String(b);
  4395. case '[object Number]':
  4396. // `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for
  4397. // other numeric values.
  4398. return a != +a ? b != +b : a === 0 ? 1 / a == 1 / b : a == +b;
  4399. case '[object Date]':
  4400. case '[object Boolean]':
  4401. // Coerce dates and booleans to numeric primitive values. Dates are compared by their
  4402. // millisecond representations. Note that invalid dates with millisecond representations
  4403. // of `NaN` are not equivalent.
  4404. return +a == +b;
  4405. // RegExps are compared by their source patterns and flags.
  4406. case '[object RegExp]':
  4407. return a.source == b.source && a.global == b.global && a.multiline == b.multiline && a.ignoreCase == b.ignoreCase;
  4408. }
  4409. if ((typeof a === 'undefined' ? 'undefined' : _typeof(a)) != 'object' || (typeof b === 'undefined' ? 'undefined' : _typeof(b)) != 'object') {
  4410. return false;
  4411. }
  4412. var aIsDomNode = isDomNode(a);
  4413. var bIsDomNode = isDomNode(b);
  4414. if (aIsDomNode && bIsDomNode) {
  4415. // At first try to use DOM3 method isEqualNode
  4416. if (a.isEqualNode) {
  4417. return a.isEqualNode(b);
  4418. }
  4419. // IE8 doesn't support isEqualNode, try to use outerHTML && innerText
  4420. var aIsElement = a instanceof Element;
  4421. var bIsElement = b instanceof Element;
  4422. if (aIsElement && bIsElement) {
  4423. return a.outerHTML == b.outerHTML;
  4424. }
  4425. if (aIsElement || bIsElement) {
  4426. return false;
  4427. }
  4428. return a.innerText == b.innerText && a.textContent == b.textContent;
  4429. }
  4430. if (aIsDomNode || bIsDomNode) {
  4431. return false;
  4432. }
  4433. // Assume equality for cyclic structures. The algorithm for detecting cyclic
  4434. // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
  4435. var length = aStack.length;
  4436. while (length--) {
  4437. // Linear search. Performance is inversely proportional to the number of
  4438. // unique nested structures.
  4439. if (aStack[length] == a) {
  4440. return bStack[length] == b;
  4441. }
  4442. }
  4443. // Add the first object to the stack of traversed objects.
  4444. aStack.push(a);
  4445. bStack.push(b);
  4446. var size = 0;
  4447. // Recursively compare objects and arrays.
  4448. // Compare array lengths to determine if a deep comparison is necessary.
  4449. if (className == '[object Array]') {
  4450. size = a.length;
  4451. if (size !== b.length) {
  4452. return false;
  4453. }
  4454. while (size--) {
  4455. result = eq(a[size], b[size], aStack, bStack, customTesters, hasKey);
  4456. if (!result) {
  4457. return false;
  4458. }
  4459. }
  4460. }
  4461. // Deep compare objects.
  4462. var aKeys = keys$2(a, className == '[object Array]', hasKey),
  4463. key;
  4464. size = aKeys.length;
  4465. // Ensure that both objects contain the same number of properties before comparing deep equality.
  4466. if (keys$2(b, className == '[object Array]', hasKey).length !== size) {
  4467. return false;
  4468. }
  4469. while (size--) {
  4470. key = aKeys[size];
  4471. // Deep compare each member
  4472. result = hasKey(b, key) && eq(a[key], b[key], aStack, bStack, customTesters, hasKey);
  4473. if (!result) {
  4474. return false;
  4475. }
  4476. }
  4477. // Remove the first object from the stack of traversed objects.
  4478. aStack.pop();
  4479. bStack.pop();
  4480. return result;
  4481. }
  4482. function keys$2(obj, isArray, hasKey) {
  4483. var allKeys = function (o) {
  4484. var keys = [];
  4485. for (var key in o) {
  4486. if (hasKey(o, key)) {
  4487. keys.push(key);
  4488. }
  4489. }
  4490. return keys.concat(_Object$getOwnPropertySymbols(o).filter(
  4491. //$FlowFixMe Jest complains about nullability, but we know for sure that property 'symbol' does exist.
  4492. function (symbol) {
  4493. return _Object$getOwnPropertyDescriptor(o, symbol).enumerable;
  4494. }));
  4495. }(obj);
  4496. if (!isArray) {
  4497. return allKeys;
  4498. }
  4499. var extraKeys = [];
  4500. if (allKeys.length === 0) {
  4501. return allKeys;
  4502. }
  4503. for (var x = 0; x < allKeys.length; x++) {
  4504. //$FlowFixMe
  4505. if (_typeof(allKeys[x]) === 'symbol' || !allKeys[x].match(/^[0-9]+$/)) {
  4506. extraKeys.push(allKeys[x]);
  4507. }
  4508. }
  4509. return extraKeys;
  4510. }
  4511. function hasDefinedKey(obj, key) {
  4512. return hasKey(obj, key) && obj[key] !== undefined;
  4513. }
  4514. function hasKey(obj, key) {
  4515. return Object.prototype.hasOwnProperty.call(obj, key);
  4516. }
  4517. function isA(typeName, value) {
  4518. return Object.prototype.toString.apply(value) === '[object ' + typeName + ']';
  4519. }
  4520. function isDomNode(obj) {
  4521. return obj !== null && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && typeof obj.nodeType === 'number' && typeof obj.nodeName === 'string';
  4522. }
  4523. function fnNameFor(func) {
  4524. if (func.name) {
  4525. return func.name;
  4526. }
  4527. var matches = func.toString().match(/^\s*function\s*(\w*)\s*\(/);
  4528. return matches ? matches[1] : '<anonymous>';
  4529. }
  4530. function isUndefined(obj) {
  4531. return obj === void 0;
  4532. }
  4533. function getPrototype(obj) {
  4534. if (_Object$getPrototypeOf) {
  4535. return _Object$getPrototypeOf(obj);
  4536. }
  4537. if (obj.constructor.prototype == obj) {
  4538. return null;
  4539. }
  4540. return obj.constructor.prototype;
  4541. }
  4542. function hasProperty(obj, property) {
  4543. if (!obj) {
  4544. return false;
  4545. }
  4546. if (Object.prototype.hasOwnProperty.call(obj, property)) {
  4547. return true;
  4548. }
  4549. return hasProperty(getPrototype(obj), property);
  4550. }
  4551. // SENTINEL constants are from https://github.com/facebook/immutable-js
  4552. var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
  4553. var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
  4554. var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
  4555. function isImmutableUnorderedKeyed(maybeKeyed) {
  4556. return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL] && !maybeKeyed[IS_ORDERED_SENTINEL]);
  4557. }
  4558. function isImmutableUnorderedSet(maybeSet) {
  4559. return !!(maybeSet && maybeSet[IS_SET_SENTINEL] && !maybeSet[IS_ORDERED_SENTINEL]);
  4560. }
  4561. var hasOwnProperty$1 = function hasOwnProperty(object, value) {
  4562. return Object.prototype.hasOwnProperty.call(object, value) || Object.prototype.hasOwnProperty.call(object.constructor.prototype, value);
  4563. };
  4564. var getPath = function getPath(object, propertyPath) {
  4565. if (!Array.isArray(propertyPath)) {
  4566. propertyPath = propertyPath.split('.');
  4567. }
  4568. if (propertyPath.length) {
  4569. var lastProp = propertyPath.length === 1;
  4570. var prop = propertyPath[0];
  4571. var newObject = object[prop];
  4572. if (!lastProp && (newObject === null || newObject === undefined)) {
  4573. // This is not the last prop in the chain. If we keep recursing it will
  4574. // hit a `can't access property X of undefined | null`. At this point we
  4575. // know that the chain has broken and we can return right away.
  4576. return {
  4577. hasEndProp: false,
  4578. lastTraversedObject: object,
  4579. traversedPath: []
  4580. };
  4581. }
  4582. var result = getPath(newObject, propertyPath.slice(1));
  4583. if (result.lastTraversedObject === null) {
  4584. result.lastTraversedObject = object;
  4585. }
  4586. result.traversedPath.unshift(prop);
  4587. if (lastProp) {
  4588. result.hasEndProp = hasOwnProperty$1(object, prop);
  4589. if (!result.hasEndProp) {
  4590. result.traversedPath.shift();
  4591. }
  4592. }
  4593. return result;
  4594. }
  4595. return {
  4596. lastTraversedObject: null,
  4597. traversedPath: [],
  4598. value: object
  4599. };
  4600. };
  4601. // Strip properties from object that are not present in the subset. Useful for
  4602. // printing the diff for toMatchObject() without adding unrelated noise.
  4603. var getObjectSubset = function getObjectSubset(object, subset) {
  4604. if (Array.isArray(object)) {
  4605. if (Array.isArray(subset) && subset.length === object.length) {
  4606. return subset.map(function (sub, i) {
  4607. return getObjectSubset(object[i], sub);
  4608. });
  4609. }
  4610. } else if (object instanceof Date) {
  4611. return object;
  4612. } else if ((typeof object === 'undefined' ? 'undefined' : _typeof(object)) === 'object' && object !== null && (typeof subset === 'undefined' ? 'undefined' : _typeof(subset)) === 'object' && subset !== null) {
  4613. var trimmed = {};
  4614. _Object$keys(subset).filter(function (key) {
  4615. return hasOwnProperty$1(object, key);
  4616. }).forEach(function (key) {
  4617. return trimmed[key] = getObjectSubset(object[key], subset[key]);
  4618. });
  4619. if (_Object$keys(trimmed).length > 0) {
  4620. return trimmed;
  4621. }
  4622. }
  4623. return object;
  4624. };
  4625. var IteratorSymbol = _Symbol$iterator;
  4626. var hasIterator = function hasIterator(object) {
  4627. return !!(object != null && object[IteratorSymbol]);
  4628. };
  4629. var iterableEquality = function iterableEquality(a, b) {
  4630. if ((typeof a === 'undefined' ? 'undefined' : _typeof(a)) !== 'object' || (typeof b === 'undefined' ? 'undefined' : _typeof(b)) !== 'object' || Array.isArray(a) || Array.isArray(b) || !hasIterator(a) || !hasIterator(b)) {
  4631. return undefined;
  4632. }
  4633. if (a.constructor !== b.constructor) {
  4634. return false;
  4635. }
  4636. if (a.size !== undefined) {
  4637. if (a.size !== b.size) {
  4638. return false;
  4639. } else if (isA('Set', a) || isImmutableUnorderedSet(a)) {
  4640. var allFound = true;
  4641. var _iteratorNormalCompletion = true;
  4642. var _didIteratorError = false;
  4643. var _iteratorError = undefined;
  4644. try {
  4645. for (var _iterator = _getIterator(a), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  4646. var aValue = _step.value;
  4647. if (!b.has(aValue)) {
  4648. var has = false;
  4649. var _iteratorNormalCompletion2 = true;
  4650. var _didIteratorError2 = false;
  4651. var _iteratorError2 = undefined;
  4652. try {
  4653. for (var _iterator2 = _getIterator(b), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  4654. var bValue = _step2.value;
  4655. var isEqual = equals(aValue, bValue, [iterableEquality]);
  4656. if (isEqual === true) {
  4657. has = true;
  4658. }
  4659. }
  4660. } catch (err) {
  4661. _didIteratorError2 = true;
  4662. _iteratorError2 = err;
  4663. } finally {
  4664. try {
  4665. if (!_iteratorNormalCompletion2 && _iterator2.return) {
  4666. _iterator2.return();
  4667. }
  4668. } finally {
  4669. if (_didIteratorError2) {
  4670. throw _iteratorError2;
  4671. }
  4672. }
  4673. }
  4674. if (has === false) {
  4675. allFound = false;
  4676. break;
  4677. }
  4678. }
  4679. }
  4680. } catch (err) {
  4681. _didIteratorError = true;
  4682. _iteratorError = err;
  4683. } finally {
  4684. try {
  4685. if (!_iteratorNormalCompletion && _iterator.return) {
  4686. _iterator.return();
  4687. }
  4688. } finally {
  4689. if (_didIteratorError) {
  4690. throw _iteratorError;
  4691. }
  4692. }
  4693. }
  4694. if (allFound) {
  4695. return true;
  4696. }
  4697. } else if (isA('Map', a) || isImmutableUnorderedKeyed(a)) {
  4698. var _allFound = true;
  4699. var _iteratorNormalCompletion3 = true;
  4700. var _didIteratorError3 = false;
  4701. var _iteratorError3 = undefined;
  4702. try {
  4703. for (var _iterator3 = _getIterator(a), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  4704. var aEntry = _step3.value;
  4705. if (!b.has(aEntry[0]) || !equals(aEntry[1], b.get(aEntry[0]), [iterableEquality])) {
  4706. var _has = false;
  4707. var _iteratorNormalCompletion4 = true;
  4708. var _didIteratorError4 = false;
  4709. var _iteratorError4 = undefined;
  4710. try {
  4711. for (var _iterator4 = _getIterator(b), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
  4712. var bEntry = _step4.value;
  4713. var matchedKey = equals(aEntry[0], bEntry[0], [iterableEquality]);
  4714. var matchedValue = false;
  4715. if (matchedKey === true) {
  4716. matchedValue = equals(aEntry[1], bEntry[1], [iterableEquality]);
  4717. }
  4718. if (matchedValue === true) {
  4719. _has = true;
  4720. }
  4721. }
  4722. } catch (err) {
  4723. _didIteratorError4 = true;
  4724. _iteratorError4 = err;
  4725. } finally {
  4726. try {
  4727. if (!_iteratorNormalCompletion4 && _iterator4.return) {
  4728. _iterator4.return();
  4729. }
  4730. } finally {
  4731. if (_didIteratorError4) {
  4732. throw _iteratorError4;
  4733. }
  4734. }
  4735. }
  4736. if (_has === false) {
  4737. _allFound = false;
  4738. break;
  4739. }
  4740. }
  4741. }
  4742. } catch (err) {
  4743. _didIteratorError3 = true;
  4744. _iteratorError3 = err;
  4745. } finally {
  4746. try {
  4747. if (!_iteratorNormalCompletion3 && _iterator3.return) {
  4748. _iterator3.return();
  4749. }
  4750. } finally {
  4751. if (_didIteratorError3) {
  4752. throw _iteratorError3;
  4753. }
  4754. }
  4755. }
  4756. if (_allFound) {
  4757. return true;
  4758. }
  4759. }
  4760. }
  4761. var bIterator = b[IteratorSymbol]();
  4762. var _iteratorNormalCompletion5 = true;
  4763. var _didIteratorError5 = false;
  4764. var _iteratorError5 = undefined;
  4765. try {
  4766. for (var _iterator5 = _getIterator(a), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
  4767. var _aValue = _step5.value;
  4768. var nextB = bIterator.next();
  4769. if (nextB.done || !equals(_aValue, nextB.value, [iterableEquality])) {
  4770. return false;
  4771. }
  4772. }
  4773. } catch (err) {
  4774. _didIteratorError5 = true;
  4775. _iteratorError5 = err;
  4776. } finally {
  4777. try {
  4778. if (!_iteratorNormalCompletion5 && _iterator5.return) {
  4779. _iterator5.return();
  4780. }
  4781. } finally {
  4782. if (_didIteratorError5) {
  4783. throw _iteratorError5;
  4784. }
  4785. }
  4786. }
  4787. if (!bIterator.next().done) {
  4788. return false;
  4789. }
  4790. return true;
  4791. };
  4792. var isObjectWithKeys = function isObjectWithKeys(a) {
  4793. return a !== null && (typeof a === 'undefined' ? 'undefined' : _typeof(a)) === 'object' && !(a instanceof Error) && !(a instanceof Array) && !(a instanceof Date);
  4794. };
  4795. var subsetEquality = function subsetEquality(object, subset) {
  4796. if (!isObjectWithKeys(subset)) {
  4797. return undefined;
  4798. }
  4799. return _Object$keys(subset).every(function (key) {
  4800. return object != null && hasOwnProperty$1(object, key) && equals(object[key], subset[key], [iterableEquality, subsetEquality]);
  4801. });
  4802. };
  4803. var typeEquality = function typeEquality(a, b) {
  4804. if (a == null || b == null || a.constructor.name === b.constructor.name) {
  4805. return undefined;
  4806. }
  4807. return false;
  4808. };
  4809. var partition = function partition(items, predicate) {
  4810. var result = [[], []];
  4811. items.forEach(function (item) {
  4812. return result[predicate(item) ? 0 : 1].push(item);
  4813. });
  4814. return result;
  4815. };
  4816. // Copied from https://github.com/graingert/angular.js/blob/a43574052e9775cbc1d7dd8a086752c979b0f020/src/Angular.js#L685-L693
  4817. var isError = function isError(value) {
  4818. switch (Object.prototype.toString.call(value)) {
  4819. case '[object Error]':
  4820. return true;
  4821. case '[object Exception]':
  4822. return true;
  4823. case '[object DOMException]':
  4824. return true;
  4825. default:
  4826. return value instanceof Error;
  4827. }
  4828. };
  4829. function emptyObject(obj) {
  4830. return obj && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' ? !_Object$keys(obj).length : false;
  4831. }
  4832. var MULTILINE_REGEXP = /[\r\n]/;
  4833. var isOneline = function isOneline(expected, received) {
  4834. return typeof expected === 'string' && typeof received === 'string' && (!MULTILINE_REGEXP.test(expected) || !MULTILINE_REGEXP.test(received));
  4835. };
  4836. var _createProperty = function (object, index, value) {
  4837. if (index in object) _objectDp.f(object, index, _propertyDesc(0, value));
  4838. else object[index] = value;
  4839. };
  4840. _export(_export.S + _export.F * !_iterDetect(function (iter) { }), 'Array', {
  4841. // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined)
  4842. from: function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
  4843. var O = _toObject(arrayLike);
  4844. var C = typeof this == 'function' ? this : Array;
  4845. var aLen = arguments.length;
  4846. var mapfn = aLen > 1 ? arguments[1] : undefined;
  4847. var mapping = mapfn !== undefined;
  4848. var index = 0;
  4849. var iterFn = core_getIteratorMethod(O);
  4850. var length, result, step, iterator;
  4851. if (mapping) mapfn = _ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2);
  4852. // if object isn't iterable or it's array with default iterator - use simple case
  4853. if (iterFn != undefined && !(C == Array && _isArrayIter(iterFn))) {
  4854. for (iterator = iterFn.call(O), result = new C(); !(step = iterator.next()).done; index++) {
  4855. _createProperty(result, index, mapping ? _iterCall(iterator, mapfn, [step.value, index], true) : step.value);
  4856. }
  4857. } else {
  4858. length = _toLength(O.length);
  4859. for (result = new C(length); length > index; index++) {
  4860. _createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]);
  4861. }
  4862. }
  4863. result.length = index;
  4864. return result;
  4865. }
  4866. });
  4867. var from = _core.Array.from;
  4868. var from$1 = createCommonjsModule(function (module) {
  4869. module.exports = { "default": from, __esModule: true };
  4870. });
  4871. var _Array$from = unwrapExports(from$1);
  4872. // 20.1.2.4 Number.isNaN(number)
  4873. _export(_export.S, 'Number', {
  4874. isNaN: function isNaN(number) {
  4875. // eslint-disable-next-line no-self-compare
  4876. return number != number;
  4877. }
  4878. });
  4879. var isNan = _core.Number.isNaN;
  4880. var isNan$1 = createCommonjsModule(function (module) {
  4881. module.exports = { "default": isNan, __esModule: true };
  4882. });
  4883. var _Number$isNaN = unwrapExports(isNan$1);
  4884. var base = createCommonjsModule(function (module, exports) {
  4885. exports.__esModule = true;
  4886. exports['default'] = /*istanbul ignore end*/Diff;
  4887. function Diff() {}
  4888. Diff.prototype = {
  4889. /*istanbul ignore start*/ /*istanbul ignore end*/diff: function diff(oldString, newString) {
  4890. /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  4891. var callback = options.callback;
  4892. if (typeof options === 'function') {
  4893. callback = options;
  4894. options = {};
  4895. }
  4896. this.options = options;
  4897. var self = this;
  4898. function done(value) {
  4899. if (callback) {
  4900. setTimeout(function () {
  4901. callback(undefined, value);
  4902. }, 0);
  4903. return true;
  4904. } else {
  4905. return value;
  4906. }
  4907. }
  4908. // Allow subclasses to massage the input prior to running
  4909. oldString = this.castInput(oldString);
  4910. newString = this.castInput(newString);
  4911. oldString = this.removeEmpty(this.tokenize(oldString));
  4912. newString = this.removeEmpty(this.tokenize(newString));
  4913. var newLen = newString.length,
  4914. oldLen = oldString.length;
  4915. var editLength = 1;
  4916. var maxEditLength = newLen + oldLen;
  4917. var bestPath = [{ newPos: -1, components: [] }];
  4918. // Seed editLength = 0, i.e. the content starts with the same values
  4919. var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
  4920. if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
  4921. // Identity per the equality and tokenizer
  4922. return done([{ value: this.join(newString), count: newString.length }]);
  4923. }
  4924. // Main worker method. checks all permutations of a given edit length for acceptance.
  4925. function execEditLength() {
  4926. for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
  4927. var basePath = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
  4928. var addPath = bestPath[diagonalPath - 1],
  4929. removePath = bestPath[diagonalPath + 1],
  4930. _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
  4931. if (addPath) {
  4932. // No one else is going to attempt to use this value, clear it
  4933. bestPath[diagonalPath - 1] = undefined;
  4934. }
  4935. var canAdd = addPath && addPath.newPos + 1 < newLen,
  4936. canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen;
  4937. if (!canAdd && !canRemove) {
  4938. // If this path is a terminal then prune
  4939. bestPath[diagonalPath] = undefined;
  4940. continue;
  4941. }
  4942. // Select the diagonal that we want to branch from. We select the prior
  4943. // path whose position in the new string is the farthest from the origin
  4944. // and does not pass the bounds of the diff graph
  4945. if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
  4946. basePath = clonePath(removePath);
  4947. self.pushComponent(basePath.components, undefined, true);
  4948. } else {
  4949. basePath = addPath; // No need to clone, we've pulled it from the list
  4950. basePath.newPos++;
  4951. self.pushComponent(basePath.components, true, undefined);
  4952. }
  4953. _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath);
  4954. // If we have hit the end of both strings, then we are done
  4955. if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) {
  4956. return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken));
  4957. } else {
  4958. // Otherwise track this path as a potential candidate and continue.
  4959. bestPath[diagonalPath] = basePath;
  4960. }
  4961. }
  4962. editLength++;
  4963. }
  4964. // Performs the length of edit iteration. Is a bit fugly as this has to support the
  4965. // sync and async mode which is never fun. Loops over execEditLength until a value
  4966. // is produced.
  4967. if (callback) {
  4968. (function exec() {
  4969. setTimeout(function () {
  4970. // This should not happen, but we want to be safe.
  4971. /* istanbul ignore next */
  4972. if (editLength > maxEditLength) {
  4973. return callback();
  4974. }
  4975. if (!execEditLength()) {
  4976. exec();
  4977. }
  4978. }, 0);
  4979. })();
  4980. } else {
  4981. while (editLength <= maxEditLength) {
  4982. var ret = execEditLength();
  4983. if (ret) {
  4984. return ret;
  4985. }
  4986. }
  4987. }
  4988. },
  4989. /*istanbul ignore start*/ /*istanbul ignore end*/pushComponent: function pushComponent(components, added, removed) {
  4990. var last = components[components.length - 1];
  4991. if (last && last.added === added && last.removed === removed) {
  4992. // We need to clone here as the component clone operation is just
  4993. // as shallow array clone
  4994. components[components.length - 1] = { count: last.count + 1, added: added, removed: removed };
  4995. } else {
  4996. components.push({ count: 1, added: added, removed: removed });
  4997. }
  4998. },
  4999. /*istanbul ignore start*/ /*istanbul ignore end*/extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
  5000. var newLen = newString.length,
  5001. oldLen = oldString.length,
  5002. newPos = basePath.newPos,
  5003. oldPos = newPos - diagonalPath,
  5004. commonCount = 0;
  5005. while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
  5006. newPos++;
  5007. oldPos++;
  5008. commonCount++;
  5009. }
  5010. if (commonCount) {
  5011. basePath.components.push({ count: commonCount });
  5012. }
  5013. basePath.newPos = newPos;
  5014. return oldPos;
  5015. },
  5016. /*istanbul ignore start*/ /*istanbul ignore end*/equals: function equals(left, right) {
  5017. if (this.options.comparator) {
  5018. return this.options.comparator(left, right);
  5019. } else {
  5020. return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase();
  5021. }
  5022. },
  5023. /*istanbul ignore start*/ /*istanbul ignore end*/removeEmpty: function removeEmpty(array) {
  5024. var ret = [];
  5025. for (var i = 0; i < array.length; i++) {
  5026. if (array[i]) {
  5027. ret.push(array[i]);
  5028. }
  5029. }
  5030. return ret;
  5031. },
  5032. /*istanbul ignore start*/ /*istanbul ignore end*/castInput: function castInput(value) {
  5033. return value;
  5034. },
  5035. /*istanbul ignore start*/ /*istanbul ignore end*/tokenize: function tokenize(value) {
  5036. return value.split('');
  5037. },
  5038. /*istanbul ignore start*/ /*istanbul ignore end*/join: function join(chars) {
  5039. return chars.join('');
  5040. }
  5041. };
  5042. function buildValues(diff, components, newString, oldString, useLongestToken) {
  5043. var componentPos = 0,
  5044. componentLen = components.length,
  5045. newPos = 0,
  5046. oldPos = 0;
  5047. for (; componentPos < componentLen; componentPos++) {
  5048. var component = components[componentPos];
  5049. if (!component.removed) {
  5050. if (!component.added && useLongestToken) {
  5051. var value = newString.slice(newPos, newPos + component.count);
  5052. value = value.map(function (value, i) {
  5053. var oldValue = oldString[oldPos + i];
  5054. return oldValue.length > value.length ? oldValue : value;
  5055. });
  5056. component.value = diff.join(value);
  5057. } else {
  5058. component.value = diff.join(newString.slice(newPos, newPos + component.count));
  5059. }
  5060. newPos += component.count;
  5061. // Common case
  5062. if (!component.added) {
  5063. oldPos += component.count;
  5064. }
  5065. } else {
  5066. component.value = diff.join(oldString.slice(oldPos, oldPos + component.count));
  5067. oldPos += component.count;
  5068. // Reverse add and remove so removes are output first to match common convention
  5069. // The diffing algorithm is tied to add then remove output and this is the simplest
  5070. // route to get the desired output with minimal overhead.
  5071. if (componentPos && components[componentPos - 1].added) {
  5072. var tmp = components[componentPos - 1];
  5073. components[componentPos - 1] = components[componentPos];
  5074. components[componentPos] = tmp;
  5075. }
  5076. }
  5077. }
  5078. // Special case handle for when one terminal is ignored (i.e. whitespace).
  5079. // For this case we merge the terminal into the prior string and drop the change.
  5080. // This is only available for string mode.
  5081. var lastComponent = components[componentLen - 1];
  5082. if (componentLen > 1 && typeof lastComponent.value === 'string' && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) {
  5083. components[componentLen - 2].value += lastComponent.value;
  5084. components.pop();
  5085. }
  5086. return components;
  5087. }
  5088. function clonePath(path) {
  5089. return { newPos: path.newPos, components: path.components.slice(0) };
  5090. }
  5091. });
  5092. unwrapExports(base);
  5093. var character = createCommonjsModule(function (module, exports) {
  5094. exports.__esModule = true;
  5095. exports.characterDiff = undefined;
  5096. exports. /*istanbul ignore end*/diffChars = diffChars;
  5097. /*istanbul ignore start*/var _base2 = _interopRequireDefault(base);
  5098. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5099. /*istanbul ignore end*/var characterDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/characterDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
  5100. function diffChars(oldStr, newStr, options) {
  5101. return characterDiff.diff(oldStr, newStr, options);
  5102. }
  5103. });
  5104. unwrapExports(character);
  5105. var character_1 = character.characterDiff;
  5106. var character_2 = character.diffChars;
  5107. var params = createCommonjsModule(function (module, exports) {
  5108. exports.__esModule = true;
  5109. exports. /*istanbul ignore end*/generateOptions = generateOptions;
  5110. function generateOptions(options, defaults) {
  5111. if (typeof options === 'function') {
  5112. defaults.callback = options;
  5113. } else if (options) {
  5114. for (var name in options) {
  5115. /* istanbul ignore else */
  5116. if (options.hasOwnProperty(name)) {
  5117. defaults[name] = options[name];
  5118. }
  5119. }
  5120. }
  5121. return defaults;
  5122. }
  5123. });
  5124. unwrapExports(params);
  5125. var params_1 = params.generateOptions;
  5126. var word = createCommonjsModule(function (module, exports) {
  5127. exports.__esModule = true;
  5128. exports.wordDiff = undefined;
  5129. exports. /*istanbul ignore end*/diffWords = diffWords;
  5130. /*istanbul ignore start*/exports. /*istanbul ignore end*/diffWordsWithSpace = diffWordsWithSpace;
  5131. /*istanbul ignore start*/var _base2 = _interopRequireDefault(base);
  5132. /*istanbul ignore end*/
  5133. /*istanbul ignore start*/function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5134. /*istanbul ignore end*/ // Based on https://en.wikipedia.org/wiki/Latin_script_in_Unicode
  5135. //
  5136. // Ranges and exceptions:
  5137. // Latin-1 Supplement, 0080–00FF
  5138. // - U+00D7 × Multiplication sign
  5139. // - U+00F7 ÷ Division sign
  5140. // Latin Extended-A, 0100–017F
  5141. // Latin Extended-B, 0180–024F
  5142. // IPA Extensions, 0250–02AF
  5143. // Spacing Modifier Letters, 02B0–02FF
  5144. // - U+02C7 ˇ &#711; Caron
  5145. // - U+02D8 ˘ &#728; Breve
  5146. // - U+02D9 ˙ &#729; Dot Above
  5147. // - U+02DA ˚ &#730; Ring Above
  5148. // - U+02DB ˛ &#731; Ogonek
  5149. // - U+02DC ˜ &#732; Small Tilde
  5150. // - U+02DD ˝ &#733; Double Acute Accent
  5151. // Latin Extended Additional, 1E00–1EFF
  5152. var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/;
  5153. var reWhitespace = /\S/;
  5154. var wordDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/wordDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
  5155. wordDiff.equals = function (left, right) {
  5156. if (this.options.ignoreCase) {
  5157. left = left.toLowerCase();
  5158. right = right.toLowerCase();
  5159. }
  5160. return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right);
  5161. };
  5162. wordDiff.tokenize = function (value) {
  5163. var tokens = value.split(/(\s+|\b)/);
  5164. // Join the boundary splits that we do not consider to be boundaries. This is primarily the extended Latin character set.
  5165. for (var i = 0; i < tokens.length - 1; i++) {
  5166. // If we have an empty string in the next field and we have only word chars before and after, merge
  5167. if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) {
  5168. tokens[i] += tokens[i + 2];
  5169. tokens.splice(i + 1, 2);
  5170. i--;
  5171. }
  5172. }
  5173. return tokens;
  5174. };
  5175. function diffWords(oldStr, newStr, options) {
  5176. options = /*istanbul ignore start*/(0, params.generateOptions) /*istanbul ignore end*/(options, { ignoreWhitespace: true });
  5177. return wordDiff.diff(oldStr, newStr, options);
  5178. }
  5179. function diffWordsWithSpace(oldStr, newStr, options) {
  5180. return wordDiff.diff(oldStr, newStr, options);
  5181. }
  5182. });
  5183. unwrapExports(word);
  5184. var word_1 = word.wordDiff;
  5185. var word_2 = word.diffWords;
  5186. var word_3 = word.diffWordsWithSpace;
  5187. var line = createCommonjsModule(function (module, exports) {
  5188. exports.__esModule = true;
  5189. exports.lineDiff = undefined;
  5190. exports. /*istanbul ignore end*/diffLines = diffLines;
  5191. /*istanbul ignore start*/exports. /*istanbul ignore end*/diffTrimmedLines = diffTrimmedLines;
  5192. /*istanbul ignore start*/var _base2 = _interopRequireDefault(base);
  5193. /*istanbul ignore end*/
  5194. /*istanbul ignore start*/function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5195. /*istanbul ignore end*/var lineDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/lineDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
  5196. lineDiff.tokenize = function (value) {
  5197. var retLines = [],
  5198. linesAndNewlines = value.split(/(\n|\r\n)/);
  5199. // Ignore the final empty token that occurs if the string ends with a new line
  5200. if (!linesAndNewlines[linesAndNewlines.length - 1]) {
  5201. linesAndNewlines.pop();
  5202. }
  5203. // Merge the content and line separators into single tokens
  5204. for (var i = 0; i < linesAndNewlines.length; i++) {
  5205. var line = linesAndNewlines[i];
  5206. if (i % 2 && !this.options.newlineIsToken) {
  5207. retLines[retLines.length - 1] += line;
  5208. } else {
  5209. if (this.options.ignoreWhitespace) {
  5210. line = line.trim();
  5211. }
  5212. retLines.push(line);
  5213. }
  5214. }
  5215. return retLines;
  5216. };
  5217. function diffLines(oldStr, newStr, callback) {
  5218. return lineDiff.diff(oldStr, newStr, callback);
  5219. }
  5220. function diffTrimmedLines(oldStr, newStr, callback) {
  5221. var options = /*istanbul ignore start*/(0, params.generateOptions) /*istanbul ignore end*/(callback, { ignoreWhitespace: true });
  5222. return lineDiff.diff(oldStr, newStr, options);
  5223. }
  5224. });
  5225. unwrapExports(line);
  5226. var line_1 = line.lineDiff;
  5227. var line_2 = line.diffLines;
  5228. var line_3 = line.diffTrimmedLines;
  5229. var sentence = createCommonjsModule(function (module, exports) {
  5230. exports.__esModule = true;
  5231. exports.sentenceDiff = undefined;
  5232. exports. /*istanbul ignore end*/diffSentences = diffSentences;
  5233. /*istanbul ignore start*/var _base2 = _interopRequireDefault(base);
  5234. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5235. /*istanbul ignore end*/var sentenceDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/sentenceDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
  5236. sentenceDiff.tokenize = function (value) {
  5237. return value.split(/(\S.+?[.!?])(?=\s+|$)/);
  5238. };
  5239. function diffSentences(oldStr, newStr, callback) {
  5240. return sentenceDiff.diff(oldStr, newStr, callback);
  5241. }
  5242. });
  5243. unwrapExports(sentence);
  5244. var sentence_1 = sentence.sentenceDiff;
  5245. var sentence_2 = sentence.diffSentences;
  5246. var css = createCommonjsModule(function (module, exports) {
  5247. exports.__esModule = true;
  5248. exports.cssDiff = undefined;
  5249. exports. /*istanbul ignore end*/diffCss = diffCss;
  5250. /*istanbul ignore start*/var _base2 = _interopRequireDefault(base);
  5251. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5252. /*istanbul ignore end*/var cssDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/cssDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
  5253. cssDiff.tokenize = function (value) {
  5254. return value.split(/([{}:;,]|\s+)/);
  5255. };
  5256. function diffCss(oldStr, newStr, callback) {
  5257. return cssDiff.diff(oldStr, newStr, callback);
  5258. }
  5259. });
  5260. unwrapExports(css);
  5261. var css_1 = css.cssDiff;
  5262. var css_2 = css.diffCss;
  5263. var json = createCommonjsModule(function (module, exports) {
  5264. exports.__esModule = true;
  5265. exports.jsonDiff = undefined;
  5266. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  5267. exports. /*istanbul ignore end*/diffJson = diffJson;
  5268. /*istanbul ignore start*/exports. /*istanbul ignore end*/canonicalize = canonicalize;
  5269. /*istanbul ignore start*/var _base2 = _interopRequireDefault(base);
  5270. /*istanbul ignore end*/
  5271. /*istanbul ignore start*/function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5272. /*istanbul ignore end*/var objectPrototypeToString = Object.prototype.toString;
  5273. var jsonDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/jsonDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
  5274. // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
  5275. // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
  5276. jsonDiff.useLongestToken = true;
  5277. jsonDiff.tokenize = /*istanbul ignore start*/line.lineDiff /*istanbul ignore end*/.tokenize;
  5278. jsonDiff.castInput = function (value) {
  5279. /*istanbul ignore start*/var _options = /*istanbul ignore end*/this.options,
  5280. undefinedReplacement = _options.undefinedReplacement,
  5281. _options$stringifyRep = _options.stringifyReplacer,
  5282. stringifyReplacer = _options$stringifyRep === undefined ? function (k, v) /*istanbul ignore start*/{
  5283. return (/*istanbul ignore end*/typeof v === 'undefined' ? undefinedReplacement : v
  5284. );
  5285. } : _options$stringifyRep;
  5286. return typeof value === 'string' ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), stringifyReplacer, ' ');
  5287. };
  5288. jsonDiff.equals = function (left, right) {
  5289. return (/*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/.prototype.equals.call(jsonDiff, left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'))
  5290. );
  5291. };
  5292. function diffJson(oldObj, newObj, options) {
  5293. return jsonDiff.diff(oldObj, newObj, options);
  5294. }
  5295. // This function handles the presence of circular references by bailing out when encountering an
  5296. // object that is already on the "stack" of items being processed. Accepts an optional replacer
  5297. function canonicalize(obj, stack, replacementStack, replacer, key) {
  5298. stack = stack || [];
  5299. replacementStack = replacementStack || [];
  5300. if (replacer) {
  5301. obj = replacer(key, obj);
  5302. }
  5303. var i = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
  5304. for (i = 0; i < stack.length; i += 1) {
  5305. if (stack[i] === obj) {
  5306. return replacementStack[i];
  5307. }
  5308. }
  5309. var canonicalizedObj = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
  5310. if ('[object Array]' === objectPrototypeToString.call(obj)) {
  5311. stack.push(obj);
  5312. canonicalizedObj = new Array(obj.length);
  5313. replacementStack.push(canonicalizedObj);
  5314. for (i = 0; i < obj.length; i += 1) {
  5315. canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, key);
  5316. }
  5317. stack.pop();
  5318. replacementStack.pop();
  5319. return canonicalizedObj;
  5320. }
  5321. if (obj && obj.toJSON) {
  5322. obj = obj.toJSON();
  5323. }
  5324. if ( /*istanbul ignore start*/(typeof /*istanbul ignore end*/obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && obj !== null) {
  5325. stack.push(obj);
  5326. canonicalizedObj = {};
  5327. replacementStack.push(canonicalizedObj);
  5328. var sortedKeys = [],
  5329. _key = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
  5330. for (_key in obj) {
  5331. /* istanbul ignore else */
  5332. if (obj.hasOwnProperty(_key)) {
  5333. sortedKeys.push(_key);
  5334. }
  5335. }
  5336. sortedKeys.sort();
  5337. for (i = 0; i < sortedKeys.length; i += 1) {
  5338. _key = sortedKeys[i];
  5339. canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key);
  5340. }
  5341. stack.pop();
  5342. replacementStack.pop();
  5343. } else {
  5344. canonicalizedObj = obj;
  5345. }
  5346. return canonicalizedObj;
  5347. }
  5348. });
  5349. unwrapExports(json);
  5350. var json_1 = json.jsonDiff;
  5351. var json_2 = json.diffJson;
  5352. var json_3 = json.canonicalize;
  5353. var array = createCommonjsModule(function (module, exports) {
  5354. exports.__esModule = true;
  5355. exports.arrayDiff = undefined;
  5356. exports. /*istanbul ignore end*/diffArrays = diffArrays;
  5357. /*istanbul ignore start*/var _base2 = _interopRequireDefault(base);
  5358. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5359. /*istanbul ignore end*/var arrayDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/arrayDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
  5360. arrayDiff.tokenize = function (value) {
  5361. return value.slice();
  5362. };
  5363. arrayDiff.join = arrayDiff.removeEmpty = function (value) {
  5364. return value;
  5365. };
  5366. function diffArrays(oldArr, newArr, callback) {
  5367. return arrayDiff.diff(oldArr, newArr, callback);
  5368. }
  5369. });
  5370. unwrapExports(array);
  5371. var array_1 = array.arrayDiff;
  5372. var array_2 = array.diffArrays;
  5373. var parse = createCommonjsModule(function (module, exports) {
  5374. exports.__esModule = true;
  5375. exports. /*istanbul ignore end*/parsePatch = parsePatch;
  5376. function parsePatch(uniDiff) {
  5377. /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  5378. var diffstr = uniDiff.split(/\r\n|[\n\v\f\r\x85]/),
  5379. delimiters = uniDiff.match(/\r\n|[\n\v\f\r\x85]/g) || [],
  5380. list = [],
  5381. i = 0;
  5382. function parseIndex() {
  5383. var index = {};
  5384. list.push(index);
  5385. // Parse diff metadata
  5386. while (i < diffstr.length) {
  5387. var line = diffstr[i];
  5388. // File header found, end parsing diff metadata
  5389. if (/^(\-\-\-|\+\+\+|@@)\s/.test(line)) {
  5390. break;
  5391. }
  5392. // Diff index
  5393. var header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line);
  5394. if (header) {
  5395. index.index = header[1];
  5396. }
  5397. i++;
  5398. }
  5399. // Parse file headers if they are defined. Unified diff requires them, but
  5400. // there's no technical issues to have an isolated hunk without file header
  5401. parseFileHeader(index);
  5402. parseFileHeader(index);
  5403. // Parse hunks
  5404. index.hunks = [];
  5405. while (i < diffstr.length) {
  5406. var _line = diffstr[i];
  5407. if (/^(Index:|diff|\-\-\-|\+\+\+)\s/.test(_line)) {
  5408. break;
  5409. } else if (/^@@/.test(_line)) {
  5410. index.hunks.push(parseHunk());
  5411. } else if (_line && options.strict) {
  5412. // Ignore unexpected content unless in strict mode
  5413. throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(_line));
  5414. } else {
  5415. i++;
  5416. }
  5417. }
  5418. }
  5419. // Parses the --- and +++ headers, if none are found, no lines
  5420. // are consumed.
  5421. function parseFileHeader(index) {
  5422. var fileHeader = /^(---|\+\+\+)\s+(.*)$/.exec(diffstr[i]);
  5423. if (fileHeader) {
  5424. var keyPrefix = fileHeader[1] === '---' ? 'old' : 'new';
  5425. var data = fileHeader[2].split('\t', 2);
  5426. var fileName = data[0].replace(/\\\\/g, '\\');
  5427. if (/^".*"$/.test(fileName)) {
  5428. fileName = fileName.substr(1, fileName.length - 2);
  5429. }
  5430. index[keyPrefix + 'FileName'] = fileName;
  5431. index[keyPrefix + 'Header'] = (data[1] || '').trim();
  5432. i++;
  5433. }
  5434. }
  5435. // Parses a hunk
  5436. // This assumes that we are at the start of a hunk.
  5437. function parseHunk() {
  5438. var chunkHeaderIndex = i,
  5439. chunkHeaderLine = diffstr[i++],
  5440. chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
  5441. var hunk = {
  5442. oldStart: +chunkHeader[1],
  5443. oldLines: +chunkHeader[2] || 1,
  5444. newStart: +chunkHeader[3],
  5445. newLines: +chunkHeader[4] || 1,
  5446. lines: [],
  5447. linedelimiters: []
  5448. };
  5449. var addCount = 0,
  5450. removeCount = 0;
  5451. for (; i < diffstr.length; i++) {
  5452. // Lines starting with '---' could be mistaken for the "remove line" operation
  5453. // But they could be the header for the next file. Therefore prune such cases out.
  5454. if (diffstr[i].indexOf('--- ') === 0 && i + 2 < diffstr.length && diffstr[i + 1].indexOf('+++ ') === 0 && diffstr[i + 2].indexOf('@@') === 0) {
  5455. break;
  5456. }
  5457. var operation = diffstr[i].length == 0 && i != diffstr.length - 1 ? ' ' : diffstr[i][0];
  5458. if (operation === '+' || operation === '-' || operation === ' ' || operation === '\\') {
  5459. hunk.lines.push(diffstr[i]);
  5460. hunk.linedelimiters.push(delimiters[i] || '\n');
  5461. if (operation === '+') {
  5462. addCount++;
  5463. } else if (operation === '-') {
  5464. removeCount++;
  5465. } else if (operation === ' ') {
  5466. addCount++;
  5467. removeCount++;
  5468. }
  5469. } else {
  5470. break;
  5471. }
  5472. }
  5473. // Handle the empty block count case
  5474. if (!addCount && hunk.newLines === 1) {
  5475. hunk.newLines = 0;
  5476. }
  5477. if (!removeCount && hunk.oldLines === 1) {
  5478. hunk.oldLines = 0;
  5479. }
  5480. // Perform optional sanity checking
  5481. if (options.strict) {
  5482. if (addCount !== hunk.newLines) {
  5483. throw new Error('Added line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
  5484. }
  5485. if (removeCount !== hunk.oldLines) {
  5486. throw new Error('Removed line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
  5487. }
  5488. }
  5489. return hunk;
  5490. }
  5491. while (i < diffstr.length) {
  5492. parseIndex();
  5493. }
  5494. return list;
  5495. }
  5496. });
  5497. unwrapExports(parse);
  5498. var parse_1 = parse.parsePatch;
  5499. var distanceIterator = createCommonjsModule(function (module, exports) {
  5500. exports.__esModule = true;
  5501. exports["default"] = /*istanbul ignore end*/function (start, minLine, maxLine) {
  5502. var wantForward = true,
  5503. backwardExhausted = false,
  5504. forwardExhausted = false,
  5505. localOffset = 1;
  5506. return function iterator() {
  5507. if (wantForward && !forwardExhausted) {
  5508. if (backwardExhausted) {
  5509. localOffset++;
  5510. } else {
  5511. wantForward = false;
  5512. }
  5513. // Check if trying to fit beyond text length, and if not, check it fits
  5514. // after offset location (or desired location on first iteration)
  5515. if (start + localOffset <= maxLine) {
  5516. return localOffset;
  5517. }
  5518. forwardExhausted = true;
  5519. }
  5520. if (!backwardExhausted) {
  5521. if (!forwardExhausted) {
  5522. wantForward = true;
  5523. }
  5524. // Check if trying to fit before text beginning, and if not, check it fits
  5525. // before offset location
  5526. if (minLine <= start - localOffset) {
  5527. return -localOffset++;
  5528. }
  5529. backwardExhausted = true;
  5530. return iterator();
  5531. }
  5532. // We tried to fit hunk before text beginning and beyond text length, then
  5533. // hunk can't fit on the text. Return undefined
  5534. };
  5535. };
  5536. });
  5537. unwrapExports(distanceIterator);
  5538. var apply = createCommonjsModule(function (module, exports) {
  5539. exports.__esModule = true;
  5540. exports. /*istanbul ignore end*/applyPatch = applyPatch;
  5541. /*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatches = applyPatches;
  5542. /*istanbul ignore start*/var _distanceIterator2 = _interopRequireDefault(distanceIterator);
  5543. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5544. /*istanbul ignore end*/function applyPatch(source, uniDiff) {
  5545. /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  5546. if (typeof uniDiff === 'string') {
  5547. uniDiff = /*istanbul ignore start*/(0, parse.parsePatch) /*istanbul ignore end*/(uniDiff);
  5548. }
  5549. if (Array.isArray(uniDiff)) {
  5550. if (uniDiff.length > 1) {
  5551. throw new Error('applyPatch only works with a single input.');
  5552. }
  5553. uniDiff = uniDiff[0];
  5554. }
  5555. // Apply the diff to the input
  5556. var lines = source.split(/\r\n|[\n\v\f\r\x85]/),
  5557. delimiters = source.match(/\r\n|[\n\v\f\r\x85]/g) || [],
  5558. hunks = uniDiff.hunks,
  5559. compareLine = options.compareLine || function (lineNumber, line, operation, patchContent) /*istanbul ignore start*/{
  5560. return (/*istanbul ignore end*/line === patchContent
  5561. );
  5562. },
  5563. errorCount = 0,
  5564. fuzzFactor = options.fuzzFactor || 0,
  5565. minLine = 0,
  5566. offset = 0,
  5567. removeEOFNL = /*istanbul ignore start*/void 0 /*istanbul ignore end*/,
  5568. addEOFNL = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
  5569. /**
  5570. * Checks if the hunk exactly fits on the provided location
  5571. */
  5572. function hunkFits(hunk, toPos) {
  5573. for (var j = 0; j < hunk.lines.length; j++) {
  5574. var line = hunk.lines[j],
  5575. operation = line.length > 0 ? line[0] : ' ',
  5576. content = line.length > 0 ? line.substr(1) : line;
  5577. if (operation === ' ' || operation === '-') {
  5578. // Context sanity check
  5579. if (!compareLine(toPos + 1, lines[toPos], operation, content)) {
  5580. errorCount++;
  5581. if (errorCount > fuzzFactor) {
  5582. return false;
  5583. }
  5584. }
  5585. toPos++;
  5586. }
  5587. }
  5588. return true;
  5589. }
  5590. // Search best fit offsets for each hunk based on the previous ones
  5591. for (var i = 0; i < hunks.length; i++) {
  5592. var hunk = hunks[i],
  5593. maxLine = lines.length - hunk.oldLines,
  5594. localOffset = 0,
  5595. toPos = offset + hunk.oldStart - 1;
  5596. var iterator = /*istanbul ignore start*/(0, _distanceIterator2['default']) /*istanbul ignore end*/(toPos, minLine, maxLine);
  5597. for (; localOffset !== undefined; localOffset = iterator()) {
  5598. if (hunkFits(hunk, toPos + localOffset)) {
  5599. hunk.offset = offset += localOffset;
  5600. break;
  5601. }
  5602. }
  5603. if (localOffset === undefined) {
  5604. return false;
  5605. }
  5606. // Set lower text limit to end of the current hunk, so next ones don't try
  5607. // to fit over already patched text
  5608. minLine = hunk.offset + hunk.oldStart + hunk.oldLines;
  5609. }
  5610. // Apply patch hunks
  5611. var diffOffset = 0;
  5612. for (var _i = 0; _i < hunks.length; _i++) {
  5613. var _hunk = hunks[_i],
  5614. _toPos = _hunk.oldStart + _hunk.offset + diffOffset - 1;
  5615. diffOffset += _hunk.newLines - _hunk.oldLines;
  5616. if (_toPos < 0) {
  5617. // Creating a new file
  5618. _toPos = 0;
  5619. }
  5620. for (var j = 0; j < _hunk.lines.length; j++) {
  5621. var line = _hunk.lines[j],
  5622. operation = line.length > 0 ? line[0] : ' ',
  5623. content = line.length > 0 ? line.substr(1) : line,
  5624. delimiter = _hunk.linedelimiters[j];
  5625. if (operation === ' ') {
  5626. _toPos++;
  5627. } else if (operation === '-') {
  5628. lines.splice(_toPos, 1);
  5629. delimiters.splice(_toPos, 1);
  5630. /* istanbul ignore else */
  5631. } else if (operation === '+') {
  5632. lines.splice(_toPos, 0, content);
  5633. delimiters.splice(_toPos, 0, delimiter);
  5634. _toPos++;
  5635. } else if (operation === '\\') {
  5636. var previousOperation = _hunk.lines[j - 1] ? _hunk.lines[j - 1][0] : null;
  5637. if (previousOperation === '+') {
  5638. removeEOFNL = true;
  5639. } else if (previousOperation === '-') {
  5640. addEOFNL = true;
  5641. }
  5642. }
  5643. }
  5644. }
  5645. // Handle EOFNL insertion/removal
  5646. if (removeEOFNL) {
  5647. while (!lines[lines.length - 1]) {
  5648. lines.pop();
  5649. delimiters.pop();
  5650. }
  5651. } else if (addEOFNL) {
  5652. lines.push('');
  5653. delimiters.push('\n');
  5654. }
  5655. for (var _k = 0; _k < lines.length - 1; _k++) {
  5656. lines[_k] = lines[_k] + delimiters[_k];
  5657. }
  5658. return lines.join('');
  5659. }
  5660. // Wrapper that supports multiple file patches via callbacks.
  5661. function applyPatches(uniDiff, options) {
  5662. if (typeof uniDiff === 'string') {
  5663. uniDiff = /*istanbul ignore start*/(0, parse.parsePatch) /*istanbul ignore end*/(uniDiff);
  5664. }
  5665. var currentIndex = 0;
  5666. function processIndex() {
  5667. var index = uniDiff[currentIndex++];
  5668. if (!index) {
  5669. return options.complete();
  5670. }
  5671. options.loadFile(index, function (err, data) {
  5672. if (err) {
  5673. return options.complete(err);
  5674. }
  5675. var updatedContent = applyPatch(data, index, options);
  5676. options.patched(index, updatedContent, function (err) {
  5677. if (err) {
  5678. return options.complete(err);
  5679. }
  5680. processIndex();
  5681. });
  5682. });
  5683. }
  5684. processIndex();
  5685. }
  5686. });
  5687. unwrapExports(apply);
  5688. var apply_1 = apply.applyPatch;
  5689. var apply_2 = apply.applyPatches;
  5690. var create$2 = createCommonjsModule(function (module, exports) {
  5691. exports.__esModule = true;
  5692. exports. /*istanbul ignore end*/structuredPatch = structuredPatch;
  5693. /*istanbul ignore start*/exports. /*istanbul ignore end*/createTwoFilesPatch = createTwoFilesPatch;
  5694. /*istanbul ignore start*/exports. /*istanbul ignore end*/createPatch = createPatch;
  5695. /*istanbul ignore start*/function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  5696. /*istanbul ignore end*/function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
  5697. if (!options) {
  5698. options = {};
  5699. }
  5700. if (typeof options.context === 'undefined') {
  5701. options.context = 4;
  5702. }
  5703. var diff = /*istanbul ignore start*/(0, line.diffLines) /*istanbul ignore end*/(oldStr, newStr, options);
  5704. diff.push({ value: '', lines: [] }); // Append an empty value to make cleanup easier
  5705. function contextLines(lines) {
  5706. return lines.map(function (entry) {
  5707. return ' ' + entry;
  5708. });
  5709. }
  5710. var hunks = [];
  5711. var oldRangeStart = 0,
  5712. newRangeStart = 0,
  5713. curRange = [],
  5714. oldLine = 1,
  5715. newLine = 1;
  5716. /*istanbul ignore start*/var _loop = function _loop( /*istanbul ignore end*/i) {
  5717. var current = diff[i],
  5718. lines = current.lines || current.value.replace(/\n$/, '').split('\n');
  5719. current.lines = lines;
  5720. if (current.added || current.removed) {
  5721. /*istanbul ignore start*/var _curRange;
  5722. /*istanbul ignore end*/ // If we have previous context, start with that
  5723. if (!oldRangeStart) {
  5724. var prev = diff[i - 1];
  5725. oldRangeStart = oldLine;
  5726. newRangeStart = newLine;
  5727. if (prev) {
  5728. curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
  5729. oldRangeStart -= curRange.length;
  5730. newRangeStart -= curRange.length;
  5731. }
  5732. }
  5733. // Output our changes
  5734. /*istanbul ignore start*/(_curRange = /*istanbul ignore end*/curRange).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_curRange /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/lines.map(function (entry) {
  5735. return (current.added ? '+' : '-') + entry;
  5736. })));
  5737. // Track the updated file position
  5738. if (current.added) {
  5739. newLine += lines.length;
  5740. } else {
  5741. oldLine += lines.length;
  5742. }
  5743. } else {
  5744. // Identical context lines. Track line changes
  5745. if (oldRangeStart) {
  5746. // Close out any changes that have been output (or join overlapping)
  5747. if (lines.length <= options.context * 2 && i < diff.length - 2) {
  5748. /*istanbul ignore start*/var _curRange2;
  5749. /*istanbul ignore end*/ // Overlapping
  5750. /*istanbul ignore start*/(_curRange2 = /*istanbul ignore end*/curRange).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_curRange2 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/contextLines(lines)));
  5751. } else {
  5752. /*istanbul ignore start*/var _curRange3;
  5753. /*istanbul ignore end*/ // end the range and output
  5754. var contextSize = Math.min(lines.length, options.context);
  5755. /*istanbul ignore start*/(_curRange3 = /*istanbul ignore end*/curRange).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_curRange3 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/contextLines(lines.slice(0, contextSize))));
  5756. var hunk = {
  5757. oldStart: oldRangeStart,
  5758. oldLines: oldLine - oldRangeStart + contextSize,
  5759. newStart: newRangeStart,
  5760. newLines: newLine - newRangeStart + contextSize,
  5761. lines: curRange
  5762. };
  5763. if (i >= diff.length - 2 && lines.length <= options.context) {
  5764. // EOF is inside this hunk
  5765. var oldEOFNewline = /\n$/.test(oldStr);
  5766. var newEOFNewline = /\n$/.test(newStr);
  5767. if (lines.length == 0 && !oldEOFNewline) {
  5768. // special case: old has no eol and no trailing context; no-nl can end up before adds
  5769. curRange.splice(hunk.oldLines, 0, '\\ No newline at end of file');
  5770. } else if (!oldEOFNewline || !newEOFNewline) {
  5771. curRange.push('\\ No newline at end of file');
  5772. }
  5773. }
  5774. hunks.push(hunk);
  5775. oldRangeStart = 0;
  5776. newRangeStart = 0;
  5777. curRange = [];
  5778. }
  5779. }
  5780. oldLine += lines.length;
  5781. newLine += lines.length;
  5782. }
  5783. };
  5784. for (var i = 0; i < diff.length; i++) {
  5785. /*istanbul ignore start*/_loop( /*istanbul ignore end*/i);
  5786. }
  5787. return {
  5788. oldFileName: oldFileName, newFileName: newFileName,
  5789. oldHeader: oldHeader, newHeader: newHeader,
  5790. hunks: hunks
  5791. };
  5792. }
  5793. function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
  5794. var diff = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
  5795. var ret = [];
  5796. if (oldFileName == newFileName) {
  5797. ret.push('Index: ' + oldFileName);
  5798. }
  5799. ret.push('===================================================================');
  5800. ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader));
  5801. ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader));
  5802. for (var i = 0; i < diff.hunks.length; i++) {
  5803. var hunk = diff.hunks[i];
  5804. ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@');
  5805. ret.push.apply(ret, hunk.lines);
  5806. }
  5807. return ret.join('\n') + '\n';
  5808. }
  5809. function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
  5810. return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);
  5811. }
  5812. });
  5813. unwrapExports(create$2);
  5814. var create_1 = create$2.structuredPatch;
  5815. var create_2 = create$2.createTwoFilesPatch;
  5816. var create_3 = create$2.createPatch;
  5817. var array$2 = createCommonjsModule(function (module, exports) {
  5818. exports.__esModule = true;
  5819. exports. /*istanbul ignore end*/arrayEqual = arrayEqual;
  5820. /*istanbul ignore start*/exports. /*istanbul ignore end*/arrayStartsWith = arrayStartsWith;
  5821. function arrayEqual(a, b) {
  5822. if (a.length !== b.length) {
  5823. return false;
  5824. }
  5825. return arrayStartsWith(a, b);
  5826. }
  5827. function arrayStartsWith(array, start) {
  5828. if (start.length > array.length) {
  5829. return false;
  5830. }
  5831. for (var i = 0; i < start.length; i++) {
  5832. if (start[i] !== array[i]) {
  5833. return false;
  5834. }
  5835. }
  5836. return true;
  5837. }
  5838. });
  5839. unwrapExports(array$2);
  5840. var array_1$1 = array$2.arrayEqual;
  5841. var array_2$1 = array$2.arrayStartsWith;
  5842. var merge_1 = createCommonjsModule(function (module, exports) {
  5843. exports.__esModule = true;
  5844. exports. /*istanbul ignore end*/calcLineCount = calcLineCount;
  5845. /*istanbul ignore start*/exports. /*istanbul ignore end*/merge = merge;
  5846. /*istanbul ignore start*/function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  5847. /*istanbul ignore end*/function calcLineCount(hunk) {
  5848. /*istanbul ignore start*/var _calcOldNewLineCount = /*istanbul ignore end*/calcOldNewLineCount(hunk.lines),
  5849. oldLines = _calcOldNewLineCount.oldLines,
  5850. newLines = _calcOldNewLineCount.newLines;
  5851. if (oldLines !== undefined) {
  5852. hunk.oldLines = oldLines;
  5853. } else {
  5854. delete hunk.oldLines;
  5855. }
  5856. if (newLines !== undefined) {
  5857. hunk.newLines = newLines;
  5858. } else {
  5859. delete hunk.newLines;
  5860. }
  5861. }
  5862. function merge(mine, theirs, base) {
  5863. mine = loadPatch(mine, base);
  5864. theirs = loadPatch(theirs, base);
  5865. var ret = {};
  5866. // For index we just let it pass through as it doesn't have any necessary meaning.
  5867. // Leaving sanity checks on this to the API consumer that may know more about the
  5868. // meaning in their own context.
  5869. if (mine.index || theirs.index) {
  5870. ret.index = mine.index || theirs.index;
  5871. }
  5872. if (mine.newFileName || theirs.newFileName) {
  5873. if (!fileNameChanged(mine)) {
  5874. // No header or no change in ours, use theirs (and ours if theirs does not exist)
  5875. ret.oldFileName = theirs.oldFileName || mine.oldFileName;
  5876. ret.newFileName = theirs.newFileName || mine.newFileName;
  5877. ret.oldHeader = theirs.oldHeader || mine.oldHeader;
  5878. ret.newHeader = theirs.newHeader || mine.newHeader;
  5879. } else if (!fileNameChanged(theirs)) {
  5880. // No header or no change in theirs, use ours
  5881. ret.oldFileName = mine.oldFileName;
  5882. ret.newFileName = mine.newFileName;
  5883. ret.oldHeader = mine.oldHeader;
  5884. ret.newHeader = mine.newHeader;
  5885. } else {
  5886. // Both changed... figure it out
  5887. ret.oldFileName = selectField(ret, mine.oldFileName, theirs.oldFileName);
  5888. ret.newFileName = selectField(ret, mine.newFileName, theirs.newFileName);
  5889. ret.oldHeader = selectField(ret, mine.oldHeader, theirs.oldHeader);
  5890. ret.newHeader = selectField(ret, mine.newHeader, theirs.newHeader);
  5891. }
  5892. }
  5893. ret.hunks = [];
  5894. var mineIndex = 0,
  5895. theirsIndex = 0,
  5896. mineOffset = 0,
  5897. theirsOffset = 0;
  5898. while (mineIndex < mine.hunks.length || theirsIndex < theirs.hunks.length) {
  5899. var mineCurrent = mine.hunks[mineIndex] || { oldStart: Infinity },
  5900. theirsCurrent = theirs.hunks[theirsIndex] || { oldStart: Infinity };
  5901. if (hunkBefore(mineCurrent, theirsCurrent)) {
  5902. // This patch does not overlap with any of the others, yay.
  5903. ret.hunks.push(cloneHunk(mineCurrent, mineOffset));
  5904. mineIndex++;
  5905. theirsOffset += mineCurrent.newLines - mineCurrent.oldLines;
  5906. } else if (hunkBefore(theirsCurrent, mineCurrent)) {
  5907. // This patch does not overlap with any of the others, yay.
  5908. ret.hunks.push(cloneHunk(theirsCurrent, theirsOffset));
  5909. theirsIndex++;
  5910. mineOffset += theirsCurrent.newLines - theirsCurrent.oldLines;
  5911. } else {
  5912. // Overlap, merge as best we can
  5913. var mergedHunk = {
  5914. oldStart: Math.min(mineCurrent.oldStart, theirsCurrent.oldStart),
  5915. oldLines: 0,
  5916. newStart: Math.min(mineCurrent.newStart + mineOffset, theirsCurrent.oldStart + theirsOffset),
  5917. newLines: 0,
  5918. lines: []
  5919. };
  5920. mergeLines(mergedHunk, mineCurrent.oldStart, mineCurrent.lines, theirsCurrent.oldStart, theirsCurrent.lines);
  5921. theirsIndex++;
  5922. mineIndex++;
  5923. ret.hunks.push(mergedHunk);
  5924. }
  5925. }
  5926. return ret;
  5927. }
  5928. function loadPatch(param, base) {
  5929. if (typeof param === 'string') {
  5930. if (/^@@/m.test(param) || /^Index:/m.test(param)) {
  5931. return (/*istanbul ignore start*/(0, parse.parsePatch) /*istanbul ignore end*/(param)[0]
  5932. );
  5933. }
  5934. if (!base) {
  5935. throw new Error('Must provide a base reference or pass in a patch');
  5936. }
  5937. return (/*istanbul ignore start*/(0, create$2.structuredPatch) /*istanbul ignore end*/(undefined, undefined, base, param)
  5938. );
  5939. }
  5940. return param;
  5941. }
  5942. function fileNameChanged(patch) {
  5943. return patch.newFileName && patch.newFileName !== patch.oldFileName;
  5944. }
  5945. function selectField(index, mine, theirs) {
  5946. if (mine === theirs) {
  5947. return mine;
  5948. } else {
  5949. index.conflict = true;
  5950. return { mine: mine, theirs: theirs };
  5951. }
  5952. }
  5953. function hunkBefore(test, check) {
  5954. return test.oldStart < check.oldStart && test.oldStart + test.oldLines < check.oldStart;
  5955. }
  5956. function cloneHunk(hunk, offset) {
  5957. return {
  5958. oldStart: hunk.oldStart, oldLines: hunk.oldLines,
  5959. newStart: hunk.newStart + offset, newLines: hunk.newLines,
  5960. lines: hunk.lines
  5961. };
  5962. }
  5963. function mergeLines(hunk, mineOffset, mineLines, theirOffset, theirLines) {
  5964. // This will generally result in a conflicted hunk, but there are cases where the context
  5965. // is the only overlap where we can successfully merge the content here.
  5966. var mine = { offset: mineOffset, lines: mineLines, index: 0 },
  5967. their = { offset: theirOffset, lines: theirLines, index: 0 };
  5968. // Handle any leading content
  5969. insertLeading(hunk, mine, their);
  5970. insertLeading(hunk, their, mine);
  5971. // Now in the overlap content. Scan through and select the best changes from each.
  5972. while (mine.index < mine.lines.length && their.index < their.lines.length) {
  5973. var mineCurrent = mine.lines[mine.index],
  5974. theirCurrent = their.lines[their.index];
  5975. if ((mineCurrent[0] === '-' || mineCurrent[0] === '+') && (theirCurrent[0] === '-' || theirCurrent[0] === '+')) {
  5976. // Both modified ...
  5977. mutualChange(hunk, mine, their);
  5978. } else if (mineCurrent[0] === '+' && theirCurrent[0] === ' ') {
  5979. /*istanbul ignore start*/var _hunk$lines;
  5980. /*istanbul ignore end*/ // Mine inserted
  5981. /*istanbul ignore start*/(_hunk$lines = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/collectChange(mine)));
  5982. } else if (theirCurrent[0] === '+' && mineCurrent[0] === ' ') {
  5983. /*istanbul ignore start*/var _hunk$lines2;
  5984. /*istanbul ignore end*/ // Theirs inserted
  5985. /*istanbul ignore start*/(_hunk$lines2 = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines2 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/collectChange(their)));
  5986. } else if (mineCurrent[0] === '-' && theirCurrent[0] === ' ') {
  5987. // Mine removed or edited
  5988. removal(hunk, mine, their);
  5989. } else if (theirCurrent[0] === '-' && mineCurrent[0] === ' ') {
  5990. // Their removed or edited
  5991. removal(hunk, their, mine, true);
  5992. } else if (mineCurrent === theirCurrent) {
  5993. // Context identity
  5994. hunk.lines.push(mineCurrent);
  5995. mine.index++;
  5996. their.index++;
  5997. } else {
  5998. // Context mismatch
  5999. conflict(hunk, collectChange(mine), collectChange(their));
  6000. }
  6001. }
  6002. // Now push anything that may be remaining
  6003. insertTrailing(hunk, mine);
  6004. insertTrailing(hunk, their);
  6005. calcLineCount(hunk);
  6006. }
  6007. function mutualChange(hunk, mine, their) {
  6008. var myChanges = collectChange(mine),
  6009. theirChanges = collectChange(their);
  6010. if (allRemoves(myChanges) && allRemoves(theirChanges)) {
  6011. // Special case for remove changes that are supersets of one another
  6012. if ( /*istanbul ignore start*/(0, array$2.arrayStartsWith) /*istanbul ignore end*/(myChanges, theirChanges) && skipRemoveSuperset(their, myChanges, myChanges.length - theirChanges.length)) {
  6013. /*istanbul ignore start*/var _hunk$lines3;
  6014. /*istanbul ignore end*/ /*istanbul ignore start*/(_hunk$lines3 = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines3 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/myChanges));
  6015. return;
  6016. } else if ( /*istanbul ignore start*/(0, array$2.arrayStartsWith) /*istanbul ignore end*/(theirChanges, myChanges) && skipRemoveSuperset(mine, theirChanges, theirChanges.length - myChanges.length)) {
  6017. /*istanbul ignore start*/var _hunk$lines4;
  6018. /*istanbul ignore end*/ /*istanbul ignore start*/(_hunk$lines4 = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines4 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/theirChanges));
  6019. return;
  6020. }
  6021. } else if ( /*istanbul ignore start*/(0, array$2.arrayEqual) /*istanbul ignore end*/(myChanges, theirChanges)) {
  6022. /*istanbul ignore start*/var _hunk$lines5;
  6023. /*istanbul ignore end*/ /*istanbul ignore start*/(_hunk$lines5 = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines5 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/myChanges));
  6024. return;
  6025. }
  6026. conflict(hunk, myChanges, theirChanges);
  6027. }
  6028. function removal(hunk, mine, their, swap) {
  6029. var myChanges = collectChange(mine),
  6030. theirChanges = collectContext(their, myChanges);
  6031. if (theirChanges.merged) {
  6032. /*istanbul ignore start*/var _hunk$lines6;
  6033. /*istanbul ignore end*/ /*istanbul ignore start*/(_hunk$lines6 = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines6 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/theirChanges.merged));
  6034. } else {
  6035. conflict(hunk, swap ? theirChanges : myChanges, swap ? myChanges : theirChanges);
  6036. }
  6037. }
  6038. function conflict(hunk, mine, their) {
  6039. hunk.conflict = true;
  6040. hunk.lines.push({
  6041. conflict: true,
  6042. mine: mine,
  6043. theirs: their
  6044. });
  6045. }
  6046. function insertLeading(hunk, insert, their) {
  6047. while (insert.offset < their.offset && insert.index < insert.lines.length) {
  6048. var line = insert.lines[insert.index++];
  6049. hunk.lines.push(line);
  6050. insert.offset++;
  6051. }
  6052. }
  6053. function insertTrailing(hunk, insert) {
  6054. while (insert.index < insert.lines.length) {
  6055. var line = insert.lines[insert.index++];
  6056. hunk.lines.push(line);
  6057. }
  6058. }
  6059. function collectChange(state) {
  6060. var ret = [],
  6061. operation = state.lines[state.index][0];
  6062. while (state.index < state.lines.length) {
  6063. var line = state.lines[state.index];
  6064. // Group additions that are immediately after subtractions and treat them as one "atomic" modify change.
  6065. if (operation === '-' && line[0] === '+') {
  6066. operation = '+';
  6067. }
  6068. if (operation === line[0]) {
  6069. ret.push(line);
  6070. state.index++;
  6071. } else {
  6072. break;
  6073. }
  6074. }
  6075. return ret;
  6076. }
  6077. function collectContext(state, matchChanges) {
  6078. var changes = [],
  6079. merged = [],
  6080. matchIndex = 0,
  6081. contextChanges = false,
  6082. conflicted = false;
  6083. while (matchIndex < matchChanges.length && state.index < state.lines.length) {
  6084. var change = state.lines[state.index],
  6085. match = matchChanges[matchIndex];
  6086. // Once we've hit our add, then we are done
  6087. if (match[0] === '+') {
  6088. break;
  6089. }
  6090. contextChanges = contextChanges || change[0] !== ' ';
  6091. merged.push(match);
  6092. matchIndex++;
  6093. // Consume any additions in the other block as a conflict to attempt
  6094. // to pull in the remaining context after this
  6095. if (change[0] === '+') {
  6096. conflicted = true;
  6097. while (change[0] === '+') {
  6098. changes.push(change);
  6099. change = state.lines[++state.index];
  6100. }
  6101. }
  6102. if (match.substr(1) === change.substr(1)) {
  6103. changes.push(change);
  6104. state.index++;
  6105. } else {
  6106. conflicted = true;
  6107. }
  6108. }
  6109. if ((matchChanges[matchIndex] || '')[0] === '+' && contextChanges) {
  6110. conflicted = true;
  6111. }
  6112. if (conflicted) {
  6113. return changes;
  6114. }
  6115. while (matchIndex < matchChanges.length) {
  6116. merged.push(matchChanges[matchIndex++]);
  6117. }
  6118. return {
  6119. merged: merged,
  6120. changes: changes
  6121. };
  6122. }
  6123. function allRemoves(changes) {
  6124. return changes.reduce(function (prev, change) {
  6125. return prev && change[0] === '-';
  6126. }, true);
  6127. }
  6128. function skipRemoveSuperset(state, removeChanges, delta) {
  6129. for (var i = 0; i < delta; i++) {
  6130. var changeContent = removeChanges[removeChanges.length - delta + i].substr(1);
  6131. if (state.lines[state.index + i] !== ' ' + changeContent) {
  6132. return false;
  6133. }
  6134. }
  6135. state.index += delta;
  6136. return true;
  6137. }
  6138. function calcOldNewLineCount(lines) {
  6139. var oldLines = 0;
  6140. var newLines = 0;
  6141. lines.forEach(function (line) {
  6142. if (typeof line !== 'string') {
  6143. var myCount = calcOldNewLineCount(line.mine);
  6144. var theirCount = calcOldNewLineCount(line.theirs);
  6145. if (oldLines !== undefined) {
  6146. if (myCount.oldLines === theirCount.oldLines) {
  6147. oldLines += myCount.oldLines;
  6148. } else {
  6149. oldLines = undefined;
  6150. }
  6151. }
  6152. if (newLines !== undefined) {
  6153. if (myCount.newLines === theirCount.newLines) {
  6154. newLines += myCount.newLines;
  6155. } else {
  6156. newLines = undefined;
  6157. }
  6158. }
  6159. } else {
  6160. if (newLines !== undefined && (line[0] === '+' || line[0] === ' ')) {
  6161. newLines++;
  6162. }
  6163. if (oldLines !== undefined && (line[0] === '-' || line[0] === ' ')) {
  6164. oldLines++;
  6165. }
  6166. }
  6167. });
  6168. return { oldLines: oldLines, newLines: newLines };
  6169. }
  6170. });
  6171. unwrapExports(merge_1);
  6172. var merge_2 = merge_1.calcLineCount;
  6173. var merge_3 = merge_1.merge;
  6174. var dmp = createCommonjsModule(function (module, exports) {
  6175. exports.__esModule = true;
  6176. exports. /*istanbul ignore end*/convertChangesToDMP = convertChangesToDMP;
  6177. // See: http://code.google.com/p/google-diff-match-patch/wiki/API
  6178. function convertChangesToDMP(changes) {
  6179. var ret = [],
  6180. change = /*istanbul ignore start*/void 0 /*istanbul ignore end*/,
  6181. operation = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
  6182. for (var i = 0; i < changes.length; i++) {
  6183. change = changes[i];
  6184. if (change.added) {
  6185. operation = 1;
  6186. } else if (change.removed) {
  6187. operation = -1;
  6188. } else {
  6189. operation = 0;
  6190. }
  6191. ret.push([operation, change.value]);
  6192. }
  6193. return ret;
  6194. }
  6195. });
  6196. unwrapExports(dmp);
  6197. var dmp_1 = dmp.convertChangesToDMP;
  6198. var xml = createCommonjsModule(function (module, exports) {
  6199. exports.__esModule = true;
  6200. exports. /*istanbul ignore end*/convertChangesToXML = convertChangesToXML;
  6201. function convertChangesToXML(changes) {
  6202. var ret = [];
  6203. for (var i = 0; i < changes.length; i++) {
  6204. var change = changes[i];
  6205. if (change.added) {
  6206. ret.push('<ins>');
  6207. } else if (change.removed) {
  6208. ret.push('<del>');
  6209. }
  6210. ret.push(escapeHTML(change.value));
  6211. if (change.added) {
  6212. ret.push('</ins>');
  6213. } else if (change.removed) {
  6214. ret.push('</del>');
  6215. }
  6216. }
  6217. return ret.join('');
  6218. }
  6219. function escapeHTML(s) {
  6220. var n = s;
  6221. n = n.replace(/&/g, '&amp;');
  6222. n = n.replace(/</g, '&lt;');
  6223. n = n.replace(/>/g, '&gt;');
  6224. n = n.replace(/"/g, '&quot;');
  6225. return n;
  6226. }
  6227. });
  6228. unwrapExports(xml);
  6229. var xml_1 = xml.convertChangesToXML;
  6230. var lib = createCommonjsModule(function (module, exports) {
  6231. exports.__esModule = true;
  6232. exports.canonicalize = exports.convertChangesToXML = exports.convertChangesToDMP = exports.merge = exports.parsePatch = exports.applyPatches = exports.applyPatch = exports.createPatch = exports.createTwoFilesPatch = exports.structuredPatch = exports.diffArrays = exports.diffJson = exports.diffCss = exports.diffSentences = exports.diffTrimmedLines = exports.diffLines = exports.diffWordsWithSpace = exports.diffWords = exports.diffChars = exports.Diff = undefined;
  6233. /*istanbul ignore end*/
  6234. /*istanbul ignore start*/var _base2 = _interopRequireDefault(base);
  6235. /*istanbul ignore end*/
  6236. /*istanbul ignore start*/function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6237. /* See LICENSE file for terms of use */
  6238. /*
  6239. * Text diff implementation.
  6240. *
  6241. * This library supports the following APIS:
  6242. * JsDiff.diffChars: Character by character diff
  6243. * JsDiff.diffWords: Word (as defined by \b regex) diff which ignores whitespace
  6244. * JsDiff.diffLines: Line based diff
  6245. *
  6246. * JsDiff.diffCss: Diff targeted at CSS content
  6247. *
  6248. * These methods are based on the implementation proposed in
  6249. * "An O(ND) Difference Algorithm and its Variations" (Myers, 1986).
  6250. * http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927
  6251. */
  6252. exports. /*istanbul ignore end*/Diff = _base2['default'];
  6253. /*istanbul ignore start*/exports. /*istanbul ignore end*/diffChars = character.diffChars;
  6254. /*istanbul ignore start*/exports. /*istanbul ignore end*/diffWords = word.diffWords;
  6255. /*istanbul ignore start*/exports. /*istanbul ignore end*/diffWordsWithSpace = word.diffWordsWithSpace;
  6256. /*istanbul ignore start*/exports. /*istanbul ignore end*/diffLines = line.diffLines;
  6257. /*istanbul ignore start*/exports. /*istanbul ignore end*/diffTrimmedLines = line.diffTrimmedLines;
  6258. /*istanbul ignore start*/exports. /*istanbul ignore end*/diffSentences = sentence.diffSentences;
  6259. /*istanbul ignore start*/exports. /*istanbul ignore end*/diffCss = css.diffCss;
  6260. /*istanbul ignore start*/exports. /*istanbul ignore end*/diffJson = json.diffJson;
  6261. /*istanbul ignore start*/exports. /*istanbul ignore end*/diffArrays = array.diffArrays;
  6262. /*istanbul ignore start*/exports. /*istanbul ignore end*/structuredPatch = create$2.structuredPatch;
  6263. /*istanbul ignore start*/exports. /*istanbul ignore end*/createTwoFilesPatch = create$2.createTwoFilesPatch;
  6264. /*istanbul ignore start*/exports. /*istanbul ignore end*/createPatch = create$2.createPatch;
  6265. /*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatch = apply.applyPatch;
  6266. /*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatches = apply.applyPatches;
  6267. /*istanbul ignore start*/exports. /*istanbul ignore end*/parsePatch = parse.parsePatch;
  6268. /*istanbul ignore start*/exports. /*istanbul ignore end*/merge = merge_1.merge;
  6269. /*istanbul ignore start*/exports. /*istanbul ignore end*/convertChangesToDMP = dmp.convertChangesToDMP;
  6270. /*istanbul ignore start*/exports. /*istanbul ignore end*/convertChangesToXML = xml.convertChangesToXML;
  6271. /*istanbul ignore start*/exports. /*istanbul ignore end*/canonicalize = json.canonicalize;
  6272. });
  6273. unwrapExports(lib);
  6274. var lib_1 = lib.canonicalize;
  6275. var lib_2 = lib.convertChangesToXML;
  6276. var lib_3 = lib.convertChangesToDMP;
  6277. var lib_4 = lib.merge;
  6278. var lib_5 = lib.parsePatch;
  6279. var lib_6 = lib.applyPatches;
  6280. var lib_7 = lib.applyPatch;
  6281. var lib_8 = lib.createPatch;
  6282. var lib_9 = lib.createTwoFilesPatch;
  6283. var lib_10 = lib.structuredPatch;
  6284. var lib_11 = lib.diffArrays;
  6285. var lib_12 = lib.diffJson;
  6286. var lib_13 = lib.diffCss;
  6287. var lib_14 = lib.diffSentences;
  6288. var lib_15 = lib.diffTrimmedLines;
  6289. var lib_16 = lib.diffLines;
  6290. var lib_17 = lib.diffWordsWithSpace;
  6291. var lib_18 = lib.diffWords;
  6292. var lib_19 = lib.diffChars;
  6293. var lib_20 = lib.Diff;
  6294. var constants = createCommonjsModule(function (module, exports) {
  6295. Object.defineProperty(exports, '__esModule', {
  6296. value: true
  6297. });
  6298. exports.SIMILAR_MESSAGE = exports.NO_DIFF_MESSAGE = undefined;
  6299. var _chalk2 = _interopRequireDefault(fake_chalk);
  6300. function _interopRequireDefault(obj) {
  6301. return obj && obj.__esModule ? obj : { default: obj };
  6302. }
  6303. var NO_DIFF_MESSAGE = exports.NO_DIFF_MESSAGE = _chalk2.default.dim('Compared values have no visual difference.');
  6304. /**
  6305. * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
  6306. *
  6307. * This source code is licensed under the MIT license found in the
  6308. * LICENSE file in the root directory of this source tree.
  6309. *
  6310. *
  6311. */
  6312. var SIMILAR_MESSAGE = exports.SIMILAR_MESSAGE = _chalk2.default.dim('Compared values serialize to the same structure.\n' + 'Printing internal object structure without calling `toJSON` instead.');
  6313. });
  6314. unwrapExports(constants);
  6315. var constants_1 = constants.SIMILAR_MESSAGE;
  6316. var constants_2 = constants.NO_DIFF_MESSAGE;
  6317. var diff_strings = createCommonjsModule(function (module, exports) {
  6318. Object.defineProperty(exports, '__esModule', {
  6319. value: true
  6320. });
  6321. exports.default = diffStrings;
  6322. var _chalk2 = _interopRequireDefault(fake_chalk);
  6323. function _interopRequireDefault(obj) {
  6324. return obj && obj.__esModule ? obj : { default: obj };
  6325. }
  6326. var DIFF_CONTEXT_DEFAULT = 5; // removed | added | equal
  6327. // Given diff digit, return array which consists of:
  6328. // if compared line is removed or added: corresponding original line
  6329. // if compared line is equal: original received and expected lines
  6330. /**
  6331. * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
  6332. *
  6333. * This source code is licensed under the MIT license found in the
  6334. * LICENSE file in the root directory of this source tree.
  6335. *
  6336. *
  6337. */
  6338. // Given chunk, return diff character.
  6339. var getDiffChar = function getDiffChar(chunk) {
  6340. return chunk.removed ? '-' : chunk.added ? '+' : ' ';
  6341. };
  6342. // Given diff character in line of hunk or computed from properties of chunk.
  6343. var getDiffDigit = function getDiffDigit(char) {
  6344. return char === '-' ? -1 : char === '+' ? 1 : 0;
  6345. };
  6346. // Color for text of line.
  6347. var getColor = function getColor(digit, onlyIndentationChanged) {
  6348. if (digit === -1) {
  6349. return _chalk2.default.green; // removed
  6350. }
  6351. if (digit === 1) {
  6352. return _chalk2.default.red; // added
  6353. }
  6354. return onlyIndentationChanged ? _chalk2.default.cyan : _chalk2.default.dim;
  6355. };
  6356. // Do NOT color leading or trailing spaces if original lines are equal:
  6357. // Background color for leading or trailing spaces.
  6358. var getBgColor = function getBgColor(digit, onlyIndentationChanged) {
  6359. return digit === 0 && !onlyIndentationChanged ? _chalk2.default.bgYellow : _chalk2.default.inverse;
  6360. };
  6361. // ONLY trailing if expected value is snapshot or multiline string.
  6362. var highlightTrailingSpaces = function highlightTrailingSpaces(line, bgColor) {
  6363. return line.replace(/\s+$/, bgColor('$&'));
  6364. };
  6365. // BOTH leading AND trailing if expected value is data structure.
  6366. var highlightLeadingTrailingSpaces = function highlightLeadingTrailingSpaces(line, bgColor
  6367. // If line consists of ALL spaces: highlight all of them.
  6368. ) {
  6369. return highlightTrailingSpaces(line, bgColor).replace(
  6370. // If line has an ODD length of leading spaces: highlight only the LAST.
  6371. /^(\s\s)*(\s)(?=[^\s])/, '$1' + bgColor('$2'));
  6372. };
  6373. var getAnnotation = function getAnnotation(options) {
  6374. return _chalk2.default.green('- ' + (options && options.aAnnotation || 'Expected')) + '\n' + _chalk2.default.red('+ ' + (options && options.bAnnotation || 'Received')) + '\n\n';
  6375. };
  6376. // Given string, return array of its lines.
  6377. var splitIntoLines = function splitIntoLines(string) {
  6378. var lines = string.split('\n');
  6379. if (lines.length !== 0 && lines[lines.length - 1] === '') {
  6380. lines.pop();
  6381. }
  6382. return lines;
  6383. };
  6384. // Given diff character and compared line, return original line with colors.
  6385. var formatLine = function formatLine(char, lineCompared, getOriginal) {
  6386. var digit = getDiffDigit(char);
  6387. if (getOriginal) {
  6388. // Compared without indentation if expected value is data structure.
  6389. var lineArray = getOriginal(digit);
  6390. var lineOriginal = lineArray[0];
  6391. var onlyIndentationChanged = digit === 0 && lineOriginal.length !== lineArray[1].length;
  6392. return getColor(digit, onlyIndentationChanged)(char + ' ' +
  6393. // Prepend indentation spaces from original to compared line.
  6394. lineOriginal.slice(0, lineOriginal.length - lineCompared.length) + highlightLeadingTrailingSpaces(lineCompared, getBgColor(digit, onlyIndentationChanged)));
  6395. }
  6396. // Format compared line when expected is snapshot or multiline string.
  6397. return getColor(digit)(char + ' ' + highlightTrailingSpaces(lineCompared, getBgColor(digit)));
  6398. };
  6399. // Given original lines, return callback function
  6400. // which given diff digit, returns array.
  6401. var getterForChunks = function getterForChunks(original) {
  6402. var linesExpected = splitIntoLines(original.a);
  6403. var linesReceived = splitIntoLines(original.b);
  6404. var iExpected = 0;
  6405. var iReceived = 0;
  6406. return function (digit) {
  6407. if (digit === -1) {
  6408. return [linesExpected[iExpected++]];
  6409. }
  6410. if (digit === 1) {
  6411. return [linesReceived[iReceived++]];
  6412. }
  6413. // Because compared line is equal: original received and expected lines.
  6414. return [linesReceived[iReceived++], linesExpected[iExpected++]];
  6415. };
  6416. };
  6417. // jest --expand
  6418. var formatChunks = function formatChunks(a, b, original) {
  6419. var chunks = (0, lib.diffLines)(a, b);
  6420. if (chunks.every(function (chunk) {
  6421. return !chunk.removed && !chunk.added;
  6422. })) {
  6423. return null;
  6424. }
  6425. var getOriginal = original && getterForChunks(original);
  6426. return chunks.reduce(function (lines, chunk) {
  6427. var char = getDiffChar(chunk);
  6428. splitIntoLines(chunk.value).forEach(function (line) {
  6429. lines.push(formatLine(char, line, getOriginal));
  6430. });
  6431. return lines;
  6432. }, []).join('\n');
  6433. };
  6434. // Only show patch marks ("@@ ... @@") if the diff is big.
  6435. // To determine this, we need to compare either the original string (a) to
  6436. // `hunk.oldLines` or a new string to `hunk.newLines`.
  6437. // If the `oldLinesCount` is greater than `hunk.oldLines`
  6438. // we can be sure that at least 1 line has been "hidden".
  6439. var shouldShowPatchMarks = function shouldShowPatchMarks(hunk, oldLinesCount) {
  6440. return oldLinesCount > hunk.oldLines;
  6441. };
  6442. var createPatchMark = function createPatchMark(hunk) {
  6443. var markOld = '-' + hunk.oldStart + ',' + hunk.oldLines;
  6444. var markNew = '+' + hunk.newStart + ',' + hunk.newLines;
  6445. return _chalk2.default.yellow('@@ ' + markOld + ' ' + markNew + ' @@');
  6446. };
  6447. // Given original lines, return callback function which given indexes for hunk,
  6448. // returns another callback function which given diff digit, returns array.
  6449. var getterForHunks = function getterForHunks(original) {
  6450. var linesExpected = splitIntoLines(original.a);
  6451. var linesReceived = splitIntoLines(original.b);
  6452. return function (iExpected, iReceived) {
  6453. return function (digit) {
  6454. if (digit === -1) {
  6455. return [linesExpected[iExpected++]];
  6456. }
  6457. if (digit === 1) {
  6458. return [linesReceived[iReceived++]];
  6459. }
  6460. // Because compared line is equal: original received and expected lines.
  6461. return [linesReceived[iReceived++], linesExpected[iExpected++]];
  6462. };
  6463. };
  6464. };
  6465. // jest --no-expand
  6466. var formatHunks = function formatHunks(a, b, contextLines, original) {
  6467. var options = {
  6468. context: typeof contextLines === 'number' && contextLines >= 0 ? contextLines : DIFF_CONTEXT_DEFAULT
  6469. };
  6470. var _structuredPatch = (0, lib.structuredPatch)('', '', a, b, '', '', options);
  6471. var hunks = _structuredPatch.hunks;
  6472. if (hunks.length === 0) {
  6473. return null;
  6474. }
  6475. var getter = original && getterForHunks(original);
  6476. var oldLinesCount = (a.match(/\n/g) || []).length;
  6477. return hunks.reduce(function (lines, hunk) {
  6478. if (shouldShowPatchMarks(hunk, oldLinesCount)) {
  6479. lines.push(createPatchMark(hunk));
  6480. }
  6481. // Hunk properties are one-based but index args are zero-based.
  6482. var getOriginal = getter && getter(hunk.oldStart - 1, hunk.newStart - 1);
  6483. hunk.lines.forEach(function (line) {
  6484. lines.push(formatLine(line[0], line.slice(1), getOriginal));
  6485. });
  6486. return lines;
  6487. }, []).join('\n');
  6488. };
  6489. function diffStrings(a, b, options, original) {
  6490. // Because `formatHunks` and `formatChunks` ignore one trailing newline,
  6491. // always append newline to strings:
  6492. a += '\n';
  6493. b += '\n';
  6494. // `diff` uses the Myers LCS diff algorithm which runs in O(n+d^2) time
  6495. // (where "d" is the edit distance) and can get very slow for large edit
  6496. // distances. Mitigate the cost by switching to a lower-resolution diff
  6497. // whenever linebreaks are involved.
  6498. var result = options && options.expand === false ? formatHunks(a, b, options && options.contextLines, original) : formatChunks(a, b, original);
  6499. return result === null ? constants.NO_DIFF_MESSAGE : getAnnotation(options) + result;
  6500. }
  6501. });
  6502. unwrapExports(diff_strings);
  6503. var build$3 = createCommonjsModule(function (module) {
  6504. var _prettyFormat2 = _interopRequireDefault(build$1);
  6505. var _chalk2 = _interopRequireDefault(fake_chalk);
  6506. var _jestGetType2 = _interopRequireDefault(build);
  6507. var _diff_strings2 = _interopRequireDefault(diff_strings);
  6508. function _interopRequireDefault(obj) {
  6509. return obj && obj.__esModule ? obj : { default: obj };
  6510. }
  6511. /**
  6512. * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
  6513. *
  6514. * This source code is licensed under the MIT license found in the
  6515. * LICENSE file in the root directory of this source tree.
  6516. *
  6517. *
  6518. */
  6519. var _prettyFormat$plugins = _prettyFormat2.default.plugins;
  6520. var AsymmetricMatcher = _prettyFormat$plugins.AsymmetricMatcher,
  6521. DOMCollection = _prettyFormat$plugins.DOMCollection,
  6522. DOMElement = _prettyFormat$plugins.DOMElement,
  6523. Immutable = _prettyFormat$plugins.Immutable,
  6524. ReactElement = _prettyFormat$plugins.ReactElement,
  6525. ReactTestComponent = _prettyFormat$plugins.ReactTestComponent;
  6526. var PLUGINS = [ReactTestComponent, ReactElement, DOMElement, DOMCollection, Immutable, AsymmetricMatcher];
  6527. var FORMAT_OPTIONS = {
  6528. plugins: PLUGINS
  6529. };
  6530. var FORMAT_OPTIONS_0 = _Object$assign({}, FORMAT_OPTIONS, {
  6531. indent: 0
  6532. });
  6533. var FALLBACK_FORMAT_OPTIONS = {
  6534. callToJSON: false,
  6535. maxDepth: 10,
  6536. plugins: PLUGINS
  6537. };
  6538. var FALLBACK_FORMAT_OPTIONS_0 = _Object$assign({}, FALLBACK_FORMAT_OPTIONS, {
  6539. indent: 0
  6540. });
  6541. // Generate a string that will highlight the difference between two values
  6542. // with green and red. (similar to how github does code diffing)
  6543. function diff(a, b, options) {
  6544. if (a === b) {
  6545. return constants.NO_DIFF_MESSAGE;
  6546. }
  6547. var aType = (0, _jestGetType2.default)(a);
  6548. var expectedType = aType;
  6549. var omitDifference = false;
  6550. if (aType === 'object' && typeof a.asymmetricMatch === 'function') {
  6551. if (a.$$typeof !== _Symbol$for('jest.asymmetricMatcher')) {
  6552. // Do not know expected type of user-defined asymmetric matcher.
  6553. return null;
  6554. }
  6555. if (typeof a.getExpectedType !== 'function') {
  6556. // For example, expect.anything() matches either null or undefined
  6557. return null;
  6558. }
  6559. expectedType = a.getExpectedType();
  6560. // Primitive types boolean and number omit difference below.
  6561. // For example, omit difference for expect.stringMatching(regexp)
  6562. omitDifference = expectedType === 'string';
  6563. }
  6564. if (expectedType !== (0, _jestGetType2.default)(b)) {
  6565. return ' Comparing two different types of values.' + (' Expected ' + _chalk2.default.green(expectedType) + ' but ') + ('received ' + _chalk2.default.red((0, _jestGetType2.default)(b)) + '.');
  6566. }
  6567. if (omitDifference) {
  6568. return null;
  6569. }
  6570. switch (aType) {
  6571. case 'string':
  6572. return (0, _diff_strings2.default)(a, b, options);
  6573. case 'number':
  6574. case 'boolean':
  6575. return null;
  6576. case 'map':
  6577. return compareObjects(sortMap(a), sortMap(b), options);
  6578. case 'set':
  6579. return compareObjects(sortSet(a), sortSet(b), options);
  6580. default:
  6581. return compareObjects(a, b, options);
  6582. }
  6583. }
  6584. function sortMap(map) {
  6585. return new _Map(_Array$from(map.entries()).sort());
  6586. }
  6587. function sortSet(set) {
  6588. return new _Set(_Array$from(set.values()).sort());
  6589. }
  6590. function compareObjects(a, b, options) {
  6591. var diffMessage = void 0;
  6592. var hasThrown = false;
  6593. try {
  6594. diffMessage = (0, _diff_strings2.default)((0, _prettyFormat2.default)(a, FORMAT_OPTIONS_0), (0, _prettyFormat2.default)(b, FORMAT_OPTIONS_0), options, {
  6595. a: (0, _prettyFormat2.default)(a, FORMAT_OPTIONS),
  6596. b: (0, _prettyFormat2.default)(b, FORMAT_OPTIONS)
  6597. });
  6598. } catch (e) {
  6599. hasThrown = true;
  6600. }
  6601. // If the comparison yields no results, compare again but this time
  6602. // without calling `toJSON`. It's also possible that toJSON might throw.
  6603. if (!diffMessage || diffMessage === constants.NO_DIFF_MESSAGE) {
  6604. diffMessage = (0, _diff_strings2.default)((0, _prettyFormat2.default)(a, FALLBACK_FORMAT_OPTIONS_0), (0, _prettyFormat2.default)(b, FALLBACK_FORMAT_OPTIONS_0), options, {
  6605. a: (0, _prettyFormat2.default)(a, FALLBACK_FORMAT_OPTIONS),
  6606. b: (0, _prettyFormat2.default)(b, FALLBACK_FORMAT_OPTIONS)
  6607. });
  6608. if (diffMessage !== constants.NO_DIFF_MESSAGE && !hasThrown) {
  6609. diffMessage = constants.SIMILAR_MESSAGE + '\n\n' + diffMessage;
  6610. }
  6611. }
  6612. return diffMessage;
  6613. }
  6614. module.exports = diff;
  6615. });
  6616. var diff = unwrapExports(build$3);
  6617. // Copyright Joyent, Inc. and other Node contributors.
  6618. //
  6619. // Permission is hereby granted, free of charge, to any person obtaining a
  6620. // copy of this software and associated documentation files (the
  6621. // "Software"), to deal in the Software without restriction, including
  6622. // without limitation the rights to use, copy, modify, merge, publish,
  6623. // distribute, sublicense, and/or sell copies of the Software, and to permit
  6624. // persons to whom the Software is furnished to do so, subject to the
  6625. // following conditions:
  6626. //
  6627. // The above copyright notice and this permission notice shall be included
  6628. // in all copies or substantial portions of the Software.
  6629. //
  6630. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  6631. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  6632. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  6633. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  6634. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  6635. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  6636. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  6637. // resolves . and .. elements in a path array with directory names there
  6638. // must be no slashes, empty elements, or device names (c:\) in the array
  6639. // (so also no leading and trailing slashes - it does not distinguish
  6640. // relative and absolute paths)
  6641. function normalizeArray(parts, allowAboveRoot) {
  6642. // if the path tries to go above the root, `up` ends up > 0
  6643. var up = 0;
  6644. for (var i = parts.length - 1; i >= 0; i--) {
  6645. var last = parts[i];
  6646. if (last === '.') {
  6647. parts.splice(i, 1);
  6648. } else if (last === '..') {
  6649. parts.splice(i, 1);
  6650. up++;
  6651. } else if (up) {
  6652. parts.splice(i, 1);
  6653. up--;
  6654. }
  6655. }
  6656. // if the path is allowed to go above the root, restore leading ..s
  6657. if (allowAboveRoot) {
  6658. for (; up--; up) {
  6659. parts.unshift('..');
  6660. }
  6661. }
  6662. return parts;
  6663. }
  6664. // Split a filename into [root, dir, basename, ext], unix version
  6665. // 'root' is just a slash, or nothing.
  6666. var splitPathRe =
  6667. /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
  6668. var splitPath = function(filename) {
  6669. return splitPathRe.exec(filename).slice(1);
  6670. };
  6671. // path.resolve([from ...], to)
  6672. // posix version
  6673. function resolve() {
  6674. var resolvedPath = '',
  6675. resolvedAbsolute = false;
  6676. for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
  6677. var path = (i >= 0) ? arguments[i] : '/';
  6678. // Skip empty and invalid entries
  6679. if (typeof path !== 'string') {
  6680. throw new TypeError('Arguments to path.resolve must be strings');
  6681. } else if (!path) {
  6682. continue;
  6683. }
  6684. resolvedPath = path + '/' + resolvedPath;
  6685. resolvedAbsolute = path.charAt(0) === '/';
  6686. }
  6687. // At this point the path should be resolved to a full absolute path, but
  6688. // handle relative paths to be safe (might happen when process.cwd() fails)
  6689. // Normalize the path
  6690. resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
  6691. return !!p;
  6692. }), !resolvedAbsolute).join('/');
  6693. return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
  6694. }
  6695. // path.normalize(path)
  6696. // posix version
  6697. function normalize(path) {
  6698. var isPathAbsolute = isAbsolute(path),
  6699. trailingSlash = substr(path, -1) === '/';
  6700. // Normalize the path
  6701. path = normalizeArray(filter(path.split('/'), function(p) {
  6702. return !!p;
  6703. }), !isPathAbsolute).join('/');
  6704. if (!path && !isPathAbsolute) {
  6705. path = '.';
  6706. }
  6707. if (path && trailingSlash) {
  6708. path += '/';
  6709. }
  6710. return (isPathAbsolute ? '/' : '') + path;
  6711. }
  6712. // posix version
  6713. function isAbsolute(path) {
  6714. return path.charAt(0) === '/';
  6715. }
  6716. // posix version
  6717. function join() {
  6718. var paths = Array.prototype.slice.call(arguments, 0);
  6719. return normalize(filter(paths, function(p, index) {
  6720. if (typeof p !== 'string') {
  6721. throw new TypeError('Arguments to path.join must be strings');
  6722. }
  6723. return p;
  6724. }).join('/'));
  6725. }
  6726. // path.relative(from, to)
  6727. // posix version
  6728. function relative(from, to) {
  6729. from = resolve(from).substr(1);
  6730. to = resolve(to).substr(1);
  6731. function trim(arr) {
  6732. var start = 0;
  6733. for (; start < arr.length; start++) {
  6734. if (arr[start] !== '') break;
  6735. }
  6736. var end = arr.length - 1;
  6737. for (; end >= 0; end--) {
  6738. if (arr[end] !== '') break;
  6739. }
  6740. if (start > end) return [];
  6741. return arr.slice(start, end - start + 1);
  6742. }
  6743. var fromParts = trim(from.split('/'));
  6744. var toParts = trim(to.split('/'));
  6745. var length = Math.min(fromParts.length, toParts.length);
  6746. var samePartsLength = length;
  6747. for (var i = 0; i < length; i++) {
  6748. if (fromParts[i] !== toParts[i]) {
  6749. samePartsLength = i;
  6750. break;
  6751. }
  6752. }
  6753. var outputParts = [];
  6754. for (var i = samePartsLength; i < fromParts.length; i++) {
  6755. outputParts.push('..');
  6756. }
  6757. outputParts = outputParts.concat(toParts.slice(samePartsLength));
  6758. return outputParts.join('/');
  6759. }
  6760. var sep = '/';
  6761. var delimiter = ':';
  6762. function dirname(path) {
  6763. var result = splitPath(path),
  6764. root = result[0],
  6765. dir = result[1];
  6766. if (!root && !dir) {
  6767. // No dirname whatsoever
  6768. return '.';
  6769. }
  6770. if (dir) {
  6771. // It has a dirname, strip trailing slash
  6772. dir = dir.substr(0, dir.length - 1);
  6773. }
  6774. return root + dir;
  6775. }
  6776. function basename(path, ext) {
  6777. var f = splitPath(path)[2];
  6778. // TODO: make this comparison case-insensitive on windows?
  6779. if (ext && f.substr(-1 * ext.length) === ext) {
  6780. f = f.substr(0, f.length - ext.length);
  6781. }
  6782. return f;
  6783. }
  6784. function extname(path) {
  6785. return splitPath(path)[3];
  6786. }
  6787. var path = {
  6788. extname: extname,
  6789. basename: basename,
  6790. dirname: dirname,
  6791. sep: sep,
  6792. delimiter: delimiter,
  6793. relative: relative,
  6794. join: join,
  6795. isAbsolute: isAbsolute,
  6796. normalize: normalize,
  6797. resolve: resolve
  6798. };
  6799. function filter (xs, f) {
  6800. if (xs.filter) return xs.filter(f);
  6801. var res = [];
  6802. for (var i = 0; i < xs.length; i++) {
  6803. if (f(xs[i], i, xs)) res.push(xs[i]);
  6804. }
  6805. return res;
  6806. }
  6807. // String.prototype.substr - negative index don't work in IE8
  6808. var substr = 'ab'.substr(-1) === 'b' ?
  6809. function (str, start, len) { return str.substr(start, len) } :
  6810. function (str, start, len) {
  6811. if (start < 0) start = str.length + start;
  6812. return str.substr(start, len);
  6813. }
  6814. ;
  6815. var path$1 = Object.freeze({
  6816. resolve: resolve,
  6817. normalize: normalize,
  6818. isAbsolute: isAbsolute,
  6819. join: join,
  6820. relative: relative,
  6821. sep: sep,
  6822. delimiter: delimiter,
  6823. dirname: dirname,
  6824. basename: basename,
  6825. extname: extname,
  6826. default: path
  6827. });
  6828. var path$2 = ( path$1 && path ) || path$1;
  6829. var build$4 = createCommonjsModule(function (module, exports) {
  6830. Object.defineProperty(exports, '__esModule', {
  6831. value: true
  6832. });
  6833. exports.replacePathSepForRegex = exports.escapeStrForRegex = exports.escapePathForRegex = undefined;
  6834. var _path2 = _interopRequireDefault(path$2);
  6835. function _interopRequireDefault(obj) {
  6836. return obj && obj.__esModule ? obj : { default: obj };
  6837. }
  6838. var escapePathForRegex = exports.escapePathForRegex = function (dir) {
  6839. if (_path2.default.sep === '\\') {
  6840. // Replace "\" with "/" so it's not escaped by escapeStrForRegex.
  6841. // replacePathSepForRegex will convert it back.
  6842. dir = dir.replace(/\\/g, '/');
  6843. }
  6844. return replacePathSepForRegex(escapeStrForRegex(dir));
  6845. };
  6846. /**
  6847. * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
  6848. *
  6849. * This source code is licensed under the MIT license found in the
  6850. * LICENSE file in the root directory of this source tree.
  6851. *
  6852. *
  6853. */
  6854. var escapeStrForRegex = exports.escapeStrForRegex = function (string) {
  6855. return string.replace(/[[\]{}()*+?.\\^$|]/g, '\\$&');
  6856. };
  6857. var replacePathSepForRegex = exports.replacePathSepForRegex = function (string) {
  6858. if (_path2.default.sep === '\\') {
  6859. return string.replace(/(\/|(.)?\\(?![[\]{}()*+?.^$|\\]))/g, function (_match, p1, p2) {
  6860. return p2 && p2 !== '\\' ? p2 + '\\\\' : '\\\\';
  6861. });
  6862. }
  6863. return string;
  6864. };
  6865. });
  6866. unwrapExports(build$4);
  6867. var build_1$1 = build$4.replacePathSepForRegex;
  6868. var build_2$1 = build$4.escapeStrForRegex;
  6869. var build_3$1 = build$4.escapePathForRegex;
  6870. var matchers = {
  6871. toBe: function toBe(received, expected) {
  6872. var _this = this;
  6873. var comment = 'Object.is equality';
  6874. var pass = _Object$is(received, expected);
  6875. var message = pass ? function () {
  6876. return build_1('.toBe', undefined, undefined, {
  6877. comment: comment,
  6878. isNot: true
  6879. }) + '\n\n' + ('Expected: ' + build_8(expected) + '\n') + ('Received: ' + build_9(received));
  6880. } : function () {
  6881. var suggestToEqual = build(received) === build(expected) && (build(received) === 'object' || build(expected) === 'array') && equals(received, expected, [iterableEquality]);
  6882. var oneline = isOneline(expected, received);
  6883. var diffString = diff(expected, received, { expand: _this.expand });
  6884. return build_1('.toBe', undefined, undefined, {
  6885. comment: comment,
  6886. isNot: false
  6887. }) + '\n\n' + ('Expected: ' + build_8(expected) + '\n') + ('Received: ' + build_9(received)) + (diffString && !oneline ? '\n\nDifference:\n\n' + diffString : '') + (suggestToEqual ? ' ' + build_13 : '');
  6888. };
  6889. // Passing the the actual and expected objects so that a custom reporter
  6890. // could access them, for example in order to display a custom visual diff,
  6891. // or create a different error message
  6892. return { actual: received, expected: expected, message: message, name: 'toBe', pass: pass };
  6893. },
  6894. toBeCloseTo: function toBeCloseTo(actual, expected) {
  6895. var _this2 = this;
  6896. var precision = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2;
  6897. var secondArgument = arguments.length === 3 ? 'precision' : null;
  6898. build_3(actual, expected, '.toBeCloseTo');
  6899. var pass = Math.abs(expected - actual) < Math.pow(10, -precision) / 2;
  6900. var message = function message() {
  6901. return build_1('.toBeCloseTo', undefined, undefined, {
  6902. isNot: _this2.isNot,
  6903. secondArgument: secondArgument
  6904. }) + '\n\n' + ('Precision: ' + build_8(precision) + '-digit\n') + ('Expected: ' + build_8(expected) + '\n') + ('Received: ' + build_9(actual));
  6905. };
  6906. return { message: message, pass: pass };
  6907. },
  6908. toBeDefined: function toBeDefined(actual, expected) {
  6909. var _this3 = this;
  6910. build_6(expected, '.toBeDefined');
  6911. var pass = actual !== void 0;
  6912. var message = function message() {
  6913. return build_1('.toBeDefined', 'received', '', {
  6914. isNot: _this3.isNot
  6915. }) + '\n\n' + ('Received: ' + build_9(actual));
  6916. };
  6917. return { message: message, pass: pass };
  6918. },
  6919. toBeFalsy: function toBeFalsy(actual, expected) {
  6920. var _this4 = this;
  6921. build_6(expected, '.toBeFalsy');
  6922. var pass = !actual;
  6923. var message = function message() {
  6924. return build_1('.toBeFalsy', 'received', '', {
  6925. isNot: _this4.isNot
  6926. }) + '\n\n' + ('Received: ' + build_9(actual));
  6927. };
  6928. return { message: message, pass: pass };
  6929. },
  6930. toBeGreaterThan: function toBeGreaterThan(actual, expected) {
  6931. var _this5 = this;
  6932. build_3(actual, expected, '.toBeGreaterThan');
  6933. var pass = actual > expected;
  6934. var message = function message() {
  6935. return build_1('.toBeGreaterThan', undefined, undefined, {
  6936. isNot: _this5.isNot
  6937. }) + '\n\n' + ('Expected: ' + build_8(expected) + '\n') + ('Received: ' + build_9(actual));
  6938. };
  6939. return { message: message, pass: pass };
  6940. },
  6941. toBeGreaterThanOrEqual: function toBeGreaterThanOrEqual(actual, expected) {
  6942. var _this6 = this;
  6943. build_3(actual, expected, '.toBeGreaterThanOrEqual');
  6944. var pass = actual >= expected;
  6945. var message = function message() {
  6946. return build_1('.toBeGreaterThanOrEqual', undefined, undefined, {
  6947. isNot: _this6.isNot
  6948. }) + '\n\n' + ('Expected: ' + build_8(expected) + '\n') + ('Received: ' + build_9(actual));
  6949. };
  6950. return { message: message, pass: pass };
  6951. },
  6952. toBeInstanceOf: function toBeInstanceOf(received, constructor) {
  6953. var _this7 = this;
  6954. var constType = build(constructor);
  6955. if (constType !== 'function') {
  6956. throw new Error(build_1('.toBeInstanceOf', 'value', 'constructor', {
  6957. isNot: this.isNot
  6958. }) + '\n\n' + 'Expected constructor to be a function. Instead got:\n' + (' ' + build_8(constType)));
  6959. }
  6960. var pass = received instanceof constructor;
  6961. var message = pass ? function () {
  6962. return build_1('.toBeInstanceOf', 'value', 'constructor', {
  6963. isNot: _this7.isNot
  6964. }) + '\n\n' + ('Expected constructor: ' + build_15(constructor.name || String(constructor)) + '\n') + ('Received value: ' + build_9(received));
  6965. } : function () {
  6966. return build_1('.toBeInstanceOf', 'value', 'constructor', {
  6967. isNot: _this7.isNot
  6968. }) + '\n\n' + ('Expected constructor: ' + build_15(constructor.name || String(constructor)) + '\n') + ('Received constructor: ' + build_14(received != null ? received.constructor && received.constructor.name : '') + '\n') + ('Received value: ' + build_9(received));
  6969. };
  6970. return { message: message, pass: pass };
  6971. },
  6972. toBeLessThan: function toBeLessThan(actual, expected) {
  6973. var _this8 = this;
  6974. build_3(actual, expected, '.toBeLessThan');
  6975. var pass = actual < expected;
  6976. var message = function message() {
  6977. return build_1('.toBeLessThan', undefined, undefined, {
  6978. isNot: _this8.isNot
  6979. }) + '\n\n' + ('Expected: ' + build_8(expected) + '\n') + ('Received: ' + build_9(actual));
  6980. };
  6981. return { message: message, pass: pass };
  6982. },
  6983. toBeLessThanOrEqual: function toBeLessThanOrEqual(actual, expected) {
  6984. var _this9 = this;
  6985. build_3(actual, expected, '.toBeLessThanOrEqual');
  6986. var pass = actual <= expected;
  6987. var message = function message() {
  6988. return build_1('.toBeLessThanOrEqual', undefined, undefined, {
  6989. isNot: _this9.isNot
  6990. }) + '\n\n' + ('Expected: ' + build_8(expected) + '\n') + ('Received: ' + build_9(actual));
  6991. };
  6992. return { message: message, pass: pass };
  6993. },
  6994. toBeNaN: function toBeNaN(actual, expected) {
  6995. var _this10 = this;
  6996. build_6(expected, '.toBeNaN');
  6997. var pass = _Number$isNaN(actual);
  6998. var message = function message() {
  6999. return build_1('.toBeNaN', 'received', '', {
  7000. isNot: _this10.isNot
  7001. }) + '\n\n' + ('Received: ' + build_9(actual));
  7002. };
  7003. return { message: message, pass: pass };
  7004. },
  7005. toBeNull: function toBeNull(actual, expected) {
  7006. var _this11 = this;
  7007. build_6(expected, '.toBeNull');
  7008. var pass = actual === null;
  7009. var message = function message() {
  7010. return build_1('.toBeNull', 'received', '', {
  7011. isNot: _this11.isNot
  7012. }) + '\n\n' + ('Received: ' + build_9(actual));
  7013. };
  7014. return { message: message, pass: pass };
  7015. },
  7016. toBeTruthy: function toBeTruthy(actual, expected) {
  7017. var _this12 = this;
  7018. build_6(expected, '.toBeTruthy');
  7019. var pass = !!actual;
  7020. var message = function message() {
  7021. return build_1('.toBeTruthy', 'received', '', {
  7022. isNot: _this12.isNot
  7023. }) + '\n\n' + ('Received: ' + build_9(actual));
  7024. };
  7025. return { message: message, pass: pass };
  7026. },
  7027. toBeUndefined: function toBeUndefined(actual, expected) {
  7028. var _this13 = this;
  7029. build_6(expected, '.toBeUndefined');
  7030. var pass = actual === void 0;
  7031. var message = function message() {
  7032. return build_1('.toBeUndefined', 'received', '', {
  7033. isNot: _this13.isNot
  7034. }) + '\n\n' + ('Received: ' + build_9(actual));
  7035. };
  7036. return { message: message, pass: pass };
  7037. },
  7038. toContain: function toContain(collection, value) {
  7039. var collectionType = build(collection);
  7040. var converted = null;
  7041. if (Array.isArray(collection) || typeof collection === 'string') {
  7042. // strings have `indexOf` so we don't need to convert
  7043. // arrays have `indexOf` and we don't want to make a copy
  7044. converted = collection;
  7045. } else {
  7046. try {
  7047. converted = _Array$from(collection);
  7048. } catch (e) {
  7049. throw new Error(build_1('[.not].toContainEqual', 'collection', 'value') + '\n\n' + ('Expected ' + build_14('collection') + ' to be an array-like structure.\n') + build_7('Received', collection, build_9));
  7050. }
  7051. }
  7052. // At this point, we're either a string or an Array,
  7053. // which was converted from an array-like structure.
  7054. var pass = converted.indexOf(value) != -1;
  7055. var message = pass ? function () {
  7056. return build_1('.not.toContain', collectionType, 'value') + '\n\n' + ('Expected ' + collectionType + ':\n') + (' ' + build_9(collection) + '\n') + 'Not to contain value:\n' + (' ' + build_8(value) + '\n');
  7057. } : function () {
  7058. var suggestToContainEqual = converted !== null && typeof converted !== 'string' && converted instanceof Array && converted.findIndex(function (item) {
  7059. return equals(item, value, [iterableEquality]);
  7060. }) !== -1;
  7061. return build_1('.toContain', collectionType, 'value') + '\n\n' + ('Expected ' + collectionType + ':\n') + (' ' + build_9(collection) + '\n') + 'To contain value:\n' + (' ' + build_8(value)) + (suggestToContainEqual ? '\n\n' + build_12 : '');
  7062. };
  7063. return { message: message, pass: pass };
  7064. },
  7065. toContainEqual: function toContainEqual(collection, value) {
  7066. var collectionType = build(collection);
  7067. var converted = null;
  7068. if (Array.isArray(collection)) {
  7069. converted = collection;
  7070. } else {
  7071. try {
  7072. converted = _Array$from(collection);
  7073. } catch (e) {
  7074. throw new Error(build_1('[.not].toContainEqual', 'collection', 'value') + '\n\n' + ('Expected ' + build_14('collection') + ' to be an array-like structure.\n') + build_7('Received', collection, build_9));
  7075. }
  7076. }
  7077. var pass = converted.findIndex(function (item) {
  7078. return equals(item, value, [iterableEquality]);
  7079. }) !== -1;
  7080. var message = pass ? function () {
  7081. return build_1('.not.toContainEqual', collectionType, 'value') + '\n\n' + ('Expected ' + collectionType + ':\n') + (' ' + build_9(collection) + '\n') + 'Not to contain a value equal to:\n' + (' ' + build_8(value) + '\n');
  7082. } : function () {
  7083. return build_1('.toContainEqual', collectionType, 'value') + '\n\n' + ('Expected ' + collectionType + ':\n') + (' ' + build_9(collection) + '\n') + 'To contain a value equal to:\n' + (' ' + build_8(value));
  7084. };
  7085. return { message: message, pass: pass };
  7086. },
  7087. toEqual: function toEqual(received, expected) {
  7088. var _this14 = this;
  7089. var pass = equals(received, expected, [iterableEquality]);
  7090. var message = pass ? function () {
  7091. return build_1('.not.toEqual') + '\n\n' + 'Expected value to not equal:\n' + (' ' + build_8(expected) + '\n') + 'Received:\n' + (' ' + build_9(received));
  7092. } : function () {
  7093. var oneline = isOneline(expected, received);
  7094. var diffString = diff(expected, received, { expand: _this14.expand });
  7095. return build_1('.toEqual') + '\n\n' + 'Expected value to equal:\n' + (' ' + build_8(expected) + '\n') + 'Received:\n' + (' ' + build_9(received)) + (diffString && !oneline ? '\n\nDifference:\n\n' + diffString : '');
  7096. };
  7097. // Passing the the actual and expected objects so that a custom reporter
  7098. // could access them, for example in order to display a custom visual diff,
  7099. // or create a different error message
  7100. return { actual: received, expected: expected, message: message, name: 'toEqual', pass: pass };
  7101. },
  7102. toHaveLength: function toHaveLength(received, length) {
  7103. if (typeof received !== 'string' && (!received || typeof received.length !== 'number')) {
  7104. throw new Error(build_1('[.not].toHaveLength', 'received', 'length') + '\n\n' + 'Expected value to have a \'length\' property that is a number. ' + 'Received:\n' + (' ' + build_9(received) + '\n') + (received ? 'received.length:\n ' + build_9(received.length) : ''));
  7105. }
  7106. var pass = received.length === length;
  7107. var message = pass ? function () {
  7108. return build_1('.not.toHaveLength', 'received', 'length') + '\n\n' + 'Expected value to not have length:\n' + (' ' + build_8(length) + '\n') + 'Received:\n' + (' ' + build_9(received) + '\n') + 'received.length:\n' + (' ' + build_9(received.length));
  7109. } : function () {
  7110. return build_1('.toHaveLength', 'received', 'length') + '\n\n' + 'Expected value to have length:\n' + (' ' + build_8(length) + '\n') + 'Received:\n' + (' ' + build_9(received) + '\n') + 'received.length:\n' + (' ' + build_9(received.length));
  7111. };
  7112. return { message: message, pass: pass };
  7113. },
  7114. toHaveProperty: function toHaveProperty(object, keyPath, value) {
  7115. var _this15 = this;
  7116. var valuePassed = arguments.length === 3;
  7117. var secondArgument = valuePassed ? 'value' : null;
  7118. if (!object && typeof object !== 'string' && typeof object !== 'number') {
  7119. throw new Error(build_1('[.not].toHaveProperty', 'object', 'path', {
  7120. secondArgument: secondArgument
  7121. }) + '\n\n' + ('Expected ' + build_14('object') + ' to be an object. Received:\n') + (' ' + build(object) + ': ' + build_9(object)));
  7122. }
  7123. var keyPathType = build(keyPath);
  7124. if (keyPathType !== 'string' && keyPathType !== 'array') {
  7125. throw new Error(build_1('[.not].toHaveProperty', 'object', 'path', {
  7126. secondArgument: secondArgument
  7127. }) + '\n\n' + ('Expected ' + build_15('path') + ' to be a string or an array. Received:\n') + (' ' + build(keyPath) + ': ' + build_9(keyPath)));
  7128. }
  7129. var result = getPath(object, keyPath);
  7130. var lastTraversedObject = result.lastTraversedObject,
  7131. hasEndProp = result.hasEndProp;
  7132. var pass = valuePassed ? equals(result.value, value, [iterableEquality]) : hasEndProp;
  7133. var traversedPath = result.traversedPath.join('.');
  7134. var message = pass ? function () {
  7135. return build_1('.not.toHaveProperty', 'object', 'path', {
  7136. secondArgument: secondArgument
  7137. }) + '\n\n' + 'Expected the object:\n' + (' ' + build_9(object) + '\n') + 'Not to have a nested property:\n' + (' ' + build_8(keyPath) + '\n') + (valuePassed ? 'With a value of:\n ' + build_8(value) + '\n' : '');
  7138. } : function () {
  7139. var diffString = valuePassed && hasEndProp ? diff(value, result.value, { expand: _this15.expand }) : '';
  7140. return build_1('.toHaveProperty', 'object', 'path', {
  7141. secondArgument: secondArgument
  7142. }) + '\n\n' + 'Expected the object:\n' + (' ' + build_9(object) + '\n') + 'To have a nested property:\n' + (' ' + build_8(keyPath) + '\n') + (valuePassed ? 'With a value of:\n ' + build_8(value) + '\n' : '') + (hasEndProp ? 'Received:\n' + (' ' + build_9(result.value)) + (diffString ? '\n\nDifference:\n\n' + diffString : '') : traversedPath ? 'Received:\n ' + build_14('object') + '.' + traversedPath + ': ' + build_9(lastTraversedObject) : '');
  7143. };
  7144. if (pass === undefined) {
  7145. throw new Error('pass must be initialized');
  7146. }
  7147. return { message: message, pass: pass };
  7148. },
  7149. toMatch: function toMatch(received, expected) {
  7150. if (typeof received !== 'string') {
  7151. throw new Error(build_1('[.not].toMatch', 'string', 'expected') + '\n\n' + (build_14('string') + ' value must be a string.\n') + build_7('Received', received, build_9));
  7152. }
  7153. if (!(expected && typeof expected.test === 'function') && !(typeof expected === 'string')) {
  7154. throw new Error(build_1('[.not].toMatch', 'string', 'expected') + '\n\n' + (build_15('expected') + ' value must be a string or a regular expression.\n') + build_7('Expected', expected, build_8));
  7155. }
  7156. var pass = new RegExp(typeof expected === 'string' ? build_2$1(expected) : expected).test(received);
  7157. var message = pass ? function () {
  7158. return build_1('.not.toMatch') + '\n\nExpected value not to match:\n' + (' ' + build_8(expected)) + '\nReceived:\n' + (' ' + build_9(received));
  7159. } : function () {
  7160. return build_1('.toMatch') + '\n\nExpected value to match:\n' + (' ' + build_8(expected)) + '\nReceived:\n' + (' ' + build_9(received));
  7161. };
  7162. return { message: message, pass: pass };
  7163. },
  7164. toMatchObject: function toMatchObject(receivedObject, expectedObject) {
  7165. var _this16 = this;
  7166. if ((typeof receivedObject === 'undefined' ? 'undefined' : _typeof(receivedObject)) !== 'object' || receivedObject === null) {
  7167. throw new Error(build_1('[.not].toMatchObject', 'object', 'expected') + '\n\n' + (build_14('received') + ' value must be an object.\n') + build_7('Received', receivedObject, build_9));
  7168. }
  7169. if ((typeof expectedObject === 'undefined' ? 'undefined' : _typeof(expectedObject)) !== 'object' || expectedObject === null) {
  7170. throw new Error(build_1('[.not].toMatchObject', 'object', 'expected') + '\n\n' + (build_15('expected') + ' value must be an object.\n') + build_7('Expected', expectedObject, build_8));
  7171. }
  7172. var pass = equals(receivedObject, expectedObject, [iterableEquality, subsetEquality]);
  7173. var message = pass ? function () {
  7174. return build_1('.not.toMatchObject') + '\n\nExpected value not to match object:\n' + (' ' + build_8(expectedObject)) + '\nReceived:\n' + (' ' + build_9(receivedObject));
  7175. } : function () {
  7176. var diffString = diff(expectedObject, getObjectSubset(receivedObject, expectedObject), {
  7177. expand: _this16.expand
  7178. });
  7179. return build_1('.toMatchObject') + '\n\nExpected value to match object:\n' + (' ' + build_8(expectedObject)) + '\nReceived:\n' + (' ' + build_9(receivedObject)) + (diffString ? '\nDifference:\n' + diffString : '');
  7180. };
  7181. return { message: message, pass: pass };
  7182. },
  7183. toStrictEqual: function toStrictEqual(received, expected) {
  7184. var _this17 = this;
  7185. var pass = equals(received, expected, [iterableEquality, typeEquality], true);
  7186. var message = pass ? function () {
  7187. return build_1('.not.toStrictEqual') + '\n\n' + 'Expected value to not equal:\n' + (' ' + build_8(expected) + '\n') + 'Received:\n' + (' ' + build_9(received));
  7188. } : function () {
  7189. var diffString = diff(expected, received, {
  7190. expand: _this17.expand
  7191. });
  7192. return build_1('.toStrictEqual') + '\n\n' + 'Expected value to equal:\n' + (' ' + build_8(expected) + '\n') + 'Received:\n' + (' ' + build_9(received)) + (diffString ? '\n\nDifference:\n\n' + diffString : '');
  7193. };
  7194. // Passing the the actual and expected objects so that a custom reporter
  7195. // could access them, for example in order to display a custom visual diff,
  7196. // or create a different error message
  7197. return { actual: received, expected: expected, message: message, name: 'toStrictEqual', pass: pass };
  7198. }
  7199. };
  7200. var ITERATOR$4 = _wks('iterator');
  7201. var core_isIterable = _core.isIterable = function (it) {
  7202. var O = Object(it);
  7203. return O[ITERATOR$4] !== undefined
  7204. || '@@iterator' in O
  7205. // eslint-disable-next-line no-prototype-builtins
  7206. || _iterators.hasOwnProperty(_classof(O));
  7207. };
  7208. var isIterable = core_isIterable;
  7209. var isIterable$1 = createCommonjsModule(function (module) {
  7210. module.exports = { "default": isIterable, __esModule: true };
  7211. });
  7212. unwrapExports(isIterable$1);
  7213. var slicedToArray = createCommonjsModule(function (module, exports) {
  7214. exports.__esModule = true;
  7215. var _isIterable3 = _interopRequireDefault(isIterable$1);
  7216. var _getIterator3 = _interopRequireDefault(getIterator$1);
  7217. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7218. exports.default = function () {
  7219. function sliceIterator(arr, i) {
  7220. var _arr = [];
  7221. var _n = true;
  7222. var _d = false;
  7223. var _e = undefined;
  7224. try {
  7225. for (var _i = (0, _getIterator3.default)(arr), _s; !(_n = (_s = _i.next()).done); _n = true) {
  7226. _arr.push(_s.value);
  7227. if (i && _arr.length === i) break;
  7228. }
  7229. } catch (err) {
  7230. _d = true;
  7231. _e = err;
  7232. } finally {
  7233. try {
  7234. if (!_n && _i["return"]) _i["return"]();
  7235. } finally {
  7236. if (_d) throw _e;
  7237. }
  7238. }
  7239. return _arr;
  7240. }
  7241. return function (arr, i) {
  7242. if (Array.isArray(arr)) {
  7243. return arr;
  7244. } else if ((0, _isIterable3.default)(Object(arr))) {
  7245. return sliceIterator(arr, i);
  7246. } else {
  7247. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  7248. }
  7249. };
  7250. }();
  7251. });
  7252. var _slicedToArray = unwrapExports(slicedToArray);
  7253. /**
  7254. * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
  7255. *
  7256. * This source code is licensed under the MIT license found in the
  7257. * LICENSE file in the root directory of this source tree.
  7258. *
  7259. *
  7260. */
  7261. var CALL_PRINT_LIMIT = 3;
  7262. var RETURN_PRINT_LIMIT = 5;
  7263. var LAST_CALL_PRINT_LIMIT = 1;
  7264. var createToBeCalledMatcher = function createToBeCalledMatcher(matcherName) {
  7265. return function (received, expected) {
  7266. build_6(expected, matcherName);
  7267. ensureMock(received, matcherName);
  7268. var receivedIsSpy = isSpy(received);
  7269. var type = receivedIsSpy ? 'spy' : 'mock function';
  7270. var receivedName = receivedIsSpy ? 'spy' : received.getMockName();
  7271. var identifier = receivedIsSpy || receivedName === 'jest.fn()' ? type : type + ' "' + receivedName + '"';
  7272. var count = receivedIsSpy ? received.calls.count() : received.mock.calls.length;
  7273. var calls = receivedIsSpy ? received.calls.all().map(function (x) {
  7274. return x.args;
  7275. }) : received.mock.calls;
  7276. var pass = count > 0;
  7277. var message = pass ? function () {
  7278. return build_1('.not' + matcherName, receivedName, '') + '\n\n' + ('Expected ' + identifier + ' not to be called ') + formatReceivedCalls(calls, CALL_PRINT_LIMIT, { sameSentence: true });
  7279. } : function () {
  7280. return build_1(matcherName, receivedName, '') + '\n\n' + ('Expected ' + identifier + ' to have been called, but it was not called.');
  7281. };
  7282. return { message: message, pass: pass };
  7283. };
  7284. };
  7285. var createToReturnMatcher = function createToReturnMatcher(matcherName) {
  7286. return function (received, expected) {
  7287. build_6(expected, matcherName);
  7288. ensureMock(received, matcherName);
  7289. var receivedName = received.getMockName();
  7290. var identifier = receivedName === 'jest.fn()' ? 'mock function' : 'mock function "' + receivedName + '"';
  7291. // List of return values that correspond only to calls that did not throw
  7292. // an error
  7293. var returnValues = received.mock.results.filter(function (result) {
  7294. return !result.isThrow;
  7295. }).map(function (result) {
  7296. return result.value;
  7297. });
  7298. var count = returnValues.length;
  7299. var pass = count > 0;
  7300. var message = pass ? function () {
  7301. return build_1('.not' + matcherName, receivedName, '') + '\n\n' + ('Expected ' + identifier + ' not to have returned, but it returned:\n') + (' ' + getPrintedReturnValues(returnValues, RETURN_PRINT_LIMIT));
  7302. } : function () {
  7303. return build_1(matcherName, receivedName, '') + '\n\n' + ('Expected ' + identifier + ' to have returned.');
  7304. };
  7305. return { message: message, pass: pass };
  7306. };
  7307. };
  7308. var createToBeCalledTimesMatcher = function createToBeCalledTimesMatcher(matcherName) {
  7309. return function (received, expected) {
  7310. build_4(expected, matcherName);
  7311. ensureMock(received, matcherName);
  7312. var receivedIsSpy = isSpy(received);
  7313. var type = receivedIsSpy ? 'spy' : 'mock function';
  7314. var receivedName = receivedIsSpy ? 'spy' : received.getMockName();
  7315. var identifier = receivedIsSpy || receivedName === 'jest.fn()' ? type : type + ' "' + receivedName + '"';
  7316. var count = receivedIsSpy ? received.calls.count() : received.mock.calls.length;
  7317. var pass = count === expected;
  7318. var message = pass ? function () {
  7319. return build_1('.not' + matcherName, receivedName, String(expected)) + '\n\n' + ('Expected ' + identifier + ' not to be called ') + (build_15(build_2('time', expected)) + ', but it was') + (' called exactly ' + build_14(build_2('time', count)) + '.');
  7320. } : function () {
  7321. return build_1(matcherName, receivedName, String(expected)) + '\n\n' + ('Expected ' + identifier + ' to have been called ') + (build_15(build_2('time', expected)) + ',') + (' but it was called ' + build_14(build_2('time', count)) + '.');
  7322. };
  7323. return { message: message, pass: pass };
  7324. };
  7325. };
  7326. var createToReturnTimesMatcher = function createToReturnTimesMatcher(matcherName) {
  7327. return function (received, expected) {
  7328. build_4(expected, matcherName);
  7329. ensureMock(received, matcherName);
  7330. var receivedName = received.getMockName();
  7331. var identifier = receivedName === 'jest.fn()' ? 'mock function' : 'mock function "' + receivedName + '"';
  7332. // List of return results that correspond only to calls that did not throw
  7333. // an error
  7334. var returnResults = received.mock.results.filter(function (result) {
  7335. return !result.isThrow;
  7336. });
  7337. var count = returnResults.length;
  7338. var pass = count === expected;
  7339. var message = pass ? function () {
  7340. return build_1('.not' + matcherName, receivedName, String(expected)) + '\n\n' + ('Expected ' + identifier + ' not to have returned ') + (build_15(build_2('time', expected)) + ', but it') + (' returned exactly ' + build_14(build_2('time', count)) + '.');
  7341. } : function () {
  7342. return build_1(matcherName, receivedName, String(expected)) + '\n\n' + ('Expected ' + identifier + ' to have returned ') + (build_15(build_2('time', expected)) + ',') + (' but it returned ' + build_14(build_2('time', count)) + '.');
  7343. };
  7344. return { message: message, pass: pass };
  7345. };
  7346. };
  7347. var createToBeCalledWithMatcher = function createToBeCalledWithMatcher(matcherName) {
  7348. return function (received) {
  7349. for (var _len = arguments.length, expected = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  7350. expected[_key - 1] = arguments[_key];
  7351. }
  7352. ensureMock(received, matcherName);
  7353. var receivedIsSpy = isSpy(received);
  7354. var type = receivedIsSpy ? 'spy' : 'mock function';
  7355. var receivedName = receivedIsSpy ? 'spy' : received.getMockName();
  7356. var identifier = receivedIsSpy || receivedName === 'jest.fn()' ? type : type + ' "' + receivedName + '"';
  7357. var calls = receivedIsSpy ? received.calls.all().map(function (x) {
  7358. return x.args;
  7359. }) : received.mock.calls;
  7360. var _partition = partition(calls, function (call) {
  7361. return equals(call, expected, [iterableEquality]);
  7362. }),
  7363. _partition2 = _slicedToArray(_partition, 2),
  7364. match = _partition2[0],
  7365. fail = _partition2[1];
  7366. var pass = match.length > 0;
  7367. var message = pass ? function () {
  7368. return build_1('.not' + matcherName, receivedName) + '\n\n' + ('Expected ' + identifier + ' not to have been called with:\n') + (' ' + build_8(expected));
  7369. } : function () {
  7370. return build_1(matcherName, receivedName) + '\n\n' + ('Expected ' + identifier + ' to have been called with:\n') + formatMismatchedCalls(fail, expected, CALL_PRINT_LIMIT);
  7371. };
  7372. return { message: message, pass: pass };
  7373. };
  7374. };
  7375. var createToReturnWithMatcher = function createToReturnWithMatcher(matcherName) {
  7376. return function (received, expected) {
  7377. ensureMock(received, matcherName);
  7378. var receivedName = received.getMockName();
  7379. var identifier = receivedName === 'jest.fn()' ? 'mock function' : 'mock function "' + receivedName + '"';
  7380. // List of return values that correspond only to calls that did not throw
  7381. // an error
  7382. var returnValues = received.mock.results.filter(function (result) {
  7383. return !result.isThrow;
  7384. }).map(function (result) {
  7385. return result.value;
  7386. });
  7387. var _partition3 = partition(returnValues, function (value) {
  7388. return equals(expected, value, [iterableEquality]);
  7389. }),
  7390. _partition4 = _slicedToArray(_partition3, 1),
  7391. match = _partition4[0];
  7392. var pass = match.length > 0;
  7393. var message = pass ? function () {
  7394. return build_1('.not' + matcherName, receivedName) + '\n\n' + ('Expected ' + identifier + ' not to have returned:\n') + (' ' + build_8(expected) + '\n') + 'But it returned exactly:\n' + (' ' + build_9(expected));
  7395. } : function () {
  7396. return build_1(matcherName, receivedName) + '\n\n' + ('Expected ' + identifier + ' to have returned:\n') + formatMismatchedReturnValues(returnValues, expected, RETURN_PRINT_LIMIT);
  7397. };
  7398. return { message: message, pass: pass };
  7399. };
  7400. };
  7401. var createLastCalledWithMatcher = function createLastCalledWithMatcher(matcherName) {
  7402. return function (received) {
  7403. for (var _len2 = arguments.length, expected = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  7404. expected[_key2 - 1] = arguments[_key2];
  7405. }
  7406. ensureMock(received, matcherName);
  7407. var receivedIsSpy = isSpy(received);
  7408. var type = receivedIsSpy ? 'spy' : 'mock function';
  7409. var receivedName = receivedIsSpy ? 'spy' : received.getMockName();
  7410. var identifier = receivedIsSpy || receivedName === 'jest.fn()' ? type : type + ' "' + receivedName + '"';
  7411. var calls = receivedIsSpy ? received.calls.all().map(function (x) {
  7412. return x.args;
  7413. }) : received.mock.calls;
  7414. var pass = equals(calls[calls.length - 1], expected, [iterableEquality]);
  7415. var message = pass ? function () {
  7416. return build_1('.not' + matcherName, receivedName) + '\n\n' + ('Expected ' + identifier + ' to not have been last called with:\n') + (' ' + build_8(expected));
  7417. } : function () {
  7418. return build_1(matcherName, receivedName) + '\n\n' + ('Expected ' + identifier + ' to have been last called with:\n') + formatMismatchedCalls(calls, expected, LAST_CALL_PRINT_LIMIT);
  7419. };
  7420. return { message: message, pass: pass };
  7421. };
  7422. };
  7423. var createLastReturnedMatcher = function createLastReturnedMatcher(matcherName) {
  7424. return function (received, expected) {
  7425. ensureMock(received, matcherName);
  7426. var receivedName = received.getMockName();
  7427. var identifier = receivedName === 'jest.fn()' ? 'mock function' : 'mock function "' + receivedName + '"';
  7428. var results = received.mock.results;
  7429. var lastResult = results[results.length - 1];
  7430. var pass = !!lastResult && !lastResult.isThrow && equals(lastResult.value, expected, [iterableEquality]);
  7431. var message = pass ? function () {
  7432. return build_1('.not' + matcherName, receivedName) + '\n\n' + ('Expected ' + identifier + ' to not have last returned:\n') + (' ' + build_8(expected) + '\n') + 'But it last returned exactly:\n' + (' ' + build_9(lastResult.value));
  7433. } : function () {
  7434. return build_1(matcherName, receivedName) + '\n\n' + ('Expected ' + identifier + ' to have last returned:\n') + (' ' + build_8(expected) + '\n') + (!lastResult ? 'But it was ' + build_14('not called') : lastResult.isThrow ? 'But the last call ' + build_14('threw an error') : 'But the last call returned:\n ' + build_9(lastResult.value));
  7435. };
  7436. return { message: message, pass: pass };
  7437. };
  7438. };
  7439. var createNthCalledWithMatcher = function createNthCalledWithMatcher(matcherName) {
  7440. return function (received, nth) {
  7441. for (var _len3 = arguments.length, expected = Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
  7442. expected[_key3 - 2] = arguments[_key3];
  7443. }
  7444. ensureMock(received, matcherName);
  7445. var receivedIsSpy = isSpy(received);
  7446. var type = receivedIsSpy ? 'spy' : 'mock function';
  7447. if (typeof nth !== 'number' || parseInt(nth, 10) !== nth || nth < 1) {
  7448. var _message = function _message() {
  7449. return 'nth value ' + build_9(nth) + ' must be a positive integer greater than ' + build_8(0);
  7450. };
  7451. var _pass = false;
  7452. return { message: _message, pass: _pass };
  7453. }
  7454. var receivedName = receivedIsSpy ? 'spy' : received.getMockName();
  7455. var identifier = receivedIsSpy || receivedName === 'jest.fn()' ? type : type + ' "' + receivedName + '"';
  7456. var calls = receivedIsSpy ? received.calls.all().map(function (x) {
  7457. return x.args;
  7458. }) : received.mock.calls;
  7459. var pass = equals(calls[nth - 1], expected, [iterableEquality]);
  7460. var message = pass ? function () {
  7461. return build_1('.not' + matcherName, receivedName) + '\n\n' + ('Expected ' + identifier + ' ' + nthToString(nth) + ' call to not have been called with:\n') + (' ' + build_8(expected));
  7462. } : function () {
  7463. return build_1(matcherName, receivedName) + '\n\n' + ('Expected ' + identifier + ' ' + nthToString(nth) + ' call to have been called with:\n') + formatMismatchedCalls(calls[nth - 1] ? [calls[nth - 1]] : [], expected, LAST_CALL_PRINT_LIMIT);
  7464. };
  7465. return { message: message, pass: pass };
  7466. };
  7467. };
  7468. var createNthReturnedWithMatcher = function createNthReturnedWithMatcher(matcherName) {
  7469. return function (received, nth, expected) {
  7470. ensureMock(received, matcherName);
  7471. if (typeof nth !== 'number' || parseInt(nth, 10) !== nth || nth < 1) {
  7472. var _message2 = function _message2() {
  7473. return 'nth value ' + build_9(nth) + ' must be a positive integer greater than ' + build_8(0);
  7474. };
  7475. var _pass2 = false;
  7476. return { message: _message2, pass: _pass2 };
  7477. }
  7478. var receivedName = received.getMockName();
  7479. var identifier = receivedName === 'jest.fn()' ? 'mock function' : 'mock function "' + receivedName + '"';
  7480. var results = received.mock.results;
  7481. var nthResult = results[nth - 1];
  7482. var pass = !!nthResult && !nthResult.isThrow && equals(nthResult.value, expected, [iterableEquality]);
  7483. var nthString = nthToString(nth);
  7484. var message = pass ? function () {
  7485. return build_1('.not' + matcherName, receivedName) + '\n\n' + ('Expected ' + identifier + ' ' + nthString + ' call to not have returned with:\n') + (' ' + build_8(expected) + '\n') + ('But the ' + nthString + ' call returned exactly:\n') + (' ' + build_9(nthResult.value));
  7486. } : function () {
  7487. return build_1(matcherName, receivedName) + '\n\n' + ('Expected ' + identifier + ' ' + nthString + ' call to have returned with:\n') + (' ' + build_8(expected) + '\n') + (results.length === 0 ? 'But it was ' + build_14('not called') : nth > results.length ? 'But it was only called ' + build_9(results.length) + ' times' : nthResult.isThrow ? 'But the ' + nthString + ' call ' + build_14('threw an error') : 'But the ' + nthString + ' call returned with:\n ' + build_9(nthResult.value));
  7488. };
  7489. return { message: message, pass: pass };
  7490. };
  7491. };
  7492. var spyMatchers = {
  7493. lastCalledWith: createLastCalledWithMatcher('.lastCalledWith'),
  7494. lastReturnedWith: createLastReturnedMatcher('.lastReturnedWith'),
  7495. nthCalledWith: createNthCalledWithMatcher('.nthCalledWith'),
  7496. nthReturnedWith: createNthReturnedWithMatcher('.nthReturnedWith'),
  7497. toBeCalled: createToBeCalledMatcher('.toBeCalled'),
  7498. toBeCalledTimes: createToBeCalledTimesMatcher('.toBeCalledTimes'),
  7499. toBeCalledWith: createToBeCalledWithMatcher('.toBeCalledWith'),
  7500. toHaveBeenCalled: createToBeCalledMatcher('.toHaveBeenCalled'),
  7501. toHaveBeenCalledTimes: createToBeCalledTimesMatcher('.toHaveBeenCalledTimes'),
  7502. toHaveBeenCalledWith: createToBeCalledWithMatcher('.toHaveBeenCalledWith'),
  7503. toHaveBeenLastCalledWith: createLastCalledWithMatcher('.toHaveBeenLastCalledWith'),
  7504. toHaveBeenNthCalledWith: createNthCalledWithMatcher('.toHaveBeenNthCalledWith'),
  7505. toHaveLastReturnedWith: createLastReturnedMatcher('.toHaveLastReturnedWith'),
  7506. toHaveNthReturnedWith: createNthReturnedWithMatcher('.toHaveNthReturnedWith'),
  7507. toHaveReturned: createToReturnMatcher('.toHaveReturned'),
  7508. toHaveReturnedTimes: createToReturnTimesMatcher('.toHaveReturnedTimes'),
  7509. toHaveReturnedWith: createToReturnWithMatcher('.toHaveReturnedWith'),
  7510. toReturn: createToReturnMatcher('.toReturn'),
  7511. toReturnTimes: createToReturnTimesMatcher('.toReturnTimes'),
  7512. toReturnWith: createToReturnWithMatcher('.toReturnWith')
  7513. };
  7514. var isSpy = function isSpy(spy) {
  7515. return spy.calls && typeof spy.calls.count === 'function';
  7516. };
  7517. var ensureMock = function ensureMock(mockOrSpy, matcherName) {
  7518. if (!mockOrSpy || (mockOrSpy.calls === undefined || mockOrSpy.calls.all === undefined) && mockOrSpy._isMockFunction !== true) {
  7519. throw new Error(build_1('[.not]' + matcherName, 'jest.fn()', '') + '\n\n' + (build_14('jest.fn()') + ' value must be a mock function ') + 'or spy.\n' + build_7('Received', mockOrSpy, build_9));
  7520. }
  7521. };
  7522. var getPrintedCalls = function getPrintedCalls(calls, limit, sep, fn) {
  7523. var result = [];
  7524. var i = calls.length;
  7525. while (--i >= 0 && --limit >= 0) {
  7526. result.push(fn(calls[i]));
  7527. }
  7528. return result.join(sep);
  7529. };
  7530. var getPrintedReturnValues = function getPrintedReturnValues(calls, limit) {
  7531. var result = [];
  7532. for (var i = 0; i < calls.length && i < limit; i += 1) {
  7533. result.push(build_9(calls[i]));
  7534. }
  7535. if (calls.length > limit) {
  7536. result.push('...and ' + build_9(calls.length - limit) + ' more');
  7537. }
  7538. return result.join('\n\n ');
  7539. };
  7540. var formatReceivedCalls = function formatReceivedCalls(calls, limit, options) {
  7541. if (calls.length) {
  7542. var but = options && options.sameSentence ? 'but' : 'But';
  7543. var count = calls.length - limit;
  7544. var printedCalls = getPrintedCalls(calls, limit, ', ', build_9);
  7545. return but + ' it was called ' + 'with:\n ' + printedCalls + (count > 0 ? '\nand ' + build_14(build_2('more call', count)) + '.' : '');
  7546. } else {
  7547. return 'But it was ' + build_14('not called') + '.';
  7548. }
  7549. };
  7550. var formatMismatchedCalls = function formatMismatchedCalls(calls, expected, limit) {
  7551. if (calls.length) {
  7552. return getPrintedCalls(calls, limit, '\n\n', formatMismatchedArgs.bind(null, expected));
  7553. } else {
  7554. return ' ' + build_8(expected) + '\n' + ('But it was ' + build_14('not called') + '.');
  7555. }
  7556. };
  7557. var formatMismatchedReturnValues = function formatMismatchedReturnValues(returnValues, expected, limit) {
  7558. if (returnValues.length) {
  7559. return ' ' + build_8(expected) + '\n' + 'But it returned:\n' + (' ' + getPrintedReturnValues(returnValues, limit));
  7560. } else {
  7561. return ' ' + build_8(expected) + '\n' + ('But it did ' + build_14('not return') + '.');
  7562. }
  7563. };
  7564. var formatMismatchedArgs = function formatMismatchedArgs(expected, received) {
  7565. var length = Math.max(expected.length, received.length);
  7566. var printedArgs = [];
  7567. for (var i = 0; i < length; i++) {
  7568. if (!equals(expected[i], received[i], [iterableEquality])) {
  7569. var oneline = isOneline(expected[i], received[i]);
  7570. var diffString = diff(expected[i], received[i]);
  7571. printedArgs.push(' ' + build_8(expected[i]) + '\n' + ('as argument ' + (i + 1) + ', but it was called with\n') + (' ' + build_9(received[i]) + '.') + (diffString && !oneline ? '\n\nDifference:\n\n' + diffString : ''));
  7572. } else if (i >= expected.length) {
  7573. printedArgs.push(' Did not expect argument ' + (i + 1) + ' ' + ('but it was called with ' + build_9(received[i]) + '.'));
  7574. }
  7575. }
  7576. return printedArgs.join('\n');
  7577. };
  7578. var nthToString = function nthToString(nth) {
  7579. switch (nth) {
  7580. case 1:
  7581. return 'first';
  7582. case 2:
  7583. return 'second';
  7584. case 3:
  7585. return 'third';
  7586. }
  7587. return nth + 'th';
  7588. };
  7589. var global$1 = (typeof global !== "undefined" ? global :
  7590. typeof self !== "undefined" ? self :
  7591. typeof window !== "undefined" ? window : {});
  7592. // shim for using process in browser
  7593. // based off https://github.com/defunctzombie/node-process/blob/master/browser.js
  7594. function defaultSetTimout() {
  7595. throw new Error('setTimeout has not been defined');
  7596. }
  7597. function defaultClearTimeout () {
  7598. throw new Error('clearTimeout has not been defined');
  7599. }
  7600. var cachedSetTimeout = defaultSetTimout;
  7601. var cachedClearTimeout = defaultClearTimeout;
  7602. if (typeof global$1.setTimeout === 'function') {
  7603. cachedSetTimeout = setTimeout;
  7604. }
  7605. if (typeof global$1.clearTimeout === 'function') {
  7606. cachedClearTimeout = clearTimeout;
  7607. }
  7608. function runTimeout(fun) {
  7609. if (cachedSetTimeout === setTimeout) {
  7610. //normal enviroments in sane situations
  7611. return setTimeout(fun, 0);
  7612. }
  7613. // if setTimeout wasn't available but was latter defined
  7614. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  7615. cachedSetTimeout = setTimeout;
  7616. return setTimeout(fun, 0);
  7617. }
  7618. try {
  7619. // when when somebody has screwed with setTimeout but no I.E. maddness
  7620. return cachedSetTimeout(fun, 0);
  7621. } catch(e){
  7622. try {
  7623. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  7624. return cachedSetTimeout.call(null, fun, 0);
  7625. } catch(e){
  7626. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  7627. return cachedSetTimeout.call(this, fun, 0);
  7628. }
  7629. }
  7630. }
  7631. function runClearTimeout(marker) {
  7632. if (cachedClearTimeout === clearTimeout) {
  7633. //normal enviroments in sane situations
  7634. return clearTimeout(marker);
  7635. }
  7636. // if clearTimeout wasn't available but was latter defined
  7637. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  7638. cachedClearTimeout = clearTimeout;
  7639. return clearTimeout(marker);
  7640. }
  7641. try {
  7642. // when when somebody has screwed with setTimeout but no I.E. maddness
  7643. return cachedClearTimeout(marker);
  7644. } catch (e){
  7645. try {
  7646. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  7647. return cachedClearTimeout.call(null, marker);
  7648. } catch (e){
  7649. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  7650. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  7651. return cachedClearTimeout.call(this, marker);
  7652. }
  7653. }
  7654. }
  7655. var queue$1 = [];
  7656. var draining = false;
  7657. var currentQueue;
  7658. var queueIndex = -1;
  7659. function cleanUpNextTick() {
  7660. if (!draining || !currentQueue) {
  7661. return;
  7662. }
  7663. draining = false;
  7664. if (currentQueue.length) {
  7665. queue$1 = currentQueue.concat(queue$1);
  7666. } else {
  7667. queueIndex = -1;
  7668. }
  7669. if (queue$1.length) {
  7670. drainQueue();
  7671. }
  7672. }
  7673. function drainQueue() {
  7674. if (draining) {
  7675. return;
  7676. }
  7677. var timeout = runTimeout(cleanUpNextTick);
  7678. draining = true;
  7679. var len = queue$1.length;
  7680. while(len) {
  7681. currentQueue = queue$1;
  7682. queue$1 = [];
  7683. while (++queueIndex < len) {
  7684. if (currentQueue) {
  7685. currentQueue[queueIndex].run();
  7686. }
  7687. }
  7688. queueIndex = -1;
  7689. len = queue$1.length;
  7690. }
  7691. currentQueue = null;
  7692. draining = false;
  7693. runClearTimeout(timeout);
  7694. }
  7695. function nextTick(fun) {
  7696. var args = new Array(arguments.length - 1);
  7697. if (arguments.length > 1) {
  7698. for (var i = 1; i < arguments.length; i++) {
  7699. args[i - 1] = arguments[i];
  7700. }
  7701. }
  7702. queue$1.push(new Item(fun, args));
  7703. if (queue$1.length === 1 && !draining) {
  7704. runTimeout(drainQueue);
  7705. }
  7706. }
  7707. // v8 likes predictible objects
  7708. function Item(fun, array) {
  7709. this.fun = fun;
  7710. this.array = array;
  7711. }
  7712. Item.prototype.run = function () {
  7713. this.fun.apply(null, this.array);
  7714. };
  7715. var title = 'browser';
  7716. var platform = 'browser';
  7717. var browser = true;
  7718. var env = {};
  7719. var argv = [];
  7720. var version = ''; // empty string to avoid regexp issues
  7721. var versions$1 = {};
  7722. var release = {};
  7723. var config = {};
  7724. function noop() {}
  7725. var on = noop;
  7726. var addListener = noop;
  7727. var once = noop;
  7728. var off = noop;
  7729. var removeListener = noop;
  7730. var removeAllListeners = noop;
  7731. var emit = noop;
  7732. function binding(name) {
  7733. throw new Error('process.binding is not supported');
  7734. }
  7735. function cwd () { return '/' }
  7736. function chdir (dir) {
  7737. throw new Error('process.chdir is not supported');
  7738. }function umask() { return 0; }
  7739. // from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js
  7740. var performance = global$1.performance || {};
  7741. var performanceNow =
  7742. performance.now ||
  7743. performance.mozNow ||
  7744. performance.msNow ||
  7745. performance.oNow ||
  7746. performance.webkitNow ||
  7747. function(){ return (new Date()).getTime() };
  7748. // generate timestamp or delta
  7749. // see http://nodejs.org/api/process.html#process_process_hrtime
  7750. function hrtime(previousTimestamp){
  7751. var clocktime = performanceNow.call(performance)*1e-3;
  7752. var seconds = Math.floor(clocktime);
  7753. var nanoseconds = Math.floor((clocktime%1)*1e9);
  7754. if (previousTimestamp) {
  7755. seconds = seconds - previousTimestamp[0];
  7756. nanoseconds = nanoseconds - previousTimestamp[1];
  7757. if (nanoseconds<0) {
  7758. seconds--;
  7759. nanoseconds += 1e9;
  7760. }
  7761. }
  7762. return [seconds,nanoseconds]
  7763. }
  7764. var startTime = new Date();
  7765. function uptime() {
  7766. var currentTime = new Date();
  7767. var dif = currentTime - startTime;
  7768. return dif / 1000;
  7769. }
  7770. var process$3 = {
  7771. nextTick: nextTick,
  7772. title: title,
  7773. browser: browser,
  7774. env: env,
  7775. argv: argv,
  7776. version: version,
  7777. versions: versions$1,
  7778. on: on,
  7779. addListener: addListener,
  7780. once: once,
  7781. off: off,
  7782. removeListener: removeListener,
  7783. removeAllListeners: removeAllListeners,
  7784. emit: emit,
  7785. binding: binding,
  7786. cwd: cwd,
  7787. chdir: chdir,
  7788. umask: umask,
  7789. hrtime: hrtime,
  7790. platform: platform,
  7791. release: release,
  7792. config: config,
  7793. uptime: uptime
  7794. };
  7795. var empty$1 = {};
  7796. var empty$2 = Object.freeze({
  7797. default: empty$1
  7798. });
  7799. /*!
  7800. * filename-regex <https://github.com/regexps/filename-regex>
  7801. *
  7802. * Copyright (c) 2014-2015, Jon Schlinkert
  7803. * Licensed under the MIT license.
  7804. */
  7805. var filenameRegex = function filenameRegex() {
  7806. return /([^\\\/]+)$/;
  7807. };
  7808. /*!
  7809. * arr-flatten <https://github.com/jonschlinkert/arr-flatten>
  7810. *
  7811. * Copyright (c) 2014-2017, Jon Schlinkert.
  7812. * Released under the MIT License.
  7813. */
  7814. var arrFlatten = function (arr) {
  7815. return flat(arr, []);
  7816. };
  7817. function flat(arr, res) {
  7818. var i = 0, cur;
  7819. var len = arr.length;
  7820. for (; i < len; i++) {
  7821. cur = arr[i];
  7822. Array.isArray(cur) ? flat(cur, res) : res.push(cur);
  7823. }
  7824. return res;
  7825. }
  7826. var slice = [].slice;
  7827. /**
  7828. * Return the difference between the first array and
  7829. * additional arrays.
  7830. *
  7831. * ```js
  7832. * var diff = require('{%= name %}');
  7833. *
  7834. * var a = ['a', 'b', 'c', 'd'];
  7835. * var b = ['b', 'c'];
  7836. *
  7837. * console.log(diff(a, b))
  7838. * //=> ['a', 'd']
  7839. * ```
  7840. *
  7841. * @param {Array} `a`
  7842. * @param {Array} `b`
  7843. * @return {Array}
  7844. * @api public
  7845. */
  7846. function diff$1(arr, arrays) {
  7847. var argsLen = arguments.length;
  7848. var len = arr.length, i = -1;
  7849. var res = [], arrays;
  7850. if (argsLen === 1) {
  7851. return arr;
  7852. }
  7853. if (argsLen > 2) {
  7854. arrays = arrFlatten(slice.call(arguments, 1));
  7855. }
  7856. while (++i < len) {
  7857. if (!~arrays.indexOf(arr[i])) {
  7858. res.push(arr[i]);
  7859. }
  7860. }
  7861. return res;
  7862. }
  7863. /**
  7864. * Expose `diff`
  7865. */
  7866. var arrDiff = diff$1;
  7867. /*!
  7868. * array-unique <https://github.com/jonschlinkert/array-unique>
  7869. *
  7870. * Copyright (c) 2014-2015, Jon Schlinkert.
  7871. * Licensed under the MIT License.
  7872. */
  7873. var arrayUnique = function unique(arr) {
  7874. if (!Array.isArray(arr)) {
  7875. throw new TypeError('array-unique expects an array.');
  7876. }
  7877. var len = arr.length;
  7878. var i = -1;
  7879. while (i++ < len) {
  7880. var j = i + 1;
  7881. for (; j < arr.length; ++j) {
  7882. if (arr[i] === arr[j]) {
  7883. arr.splice(j--, 1);
  7884. }
  7885. }
  7886. }
  7887. return arr;
  7888. };
  7889. var toString$3 = {}.toString;
  7890. var isarray = Array.isArray || function (arr) {
  7891. return toString$3.call(arr) == '[object Array]';
  7892. };
  7893. var isobject = function isObject(val) {
  7894. return val != null && typeof val === 'object' && isarray(val) === false;
  7895. };
  7896. /*!
  7897. * Determine if an object is a Buffer
  7898. *
  7899. * @author Feross Aboukhadijeh <https://feross.org>
  7900. * @license MIT
  7901. */
  7902. // The _isBuffer check is for Safari 5-7 support, because it's missing
  7903. // Object.prototype.constructor. Remove this eventually
  7904. var isBuffer_1 = function (obj) {
  7905. return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
  7906. };
  7907. function isBuffer (obj) {
  7908. return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
  7909. }
  7910. // For Node v0.10 support. Remove this eventually.
  7911. function isSlowBuffer (obj) {
  7912. return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
  7913. }
  7914. var toString$4 = Object.prototype.toString;
  7915. /**
  7916. * Get the native `typeof` a value.
  7917. *
  7918. * @param {*} `val`
  7919. * @return {*} Native javascript type
  7920. */
  7921. var kindOf = function kindOf(val) {
  7922. // primitivies
  7923. if (typeof val === 'undefined') {
  7924. return 'undefined';
  7925. }
  7926. if (val === null) {
  7927. return 'null';
  7928. }
  7929. if (val === true || val === false || val instanceof Boolean) {
  7930. return 'boolean';
  7931. }
  7932. if (typeof val === 'string' || val instanceof String) {
  7933. return 'string';
  7934. }
  7935. if (typeof val === 'number' || val instanceof Number) {
  7936. return 'number';
  7937. }
  7938. // functions
  7939. if (typeof val === 'function' || val instanceof Function) {
  7940. return 'function';
  7941. }
  7942. // array
  7943. if (typeof Array.isArray !== 'undefined' && Array.isArray(val)) {
  7944. return 'array';
  7945. }
  7946. // check for instances of RegExp and Date before calling `toString`
  7947. if (val instanceof RegExp) {
  7948. return 'regexp';
  7949. }
  7950. if (val instanceof Date) {
  7951. return 'date';
  7952. }
  7953. // other objects
  7954. var type = toString$4.call(val);
  7955. if (type === '[object RegExp]') {
  7956. return 'regexp';
  7957. }
  7958. if (type === '[object Date]') {
  7959. return 'date';
  7960. }
  7961. if (type === '[object Arguments]') {
  7962. return 'arguments';
  7963. }
  7964. if (type === '[object Error]') {
  7965. return 'error';
  7966. }
  7967. // buffer
  7968. if (isBuffer_1(val)) {
  7969. return 'buffer';
  7970. }
  7971. // es6: Map, WeakMap, Set, WeakSet
  7972. if (type === '[object Set]') {
  7973. return 'set';
  7974. }
  7975. if (type === '[object WeakSet]') {
  7976. return 'weakset';
  7977. }
  7978. if (type === '[object Map]') {
  7979. return 'map';
  7980. }
  7981. if (type === '[object WeakMap]') {
  7982. return 'weakmap';
  7983. }
  7984. if (type === '[object Symbol]') {
  7985. return 'symbol';
  7986. }
  7987. // typed arrays
  7988. if (type === '[object Int8Array]') {
  7989. return 'int8array';
  7990. }
  7991. if (type === '[object Uint8Array]') {
  7992. return 'uint8array';
  7993. }
  7994. if (type === '[object Uint8ClampedArray]') {
  7995. return 'uint8clampedarray';
  7996. }
  7997. if (type === '[object Int16Array]') {
  7998. return 'int16array';
  7999. }
  8000. if (type === '[object Uint16Array]') {
  8001. return 'uint16array';
  8002. }
  8003. if (type === '[object Int32Array]') {
  8004. return 'int32array';
  8005. }
  8006. if (type === '[object Uint32Array]') {
  8007. return 'uint32array';
  8008. }
  8009. if (type === '[object Float32Array]') {
  8010. return 'float32array';
  8011. }
  8012. if (type === '[object Float64Array]') {
  8013. return 'float64array';
  8014. }
  8015. // must be a plain object
  8016. return 'object';
  8017. };
  8018. var isNumber = function isNumber(num) {
  8019. var type = kindOf(num);
  8020. if (type !== 'number' && type !== 'string') {
  8021. return false;
  8022. }
  8023. var n = +num;
  8024. return (n - n + 1) >= 0 && num !== '';
  8025. };
  8026. /*!
  8027. * is-number <https://github.com/jonschlinkert/is-number>
  8028. *
  8029. * Copyright (c) 2014-2017, Jon Schlinkert.
  8030. * Released under the MIT License.
  8031. */
  8032. var isNumber$1 = function isNumber(num) {
  8033. var type = typeof num;
  8034. if (type === 'string' || num instanceof String) {
  8035. // an empty string would be coerced to true with the below logic
  8036. if (!num.trim()) return false;
  8037. } else if (type !== 'number' && !(num instanceof Number)) {
  8038. return false;
  8039. }
  8040. return (num - num + 1) >= 0;
  8041. };
  8042. var toString$5 = Object.prototype.toString;
  8043. var kindOf$1 = function kindOf(val) {
  8044. if (val === void 0) return 'undefined';
  8045. if (val === null) return 'null';
  8046. var type = typeof val;
  8047. if (type === 'boolean') return 'boolean';
  8048. if (type === 'string') return 'string';
  8049. if (type === 'number') return 'number';
  8050. if (type === 'symbol') return 'symbol';
  8051. if (type === 'function') {
  8052. return isGeneratorFn(val) ? 'generatorfunction' : 'function';
  8053. }
  8054. if (isArray(val)) return 'array';
  8055. if (isBuffer$1(val)) return 'buffer';
  8056. if (isArguments(val)) return 'arguments';
  8057. if (isDate(val)) return 'date';
  8058. if (isError$1(val)) return 'error';
  8059. if (isRegexp(val)) return 'regexp';
  8060. switch (ctorName(val)) {
  8061. case 'Symbol': return 'symbol';
  8062. case 'Promise': return 'promise';
  8063. // Set, Map, WeakSet, WeakMap
  8064. case 'WeakMap': return 'weakmap';
  8065. case 'WeakSet': return 'weakset';
  8066. case 'Map': return 'map';
  8067. case 'Set': return 'set';
  8068. // 8-bit typed arrays
  8069. case 'Int8Array': return 'int8array';
  8070. case 'Uint8Array': return 'uint8array';
  8071. case 'Uint8ClampedArray': return 'uint8clampedarray';
  8072. // 16-bit typed arrays
  8073. case 'Int16Array': return 'int16array';
  8074. case 'Uint16Array': return 'uint16array';
  8075. // 32-bit typed arrays
  8076. case 'Int32Array': return 'int32array';
  8077. case 'Uint32Array': return 'uint32array';
  8078. case 'Float32Array': return 'float32array';
  8079. case 'Float64Array': return 'float64array';
  8080. }
  8081. if (isGeneratorObj(val)) {
  8082. return 'generator';
  8083. }
  8084. // Non-plain objects
  8085. type = toString$5.call(val);
  8086. switch (type) {
  8087. case '[object Object]': return 'object';
  8088. // iterators
  8089. case '[object Map Iterator]': return 'mapiterator';
  8090. case '[object Set Iterator]': return 'setiterator';
  8091. case '[object String Iterator]': return 'stringiterator';
  8092. case '[object Array Iterator]': return 'arrayiterator';
  8093. }
  8094. // other
  8095. return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
  8096. };
  8097. function ctorName(val) {
  8098. return val.constructor ? val.constructor.name : null;
  8099. }
  8100. function isArray(val) {
  8101. if (Array.isArray) return Array.isArray(val);
  8102. return val instanceof Array;
  8103. }
  8104. function isError$1(val) {
  8105. return val instanceof Error || (typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number');
  8106. }
  8107. function isDate(val) {
  8108. if (val instanceof Date) return true;
  8109. return typeof val.toDateString === 'function'
  8110. && typeof val.getDate === 'function'
  8111. && typeof val.setDate === 'function';
  8112. }
  8113. function isRegexp(val) {
  8114. if (val instanceof RegExp) return true;
  8115. return typeof val.flags === 'string'
  8116. && typeof val.ignoreCase === 'boolean'
  8117. && typeof val.multiline === 'boolean'
  8118. && typeof val.global === 'boolean';
  8119. }
  8120. function isGeneratorFn(name, val) {
  8121. return ctorName(name) === 'GeneratorFunction';
  8122. }
  8123. function isGeneratorObj(val) {
  8124. return typeof val.throw === 'function'
  8125. && typeof val.return === 'function'
  8126. && typeof val.next === 'function';
  8127. }
  8128. function isArguments(val) {
  8129. try {
  8130. if (typeof val.length === 'number' && typeof val.callee === 'function') {
  8131. return true;
  8132. }
  8133. } catch (err) {
  8134. if (err.message.indexOf('callee') !== -1) {
  8135. return true;
  8136. }
  8137. }
  8138. return false;
  8139. }
  8140. /**
  8141. * If you need to support Safari 5-7 (8-10 yr-old browser),
  8142. * take a look at https://github.com/feross/is-buffer
  8143. */
  8144. function isBuffer$1(val) {
  8145. if (val.constructor && typeof val.constructor.isBuffer === 'function') {
  8146. return val.constructor.isBuffer(val);
  8147. }
  8148. return false;
  8149. }
  8150. var crypto = ( empty$2 && empty$1 ) || empty$2;
  8151. var max$1 = Math.pow(2, 32);
  8152. var node = random;
  8153. var cryptographic = true;
  8154. function random () {
  8155. var buf = crypto
  8156. .randomBytes(4)
  8157. .toString('hex');
  8158. return parseInt(buf, 16) / max$1
  8159. }
  8160. node.cryptographic = cryptographic;
  8161. /**
  8162. * Expose `randomatic`
  8163. */
  8164. var randomatic_1 = randomatic;
  8165. var isCrypto = !!node.cryptographic;
  8166. /**
  8167. * Available mask characters
  8168. */
  8169. var type = {
  8170. lower: 'abcdefghijklmnopqrstuvwxyz',
  8171. upper: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
  8172. number: '0123456789',
  8173. special: '~!@#$%^&()_+-={}[];\',.'
  8174. };
  8175. type.all = type.lower + type.upper + type.number + type.special;
  8176. /**
  8177. * Generate random character sequences of a specified `length`,
  8178. * based on the given `pattern`.
  8179. *
  8180. * @param {String} `pattern` The pattern to use for generating the random string.
  8181. * @param {String} `length` The length of the string to generate.
  8182. * @param {String} `options`
  8183. * @return {String}
  8184. * @api public
  8185. */
  8186. function randomatic(pattern, length, options) {
  8187. if (typeof pattern === 'undefined') {
  8188. throw new Error('randomatic expects a string or number.');
  8189. }
  8190. var custom = false;
  8191. if (arguments.length === 1) {
  8192. if (typeof pattern === 'string') {
  8193. length = pattern.length;
  8194. } else if (isNumber$1(pattern)) {
  8195. options = {};
  8196. length = pattern;
  8197. pattern = '*';
  8198. }
  8199. }
  8200. if (kindOf$1(length) === 'object' && length.hasOwnProperty('chars')) {
  8201. options = length;
  8202. pattern = options.chars;
  8203. length = pattern.length;
  8204. custom = true;
  8205. }
  8206. var opts = options || {};
  8207. var mask = '';
  8208. var res = '';
  8209. // Characters to be used
  8210. if (pattern.indexOf('?') !== -1) mask += opts.chars;
  8211. if (pattern.indexOf('a') !== -1) mask += type.lower;
  8212. if (pattern.indexOf('A') !== -1) mask += type.upper;
  8213. if (pattern.indexOf('0') !== -1) mask += type.number;
  8214. if (pattern.indexOf('!') !== -1) mask += type.special;
  8215. if (pattern.indexOf('*') !== -1) mask += type.all;
  8216. if (custom) mask += pattern;
  8217. while (length--) {
  8218. res += mask.charAt(parseInt(node() * mask.length, 10));
  8219. }
  8220. return res;
  8221. }randomatic_1.isCrypto = isCrypto;
  8222. /*!
  8223. * repeat-string <https://github.com/jonschlinkert/repeat-string>
  8224. *
  8225. * Copyright (c) 2014-2015, Jon Schlinkert.
  8226. * Licensed under the MIT License.
  8227. */
  8228. /**
  8229. * Results cache
  8230. */
  8231. var res = '';
  8232. var cache;
  8233. /**
  8234. * Expose `repeat`
  8235. */
  8236. var repeatString = repeat;
  8237. /**
  8238. * Repeat the given `string` the specified `number`
  8239. * of times.
  8240. *
  8241. * **Example:**
  8242. *
  8243. * ```js
  8244. * var repeat = require('repeat-string');
  8245. * repeat('A', 5);
  8246. * //=> AAAAA
  8247. * ```
  8248. *
  8249. * @param {String} `string` The string to repeat
  8250. * @param {Number} `number` The number of times to repeat the string
  8251. * @return {String} Repeated string
  8252. * @api public
  8253. */
  8254. function repeat(str, num) {
  8255. if (typeof str !== 'string') {
  8256. throw new TypeError('expected a string');
  8257. }
  8258. // cover common, quick use cases
  8259. if (num === 1) return str;
  8260. if (num === 2) return str + str;
  8261. var max = str.length * num;
  8262. if (cache !== str || typeof cache === 'undefined') {
  8263. cache = str;
  8264. res = '';
  8265. } else if (res.length >= max) {
  8266. return res.substr(0, max);
  8267. }
  8268. while (max > res.length && num > 1) {
  8269. if (num & 1) {
  8270. res += str;
  8271. }
  8272. num >>= 1;
  8273. str += str;
  8274. }
  8275. res += str;
  8276. res = res.substr(0, max);
  8277. return res;
  8278. }
  8279. /*!
  8280. * repeat-element <https://github.com/jonschlinkert/repeat-element>
  8281. *
  8282. * Copyright (c) 2015 Jon Schlinkert.
  8283. * Licensed under the MIT license.
  8284. */
  8285. var repeatElement = function repeat(ele, num) {
  8286. var arr = new Array(num);
  8287. for (var i = 0; i < num; i++) {
  8288. arr[i] = ele;
  8289. }
  8290. return arr;
  8291. };
  8292. /**
  8293. * Expose `fillRange`
  8294. */
  8295. var fillRange_1 = fillRange;
  8296. /**
  8297. * Return a range of numbers or letters.
  8298. *
  8299. * @param {String} `a` Start of the range
  8300. * @param {String} `b` End of the range
  8301. * @param {String} `step` Increment or decrement to use.
  8302. * @param {Function} `fn` Custom function to modify each element in the range.
  8303. * @return {Array}
  8304. */
  8305. function fillRange(a, b, step, options, fn) {
  8306. if (a == null || b == null) {
  8307. throw new Error('fill-range expects the first and second args to be strings.');
  8308. }
  8309. if (typeof step === 'function') {
  8310. fn = step; options = {}; step = null;
  8311. }
  8312. if (typeof options === 'function') {
  8313. fn = options; options = {};
  8314. }
  8315. if (isobject(step)) {
  8316. options = step; step = '';
  8317. }
  8318. var expand, regex = false, sep = '';
  8319. var opts = options || {};
  8320. if (typeof opts.silent === 'undefined') {
  8321. opts.silent = true;
  8322. }
  8323. step = step || opts.step;
  8324. // store a ref to unmodified arg
  8325. var origA = a, origB = b;
  8326. b = (b.toString() === '-0') ? 0 : b;
  8327. if (opts.optimize || opts.makeRe) {
  8328. step = step ? (step += '~') : step;
  8329. expand = true;
  8330. regex = true;
  8331. sep = '~';
  8332. }
  8333. // handle special step characters
  8334. if (typeof step === 'string') {
  8335. var match = stepRe().exec(step);
  8336. if (match) {
  8337. var i = match.index;
  8338. var m = match[0];
  8339. // repeat string
  8340. if (m === '+') {
  8341. return repeatElement(a, b);
  8342. // randomize a, `b` times
  8343. } else if (m === '?') {
  8344. return [randomatic_1(a, b)];
  8345. // expand right, no regex reduction
  8346. } else if (m === '>') {
  8347. step = step.substr(0, i) + step.substr(i + 1);
  8348. expand = true;
  8349. // expand to an array, or if valid create a reduced
  8350. // string for a regex logic `or`
  8351. } else if (m === '|') {
  8352. step = step.substr(0, i) + step.substr(i + 1);
  8353. expand = true;
  8354. regex = true;
  8355. sep = m;
  8356. // expand to an array, or if valid create a reduced
  8357. // string for a regex range
  8358. } else if (m === '~') {
  8359. step = step.substr(0, i) + step.substr(i + 1);
  8360. expand = true;
  8361. regex = true;
  8362. sep = m;
  8363. }
  8364. } else if (!isNumber(step)) {
  8365. if (!opts.silent) {
  8366. throw new TypeError('fill-range: invalid step.');
  8367. }
  8368. return null;
  8369. }
  8370. }
  8371. if (/[.&*()[\]^%$#@!]/.test(a) || /[.&*()[\]^%$#@!]/.test(b)) {
  8372. if (!opts.silent) {
  8373. throw new RangeError('fill-range: invalid range arguments.');
  8374. }
  8375. return null;
  8376. }
  8377. // has neither a letter nor number, or has both letters and numbers
  8378. // this needs to be after the step logic
  8379. if (!noAlphaNum(a) || !noAlphaNum(b) || hasBoth(a) || hasBoth(b)) {
  8380. if (!opts.silent) {
  8381. throw new RangeError('fill-range: invalid range arguments.');
  8382. }
  8383. return null;
  8384. }
  8385. // validate arguments
  8386. var isNumA = isNumber(zeros(a));
  8387. var isNumB = isNumber(zeros(b));
  8388. if ((!isNumA && isNumB) || (isNumA && !isNumB)) {
  8389. if (!opts.silent) {
  8390. throw new TypeError('fill-range: first range argument is incompatible with second.');
  8391. }
  8392. return null;
  8393. }
  8394. // by this point both are the same, so we
  8395. // can use A to check going forward.
  8396. var isNum = isNumA;
  8397. var num = formatStep(step);
  8398. // is the range alphabetical? or numeric?
  8399. if (isNum) {
  8400. // if numeric, coerce to an integer
  8401. a = +a; b = +b;
  8402. } else {
  8403. // otherwise, get the charCode to expand alpha ranges
  8404. a = a.charCodeAt(0);
  8405. b = b.charCodeAt(0);
  8406. }
  8407. // is the pattern descending?
  8408. var isDescending = a > b;
  8409. // don't create a character class if the args are < 0
  8410. if (a < 0 || b < 0) {
  8411. expand = false;
  8412. regex = false;
  8413. }
  8414. // detect padding
  8415. var padding = isPadded(origA, origB);
  8416. var res, pad, arr = [];
  8417. var ii = 0;
  8418. // character classes, ranges and logical `or`
  8419. if (regex) {
  8420. if (shouldExpand(a, b, num, isNum, padding, opts)) {
  8421. // make sure the correct separator is used
  8422. if (sep === '|' || sep === '~') {
  8423. sep = detectSeparator(a, b, num, isNum, isDescending);
  8424. }
  8425. return wrap$1([origA, origB], sep, opts);
  8426. }
  8427. }
  8428. while (isDescending ? (a >= b) : (a <= b)) {
  8429. if (padding && isNum) {
  8430. pad = padding(a);
  8431. }
  8432. // custom function
  8433. if (typeof fn === 'function') {
  8434. res = fn(a, isNum, pad, ii++);
  8435. // letters
  8436. } else if (!isNum) {
  8437. if (regex && isInvalidChar(a)) {
  8438. res = null;
  8439. } else {
  8440. res = String.fromCharCode(a);
  8441. }
  8442. // numbers
  8443. } else {
  8444. res = formatPadding(a, pad);
  8445. }
  8446. // add result to the array, filtering any nulled values
  8447. if (res !== null) arr.push(res);
  8448. // increment or decrement
  8449. if (isDescending) {
  8450. a -= num;
  8451. } else {
  8452. a += num;
  8453. }
  8454. }
  8455. // now that the array is expanded, we need to handle regex
  8456. // character classes, ranges or logical `or` that wasn't
  8457. // already handled before the loop
  8458. if ((regex || expand) && !opts.noexpand) {
  8459. // make sure the correct separator is used
  8460. if (sep === '|' || sep === '~') {
  8461. sep = detectSeparator(a, b, num, isNum, isDescending);
  8462. }
  8463. if (arr.length === 1 || a < 0 || b < 0) { return arr; }
  8464. return wrap$1(arr, sep, opts);
  8465. }
  8466. return arr;
  8467. }
  8468. /**
  8469. * Wrap the string with the correct regex
  8470. * syntax.
  8471. */
  8472. function wrap$1(arr, sep, opts) {
  8473. if (sep === '~') { sep = '-'; }
  8474. var str = arr.join(sep);
  8475. var pre = opts && opts.regexPrefix;
  8476. // regex logical `or`
  8477. if (sep === '|') {
  8478. str = pre ? pre + str : str;
  8479. str = '(' + str + ')';
  8480. }
  8481. // regex character class
  8482. if (sep === '-') {
  8483. str = (pre && pre === '^')
  8484. ? pre + str
  8485. : str;
  8486. str = '[' + str + ']';
  8487. }
  8488. return [str];
  8489. }
  8490. /**
  8491. * Check for invalid characters
  8492. */
  8493. function isCharClass(a, b, step, isNum, isDescending) {
  8494. if (isDescending) { return false; }
  8495. if (isNum) { return a <= 9 && b <= 9; }
  8496. if (a < b) { return step === 1; }
  8497. return false;
  8498. }
  8499. /**
  8500. * Detect the correct separator to use
  8501. */
  8502. function shouldExpand(a, b, num, isNum, padding, opts) {
  8503. if (isNum && (a > 9 || b > 9)) { return false; }
  8504. return !padding && num === 1 && a < b;
  8505. }
  8506. /**
  8507. * Detect the correct separator to use
  8508. */
  8509. function detectSeparator(a, b, step, isNum, isDescending) {
  8510. var isChar = isCharClass(a, b, step, isNum, isDescending);
  8511. if (!isChar) {
  8512. return '|';
  8513. }
  8514. return '~';
  8515. }
  8516. /**
  8517. * Correctly format the step based on type
  8518. */
  8519. function formatStep(step) {
  8520. return Math.abs(step >> 0) || 1;
  8521. }
  8522. /**
  8523. * Format padding, taking leading `-` into account
  8524. */
  8525. function formatPadding(ch, pad) {
  8526. var res = pad ? pad + ch : ch;
  8527. if (pad && ch.toString().charAt(0) === '-') {
  8528. res = '-' + pad + ch.toString().substr(1);
  8529. }
  8530. return res.toString();
  8531. }
  8532. /**
  8533. * Check for invalid characters
  8534. */
  8535. function isInvalidChar(str) {
  8536. var ch = toStr(str);
  8537. return ch === '\\'
  8538. || ch === '['
  8539. || ch === ']'
  8540. || ch === '^'
  8541. || ch === '('
  8542. || ch === ')'
  8543. || ch === '`';
  8544. }
  8545. /**
  8546. * Convert to a string from a charCode
  8547. */
  8548. function toStr(ch) {
  8549. return String.fromCharCode(ch);
  8550. }
  8551. /**
  8552. * Step regex
  8553. */
  8554. function stepRe() {
  8555. return /\?|>|\||\+|\~/g;
  8556. }
  8557. /**
  8558. * Return true if `val` has either a letter
  8559. * or a number
  8560. */
  8561. function noAlphaNum(val) {
  8562. return /[a-z0-9]/i.test(val);
  8563. }
  8564. /**
  8565. * Return true if `val` has both a letter and
  8566. * a number (invalid)
  8567. */
  8568. function hasBoth(val) {
  8569. return /[a-z][0-9]|[0-9][a-z]/i.test(val);
  8570. }
  8571. /**
  8572. * Normalize zeros for checks
  8573. */
  8574. function zeros(val) {
  8575. if (/^-*0+$/.test(val.toString())) {
  8576. return '0';
  8577. }
  8578. return val;
  8579. }
  8580. /**
  8581. * Return true if `val` has leading zeros,
  8582. * or a similar valid pattern.
  8583. */
  8584. function hasZeros(val) {
  8585. return /[^.]\.|^-*0+[0-9]/.test(val);
  8586. }
  8587. /**
  8588. * If the string is padded, returns a curried function with
  8589. * the a cached padding string, or `false` if no padding.
  8590. *
  8591. * @param {*} `origA` String or number.
  8592. * @return {String|Boolean}
  8593. */
  8594. function isPadded(origA, origB) {
  8595. if (hasZeros(origA) || hasZeros(origB)) {
  8596. var alen = length(origA);
  8597. var blen = length(origB);
  8598. var len = alen >= blen
  8599. ? alen
  8600. : blen;
  8601. return function (a) {
  8602. return repeatString('0', len - length(a));
  8603. };
  8604. }
  8605. return false;
  8606. }
  8607. /**
  8608. * Get the string length of `val`
  8609. */
  8610. function length(val) {
  8611. return val.toString().length;
  8612. }
  8613. var expandRange = function expandRange(str, options, fn) {
  8614. if (typeof str !== 'string') {
  8615. throw new TypeError('expand-range expects a string.');
  8616. }
  8617. if (typeof options === 'function') {
  8618. fn = options;
  8619. options = {};
  8620. }
  8621. if (typeof options === 'boolean') {
  8622. options = {};
  8623. options.makeRe = true;
  8624. }
  8625. // create arguments to pass to fill-range
  8626. var opts = options || {};
  8627. var args = str.split('..');
  8628. var len = args.length;
  8629. if (len > 3) { return str; }
  8630. // if only one argument, it can't expand so return it
  8631. if (len === 1) { return args; }
  8632. // if `true`, tell fill-range to regexify the string
  8633. if (typeof fn === 'boolean' && fn === true) {
  8634. opts.makeRe = true;
  8635. }
  8636. args.push(opts);
  8637. return fillRange_1.apply(null, args.concat(fn));
  8638. };
  8639. /*!
  8640. * preserve <https://github.com/jonschlinkert/preserve>
  8641. *
  8642. * Copyright (c) 2014-2015, Jon Schlinkert.
  8643. * Licensed under the MIT license.
  8644. */
  8645. /**
  8646. * Replace tokens in `str` with a temporary, heuristic placeholder.
  8647. *
  8648. * ```js
  8649. * tokens.before('{a\\,b}');
  8650. * //=> '{__ID1__}'
  8651. * ```
  8652. *
  8653. * @param {String} `str`
  8654. * @return {String} String with placeholders.
  8655. * @api public
  8656. */
  8657. var before = function before(str, re) {
  8658. return str.replace(re, function (match) {
  8659. var id = randomize();
  8660. cache$1[id] = match;
  8661. return '__ID' + id + '__';
  8662. });
  8663. };
  8664. /**
  8665. * Replace placeholders in `str` with original tokens.
  8666. *
  8667. * ```js
  8668. * tokens.after('{__ID1__}');
  8669. * //=> '{a\\,b}'
  8670. * ```
  8671. *
  8672. * @param {String} `str` String with placeholders
  8673. * @return {String} `str` String with original tokens.
  8674. * @api public
  8675. */
  8676. var after = function after(str) {
  8677. return str.replace(/__ID(.{5})__/g, function (_, id) {
  8678. return cache$1[id];
  8679. });
  8680. };
  8681. function randomize() {
  8682. return Math.random().toString().slice(2, 7);
  8683. }
  8684. var cache$1 = {};
  8685. var preserve = {
  8686. before: before,
  8687. after: after
  8688. };
  8689. /**
  8690. * Module dependencies
  8691. */
  8692. /**
  8693. * Expose `braces`
  8694. */
  8695. var braces_1 = function(str, options) {
  8696. if (typeof str !== 'string') {
  8697. throw new Error('braces expects a string');
  8698. }
  8699. return braces(str, options);
  8700. };
  8701. /**
  8702. * Expand `{foo,bar}` or `{1..5}` braces in the
  8703. * given `string`.
  8704. *
  8705. * @param {String} `str`
  8706. * @param {Array} `arr`
  8707. * @param {Object} `options`
  8708. * @return {Array}
  8709. */
  8710. function braces(str, arr, options) {
  8711. if (str === '') {
  8712. return [];
  8713. }
  8714. if (!Array.isArray(arr)) {
  8715. options = arr;
  8716. arr = [];
  8717. }
  8718. var opts = options || {};
  8719. arr = arr || [];
  8720. if (typeof opts.nodupes === 'undefined') {
  8721. opts.nodupes = true;
  8722. }
  8723. var fn = opts.fn;
  8724. var es6;
  8725. if (typeof opts === 'function') {
  8726. fn = opts;
  8727. opts = {};
  8728. }
  8729. if (!(patternRe instanceof RegExp)) {
  8730. patternRe = patternRegex();
  8731. }
  8732. var matches = str.match(patternRe) || [];
  8733. var m = matches[0];
  8734. switch(m) {
  8735. case '\\,':
  8736. return escapeCommas(str, arr, opts);
  8737. case '\\.':
  8738. return escapeDots(str, arr, opts);
  8739. case '\/.':
  8740. return escapePaths(str, arr, opts);
  8741. case ' ':
  8742. return splitWhitespace(str);
  8743. case '{,}':
  8744. return exponential(str, opts, braces);
  8745. case '{}':
  8746. return emptyBraces(str, arr, opts);
  8747. case '\\{':
  8748. case '\\}':
  8749. return escapeBraces(str, arr, opts);
  8750. case '${':
  8751. if (!/\{[^{]+\{/.test(str)) {
  8752. return arr.concat(str);
  8753. } else {
  8754. es6 = true;
  8755. str = preserve.before(str, es6Regex());
  8756. }
  8757. }
  8758. if (!(braceRe instanceof RegExp)) {
  8759. braceRe = braceRegex();
  8760. }
  8761. var match = braceRe.exec(str);
  8762. if (match == null) {
  8763. return [str];
  8764. }
  8765. var outter = match[1];
  8766. var inner = match[2];
  8767. if (inner === '') { return [str]; }
  8768. var segs, segsLength;
  8769. if (inner.indexOf('..') !== -1) {
  8770. segs = expandRange(inner, opts, fn) || inner.split(',');
  8771. segsLength = segs.length;
  8772. } else if (inner[0] === '"' || inner[0] === '\'') {
  8773. return arr.concat(str.split(/['"]/).join(''));
  8774. } else {
  8775. segs = inner.split(',');
  8776. if (opts.makeRe) {
  8777. return braces(str.replace(outter, wrap$2(segs, '|')), opts);
  8778. }
  8779. segsLength = segs.length;
  8780. if (segsLength === 1 && opts.bash) {
  8781. segs[0] = wrap$2(segs[0], '\\');
  8782. }
  8783. }
  8784. var len = segs.length;
  8785. var i = 0, val;
  8786. while (len--) {
  8787. var path = segs[i++];
  8788. if (/(\.[^.\/])/.test(path)) {
  8789. if (segsLength > 1) {
  8790. return segs;
  8791. } else {
  8792. return [str];
  8793. }
  8794. }
  8795. val = splice(str, outter, path);
  8796. if (/\{[^{}]+?\}/.test(val)) {
  8797. arr = braces(val, arr, opts);
  8798. } else if (val !== '') {
  8799. if (opts.nodupes && arr.indexOf(val) !== -1) { continue; }
  8800. arr.push(es6 ? preserve.after(val) : val);
  8801. }
  8802. }
  8803. if (opts.strict) { return filter$1(arr, filterEmpty); }
  8804. return arr;
  8805. }
  8806. /**
  8807. * Expand exponential ranges
  8808. *
  8809. * `a{,}{,}` => ['a', 'a', 'a', 'a']
  8810. */
  8811. function exponential(str, options, fn) {
  8812. if (typeof options === 'function') {
  8813. fn = options;
  8814. options = null;
  8815. }
  8816. var opts = options || {};
  8817. var esc = '__ESC_EXP__';
  8818. var exp = 0;
  8819. var res;
  8820. var parts = str.split('{,}');
  8821. if (opts.nodupes) {
  8822. return fn(parts.join(''), opts);
  8823. }
  8824. exp = parts.length - 1;
  8825. res = fn(parts.join(esc), opts);
  8826. var len = res.length;
  8827. var arr = [];
  8828. var i = 0;
  8829. while (len--) {
  8830. var ele = res[i++];
  8831. var idx = ele.indexOf(esc);
  8832. if (idx === -1) {
  8833. arr.push(ele);
  8834. } else {
  8835. ele = ele.split('__ESC_EXP__').join('');
  8836. if (!!ele && opts.nodupes !== false) {
  8837. arr.push(ele);
  8838. } else {
  8839. var num = Math.pow(2, exp);
  8840. arr.push.apply(arr, repeatElement(ele, num));
  8841. }
  8842. }
  8843. }
  8844. return arr;
  8845. }
  8846. /**
  8847. * Wrap a value with parens, brackets or braces,
  8848. * based on the given character/separator.
  8849. *
  8850. * @param {String|Array} `val`
  8851. * @param {String} `ch`
  8852. * @return {String}
  8853. */
  8854. function wrap$2(val, ch) {
  8855. if (ch === '|') {
  8856. return '(' + val.join(ch) + ')';
  8857. }
  8858. if (ch === ',') {
  8859. return '{' + val.join(ch) + '}';
  8860. }
  8861. if (ch === '-') {
  8862. return '[' + val.join(ch) + ']';
  8863. }
  8864. if (ch === '\\') {
  8865. return '\\{' + val + '\\}';
  8866. }
  8867. }
  8868. /**
  8869. * Handle empty braces: `{}`
  8870. */
  8871. function emptyBraces(str, arr, opts) {
  8872. return braces(str.split('{}').join('\\{\\}'), arr, opts);
  8873. }
  8874. /**
  8875. * Filter out empty-ish values
  8876. */
  8877. function filterEmpty(ele) {
  8878. return !!ele && ele !== '\\';
  8879. }
  8880. /**
  8881. * Handle patterns with whitespace
  8882. */
  8883. function splitWhitespace(str) {
  8884. var segs = str.split(' ');
  8885. var len = segs.length;
  8886. var res = [];
  8887. var i = 0;
  8888. while (len--) {
  8889. res.push.apply(res, braces(segs[i++]));
  8890. }
  8891. return res;
  8892. }
  8893. /**
  8894. * Handle escaped braces: `\\{foo,bar}`
  8895. */
  8896. function escapeBraces(str, arr, opts) {
  8897. if (!/\{[^{]+\{/.test(str)) {
  8898. return arr.concat(str.split('\\').join(''));
  8899. } else {
  8900. str = str.split('\\{').join('__LT_BRACE__');
  8901. str = str.split('\\}').join('__RT_BRACE__');
  8902. return map$2(braces(str, arr, opts), function(ele) {
  8903. ele = ele.split('__LT_BRACE__').join('{');
  8904. return ele.split('__RT_BRACE__').join('}');
  8905. });
  8906. }
  8907. }
  8908. /**
  8909. * Handle escaped dots: `{1\\.2}`
  8910. */
  8911. function escapeDots(str, arr, opts) {
  8912. if (!/[^\\]\..+\\\./.test(str)) {
  8913. return arr.concat(str.split('\\').join(''));
  8914. } else {
  8915. str = str.split('\\.').join('__ESC_DOT__');
  8916. return map$2(braces(str, arr, opts), function(ele) {
  8917. return ele.split('__ESC_DOT__').join('.');
  8918. });
  8919. }
  8920. }
  8921. /**
  8922. * Handle escaped dots: `{1\\.2}`
  8923. */
  8924. function escapePaths(str, arr, opts) {
  8925. str = str.split('\/.').join('__ESC_PATH__');
  8926. return map$2(braces(str, arr, opts), function(ele) {
  8927. return ele.split('__ESC_PATH__').join('\/.');
  8928. });
  8929. }
  8930. /**
  8931. * Handle escaped commas: `{a\\,b}`
  8932. */
  8933. function escapeCommas(str, arr, opts) {
  8934. if (!/\w,/.test(str)) {
  8935. return arr.concat(str.split('\\').join(''));
  8936. } else {
  8937. str = str.split('\\,').join('__ESC_COMMA__');
  8938. return map$2(braces(str, arr, opts), function(ele) {
  8939. return ele.split('__ESC_COMMA__').join(',');
  8940. });
  8941. }
  8942. }
  8943. /**
  8944. * Regex for common patterns
  8945. */
  8946. function patternRegex() {
  8947. return /\${|( (?=[{,}])|(?=[{,}]) )|{}|{,}|\\,(?=.*[{}])|\/\.(?=.*[{}])|\\\.(?={)|\\{|\\}/;
  8948. }
  8949. /**
  8950. * Braces regex.
  8951. */
  8952. function braceRegex() {
  8953. return /.*(\\?\{([^}]+)\})/;
  8954. }
  8955. /**
  8956. * es6 delimiter regex.
  8957. */
  8958. function es6Regex() {
  8959. return /\$\{([^}]+)\}/;
  8960. }
  8961. var braceRe;
  8962. var patternRe;
  8963. /**
  8964. * Faster alternative to `String.replace()` when the
  8965. * index of the token to be replaces can't be supplied
  8966. */
  8967. function splice(str, token, replacement) {
  8968. var i = str.indexOf(token);
  8969. return str.substr(0, i) + replacement
  8970. + str.substr(i + token.length);
  8971. }
  8972. /**
  8973. * Fast array map
  8974. */
  8975. function map$2(arr, fn) {
  8976. if (arr == null) {
  8977. return [];
  8978. }
  8979. var len = arr.length;
  8980. var res = new Array(len);
  8981. var i = -1;
  8982. while (++i < len) {
  8983. res[i] = fn(arr[i], i, arr);
  8984. }
  8985. return res;
  8986. }
  8987. /**
  8988. * Fast array filter
  8989. */
  8990. function filter$1(arr, cb) {
  8991. if (arr == null) return [];
  8992. if (typeof cb !== 'function') {
  8993. throw new TypeError('braces: filter expects a callback function.');
  8994. }
  8995. var len = arr.length;
  8996. var res = arr.slice();
  8997. var i = 0;
  8998. while (len--) {
  8999. if (!cb(arr[len], i++)) {
  9000. res.splice(len, 1);
  9001. }
  9002. }
  9003. return res;
  9004. }
  9005. /*!
  9006. * is-posix-bracket <https://github.com/jonschlinkert/is-posix-bracket>
  9007. *
  9008. * Copyright (c) 2015-2016, Jon Schlinkert.
  9009. * Licensed under the MIT License.
  9010. */
  9011. var isPosixBracket = function isPosixBracket(str) {
  9012. return typeof str === 'string' && /\[([:.=+])(?:[^\[\]]|)+\1\]/.test(str);
  9013. };
  9014. /**
  9015. * POSIX character classes
  9016. */
  9017. var POSIX = {
  9018. alnum: 'a-zA-Z0-9',
  9019. alpha: 'a-zA-Z',
  9020. blank: ' \\t',
  9021. cntrl: '\\x00-\\x1F\\x7F',
  9022. digit: '0-9',
  9023. graph: '\\x21-\\x7E',
  9024. lower: 'a-z',
  9025. print: '\\x20-\\x7E',
  9026. punct: '-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
  9027. space: ' \\t\\r\\n\\v\\f',
  9028. upper: 'A-Z',
  9029. word: 'A-Za-z0-9_',
  9030. xdigit: 'A-Fa-f0-9',
  9031. };
  9032. /**
  9033. * Expose `brackets`
  9034. */
  9035. var expandBrackets = brackets;
  9036. function brackets(str) {
  9037. if (!isPosixBracket(str)) {
  9038. return str;
  9039. }
  9040. var negated = false;
  9041. if (str.indexOf('[^') !== -1) {
  9042. negated = true;
  9043. str = str.split('[^').join('[');
  9044. }
  9045. if (str.indexOf('[!') !== -1) {
  9046. negated = true;
  9047. str = str.split('[!').join('[');
  9048. }
  9049. var a = str.split('[');
  9050. var b = str.split(']');
  9051. var imbalanced = a.length !== b.length;
  9052. var parts = str.split(/(?::\]\[:|\[?\[:|:\]\]?)/);
  9053. var len = parts.length, i = 0;
  9054. var end = '', beg = '';
  9055. var res = [];
  9056. // start at the end (innermost) first
  9057. while (len--) {
  9058. var inner = parts[i++];
  9059. if (inner === '^[!' || inner === '[!') {
  9060. inner = '';
  9061. negated = true;
  9062. }
  9063. var prefix = negated ? '^' : '';
  9064. var ch = POSIX[inner];
  9065. if (ch) {
  9066. res.push('[' + prefix + ch + ']');
  9067. } else if (inner) {
  9068. if (/^\[?\w-\w\]?$/.test(inner)) {
  9069. if (i === parts.length) {
  9070. res.push('[' + prefix + inner);
  9071. } else if (i === 1) {
  9072. res.push(prefix + inner + ']');
  9073. } else {
  9074. res.push(prefix + inner);
  9075. }
  9076. } else {
  9077. if (i === 1) {
  9078. beg += inner;
  9079. } else if (i === parts.length) {
  9080. end += inner;
  9081. } else {
  9082. res.push('[' + prefix + inner + ']');
  9083. }
  9084. }
  9085. }
  9086. }
  9087. var result = res.join('|');
  9088. var rlen = res.length || 1;
  9089. if (rlen > 1) {
  9090. result = '(?:' + result + ')';
  9091. rlen = 1;
  9092. }
  9093. if (beg) {
  9094. rlen++;
  9095. if (beg.charAt(0) === '[') {
  9096. if (imbalanced) {
  9097. beg = '\\[' + beg.slice(1);
  9098. } else {
  9099. beg += ']';
  9100. }
  9101. }
  9102. result = beg + result;
  9103. }
  9104. if (end) {
  9105. rlen++;
  9106. if (end.slice(-1) === ']') {
  9107. if (imbalanced) {
  9108. end = end.slice(0, end.length - 1) + '\\]';
  9109. } else {
  9110. end = '[' + end;
  9111. }
  9112. }
  9113. result += end;
  9114. }
  9115. if (rlen > 1) {
  9116. result = result.split('][').join(']|[');
  9117. if (result.indexOf('|') !== -1 && !/\(\?/.test(result)) {
  9118. result = '(?:' + result + ')';
  9119. }
  9120. }
  9121. result = result.replace(/\[+=|=\]+/g, '\\b');
  9122. return result;
  9123. }
  9124. brackets.makeRe = function(pattern) {
  9125. try {
  9126. return new RegExp(brackets(pattern));
  9127. } catch (err) {}
  9128. };
  9129. brackets.isMatch = function(str, pattern) {
  9130. try {
  9131. return brackets.makeRe(pattern).test(str);
  9132. } catch (err) {
  9133. return false;
  9134. }
  9135. };
  9136. brackets.match = function(arr, pattern) {
  9137. var len = arr.length, i = 0;
  9138. var res = arr.slice();
  9139. var re = brackets.makeRe(pattern);
  9140. while (i < len) {
  9141. var ele = arr[i++];
  9142. if (!re.test(ele)) {
  9143. continue;
  9144. }
  9145. res.splice(i, 1);
  9146. }
  9147. return res;
  9148. };
  9149. /*!
  9150. * is-extglob <https://github.com/jonschlinkert/is-extglob>
  9151. *
  9152. * Copyright (c) 2014-2015, Jon Schlinkert.
  9153. * Licensed under the MIT License.
  9154. */
  9155. var isExtglob = function isExtglob(str) {
  9156. return typeof str === 'string'
  9157. && /[@?!+*]\(/.test(str);
  9158. };
  9159. /**
  9160. * Module dependencies
  9161. */
  9162. var re, cache$2 = {};
  9163. /**
  9164. * Expose `extglob`
  9165. */
  9166. var extglob_1 = extglob;
  9167. /**
  9168. * Convert the given extglob `string` to a regex-compatible
  9169. * string.
  9170. *
  9171. * ```js
  9172. * var extglob = require('extglob');
  9173. * extglob('!(a?(b))');
  9174. * //=> '(?!a(?:b)?)[^/]*?'
  9175. * ```
  9176. *
  9177. * @param {String} `str` The string to convert.
  9178. * @param {Object} `options`
  9179. * @option {Boolean} [options] `esc` If `false` special characters will not be escaped. Defaults to `true`.
  9180. * @option {Boolean} [options] `regex` If `true` a regular expression is returned instead of a string.
  9181. * @return {String}
  9182. * @api public
  9183. */
  9184. function extglob(str, opts) {
  9185. opts = opts || {};
  9186. var o = {}, i = 0;
  9187. // fix common character reversals
  9188. // '*!(.js)' => '*.!(js)'
  9189. str = str.replace(/!\(([^\w*()])/g, '$1!(');
  9190. // support file extension negation
  9191. str = str.replace(/([*\/])\.!\([*]\)/g, function (m, ch) {
  9192. if (ch === '/') {
  9193. return escape('\\/[^.]+');
  9194. }
  9195. return escape('[^.]+');
  9196. });
  9197. // create a unique key for caching by
  9198. // combining the string and options
  9199. var key = str
  9200. + String(!!opts.regex)
  9201. + String(!!opts.contains)
  9202. + String(!!opts.escape);
  9203. if (cache$2.hasOwnProperty(key)) {
  9204. return cache$2[key];
  9205. }
  9206. if (!(re instanceof RegExp)) {
  9207. re = regex();
  9208. }
  9209. opts.negate = false;
  9210. var m;
  9211. while (m = re.exec(str)) {
  9212. var prefix = m[1];
  9213. var inner = m[3];
  9214. if (prefix === '!') {
  9215. opts.negate = true;
  9216. }
  9217. var id = '__EXTGLOB_' + (i++) + '__';
  9218. // use the prefix of the _last_ (outtermost) pattern
  9219. o[id] = wrap$3(inner, prefix, opts.escape);
  9220. str = str.split(m[0]).join(id);
  9221. }
  9222. var keys = Object.keys(o);
  9223. var len = keys.length;
  9224. // we have to loop again to allow us to convert
  9225. // patterns in reverse order (starting with the
  9226. // innermost/last pattern first)
  9227. while (len--) {
  9228. var prop = keys[len];
  9229. str = str.split(prop).join(o[prop]);
  9230. }
  9231. var result = opts.regex
  9232. ? toRegex(str, opts.contains, opts.negate)
  9233. : str;
  9234. result = result.split('.').join('\\.');
  9235. // cache the result and return it
  9236. return (cache$2[key] = result);
  9237. }
  9238. /**
  9239. * Convert `string` to a regex string.
  9240. *
  9241. * @param {String} `str`
  9242. * @param {String} `prefix` Character that determines how to wrap the string.
  9243. * @param {Boolean} `esc` If `false` special characters will not be escaped. Defaults to `true`.
  9244. * @return {String}
  9245. */
  9246. function wrap$3(inner, prefix, esc) {
  9247. if (esc) inner = escape(inner);
  9248. switch (prefix) {
  9249. case '!':
  9250. return '(?!' + inner + ')[^/]' + (esc ? '%%%~' : '*?');
  9251. case '@':
  9252. return '(?:' + inner + ')';
  9253. case '+':
  9254. return '(?:' + inner + ')+';
  9255. case '*':
  9256. return '(?:' + inner + ')' + (esc ? '%%' : '*')
  9257. case '?':
  9258. return '(?:' + inner + '|)';
  9259. default:
  9260. return inner;
  9261. }
  9262. }
  9263. function escape(str) {
  9264. str = str.split('*').join('[^/]%%%~');
  9265. str = str.split('.').join('\\.');
  9266. return str;
  9267. }
  9268. /**
  9269. * extglob regex.
  9270. */
  9271. function regex() {
  9272. return /(\\?[@?!+*$]\\?)(\(([^()]*?)\))/;
  9273. }
  9274. /**
  9275. * Negation regex
  9276. */
  9277. function negate(str) {
  9278. return '(?!^' + str + ').*$';
  9279. }
  9280. /**
  9281. * Create the regex to do the matching. If
  9282. * the leading character in the `pattern` is `!`
  9283. * a negation regex is returned.
  9284. *
  9285. * @param {String} `pattern`
  9286. * @param {Boolean} `contains` Allow loose matching.
  9287. * @param {Boolean} `isNegated` True if the pattern is a negation pattern.
  9288. */
  9289. function toRegex(pattern, contains, isNegated) {
  9290. var prefix = contains ? '^' : '';
  9291. var after = contains ? '$' : '';
  9292. pattern = ('(?:' + pattern + ')' + after);
  9293. if (isNegated) {
  9294. pattern = prefix + negate(pattern);
  9295. }
  9296. return new RegExp(prefix + pattern);
  9297. }
  9298. /*!
  9299. * is-glob <https://github.com/jonschlinkert/is-glob>
  9300. *
  9301. * Copyright (c) 2014-2015, Jon Schlinkert.
  9302. * Licensed under the MIT License.
  9303. */
  9304. var isGlob = function isGlob(str) {
  9305. return typeof str === 'string'
  9306. && (/[*!?{}(|)[\]]/.test(str)
  9307. || isExtglob(str));
  9308. };
  9309. var isWin = process$3.platform === 'win32';
  9310. var removeTrailingSeparator = function (str) {
  9311. var i = str.length - 1;
  9312. if (i < 2) {
  9313. return str;
  9314. }
  9315. while (isSeparator(str, i)) {
  9316. i--;
  9317. }
  9318. return str.substr(0, i + 1);
  9319. };
  9320. function isSeparator(str, i) {
  9321. var char = str[i];
  9322. return i > 0 && (char === '/' || (isWin && char === '\\'));
  9323. }
  9324. /*!
  9325. * normalize-path <https://github.com/jonschlinkert/normalize-path>
  9326. *
  9327. * Copyright (c) 2014-2017, Jon Schlinkert.
  9328. * Released under the MIT License.
  9329. */
  9330. var normalizePath = function normalizePath(str, stripTrailing) {
  9331. if (typeof str !== 'string') {
  9332. throw new TypeError('expected a string');
  9333. }
  9334. str = str.replace(/[\\\/]+/g, '/');
  9335. if (stripTrailing !== false) {
  9336. str = removeTrailingSeparator(str);
  9337. }
  9338. return str;
  9339. };
  9340. /*!
  9341. * is-extendable <https://github.com/jonschlinkert/is-extendable>
  9342. *
  9343. * Copyright (c) 2015, Jon Schlinkert.
  9344. * Licensed under the MIT License.
  9345. */
  9346. var isExtendable = function isExtendable(val) {
  9347. return typeof val !== 'undefined' && val !== null
  9348. && (typeof val === 'object' || typeof val === 'function');
  9349. };
  9350. /*!
  9351. * for-in <https://github.com/jonschlinkert/for-in>
  9352. *
  9353. * Copyright (c) 2014-2017, Jon Schlinkert.
  9354. * Released under the MIT License.
  9355. */
  9356. var forIn = function forIn(obj, fn, thisArg) {
  9357. for (var key in obj) {
  9358. if (fn.call(thisArg, obj[key], key, obj) === false) {
  9359. break;
  9360. }
  9361. }
  9362. };
  9363. var hasOwn = Object.prototype.hasOwnProperty;
  9364. var forOwn = function forOwn(obj, fn, thisArg) {
  9365. forIn(obj, function(val, key) {
  9366. if (hasOwn.call(obj, key)) {
  9367. return fn.call(thisArg, obj[key], key, obj);
  9368. }
  9369. });
  9370. };
  9371. var object_omit = function omit(obj, keys) {
  9372. if (!isExtendable(obj)) return {};
  9373. keys = [].concat.apply([], [].slice.call(arguments, 1));
  9374. var last = keys[keys.length - 1];
  9375. var res = {}, fn;
  9376. if (typeof last === 'function') {
  9377. fn = keys.pop();
  9378. }
  9379. var isFunction = typeof fn === 'function';
  9380. if (!keys.length && !isFunction) {
  9381. return obj;
  9382. }
  9383. forOwn(obj, function(value, key) {
  9384. if (keys.indexOf(key) === -1) {
  9385. if (!isFunction) {
  9386. res[key] = value;
  9387. } else if (fn(value, key, obj)) {
  9388. res[key] = value;
  9389. }
  9390. }
  9391. });
  9392. return res;
  9393. };
  9394. var globParent = function globParent(str) {
  9395. str += 'a'; // preserves full path in case of trailing path separator
  9396. do {str = path$2.dirname(str);} while (isGlob(str));
  9397. return str;
  9398. };
  9399. var globBase = function globBase(pattern) {
  9400. if (typeof pattern !== 'string') {
  9401. throw new TypeError('glob-base expects a string.');
  9402. }
  9403. var res = {};
  9404. res.base = globParent(pattern);
  9405. res.isGlob = isGlob(pattern);
  9406. if (res.base !== '.') {
  9407. res.glob = pattern.substr(res.base.length);
  9408. if (res.glob.charAt(0) === '/') {
  9409. res.glob = res.glob.substr(1);
  9410. }
  9411. } else {
  9412. res.glob = pattern;
  9413. }
  9414. if (!res.isGlob) {
  9415. res.base = dirname$1(pattern);
  9416. res.glob = res.base !== '.'
  9417. ? pattern.substr(res.base.length)
  9418. : pattern;
  9419. }
  9420. if (res.glob.substr(0, 2) === './') {
  9421. res.glob = res.glob.substr(2);
  9422. }
  9423. if (res.glob.charAt(0) === '/') {
  9424. res.glob = res.glob.substr(1);
  9425. }
  9426. return res;
  9427. };
  9428. function dirname$1(glob) {
  9429. if (glob.slice(-1) === '/') return glob;
  9430. return path$2.dirname(glob);
  9431. }
  9432. /*!
  9433. * is-dotfile <https://github.com/jonschlinkert/is-dotfile>
  9434. *
  9435. * Copyright (c) 2015-2017, Jon Schlinkert.
  9436. * Released under the MIT License.
  9437. */
  9438. var isDotfile = function(str) {
  9439. if (str.charCodeAt(0) === 46 /* . */ && str.indexOf('/', 1) === -1) {
  9440. return true;
  9441. }
  9442. var slash = str.lastIndexOf('/');
  9443. return slash !== -1 ? str.charCodeAt(slash + 1) === 46 /* . */ : false;
  9444. };
  9445. var parseGlob = createCommonjsModule(function (module) {
  9446. /**
  9447. * Expose `cache`
  9448. */
  9449. var cache = module.exports.cache = {};
  9450. /**
  9451. * Parse a glob pattern into tokens.
  9452. *
  9453. * When no paths or '**' are in the glob, we use a
  9454. * different strategy for parsing the filename, since
  9455. * file names can contain braces and other difficult
  9456. * patterns. such as:
  9457. *
  9458. * - `*.{a,b}`
  9459. * - `(**|*.js)`
  9460. */
  9461. module.exports = function parseGlob(glob) {
  9462. if (cache.hasOwnProperty(glob)) {
  9463. return cache[glob];
  9464. }
  9465. var tok = {};
  9466. tok.orig = glob;
  9467. tok.is = {};
  9468. // unescape dots and slashes in braces/brackets
  9469. glob = escape(glob);
  9470. var parsed = globBase(glob);
  9471. tok.is.glob = parsed.isGlob;
  9472. tok.glob = parsed.glob;
  9473. tok.base = parsed.base;
  9474. var segs = /([^\/]*)$/.exec(glob);
  9475. tok.path = {};
  9476. tok.path.dirname = '';
  9477. tok.path.basename = segs[1] || '';
  9478. tok.path.dirname = glob.split(tok.path.basename).join('') || '';
  9479. var basename = (tok.path.basename || '').split('.') || '';
  9480. tok.path.filename = basename[0] || '';
  9481. tok.path.extname = basename.slice(1).join('.') || '';
  9482. tok.path.ext = '';
  9483. if (isGlob(tok.path.dirname) && !tok.path.basename) {
  9484. if (!/\/$/.test(tok.glob)) {
  9485. tok.path.basename = tok.glob;
  9486. }
  9487. tok.path.dirname = tok.base;
  9488. }
  9489. if (glob.indexOf('/') === -1 && !tok.is.globstar) {
  9490. tok.path.dirname = '';
  9491. tok.path.basename = tok.orig;
  9492. }
  9493. var dot = tok.path.basename.indexOf('.');
  9494. if (dot !== -1) {
  9495. tok.path.filename = tok.path.basename.slice(0, dot);
  9496. tok.path.extname = tok.path.basename.slice(dot);
  9497. }
  9498. if (tok.path.extname.charAt(0) === '.') {
  9499. var exts = tok.path.extname.split('.');
  9500. tok.path.ext = exts[exts.length - 1];
  9501. }
  9502. // unescape dots and slashes in braces/brackets
  9503. tok.glob = unescape(tok.glob);
  9504. tok.path.dirname = unescape(tok.path.dirname);
  9505. tok.path.basename = unescape(tok.path.basename);
  9506. tok.path.filename = unescape(tok.path.filename);
  9507. tok.path.extname = unescape(tok.path.extname);
  9508. // Booleans
  9509. var is = (glob && tok.is.glob);
  9510. tok.is.negated = glob && glob.charAt(0) === '!';
  9511. tok.is.extglob = glob && isExtglob(glob);
  9512. tok.is.braces = has(is, glob, '{');
  9513. tok.is.brackets = has(is, glob, '[:');
  9514. tok.is.globstar = has(is, glob, '**');
  9515. tok.is.dotfile = isDotfile(tok.path.basename) || isDotfile(tok.path.filename);
  9516. tok.is.dotdir = dotdir(tok.path.dirname);
  9517. return (cache[glob] = tok);
  9518. };
  9519. /**
  9520. * Returns true if the glob matches dot-directories.
  9521. *
  9522. * @param {Object} `tok` The tokens object
  9523. * @param {Object} `path` The path object
  9524. * @return {Object}
  9525. */
  9526. function dotdir(base) {
  9527. if (base.indexOf('/.') !== -1) {
  9528. return true;
  9529. }
  9530. if (base.charAt(0) === '.' && base.charAt(1) !== '/') {
  9531. return true;
  9532. }
  9533. return false;
  9534. }
  9535. /**
  9536. * Returns true if the pattern has the given `ch`aracter(s)
  9537. *
  9538. * @param {Object} `glob` The glob pattern.
  9539. * @param {Object} `ch` The character to test for
  9540. * @return {Object}
  9541. */
  9542. function has(is, glob, ch) {
  9543. return is && glob.indexOf(ch) !== -1;
  9544. }
  9545. /**
  9546. * Escape/unescape utils
  9547. */
  9548. function escape(str) {
  9549. var re = /\{([^{}]*?)}|\(([^()]*?)\)|\[([^\[\]]*?)\]/g;
  9550. return str.replace(re, function (outter, braces, parens, brackets) {
  9551. var inner = braces || parens || brackets;
  9552. if (!inner) { return outter; }
  9553. return outter.split(inner).join(esc(inner));
  9554. });
  9555. }
  9556. function esc(str) {
  9557. str = str.split('/').join('__SLASH__');
  9558. str = str.split('.').join('__DOT__');
  9559. return str;
  9560. }
  9561. function unescape(str) {
  9562. str = str.split('__SLASH__').join('/');
  9563. str = str.split('__DOT__').join('.');
  9564. return str;
  9565. }
  9566. });
  9567. var parseGlob_1 = parseGlob.cache;
  9568. /*!
  9569. * is-primitive <https://github.com/jonschlinkert/is-primitive>
  9570. *
  9571. * Copyright (c) 2014-2015, Jon Schlinkert.
  9572. * Licensed under the MIT License.
  9573. */
  9574. // see http://jsperf.com/testing-value-is-primitive/7
  9575. var isPrimitive = function isPrimitive(value) {
  9576. return value == null || (typeof value !== 'function' && typeof value !== 'object');
  9577. };
  9578. var isEqualShallow = function isEqual(a, b) {
  9579. if (!a && !b) { return true; }
  9580. if (!a && b || a && !b) { return false; }
  9581. var numKeysA = 0, numKeysB = 0, key;
  9582. for (key in b) {
  9583. numKeysB++;
  9584. if (!isPrimitive(b[key]) || !a.hasOwnProperty(key) || (a[key] !== b[key])) {
  9585. return false;
  9586. }
  9587. }
  9588. for (key in a) {
  9589. numKeysA++;
  9590. }
  9591. return numKeysA === numKeysB;
  9592. };
  9593. var basic = {};
  9594. var cache$3 = {};
  9595. /**
  9596. * Expose `regexCache`
  9597. */
  9598. var regexCache_1 = regexCache;
  9599. /**
  9600. * Memoize the results of a call to the new RegExp constructor.
  9601. *
  9602. * @param {Function} fn [description]
  9603. * @param {String} str [description]
  9604. * @param {Options} options [description]
  9605. * @param {Boolean} nocompare [description]
  9606. * @return {RegExp}
  9607. */
  9608. function regexCache(fn, str, opts) {
  9609. var key = '_default_', regex, cached;
  9610. if (!str && !opts) {
  9611. if (typeof fn !== 'function') {
  9612. return fn;
  9613. }
  9614. return basic[key] || (basic[key] = fn(str));
  9615. }
  9616. var isString = typeof str === 'string';
  9617. if (isString) {
  9618. if (!opts) {
  9619. return basic[str] || (basic[str] = fn(str));
  9620. }
  9621. key = str;
  9622. } else {
  9623. opts = str;
  9624. }
  9625. cached = cache$3[key];
  9626. if (cached && isEqualShallow(cached.opts, opts)) {
  9627. return cached.regex;
  9628. }
  9629. memo(key, opts, (regex = fn(str, opts)));
  9630. return regex;
  9631. }
  9632. function memo(key, opts, regex) {
  9633. cache$3[key] = {regex: regex, opts: opts};
  9634. }
  9635. /**
  9636. * Expose `cache`
  9637. */
  9638. var cache_1 = cache$3;
  9639. var basic_1 = basic;
  9640. regexCache_1.cache = cache_1;
  9641. regexCache_1.basic = basic_1;
  9642. var utils_1 = createCommonjsModule(function (module) {
  9643. var win32 = process$3 && process$3.platform === 'win32';
  9644. var utils = module.exports;
  9645. /**
  9646. * Module dependencies
  9647. */
  9648. utils.diff = arrDiff;
  9649. utils.unique = arrayUnique;
  9650. utils.braces = braces_1;
  9651. utils.brackets = expandBrackets;
  9652. utils.extglob = extglob_1;
  9653. utils.isExtglob = isExtglob;
  9654. utils.isGlob = isGlob;
  9655. utils.typeOf = kindOf;
  9656. utils.normalize = normalizePath;
  9657. utils.omit = object_omit;
  9658. utils.parseGlob = parseGlob;
  9659. utils.cache = regexCache_1;
  9660. /**
  9661. * Get the filename of a filepath
  9662. *
  9663. * @param {String} `string`
  9664. * @return {String}
  9665. */
  9666. utils.filename = function filename(fp) {
  9667. var seg = fp.match(filenameRegex());
  9668. return seg && seg[0];
  9669. };
  9670. /**
  9671. * Returns a function that returns true if the given
  9672. * pattern is the same as a given `filepath`
  9673. *
  9674. * @param {String} `pattern`
  9675. * @return {Function}
  9676. */
  9677. utils.isPath = function isPath(pattern, opts) {
  9678. opts = opts || {};
  9679. return function(fp) {
  9680. var unixified = utils.unixify(fp, opts);
  9681. if(opts.nocase){
  9682. return pattern.toLowerCase() === unixified.toLowerCase();
  9683. }
  9684. return pattern === unixified;
  9685. };
  9686. };
  9687. /**
  9688. * Returns a function that returns true if the given
  9689. * pattern contains a `filepath`
  9690. *
  9691. * @param {String} `pattern`
  9692. * @return {Function}
  9693. */
  9694. utils.hasPath = function hasPath(pattern, opts) {
  9695. return function(fp) {
  9696. return utils.unixify(pattern, opts).indexOf(fp) !== -1;
  9697. };
  9698. };
  9699. /**
  9700. * Returns a function that returns true if the given
  9701. * pattern matches or contains a `filepath`
  9702. *
  9703. * @param {String} `pattern`
  9704. * @return {Function}
  9705. */
  9706. utils.matchPath = function matchPath(pattern, opts) {
  9707. var fn = (opts && opts.contains)
  9708. ? utils.hasPath(pattern, opts)
  9709. : utils.isPath(pattern, opts);
  9710. return fn;
  9711. };
  9712. /**
  9713. * Returns a function that returns true if the given
  9714. * regex matches the `filename` of a file path.
  9715. *
  9716. * @param {RegExp} `re`
  9717. * @return {Boolean}
  9718. */
  9719. utils.hasFilename = function hasFilename(re) {
  9720. return function(fp) {
  9721. var name = utils.filename(fp);
  9722. return name && re.test(name);
  9723. };
  9724. };
  9725. /**
  9726. * Coerce `val` to an array
  9727. *
  9728. * @param {*} val
  9729. * @return {Array}
  9730. */
  9731. utils.arrayify = function arrayify(val) {
  9732. return !Array.isArray(val)
  9733. ? [val]
  9734. : val;
  9735. };
  9736. /**
  9737. * Normalize all slashes in a file path or glob pattern to
  9738. * forward slashes.
  9739. */
  9740. utils.unixify = function unixify(fp, opts) {
  9741. if (opts && opts.unixify === false) return fp;
  9742. if (opts && opts.unixify === true || win32 || path$2.sep === '\\') {
  9743. return utils.normalize(fp, false);
  9744. }
  9745. if (opts && opts.unescape === true) {
  9746. return fp ? fp.toString().replace(/\\(\w)/g, '$1') : '';
  9747. }
  9748. return fp;
  9749. };
  9750. /**
  9751. * Escape/unescape utils
  9752. */
  9753. utils.escapePath = function escapePath(fp) {
  9754. return fp.replace(/[\\.]/g, '\\$&');
  9755. };
  9756. utils.unescapeGlob = function unescapeGlob(fp) {
  9757. return fp.replace(/[\\"']/g, '');
  9758. };
  9759. utils.escapeRe = function escapeRe(str) {
  9760. return str.replace(/[-[\\$*+?.#^\s{}(|)\]]/g, '\\$&');
  9761. };
  9762. /**
  9763. * Expose `utils`
  9764. */
  9765. module.exports = utils;
  9766. });
  9767. var chars = {}, unesc, temp;
  9768. function reverse(object, prepender) {
  9769. return Object.keys(object).reduce(function(reversed, key) {
  9770. var newKey = prepender ? prepender + key : key; // Optionally prepend a string to key.
  9771. reversed[object[key]] = newKey; // Swap key and value.
  9772. return reversed; // Return the result.
  9773. }, {});
  9774. }
  9775. /**
  9776. * Regex for common characters
  9777. */
  9778. chars.escapeRegex = {
  9779. '?': /\?/g,
  9780. '@': /\@/g,
  9781. '!': /\!/g,
  9782. '+': /\+/g,
  9783. '*': /\*/g,
  9784. '(': /\(/g,
  9785. ')': /\)/g,
  9786. '[': /\[/g,
  9787. ']': /\]/g
  9788. };
  9789. /**
  9790. * Escape characters
  9791. */
  9792. chars.ESC = {
  9793. '?': '__UNESC_QMRK__',
  9794. '@': '__UNESC_AMPE__',
  9795. '!': '__UNESC_EXCL__',
  9796. '+': '__UNESC_PLUS__',
  9797. '*': '__UNESC_STAR__',
  9798. ',': '__UNESC_COMMA__',
  9799. '(': '__UNESC_LTPAREN__',
  9800. ')': '__UNESC_RTPAREN__',
  9801. '[': '__UNESC_LTBRACK__',
  9802. ']': '__UNESC_RTBRACK__'
  9803. };
  9804. /**
  9805. * Unescape characters
  9806. */
  9807. chars.UNESC = unesc || (unesc = reverse(chars.ESC, '\\'));
  9808. chars.ESC_TEMP = {
  9809. '?': '__TEMP_QMRK__',
  9810. '@': '__TEMP_AMPE__',
  9811. '!': '__TEMP_EXCL__',
  9812. '*': '__TEMP_STAR__',
  9813. '+': '__TEMP_PLUS__',
  9814. ',': '__TEMP_COMMA__',
  9815. '(': '__TEMP_LTPAREN__',
  9816. ')': '__TEMP_RTPAREN__',
  9817. '[': '__TEMP_LTBRACK__',
  9818. ']': '__TEMP_RTBRACK__'
  9819. };
  9820. chars.TEMP = temp || (temp = reverse(chars.ESC_TEMP));
  9821. var chars_1 = chars;
  9822. var glob = createCommonjsModule(function (module) {
  9823. /**
  9824. * Expose `Glob`
  9825. */
  9826. var Glob = module.exports = function Glob(pattern, options) {
  9827. if (!(this instanceof Glob)) {
  9828. return new Glob(pattern, options);
  9829. }
  9830. this.options = options || {};
  9831. this.pattern = pattern;
  9832. this.history = [];
  9833. this.tokens = {};
  9834. this.init(pattern);
  9835. };
  9836. /**
  9837. * Initialize defaults
  9838. */
  9839. Glob.prototype.init = function(pattern) {
  9840. this.orig = pattern;
  9841. this.negated = this.isNegated();
  9842. this.options.track = this.options.track || false;
  9843. this.options.makeRe = true;
  9844. };
  9845. /**
  9846. * Push a change into `glob.history`. Useful
  9847. * for debugging.
  9848. */
  9849. Glob.prototype.track = function(msg) {
  9850. if (this.options.track) {
  9851. this.history.push({msg: msg, pattern: this.pattern});
  9852. }
  9853. };
  9854. /**
  9855. * Return true if `glob.pattern` was negated
  9856. * with `!`, also remove the `!` from the pattern.
  9857. *
  9858. * @return {Boolean}
  9859. */
  9860. Glob.prototype.isNegated = function() {
  9861. if (this.pattern.charCodeAt(0) === 33 /* '!' */) {
  9862. this.pattern = this.pattern.slice(1);
  9863. return true;
  9864. }
  9865. return false;
  9866. };
  9867. /**
  9868. * Expand braces in the given glob pattern.
  9869. *
  9870. * We only need to use the [braces] lib when
  9871. * patterns are nested.
  9872. */
  9873. Glob.prototype.braces = function() {
  9874. if (this.options.nobraces !== true && this.options.nobrace !== true) {
  9875. // naive/fast check for imbalanced characters
  9876. var a = this.pattern.match(/[\{\(\[]/g);
  9877. var b = this.pattern.match(/[\}\)\]]/g);
  9878. // if imbalanced, don't optimize the pattern
  9879. if (a && b && (a.length !== b.length)) {
  9880. this.options.makeRe = false;
  9881. }
  9882. // expand brace patterns and join the resulting array
  9883. var expanded = utils_1.braces(this.pattern, this.options);
  9884. this.pattern = expanded.join('|');
  9885. }
  9886. };
  9887. /**
  9888. * Expand bracket expressions in `glob.pattern`
  9889. */
  9890. Glob.prototype.brackets = function() {
  9891. if (this.options.nobrackets !== true) {
  9892. this.pattern = utils_1.brackets(this.pattern);
  9893. }
  9894. };
  9895. /**
  9896. * Expand bracket expressions in `glob.pattern`
  9897. */
  9898. Glob.prototype.extglob = function() {
  9899. if (this.options.noextglob === true) return;
  9900. if (utils_1.isExtglob(this.pattern)) {
  9901. this.pattern = utils_1.extglob(this.pattern, {escape: true});
  9902. }
  9903. };
  9904. /**
  9905. * Parse the given pattern
  9906. */
  9907. Glob.prototype.parse = function(pattern) {
  9908. this.tokens = utils_1.parseGlob(pattern || this.pattern, true);
  9909. return this.tokens;
  9910. };
  9911. /**
  9912. * Replace `a` with `b`. Also tracks the change before and
  9913. * after each replacement. This is disabled by default, but
  9914. * can be enabled by setting `options.track` to true.
  9915. *
  9916. * Also, when the pattern is a string, `.split()` is used,
  9917. * because it's much faster than replace.
  9918. *
  9919. * @param {RegExp|String} `a`
  9920. * @param {String} `b`
  9921. * @param {Boolean} `escape` When `true`, escapes `*` and `?` in the replacement.
  9922. * @return {String}
  9923. */
  9924. Glob.prototype._replace = function(a, b, escape) {
  9925. this.track('before (find): "' + a + '" (replace with): "' + b + '"');
  9926. if (escape) b = esc(b);
  9927. if (a && b && typeof a === 'string') {
  9928. this.pattern = this.pattern.split(a).join(b);
  9929. } else {
  9930. this.pattern = this.pattern.replace(a, b);
  9931. }
  9932. this.track('after');
  9933. };
  9934. /**
  9935. * Escape special characters in the given string.
  9936. *
  9937. * @param {String} `str` Glob pattern
  9938. * @return {String}
  9939. */
  9940. Glob.prototype.escape = function(str) {
  9941. this.track('before escape: ');
  9942. var re = /["\\](['"]?[^"'\\]['"]?)/g;
  9943. this.pattern = str.replace(re, function($0, $1) {
  9944. var o = chars_1.ESC;
  9945. var ch = o && o[$1];
  9946. if (ch) {
  9947. return ch;
  9948. }
  9949. if (/[a-z]/i.test($0)) {
  9950. return $0.split('\\').join('');
  9951. }
  9952. return $0;
  9953. });
  9954. this.track('after escape: ');
  9955. };
  9956. /**
  9957. * Unescape special characters in the given string.
  9958. *
  9959. * @param {String} `str`
  9960. * @return {String}
  9961. */
  9962. Glob.prototype.unescape = function(str) {
  9963. var re = /__([A-Z]+)_([A-Z]+)__/g;
  9964. this.pattern = str.replace(re, function($0, $1) {
  9965. return chars_1[$1][$0];
  9966. });
  9967. this.pattern = unesc(this.pattern);
  9968. };
  9969. /**
  9970. * Escape/unescape utils
  9971. */
  9972. function esc(str) {
  9973. str = str.split('?').join('%~');
  9974. str = str.split('*').join('%%');
  9975. return str;
  9976. }
  9977. function unesc(str) {
  9978. str = str.split('%~').join('?');
  9979. str = str.split('%%').join('*');
  9980. return str;
  9981. }
  9982. });
  9983. /**
  9984. * Expose `expand`
  9985. */
  9986. var expand_1 = expand;
  9987. /**
  9988. * Expand a glob pattern to resolve braces and
  9989. * similar patterns before converting to regex.
  9990. *
  9991. * @param {String|Array} `pattern`
  9992. * @param {Array} `files`
  9993. * @param {Options} `opts`
  9994. * @return {Array}
  9995. */
  9996. function expand(pattern, options) {
  9997. if (typeof pattern !== 'string') {
  9998. throw new TypeError('micromatch.expand(): argument should be a string.');
  9999. }
  10000. var glob$$1 = new glob(pattern, options || {});
  10001. var opts = glob$$1.options;
  10002. if (!utils_1.isGlob(pattern)) {
  10003. glob$$1.pattern = glob$$1.pattern.replace(/([\/.])/g, '\\$1');
  10004. return glob$$1;
  10005. }
  10006. glob$$1.pattern = glob$$1.pattern.replace(/(\+)(?!\()/g, '\\$1');
  10007. glob$$1.pattern = glob$$1.pattern.split('$').join('\\$');
  10008. if (typeof opts.braces !== 'boolean' && typeof opts.nobraces !== 'boolean') {
  10009. opts.braces = true;
  10010. }
  10011. if (glob$$1.pattern === '.*') {
  10012. return {
  10013. pattern: '\\.' + star,
  10014. tokens: tok,
  10015. options: opts
  10016. };
  10017. }
  10018. if (glob$$1.pattern === '*') {
  10019. return {
  10020. pattern: oneStar(opts.dot),
  10021. tokens: tok,
  10022. options: opts
  10023. };
  10024. }
  10025. // parse the glob pattern into tokens
  10026. glob$$1.parse();
  10027. var tok = glob$$1.tokens;
  10028. tok.is.negated = opts.negated;
  10029. // dotfile handling
  10030. if ((opts.dotfiles === true || tok.is.dotfile) && opts.dot !== false) {
  10031. opts.dotfiles = true;
  10032. opts.dot = true;
  10033. }
  10034. if ((opts.dotdirs === true || tok.is.dotdir) && opts.dot !== false) {
  10035. opts.dotdirs = true;
  10036. opts.dot = true;
  10037. }
  10038. // check for braces with a dotfile pattern
  10039. if (/[{,]\./.test(glob$$1.pattern)) {
  10040. opts.makeRe = false;
  10041. opts.dot = true;
  10042. }
  10043. if (opts.nonegate !== true) {
  10044. opts.negated = glob$$1.negated;
  10045. }
  10046. // if the leading character is a dot or a slash, escape it
  10047. if (glob$$1.pattern.charAt(0) === '.' && glob$$1.pattern.charAt(1) !== '/') {
  10048. glob$$1.pattern = '\\' + glob$$1.pattern;
  10049. }
  10050. /**
  10051. * Extended globs
  10052. */
  10053. // expand braces, e.g `{1..5}`
  10054. glob$$1.track('before braces');
  10055. if (tok.is.braces) {
  10056. glob$$1.braces();
  10057. }
  10058. glob$$1.track('after braces');
  10059. // expand extglobs, e.g `foo/!(a|b)`
  10060. glob$$1.track('before extglob');
  10061. if (tok.is.extglob) {
  10062. glob$$1.extglob();
  10063. }
  10064. glob$$1.track('after extglob');
  10065. // expand brackets, e.g `[[:alpha:]]`
  10066. glob$$1.track('before brackets');
  10067. if (tok.is.brackets) {
  10068. glob$$1.brackets();
  10069. }
  10070. glob$$1.track('after brackets');
  10071. // special patterns
  10072. glob$$1._replace('[!', '[^');
  10073. glob$$1._replace('(?', '(%~');
  10074. glob$$1._replace(/\[\]/, '\\[\\]');
  10075. glob$$1._replace('/[', '/' + (opts.dot ? dotfiles : nodot) + '[', true);
  10076. glob$$1._replace('/?', '/' + (opts.dot ? dotfiles : nodot) + '[^/]', true);
  10077. glob$$1._replace('/.', '/(?=.)\\.', true);
  10078. // windows drives
  10079. glob$$1._replace(/^(\w):([\\\/]+?)/gi, '(?=.)$1:$2', true);
  10080. // negate slashes in exclusion ranges
  10081. if (glob$$1.pattern.indexOf('[^') !== -1) {
  10082. glob$$1.pattern = negateSlash(glob$$1.pattern);
  10083. }
  10084. if (opts.globstar !== false && glob$$1.pattern === '**') {
  10085. glob$$1.pattern = globstar(opts.dot);
  10086. } else {
  10087. glob$$1.pattern = balance(glob$$1.pattern, '[', ']');
  10088. glob$$1.escape(glob$$1.pattern);
  10089. // if the pattern has `**`
  10090. if (tok.is.globstar) {
  10091. glob$$1.pattern = collapse(glob$$1.pattern, '/**');
  10092. glob$$1.pattern = collapse(glob$$1.pattern, '**/');
  10093. glob$$1._replace('/**/', '(?:/' + globstar(opts.dot) + '/|/)', true);
  10094. glob$$1._replace(/\*{2,}/g, '**');
  10095. // 'foo/*'
  10096. glob$$1._replace(/(\w+)\*(?!\/)/g, '$1[^/]*?', true);
  10097. glob$$1._replace(/\*\*\/\*(\w)/g, globstar(opts.dot) + '\\/' + (opts.dot ? dotfiles : nodot) + '[^/]*?$1', true);
  10098. if (opts.dot !== true) {
  10099. glob$$1._replace(/\*\*\/(.)/g, '(?:**\\/|)$1');
  10100. }
  10101. // 'foo/**' or '{**,*}', but not 'foo**'
  10102. if (tok.path.dirname !== '' || /,\*\*|\*\*,/.test(glob$$1.orig)) {
  10103. glob$$1._replace('**', globstar(opts.dot), true);
  10104. }
  10105. }
  10106. // ends with /*
  10107. glob$$1._replace(/\/\*$/, '\\/' + oneStar(opts.dot), true);
  10108. // ends with *, no slashes
  10109. glob$$1._replace(/(?!\/)\*$/, star, true);
  10110. // has 'n*.' (partial wildcard w/ file extension)
  10111. glob$$1._replace(/([^\/]+)\*/, '$1' + oneStar(true), true);
  10112. // has '*'
  10113. glob$$1._replace('*', oneStar(opts.dot), true);
  10114. glob$$1._replace('?.', '?\\.', true);
  10115. glob$$1._replace('?:', '?:', true);
  10116. glob$$1._replace(/\?+/g, function(match) {
  10117. var len = match.length;
  10118. if (len === 1) {
  10119. return qmark;
  10120. }
  10121. return qmark + '{' + len + '}';
  10122. });
  10123. // escape '.abc' => '\\.abc'
  10124. glob$$1._replace(/\.([*\w]+)/g, '\\.$1');
  10125. // fix '[^\\\\/]'
  10126. glob$$1._replace(/\[\^[\\\/]+\]/g, qmark);
  10127. // '///' => '\/'
  10128. glob$$1._replace(/\/+/g, '\\/');
  10129. // '\\\\\\' => '\\'
  10130. glob$$1._replace(/\\{2,}/g, '\\');
  10131. }
  10132. // unescape previously escaped patterns
  10133. glob$$1.unescape(glob$$1.pattern);
  10134. glob$$1._replace('__UNESC_STAR__', '*');
  10135. // escape dots that follow qmarks
  10136. glob$$1._replace('?.', '?\\.');
  10137. // remove unnecessary slashes in character classes
  10138. glob$$1._replace('[^\\/]', qmark);
  10139. if (glob$$1.pattern.length > 1) {
  10140. if (/^[\[?*]/.test(glob$$1.pattern)) {
  10141. // only prepend the string if we don't want to match dotfiles
  10142. glob$$1.pattern = (opts.dot ? dotfiles : nodot) + glob$$1.pattern;
  10143. }
  10144. }
  10145. return glob$$1;
  10146. }
  10147. /**
  10148. * Collapse repeated character sequences.
  10149. *
  10150. * ```js
  10151. * collapse('a/../../../b', '../');
  10152. * //=> 'a/../b'
  10153. * ```
  10154. *
  10155. * @param {String} `str`
  10156. * @param {String} `ch` Character sequence to collapse
  10157. * @return {String}
  10158. */
  10159. function collapse(str, ch) {
  10160. var res = str.split(ch);
  10161. var isFirst = res[0] === '';
  10162. var isLast = res[res.length - 1] === '';
  10163. res = res.filter(Boolean);
  10164. if (isFirst) res.unshift('');
  10165. if (isLast) res.push('');
  10166. return res.join(ch);
  10167. }
  10168. /**
  10169. * Negate slashes in exclusion ranges, per glob spec:
  10170. *
  10171. * ```js
  10172. * negateSlash('[^foo]');
  10173. * //=> '[^\\/foo]'
  10174. * ```
  10175. *
  10176. * @param {String} `str` glob pattern
  10177. * @return {String}
  10178. */
  10179. function negateSlash(str) {
  10180. return str.replace(/\[\^([^\]]*?)\]/g, function(match, inner) {
  10181. if (inner.indexOf('/') === -1) {
  10182. inner = '\\/' + inner;
  10183. }
  10184. return '[^' + inner + ']';
  10185. });
  10186. }
  10187. /**
  10188. * Escape imbalanced braces/bracket. This is a very
  10189. * basic, naive implementation that only does enough
  10190. * to serve the purpose.
  10191. */
  10192. function balance(str, a, b) {
  10193. var aarr = str.split(a);
  10194. var alen = aarr.join('').length;
  10195. var blen = str.split(b).join('').length;
  10196. if (alen !== blen) {
  10197. str = aarr.join('\\' + a);
  10198. return str.split(b).join('\\' + b);
  10199. }
  10200. return str;
  10201. }
  10202. /**
  10203. * Special patterns to be converted to regex.
  10204. * Heuristics are used to simplify patterns
  10205. * and speed up processing.
  10206. */
  10207. /* eslint no-multi-spaces: 0 */
  10208. var qmark = '[^/]';
  10209. var star = qmark + '*?';
  10210. var nodot = '(?!\\.)(?=.)';
  10211. var dotfileGlob = '(?:\\/|^)\\.{1,2}($|\\/)';
  10212. var dotfiles = '(?!' + dotfileGlob + ')(?=.)';
  10213. var twoStarDot = '(?:(?!' + dotfileGlob + ').)*?';
  10214. /**
  10215. * Create a regex for `*`.
  10216. *
  10217. * If `dot` is true, or the pattern does not begin with
  10218. * a leading star, then return the simpler regex.
  10219. */
  10220. function oneStar(dotfile) {
  10221. return dotfile ? '(?!' + dotfileGlob + ')(?=.)' + star : (nodot + star);
  10222. }
  10223. function globstar(dotfile) {
  10224. if (dotfile) { return twoStarDot; }
  10225. return '(?:(?!(?:\\/|^)\\.).)*?';
  10226. }
  10227. /**
  10228. * The main function. Pass an array of filepaths,
  10229. * and a string or array of glob patterns
  10230. *
  10231. * @param {Array|String} `files`
  10232. * @param {Array|String} `patterns`
  10233. * @param {Object} `opts`
  10234. * @return {Array} Array of matches
  10235. */
  10236. function micromatch(files, patterns, opts) {
  10237. if (!files || !patterns) return [];
  10238. opts = opts || {};
  10239. if (typeof opts.cache === 'undefined') {
  10240. opts.cache = true;
  10241. }
  10242. if (!Array.isArray(patterns)) {
  10243. return match(files, patterns, opts);
  10244. }
  10245. var len = patterns.length, i = 0;
  10246. var omit = [], keep = [];
  10247. while (len--) {
  10248. var glob = patterns[i++];
  10249. if (typeof glob === 'string' && glob.charCodeAt(0) === 33 /* ! */) {
  10250. omit.push.apply(omit, match(files, glob.slice(1), opts));
  10251. } else {
  10252. keep.push.apply(keep, match(files, glob, opts));
  10253. }
  10254. }
  10255. return utils_1.diff(keep, omit);
  10256. }
  10257. /**
  10258. * Return an array of files that match the given glob pattern.
  10259. *
  10260. * This function is called by the main `micromatch` function If you only
  10261. * need to pass a single pattern you might get very minor speed improvements
  10262. * using this function.
  10263. *
  10264. * @param {Array} `files`
  10265. * @param {String} `pattern`
  10266. * @param {Object} `options`
  10267. * @return {Array}
  10268. */
  10269. function match(files, pattern, opts) {
  10270. if (utils_1.typeOf(files) !== 'string' && !Array.isArray(files)) {
  10271. throw new Error(msg('match', 'files', 'a string or array'));
  10272. }
  10273. files = utils_1.arrayify(files);
  10274. opts = opts || {};
  10275. var negate = opts.negate || false;
  10276. var orig = pattern;
  10277. if (typeof pattern === 'string') {
  10278. negate = pattern.charAt(0) === '!';
  10279. if (negate) {
  10280. pattern = pattern.slice(1);
  10281. }
  10282. // we need to remove the character regardless,
  10283. // so the above logic is still needed
  10284. if (opts.nonegate === true) {
  10285. negate = false;
  10286. }
  10287. }
  10288. var _isMatch = matcher(pattern, opts);
  10289. var len = files.length, i = 0;
  10290. var res = [];
  10291. while (i < len) {
  10292. var file = files[i++];
  10293. var fp = utils_1.unixify(file, opts);
  10294. if (!_isMatch(fp)) { continue; }
  10295. res.push(fp);
  10296. }
  10297. if (res.length === 0) {
  10298. if (opts.failglob === true) {
  10299. throw new Error('micromatch.match() found no matches for: "' + orig + '".');
  10300. }
  10301. if (opts.nonull || opts.nullglob) {
  10302. res.push(utils_1.unescapeGlob(orig));
  10303. }
  10304. }
  10305. // if `negate` was defined, diff negated files
  10306. if (negate) { res = utils_1.diff(files, res); }
  10307. // if `ignore` was defined, diff ignored filed
  10308. if (opts.ignore && opts.ignore.length) {
  10309. pattern = opts.ignore;
  10310. opts = utils_1.omit(opts, ['ignore']);
  10311. res = utils_1.diff(res, micromatch(res, pattern, opts));
  10312. }
  10313. if (opts.nodupes) {
  10314. return utils_1.unique(res);
  10315. }
  10316. return res;
  10317. }
  10318. /**
  10319. * Returns a function that takes a glob pattern or array of glob patterns
  10320. * to be used with `Array#filter()`. (Internally this function generates
  10321. * the matching function using the [matcher] method).
  10322. *
  10323. * ```js
  10324. * var fn = mm.filter('[a-c]');
  10325. * ['a', 'b', 'c', 'd', 'e'].filter(fn);
  10326. * //=> ['a', 'b', 'c']
  10327. * ```
  10328. * @param {String|Array} `patterns` Can be a glob or array of globs.
  10329. * @param {Options} `opts` Options to pass to the [matcher] method.
  10330. * @return {Function} Filter function to be passed to `Array#filter()`.
  10331. */
  10332. function filter$2(patterns, opts) {
  10333. if (!Array.isArray(patterns) && typeof patterns !== 'string') {
  10334. throw new TypeError(msg('filter', 'patterns', 'a string or array'));
  10335. }
  10336. patterns = utils_1.arrayify(patterns);
  10337. var len = patterns.length, i = 0;
  10338. var patternMatchers = Array(len);
  10339. while (i < len) {
  10340. patternMatchers[i] = matcher(patterns[i++], opts);
  10341. }
  10342. return function(fp) {
  10343. if (fp == null) return [];
  10344. var len = patternMatchers.length, i = 0;
  10345. var res = true;
  10346. fp = utils_1.unixify(fp, opts);
  10347. while (i < len) {
  10348. var fn = patternMatchers[i++];
  10349. if (!fn(fp)) {
  10350. res = false;
  10351. break;
  10352. }
  10353. }
  10354. return res;
  10355. };
  10356. }
  10357. /**
  10358. * Returns true if the filepath contains the given
  10359. * pattern. Can also return a function for matching.
  10360. *
  10361. * ```js
  10362. * isMatch('foo.md', '*.md', {});
  10363. * //=> true
  10364. *
  10365. * isMatch('*.md', {})('foo.md')
  10366. * //=> true
  10367. * ```
  10368. * @param {String} `fp`
  10369. * @param {String} `pattern`
  10370. * @param {Object} `opts`
  10371. * @return {Boolean}
  10372. */
  10373. function isMatch(fp, pattern, opts) {
  10374. if (typeof fp !== 'string') {
  10375. throw new TypeError(msg('isMatch', 'filepath', 'a string'));
  10376. }
  10377. fp = utils_1.unixify(fp, opts);
  10378. if (utils_1.typeOf(pattern) === 'object') {
  10379. return matcher(fp, pattern);
  10380. }
  10381. return matcher(pattern, opts)(fp);
  10382. }
  10383. /**
  10384. * Returns true if the filepath matches the
  10385. * given pattern.
  10386. */
  10387. function contains(fp, pattern, opts) {
  10388. if (typeof fp !== 'string') {
  10389. throw new TypeError(msg('contains', 'pattern', 'a string'));
  10390. }
  10391. opts = opts || {};
  10392. opts.contains = (pattern !== '');
  10393. fp = utils_1.unixify(fp, opts);
  10394. if (opts.contains && !utils_1.isGlob(pattern)) {
  10395. return fp.indexOf(pattern) !== -1;
  10396. }
  10397. return matcher(pattern, opts)(fp);
  10398. }
  10399. /**
  10400. * Returns true if a file path matches any of the
  10401. * given patterns.
  10402. *
  10403. * @param {String} `fp` The filepath to test.
  10404. * @param {String|Array} `patterns` Glob patterns to use.
  10405. * @param {Object} `opts` Options to pass to the `matcher()` function.
  10406. * @return {String}
  10407. */
  10408. function any(fp, patterns, opts) {
  10409. if (!Array.isArray(patterns) && typeof patterns !== 'string') {
  10410. throw new TypeError(msg('any', 'patterns', 'a string or array'));
  10411. }
  10412. patterns = utils_1.arrayify(patterns);
  10413. var len = patterns.length;
  10414. fp = utils_1.unixify(fp, opts);
  10415. while (len--) {
  10416. var isMatch = matcher(patterns[len], opts);
  10417. if (isMatch(fp)) {
  10418. return true;
  10419. }
  10420. }
  10421. return false;
  10422. }
  10423. /**
  10424. * Filter the keys of an object with the given `glob` pattern
  10425. * and `options`
  10426. *
  10427. * @param {Object} `object`
  10428. * @param {Pattern} `object`
  10429. * @return {Array}
  10430. */
  10431. function matchKeys(obj, glob, options) {
  10432. if (utils_1.typeOf(obj) !== 'object') {
  10433. throw new TypeError(msg('matchKeys', 'first argument', 'an object'));
  10434. }
  10435. var fn = matcher(glob, options);
  10436. var res = {};
  10437. for (var key in obj) {
  10438. if (obj.hasOwnProperty(key) && fn(key)) {
  10439. res[key] = obj[key];
  10440. }
  10441. }
  10442. return res;
  10443. }
  10444. /**
  10445. * Return a function for matching based on the
  10446. * given `pattern` and `options`.
  10447. *
  10448. * @param {String} `pattern`
  10449. * @param {Object} `options`
  10450. * @return {Function}
  10451. */
  10452. function matcher(pattern, opts) {
  10453. // pattern is a function
  10454. if (typeof pattern === 'function') {
  10455. return pattern;
  10456. }
  10457. // pattern is a regex
  10458. if (pattern instanceof RegExp) {
  10459. return function(fp) {
  10460. return pattern.test(fp);
  10461. };
  10462. }
  10463. if (typeof pattern !== 'string') {
  10464. throw new TypeError(msg('matcher', 'pattern', 'a string, regex, or function'));
  10465. }
  10466. // strings, all the way down...
  10467. pattern = utils_1.unixify(pattern, opts);
  10468. // pattern is a non-glob string
  10469. if (!utils_1.isGlob(pattern)) {
  10470. return utils_1.matchPath(pattern, opts);
  10471. }
  10472. // pattern is a glob string
  10473. var re = makeRe(pattern, opts);
  10474. // `matchBase` is defined
  10475. if (opts && opts.matchBase) {
  10476. return utils_1.hasFilename(re, opts);
  10477. }
  10478. // `matchBase` is not defined
  10479. return function(fp) {
  10480. fp = utils_1.unixify(fp, opts);
  10481. return re.test(fp);
  10482. };
  10483. }
  10484. /**
  10485. * Create and cache a regular expression for matching
  10486. * file paths.
  10487. *
  10488. * If the leading character in the `glob` is `!`, a negation
  10489. * regex is returned.
  10490. *
  10491. * @param {String} `glob`
  10492. * @param {Object} `options`
  10493. * @return {RegExp}
  10494. */
  10495. function toRegex$1(glob, options) {
  10496. // clone options to prevent mutating the original object
  10497. var opts = Object.create(options || {});
  10498. var flags = opts.flags || '';
  10499. if (opts.nocase && flags.indexOf('i') === -1) {
  10500. flags += 'i';
  10501. }
  10502. var parsed = expand_1(glob, opts);
  10503. // pass in tokens to avoid parsing more than once
  10504. opts.negated = opts.negated || parsed.negated;
  10505. opts.negate = opts.negated;
  10506. glob = wrapGlob(parsed.pattern, opts);
  10507. var re;
  10508. try {
  10509. re = new RegExp(glob, flags);
  10510. return re;
  10511. } catch (err) {
  10512. err.reason = 'micromatch invalid regex: (' + re + ')';
  10513. if (opts.strict) throw new SyntaxError(err);
  10514. }
  10515. // we're only here if a bad pattern was used and the user
  10516. // passed `options.silent`, so match nothing
  10517. return /$^/;
  10518. }
  10519. /**
  10520. * Create the regex to do the matching. If the leading
  10521. * character in the `glob` is `!` a negation regex is returned.
  10522. *
  10523. * @param {String} `glob`
  10524. * @param {Boolean} `negate`
  10525. */
  10526. function wrapGlob(glob, opts) {
  10527. var prefix = (opts && !opts.contains) ? '^' : '';
  10528. var after = (opts && !opts.contains) ? '$' : '';
  10529. glob = ('(?:' + glob + ')' + after);
  10530. if (opts && opts.negate) {
  10531. return prefix + ('(?!^' + glob + ').*$');
  10532. }
  10533. return prefix + glob;
  10534. }
  10535. /**
  10536. * Create and cache a regular expression for matching file paths.
  10537. * If the leading character in the `glob` is `!`, a negation
  10538. * regex is returned.
  10539. *
  10540. * @param {String} `glob`
  10541. * @param {Object} `options`
  10542. * @return {RegExp}
  10543. */
  10544. function makeRe(glob, opts) {
  10545. if (utils_1.typeOf(glob) !== 'string') {
  10546. throw new Error(msg('makeRe', 'glob', 'a string'));
  10547. }
  10548. return utils_1.cache(toRegex$1, glob, opts);
  10549. }
  10550. /**
  10551. * Make error messages consistent. Follows this format:
  10552. *
  10553. * ```js
  10554. * msg(methodName, argNumber, nativeType);
  10555. * // example:
  10556. * msg('matchKeys', 'first', 'an object');
  10557. * ```
  10558. *
  10559. * @param {String} `method`
  10560. * @param {String} `num`
  10561. * @param {String} `type`
  10562. * @return {String}
  10563. */
  10564. function msg(method, what, type) {
  10565. return 'micromatch.' + method + '(): ' + what + ' should be ' + type + '.';
  10566. }
  10567. /**
  10568. * Public methods
  10569. */
  10570. /* eslint no-multi-spaces: 0 */
  10571. micromatch.any = any;
  10572. micromatch.braces = micromatch.braceExpand = utils_1.braces;
  10573. micromatch.contains = contains;
  10574. micromatch.expand = expand_1;
  10575. micromatch.filter = filter$2;
  10576. micromatch.isMatch = isMatch;
  10577. micromatch.makeRe = makeRe;
  10578. micromatch.match = match;
  10579. micromatch.matcher = matcher;
  10580. micromatch.matchKeys = matchKeys;
  10581. /**
  10582. * Expose `micromatch`
  10583. */
  10584. var micromatch_1 = micromatch;
  10585. var slash = function (str) {
  10586. var isExtendedLengthPath = /^\\\\\?\\/.test(str);
  10587. var hasNonAscii = /[^\x00-\x80]+/.test(str);
  10588. if (isExtendedLengthPath || hasNonAscii) {
  10589. return str;
  10590. }
  10591. return str.replace(/\\/g, '/');
  10592. };
  10593. var jsTokens = createCommonjsModule(function (module, exports) {
  10594. // Copyright 2014, 2015, 2016, 2017 Simon Lydell
  10595. // License: MIT. (See LICENSE.)
  10596. Object.defineProperty(exports, "__esModule", {
  10597. value: true
  10598. });
  10599. // This regex comes from regex.coffee, and is inserted here by generate-index.js
  10600. // (run `npm run build`).
  10601. exports.default = /((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[gmiyu]{1,5}\b(?![\u0080-\uFFFF$\\]|\s*(?:[+\-*%&|^<>!=?({]|\/(?![\/*])))))|(0[xX][\da-fA-F]+|0[oO][0-7]+|0[bB][01]+|(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?)|((?!\d)(?:(?!\s)[$\w\u0080-\uFFFF]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+)|(--|\+\+|&&|\|\||=>|\.{3}|(?:[+\-\/%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2})=?|[?~.,:;[\](){}])|(\s+)|(^$|[\s\S])/g;
  10602. exports.matchToToken = function(match) {
  10603. var token = {type: "invalid", value: match[0]};
  10604. if (match[ 1]) token.type = "string", token.closed = !!(match[3] || match[4]);
  10605. else if (match[ 5]) token.type = "comment";
  10606. else if (match[ 6]) token.type = "comment", token.closed = !!match[7];
  10607. else if (match[ 8]) token.type = "regex";
  10608. else if (match[ 9]) token.type = "number";
  10609. else if (match[10]) token.type = "name";
  10610. else if (match[11]) token.type = "punctuator";
  10611. else if (match[12]) token.type = "whitespace";
  10612. return token
  10613. };
  10614. });
  10615. unwrapExports(jsTokens);
  10616. var jsTokens_1 = jsTokens.matchToToken;
  10617. var ast = createCommonjsModule(function (module) {
  10618. /*
  10619. Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
  10620. Redistribution and use in source and binary forms, with or without
  10621. modification, are permitted provided that the following conditions are met:
  10622. * Redistributions of source code must retain the above copyright
  10623. notice, this list of conditions and the following disclaimer.
  10624. * Redistributions in binary form must reproduce the above copyright
  10625. notice, this list of conditions and the following disclaimer in the
  10626. documentation and/or other materials provided with the distribution.
  10627. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
  10628. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  10629. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  10630. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  10631. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  10632. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  10633. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  10634. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  10635. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  10636. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  10637. */
  10638. (function () {
  10639. function isExpression(node) {
  10640. if (node == null) { return false; }
  10641. switch (node.type) {
  10642. case 'ArrayExpression':
  10643. case 'AssignmentExpression':
  10644. case 'BinaryExpression':
  10645. case 'CallExpression':
  10646. case 'ConditionalExpression':
  10647. case 'FunctionExpression':
  10648. case 'Identifier':
  10649. case 'Literal':
  10650. case 'LogicalExpression':
  10651. case 'MemberExpression':
  10652. case 'NewExpression':
  10653. case 'ObjectExpression':
  10654. case 'SequenceExpression':
  10655. case 'ThisExpression':
  10656. case 'UnaryExpression':
  10657. case 'UpdateExpression':
  10658. return true;
  10659. }
  10660. return false;
  10661. }
  10662. function isIterationStatement(node) {
  10663. if (node == null) { return false; }
  10664. switch (node.type) {
  10665. case 'DoWhileStatement':
  10666. case 'ForInStatement':
  10667. case 'ForStatement':
  10668. case 'WhileStatement':
  10669. return true;
  10670. }
  10671. return false;
  10672. }
  10673. function isStatement(node) {
  10674. if (node == null) { return false; }
  10675. switch (node.type) {
  10676. case 'BlockStatement':
  10677. case 'BreakStatement':
  10678. case 'ContinueStatement':
  10679. case 'DebuggerStatement':
  10680. case 'DoWhileStatement':
  10681. case 'EmptyStatement':
  10682. case 'ExpressionStatement':
  10683. case 'ForInStatement':
  10684. case 'ForStatement':
  10685. case 'IfStatement':
  10686. case 'LabeledStatement':
  10687. case 'ReturnStatement':
  10688. case 'SwitchStatement':
  10689. case 'ThrowStatement':
  10690. case 'TryStatement':
  10691. case 'VariableDeclaration':
  10692. case 'WhileStatement':
  10693. case 'WithStatement':
  10694. return true;
  10695. }
  10696. return false;
  10697. }
  10698. function isSourceElement(node) {
  10699. return isStatement(node) || node != null && node.type === 'FunctionDeclaration';
  10700. }
  10701. function trailingStatement(node) {
  10702. switch (node.type) {
  10703. case 'IfStatement':
  10704. if (node.alternate != null) {
  10705. return node.alternate;
  10706. }
  10707. return node.consequent;
  10708. case 'LabeledStatement':
  10709. case 'ForStatement':
  10710. case 'ForInStatement':
  10711. case 'WhileStatement':
  10712. case 'WithStatement':
  10713. return node.body;
  10714. }
  10715. return null;
  10716. }
  10717. function isProblematicIfStatement(node) {
  10718. var current;
  10719. if (node.type !== 'IfStatement') {
  10720. return false;
  10721. }
  10722. if (node.alternate == null) {
  10723. return false;
  10724. }
  10725. current = node.consequent;
  10726. do {
  10727. if (current.type === 'IfStatement') {
  10728. if (current.alternate == null) {
  10729. return true;
  10730. }
  10731. }
  10732. current = trailingStatement(current);
  10733. } while (current);
  10734. return false;
  10735. }
  10736. module.exports = {
  10737. isExpression: isExpression,
  10738. isStatement: isStatement,
  10739. isIterationStatement: isIterationStatement,
  10740. isSourceElement: isSourceElement,
  10741. isProblematicIfStatement: isProblematicIfStatement,
  10742. trailingStatement: trailingStatement
  10743. };
  10744. }());
  10745. /* vim: set sw=4 ts=4 et tw=80 : */
  10746. });
  10747. var ast_1 = ast.isExpression;
  10748. var ast_2 = ast.isStatement;
  10749. var ast_3 = ast.isIterationStatement;
  10750. var ast_4 = ast.isSourceElement;
  10751. var ast_5 = ast.isProblematicIfStatement;
  10752. var ast_6 = ast.trailingStatement;
  10753. var code = createCommonjsModule(function (module) {
  10754. /*
  10755. Copyright (C) 2013-2014 Yusuke Suzuki <utatane.tea@gmail.com>
  10756. Copyright (C) 2014 Ivan Nikulin <ifaaan@gmail.com>
  10757. Redistribution and use in source and binary forms, with or without
  10758. modification, are permitted provided that the following conditions are met:
  10759. * Redistributions of source code must retain the above copyright
  10760. notice, this list of conditions and the following disclaimer.
  10761. * Redistributions in binary form must reproduce the above copyright
  10762. notice, this list of conditions and the following disclaimer in the
  10763. documentation and/or other materials provided with the distribution.
  10764. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  10765. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  10766. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  10767. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  10768. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  10769. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  10770. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  10771. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  10772. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  10773. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  10774. */
  10775. (function () {
  10776. var ES6Regex, ES5Regex, NON_ASCII_WHITESPACES, IDENTIFIER_START, IDENTIFIER_PART, ch;
  10777. // See `tools/generate-identifier-regex.js`.
  10778. ES5Regex = {
  10779. // ECMAScript 5.1/Unicode v7.0.0 NonAsciiIdentifierStart:
  10780. NonAsciiIdentifierStart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B2\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/,
  10781. // ECMAScript 5.1/Unicode v7.0.0 NonAsciiIdentifierPart:
  10782. NonAsciiIdentifierPart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B2\u08E4-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D60-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA69D\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2D\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/
  10783. };
  10784. ES6Regex = {
  10785. // ECMAScript 6/Unicode v7.0.0 NonAsciiIdentifierStart:
  10786. NonAsciiIdentifierStart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B2\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDE00-\uDE11\uDE13-\uDE2B\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF5D-\uDF61]|\uD805[\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDE00-\uDE2F\uDE44\uDE80-\uDEAA]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF98]|\uD809[\uDC00-\uDC6E]|[\uD80C\uD840-\uD868\uD86A-\uD86C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D]|\uD87E[\uDC00-\uDE1D]/,
  10787. // ECMAScript 6/Unicode v7.0.0 NonAsciiIdentifierPart:
  10788. NonAsciiIdentifierPart: /[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B2\u08E4-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D60-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA69D\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2D\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDD0-\uDDDA\uDE00-\uDE11\uDE13-\uDE37\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF01-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF98]|\uD809[\uDC00-\uDC6E]|[\uD80C\uD840-\uD868\uD86A-\uD86C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/
  10789. };
  10790. function isDecimalDigit(ch) {
  10791. return 0x30 <= ch && ch <= 0x39; // 0..9
  10792. }
  10793. function isHexDigit(ch) {
  10794. return 0x30 <= ch && ch <= 0x39 || // 0..9
  10795. 0x61 <= ch && ch <= 0x66 || // a..f
  10796. 0x41 <= ch && ch <= 0x46; // A..F
  10797. }
  10798. function isOctalDigit(ch) {
  10799. return ch >= 0x30 && ch <= 0x37; // 0..7
  10800. }
  10801. // 7.2 White Space
  10802. NON_ASCII_WHITESPACES = [
  10803. 0x1680, 0x180E,
  10804. 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A,
  10805. 0x202F, 0x205F,
  10806. 0x3000,
  10807. 0xFEFF
  10808. ];
  10809. function isWhiteSpace(ch) {
  10810. return ch === 0x20 || ch === 0x09 || ch === 0x0B || ch === 0x0C || ch === 0xA0 ||
  10811. ch >= 0x1680 && NON_ASCII_WHITESPACES.indexOf(ch) >= 0;
  10812. }
  10813. // 7.3 Line Terminators
  10814. function isLineTerminator(ch) {
  10815. return ch === 0x0A || ch === 0x0D || ch === 0x2028 || ch === 0x2029;
  10816. }
  10817. // 7.6 Identifier Names and Identifiers
  10818. function fromCodePoint(cp) {
  10819. if (cp <= 0xFFFF) { return String.fromCharCode(cp); }
  10820. var cu1 = String.fromCharCode(Math.floor((cp - 0x10000) / 0x400) + 0xD800);
  10821. var cu2 = String.fromCharCode(((cp - 0x10000) % 0x400) + 0xDC00);
  10822. return cu1 + cu2;
  10823. }
  10824. IDENTIFIER_START = new Array(0x80);
  10825. for(ch = 0; ch < 0x80; ++ch) {
  10826. IDENTIFIER_START[ch] =
  10827. ch >= 0x61 && ch <= 0x7A || // a..z
  10828. ch >= 0x41 && ch <= 0x5A || // A..Z
  10829. ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore)
  10830. }
  10831. IDENTIFIER_PART = new Array(0x80);
  10832. for(ch = 0; ch < 0x80; ++ch) {
  10833. IDENTIFIER_PART[ch] =
  10834. ch >= 0x61 && ch <= 0x7A || // a..z
  10835. ch >= 0x41 && ch <= 0x5A || // A..Z
  10836. ch >= 0x30 && ch <= 0x39 || // 0..9
  10837. ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore)
  10838. }
  10839. function isIdentifierStartES5(ch) {
  10840. return ch < 0x80 ? IDENTIFIER_START[ch] : ES5Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch));
  10841. }
  10842. function isIdentifierPartES5(ch) {
  10843. return ch < 0x80 ? IDENTIFIER_PART[ch] : ES5Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch));
  10844. }
  10845. function isIdentifierStartES6(ch) {
  10846. return ch < 0x80 ? IDENTIFIER_START[ch] : ES6Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch));
  10847. }
  10848. function isIdentifierPartES6(ch) {
  10849. return ch < 0x80 ? IDENTIFIER_PART[ch] : ES6Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch));
  10850. }
  10851. module.exports = {
  10852. isDecimalDigit: isDecimalDigit,
  10853. isHexDigit: isHexDigit,
  10854. isOctalDigit: isOctalDigit,
  10855. isWhiteSpace: isWhiteSpace,
  10856. isLineTerminator: isLineTerminator,
  10857. isIdentifierStartES5: isIdentifierStartES5,
  10858. isIdentifierPartES5: isIdentifierPartES5,
  10859. isIdentifierStartES6: isIdentifierStartES6,
  10860. isIdentifierPartES6: isIdentifierPartES6
  10861. };
  10862. }());
  10863. /* vim: set sw=4 ts=4 et tw=80 : */
  10864. });
  10865. var code_1 = code.isDecimalDigit;
  10866. var code_2 = code.isHexDigit;
  10867. var code_3 = code.isOctalDigit;
  10868. var code_4 = code.isWhiteSpace;
  10869. var code_5 = code.isLineTerminator;
  10870. var code_6 = code.isIdentifierStartES5;
  10871. var code_7 = code.isIdentifierPartES5;
  10872. var code_8 = code.isIdentifierStartES6;
  10873. var code_9 = code.isIdentifierPartES6;
  10874. var keyword = createCommonjsModule(function (module) {
  10875. /*
  10876. Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
  10877. Redistribution and use in source and binary forms, with or without
  10878. modification, are permitted provided that the following conditions are met:
  10879. * Redistributions of source code must retain the above copyright
  10880. notice, this list of conditions and the following disclaimer.
  10881. * Redistributions in binary form must reproduce the above copyright
  10882. notice, this list of conditions and the following disclaimer in the
  10883. documentation and/or other materials provided with the distribution.
  10884. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  10885. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  10886. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  10887. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  10888. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  10889. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  10890. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  10891. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  10892. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  10893. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  10894. */
  10895. (function () {
  10896. var code$$1 = code;
  10897. function isStrictModeReservedWordES6(id) {
  10898. switch (id) {
  10899. case 'implements':
  10900. case 'interface':
  10901. case 'package':
  10902. case 'private':
  10903. case 'protected':
  10904. case 'public':
  10905. case 'static':
  10906. case 'let':
  10907. return true;
  10908. default:
  10909. return false;
  10910. }
  10911. }
  10912. function isKeywordES5(id, strict) {
  10913. // yield should not be treated as keyword under non-strict mode.
  10914. if (!strict && id === 'yield') {
  10915. return false;
  10916. }
  10917. return isKeywordES6(id, strict);
  10918. }
  10919. function isKeywordES6(id, strict) {
  10920. if (strict && isStrictModeReservedWordES6(id)) {
  10921. return true;
  10922. }
  10923. switch (id.length) {
  10924. case 2:
  10925. return (id === 'if') || (id === 'in') || (id === 'do');
  10926. case 3:
  10927. return (id === 'var') || (id === 'for') || (id === 'new') || (id === 'try');
  10928. case 4:
  10929. return (id === 'this') || (id === 'else') || (id === 'case') ||
  10930. (id === 'void') || (id === 'with') || (id === 'enum');
  10931. case 5:
  10932. return (id === 'while') || (id === 'break') || (id === 'catch') ||
  10933. (id === 'throw') || (id === 'const') || (id === 'yield') ||
  10934. (id === 'class') || (id === 'super');
  10935. case 6:
  10936. return (id === 'return') || (id === 'typeof') || (id === 'delete') ||
  10937. (id === 'switch') || (id === 'export') || (id === 'import');
  10938. case 7:
  10939. return (id === 'default') || (id === 'finally') || (id === 'extends');
  10940. case 8:
  10941. return (id === 'function') || (id === 'continue') || (id === 'debugger');
  10942. case 10:
  10943. return (id === 'instanceof');
  10944. default:
  10945. return false;
  10946. }
  10947. }
  10948. function isReservedWordES5(id, strict) {
  10949. return id === 'null' || id === 'true' || id === 'false' || isKeywordES5(id, strict);
  10950. }
  10951. function isReservedWordES6(id, strict) {
  10952. return id === 'null' || id === 'true' || id === 'false' || isKeywordES6(id, strict);
  10953. }
  10954. function isRestrictedWord(id) {
  10955. return id === 'eval' || id === 'arguments';
  10956. }
  10957. function isIdentifierNameES5(id) {
  10958. var i, iz, ch;
  10959. if (id.length === 0) { return false; }
  10960. ch = id.charCodeAt(0);
  10961. if (!code$$1.isIdentifierStartES5(ch)) {
  10962. return false;
  10963. }
  10964. for (i = 1, iz = id.length; i < iz; ++i) {
  10965. ch = id.charCodeAt(i);
  10966. if (!code$$1.isIdentifierPartES5(ch)) {
  10967. return false;
  10968. }
  10969. }
  10970. return true;
  10971. }
  10972. function decodeUtf16(lead, trail) {
  10973. return (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
  10974. }
  10975. function isIdentifierNameES6(id) {
  10976. var i, iz, ch, lowCh, check;
  10977. if (id.length === 0) { return false; }
  10978. check = code$$1.isIdentifierStartES6;
  10979. for (i = 0, iz = id.length; i < iz; ++i) {
  10980. ch = id.charCodeAt(i);
  10981. if (0xD800 <= ch && ch <= 0xDBFF) {
  10982. ++i;
  10983. if (i >= iz) { return false; }
  10984. lowCh = id.charCodeAt(i);
  10985. if (!(0xDC00 <= lowCh && lowCh <= 0xDFFF)) {
  10986. return false;
  10987. }
  10988. ch = decodeUtf16(ch, lowCh);
  10989. }
  10990. if (!check(ch)) {
  10991. return false;
  10992. }
  10993. check = code$$1.isIdentifierPartES6;
  10994. }
  10995. return true;
  10996. }
  10997. function isIdentifierES5(id, strict) {
  10998. return isIdentifierNameES5(id) && !isReservedWordES5(id, strict);
  10999. }
  11000. function isIdentifierES6(id, strict) {
  11001. return isIdentifierNameES6(id) && !isReservedWordES6(id, strict);
  11002. }
  11003. module.exports = {
  11004. isKeywordES5: isKeywordES5,
  11005. isKeywordES6: isKeywordES6,
  11006. isReservedWordES5: isReservedWordES5,
  11007. isReservedWordES6: isReservedWordES6,
  11008. isRestrictedWord: isRestrictedWord,
  11009. isIdentifierNameES5: isIdentifierNameES5,
  11010. isIdentifierNameES6: isIdentifierNameES6,
  11011. isIdentifierES5: isIdentifierES5,
  11012. isIdentifierES6: isIdentifierES6
  11013. };
  11014. }());
  11015. /* vim: set sw=4 ts=4 et tw=80 : */
  11016. });
  11017. var keyword_1 = keyword.isKeywordES5;
  11018. var keyword_2 = keyword.isKeywordES6;
  11019. var keyword_3 = keyword.isReservedWordES5;
  11020. var keyword_4 = keyword.isReservedWordES6;
  11021. var keyword_5 = keyword.isRestrictedWord;
  11022. var keyword_6 = keyword.isIdentifierNameES5;
  11023. var keyword_7 = keyword.isIdentifierNameES6;
  11024. var keyword_8 = keyword.isIdentifierES5;
  11025. var keyword_9 = keyword.isIdentifierES6;
  11026. var utils = createCommonjsModule(function (module, exports) {
  11027. /*
  11028. Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
  11029. Redistribution and use in source and binary forms, with or without
  11030. modification, are permitted provided that the following conditions are met:
  11031. * Redistributions of source code must retain the above copyright
  11032. notice, this list of conditions and the following disclaimer.
  11033. * Redistributions in binary form must reproduce the above copyright
  11034. notice, this list of conditions and the following disclaimer in the
  11035. documentation and/or other materials provided with the distribution.
  11036. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  11037. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  11038. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  11039. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  11040. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  11041. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  11042. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  11043. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  11044. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  11045. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  11046. */
  11047. (function () {
  11048. exports.ast = ast;
  11049. exports.code = code;
  11050. exports.keyword = keyword;
  11051. }());
  11052. /* vim: set sw=4 ts=4 et tw=80 : */
  11053. });
  11054. var utils_1$1 = utils.ast;
  11055. var utils_2 = utils.code;
  11056. var utils_3 = utils.keyword;
  11057. var lib$1 = createCommonjsModule(function (module, exports) {
  11058. Object.defineProperty(exports, "__esModule", {
  11059. value: true
  11060. });
  11061. exports.shouldHighlight = shouldHighlight;
  11062. exports.getChalk = getChalk;
  11063. exports.default = highlight;
  11064. function _jsTokens() {
  11065. var data = _interopRequireWildcard(jsTokens);
  11066. _jsTokens = function _jsTokens() {
  11067. return data;
  11068. };
  11069. return data;
  11070. }
  11071. function _esutils() {
  11072. var data = _interopRequireDefault(utils);
  11073. _esutils = function _esutils() {
  11074. return data;
  11075. };
  11076. return data;
  11077. }
  11078. function _chalk() {
  11079. var data = _interopRequireDefault(fake_chalk);
  11080. _chalk = function _chalk() {
  11081. return data;
  11082. };
  11083. return data;
  11084. }
  11085. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11086. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
  11087. function getDefs(chalk) {
  11088. return {
  11089. keyword: chalk.cyan,
  11090. capitalized: chalk.yellow,
  11091. jsx_tag: chalk.yellow,
  11092. punctuator: chalk.yellow,
  11093. number: chalk.magenta,
  11094. string: chalk.green,
  11095. regex: chalk.magenta,
  11096. comment: chalk.grey,
  11097. invalid: chalk.white.bgRed.bold
  11098. };
  11099. }
  11100. var NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
  11101. var JSX_TAG = /^[a-z][\w-]*$/i;
  11102. var BRACKET = /^[()[\]{}]$/;
  11103. function getTokenType(match) {
  11104. var _match$slice = match.slice(-2),
  11105. offset = _match$slice[0],
  11106. text = _match$slice[1];
  11107. var token = (0, _jsTokens().matchToToken)(match);
  11108. if (token.type === "name") {
  11109. if (_esutils().default.keyword.isReservedWordES6(token.value)) {
  11110. return "keyword";
  11111. }
  11112. if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.substr(offset - 2, 2) == "</")) {
  11113. return "jsx_tag";
  11114. }
  11115. if (token.value[0] !== token.value[0].toLowerCase()) {
  11116. return "capitalized";
  11117. }
  11118. }
  11119. if (token.type === "punctuator" && BRACKET.test(token.value)) {
  11120. return "bracket";
  11121. }
  11122. if (token.type === "invalid" && (token.value === "@" || token.value === "#")) {
  11123. return "punctuator";
  11124. }
  11125. return token.type;
  11126. }
  11127. function highlightTokens(defs, text) {
  11128. return text.replace(_jsTokens().default, function () {
  11129. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  11130. args[_key] = arguments[_key];
  11131. }
  11132. var type = getTokenType(args);
  11133. var colorize = defs[type];
  11134. if (colorize) {
  11135. return args[0].split(NEWLINE).map(function (str) {
  11136. return colorize(str);
  11137. }).join("\n");
  11138. } else {
  11139. return args[0];
  11140. }
  11141. });
  11142. }
  11143. function shouldHighlight(options) {
  11144. return _chalk().default.supportsColor || options.forceColor;
  11145. }
  11146. function getChalk(options) {
  11147. var chalk = _chalk().default;
  11148. if (options.forceColor) {
  11149. chalk = new (_chalk().default.constructor)({
  11150. enabled: true,
  11151. level: 1
  11152. });
  11153. }
  11154. return chalk;
  11155. }
  11156. function highlight(code, options) {
  11157. if (options === void 0) {
  11158. options = {};
  11159. }
  11160. if (shouldHighlight(options)) {
  11161. var chalk = getChalk(options);
  11162. var defs = getDefs(chalk);
  11163. return highlightTokens(defs, code);
  11164. } else {
  11165. return code;
  11166. }
  11167. }
  11168. });
  11169. unwrapExports(lib$1);
  11170. var lib_1$1 = lib$1.shouldHighlight;
  11171. var lib_2$1 = lib$1.getChalk;
  11172. var lib$2 = createCommonjsModule(function (module, exports) {
  11173. Object.defineProperty(exports, "__esModule", {
  11174. value: true
  11175. });
  11176. exports.codeFrameColumns = codeFrameColumns;
  11177. exports.default = _default;
  11178. function _highlight() {
  11179. var data = _interopRequireWildcard(lib$1);
  11180. _highlight = function _highlight() {
  11181. return data;
  11182. };
  11183. return data;
  11184. }
  11185. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
  11186. var deprecationWarningShown = false;
  11187. function getDefs(chalk) {
  11188. return {
  11189. gutter: chalk.grey,
  11190. marker: chalk.red.bold,
  11191. message: chalk.red.bold
  11192. };
  11193. }
  11194. var NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
  11195. function getMarkerLines(loc, source, opts) {
  11196. var startLoc = Object.assign({}, {
  11197. column: 0,
  11198. line: -1
  11199. }, loc.start);
  11200. var endLoc = Object.assign({}, startLoc, loc.end);
  11201. var _ref = opts || {},
  11202. _ref$linesAbove = _ref.linesAbove,
  11203. linesAbove = _ref$linesAbove === void 0 ? 2 : _ref$linesAbove,
  11204. _ref$linesBelow = _ref.linesBelow,
  11205. linesBelow = _ref$linesBelow === void 0 ? 3 : _ref$linesBelow;
  11206. var startLine = startLoc.line;
  11207. var startColumn = startLoc.column;
  11208. var endLine = endLoc.line;
  11209. var endColumn = endLoc.column;
  11210. var start = Math.max(startLine - (linesAbove + 1), 0);
  11211. var end = Math.min(source.length, endLine + linesBelow);
  11212. if (startLine === -1) {
  11213. start = 0;
  11214. }
  11215. if (endLine === -1) {
  11216. end = source.length;
  11217. }
  11218. var lineDiff = endLine - startLine;
  11219. var markerLines = {};
  11220. if (lineDiff) {
  11221. for (var i = 0; i <= lineDiff; i++) {
  11222. var lineNumber = i + startLine;
  11223. if (!startColumn) {
  11224. markerLines[lineNumber] = true;
  11225. } else if (i === 0) {
  11226. var sourceLength = source[lineNumber - 1].length;
  11227. markerLines[lineNumber] = [startColumn, sourceLength - startColumn];
  11228. } else if (i === lineDiff) {
  11229. markerLines[lineNumber] = [0, endColumn];
  11230. } else {
  11231. var _sourceLength = source[lineNumber - i].length;
  11232. markerLines[lineNumber] = [0, _sourceLength];
  11233. }
  11234. }
  11235. } else {
  11236. if (startColumn === endColumn) {
  11237. if (startColumn) {
  11238. markerLines[startLine] = [startColumn, 0];
  11239. } else {
  11240. markerLines[startLine] = true;
  11241. }
  11242. } else {
  11243. markerLines[startLine] = [startColumn, endColumn - startColumn];
  11244. }
  11245. }
  11246. return {
  11247. start: start,
  11248. end: end,
  11249. markerLines: markerLines
  11250. };
  11251. }
  11252. function codeFrameColumns(rawLines, loc, opts) {
  11253. if (opts === void 0) {
  11254. opts = {};
  11255. }
  11256. var highlighted = (opts.highlightCode || opts.forceColor) && (0, _highlight().shouldHighlight)(opts);
  11257. var chalk = (0, _highlight().getChalk)(opts);
  11258. var defs = getDefs(chalk);
  11259. var maybeHighlight = function maybeHighlight(chalkFn, string) {
  11260. return highlighted ? chalkFn(string) : string;
  11261. };
  11262. if (highlighted) rawLines = (0, _highlight().default)(rawLines, opts);
  11263. var lines = rawLines.split(NEWLINE);
  11264. var _getMarkerLines = getMarkerLines(loc, lines, opts),
  11265. start = _getMarkerLines.start,
  11266. end = _getMarkerLines.end,
  11267. markerLines = _getMarkerLines.markerLines;
  11268. var hasColumns = loc.start && typeof loc.start.column === "number";
  11269. var numberMaxWidth = String(end).length;
  11270. var frame = lines.slice(start, end).map(function (line, index) {
  11271. var number = start + 1 + index;
  11272. var paddedNumber = (" " + number).slice(-numberMaxWidth);
  11273. var gutter = " " + paddedNumber + " | ";
  11274. var hasMarker = markerLines[number];
  11275. var lastMarkerLine = !markerLines[number + 1];
  11276. if (hasMarker) {
  11277. var markerLine = "";
  11278. if (Array.isArray(hasMarker)) {
  11279. var markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " ");
  11280. var numberOfMarkers = hasMarker[1] || 1;
  11281. markerLine = ["\n ", maybeHighlight(defs.gutter, gutter.replace(/\d/g, " ")), markerSpacing, maybeHighlight(defs.marker, "^").repeat(numberOfMarkers)].join("");
  11282. if (lastMarkerLine && opts.message) {
  11283. markerLine += " " + maybeHighlight(defs.message, opts.message);
  11284. }
  11285. }
  11286. return [maybeHighlight(defs.marker, ">"), maybeHighlight(defs.gutter, gutter), line, markerLine].join("");
  11287. } else {
  11288. return " " + maybeHighlight(defs.gutter, gutter) + line;
  11289. }
  11290. }).join("\n");
  11291. if (opts.message && !hasColumns) {
  11292. frame = "" + " ".repeat(numberMaxWidth + 1) + opts.message + "\n" + frame;
  11293. }
  11294. if (highlighted) {
  11295. return chalk.reset(frame);
  11296. } else {
  11297. return frame;
  11298. }
  11299. }
  11300. function _default(rawLines, lineNumber, colNumber, opts) {
  11301. if (opts === void 0) {
  11302. opts = {};
  11303. }
  11304. if (!deprecationWarningShown) {
  11305. deprecationWarningShown = true;
  11306. var message = "Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`.";
  11307. if (process$3.emitWarning) {
  11308. process$3.emitWarning(message, "DeprecationWarning");
  11309. } else {
  11310. var deprecationError = new Error(message);
  11311. deprecationError.name = "DeprecationWarning";
  11312. console.warn(new Error(message));
  11313. }
  11314. }
  11315. colNumber = Math.max(colNumber, 0);
  11316. var location = {
  11317. start: {
  11318. column: colNumber,
  11319. line: lineNumber
  11320. }
  11321. };
  11322. return codeFrameColumns(rawLines, location, opts);
  11323. }
  11324. });
  11325. unwrapExports(lib$2);
  11326. var lib_1$2 = lib$2.codeFrameColumns;
  11327. var stackUtils = createCommonjsModule(function (module) {
  11328. module.exports = StackUtils;
  11329. function StackUtils(opts) {
  11330. if (!(this instanceof StackUtils)) {
  11331. throw new Error('StackUtils constructor must be called with new');
  11332. }
  11333. opts = opts || {};
  11334. this._cwd = (opts.cwd || process$3.cwd()).replace(/\\/g, '/');
  11335. this._internals = opts.internals || [];
  11336. this._wrapCallSite = opts.wrapCallSite || false;
  11337. }
  11338. module.exports.nodeInternals = nodeInternals;
  11339. function nodeInternals() {
  11340. if (!module.exports.natives) {
  11341. module.exports.natives = Object.keys(process$3.binding('natives'));
  11342. module.exports.natives.push('bootstrap_node', 'node');
  11343. }
  11344. return module.exports.natives.map(function (n) {
  11345. return new RegExp('\\(' + n + '\\.js:\\d+:\\d+\\)$');
  11346. }).concat([
  11347. /\s*at (bootstrap_)?node\.js:\d+:\d+?$/,
  11348. /\/\.node-spawn-wrap-\w+-\w+\/node:\d+:\d+\)?$/
  11349. ]);
  11350. }
  11351. StackUtils.prototype.clean = function (stack) {
  11352. if (!Array.isArray(stack)) {
  11353. stack = stack.split('\n');
  11354. }
  11355. if (!(/^\s*at /.test(stack[0])) &&
  11356. (/^\s*at /.test(stack[1]))) {
  11357. stack = stack.slice(1);
  11358. }
  11359. var outdent = false;
  11360. var lastNonAtLine = null;
  11361. var result = [];
  11362. stack.forEach(function (st) {
  11363. st = st.replace(/\\/g, '/');
  11364. var isInternal = this._internals.some(function (internal) {
  11365. return internal.test(st);
  11366. });
  11367. if (isInternal) {
  11368. return null;
  11369. }
  11370. var isAtLine = /^\s*at /.test(st);
  11371. if (outdent) {
  11372. st = st.replace(/\s+$/, '').replace(/^(\s+)at /, '$1');
  11373. } else {
  11374. st = st.trim();
  11375. if (isAtLine) {
  11376. st = st.substring(3);
  11377. }
  11378. }
  11379. st = st.replace(this._cwd + '/', '');
  11380. if (st) {
  11381. if (isAtLine) {
  11382. if (lastNonAtLine) {
  11383. result.push(lastNonAtLine);
  11384. lastNonAtLine = null;
  11385. }
  11386. result.push(st);
  11387. } else {
  11388. outdent = true;
  11389. lastNonAtLine = st;
  11390. }
  11391. }
  11392. }, this);
  11393. stack = result.join('\n').trim();
  11394. if (stack) {
  11395. return stack + '\n';
  11396. }
  11397. return '';
  11398. };
  11399. StackUtils.prototype.captureString = function (limit, fn) {
  11400. if (typeof limit === 'function') {
  11401. fn = limit;
  11402. limit = Infinity;
  11403. }
  11404. if (!fn) {
  11405. fn = this.captureString;
  11406. }
  11407. var limitBefore = Error.stackTraceLimit;
  11408. if (limit) {
  11409. Error.stackTraceLimit = limit;
  11410. }
  11411. var obj = {};
  11412. Error.captureStackTrace(obj, fn);
  11413. var stack = obj.stack;
  11414. Error.stackTraceLimit = limitBefore;
  11415. return this.clean(stack);
  11416. };
  11417. StackUtils.prototype.capture = function (limit, fn) {
  11418. if (typeof limit === 'function') {
  11419. fn = limit;
  11420. limit = Infinity;
  11421. }
  11422. if (!fn) {
  11423. fn = this.capture;
  11424. }
  11425. var prepBefore = Error.prepareStackTrace;
  11426. var limitBefore = Error.stackTraceLimit;
  11427. var wrapCallSite = this._wrapCallSite;
  11428. Error.prepareStackTrace = function (obj, site) {
  11429. if (wrapCallSite) {
  11430. return site.map(wrapCallSite);
  11431. }
  11432. return site;
  11433. };
  11434. if (limit) {
  11435. Error.stackTraceLimit = limit;
  11436. }
  11437. var obj = {};
  11438. Error.captureStackTrace(obj, fn);
  11439. var stack = obj.stack;
  11440. Error.prepareStackTrace = prepBefore;
  11441. Error.stackTraceLimit = limitBefore;
  11442. return stack;
  11443. };
  11444. StackUtils.prototype.at = function at(fn) {
  11445. if (!fn) {
  11446. fn = at;
  11447. }
  11448. var site = this.capture(1, fn)[0];
  11449. if (!site) {
  11450. return {};
  11451. }
  11452. var res = {
  11453. line: site.getLineNumber(),
  11454. column: site.getColumnNumber()
  11455. };
  11456. this._setFile(res, site.getFileName());
  11457. if (site.isConstructor()) {
  11458. res.constructor = true;
  11459. }
  11460. if (site.isEval()) {
  11461. res.evalOrigin = site.getEvalOrigin();
  11462. }
  11463. if (site.isNative()) {
  11464. res.native = true;
  11465. }
  11466. var typename = null;
  11467. try {
  11468. typename = site.getTypeName();
  11469. } catch (er) {}
  11470. if (typename &&
  11471. typename !== 'Object' &&
  11472. typename !== '[object Object]') {
  11473. res.type = typename;
  11474. }
  11475. var fname = site.getFunctionName();
  11476. if (fname) {
  11477. res.function = fname;
  11478. }
  11479. var meth = site.getMethodName();
  11480. if (meth && fname !== meth) {
  11481. res.method = meth;
  11482. }
  11483. return res;
  11484. };
  11485. StackUtils.prototype._setFile = function (result, filename) {
  11486. if (filename) {
  11487. filename = filename.replace(/\\/g, '/');
  11488. if ((filename.indexOf(this._cwd + '/') === 0)) {
  11489. filename = filename.substr(this._cwd.length + 1);
  11490. }
  11491. result.file = filename;
  11492. }
  11493. };
  11494. var re = new RegExp(
  11495. '^' +
  11496. // Sometimes we strip out the ' at' because it's noisy
  11497. '(?:\\s*at )?' +
  11498. // $1 = ctor if 'new'
  11499. '(?:(new) )?' +
  11500. // $2 = function name (can be literally anything)
  11501. // May contain method at the end as [as xyz]
  11502. '(?:(.*?) \\()?' +
  11503. // (eval at <anonymous> (file.js:1:1),
  11504. // $3 = eval origin
  11505. // $4:$5:$6 are eval file/line/col, but not normally reported
  11506. '(?:eval at ([^ ]+) \\((.+?):(\\d+):(\\d+)\\), )?' +
  11507. // file:line:col
  11508. // $7:$8:$9
  11509. // $10 = 'native' if native
  11510. '(?:(.+?):(\\d+):(\\d+)|(native))' +
  11511. // maybe close the paren, then end
  11512. // if $11 is ), then we only allow balanced parens in the filename
  11513. // any imbalance is placed on the fname. This is a heuristic, and
  11514. // bound to be incorrect in some edge cases. The bet is that
  11515. // having weird characters in method names is more common than
  11516. // having weird characters in filenames, which seems reasonable.
  11517. '(\\)?)$'
  11518. );
  11519. var methodRe = /^(.*?) \[as (.*?)\]$/;
  11520. StackUtils.prototype.parseLine = function parseLine(line) {
  11521. var match = line && line.match(re);
  11522. if (!match) {
  11523. return null;
  11524. }
  11525. var ctor = match[1] === 'new';
  11526. var fname = match[2];
  11527. var evalOrigin = match[3];
  11528. var evalFile = match[4];
  11529. var evalLine = Number(match[5]);
  11530. var evalCol = Number(match[6]);
  11531. var file = match[7];
  11532. var lnum = match[8];
  11533. var col = match[9];
  11534. var native = match[10] === 'native';
  11535. var closeParen = match[11] === ')';
  11536. var res = {};
  11537. if (lnum) {
  11538. res.line = Number(lnum);
  11539. }
  11540. if (col) {
  11541. res.column = Number(col);
  11542. }
  11543. if (closeParen && file) {
  11544. // make sure parens are balanced
  11545. // if we have a file like "asdf) [as foo] (xyz.js", then odds are
  11546. // that the fname should be += " (asdf) [as foo]" and the file
  11547. // should be just "xyz.js"
  11548. // walk backwards from the end to find the last unbalanced (
  11549. var closes = 0;
  11550. for (var i = file.length - 1; i > 0; i--) {
  11551. if (file.charAt(i) === ')') {
  11552. closes ++;
  11553. } else if (file.charAt(i) === '(' && file.charAt(i - 1) === ' ') {
  11554. closes --;
  11555. if (closes === -1 && file.charAt(i - 1) === ' ') {
  11556. var before = file.substr(0, i - 1);
  11557. var after = file.substr(i + 1);
  11558. file = after;
  11559. fname += ' (' + before;
  11560. break;
  11561. }
  11562. }
  11563. }
  11564. }
  11565. if (fname) {
  11566. var methodMatch = fname.match(methodRe);
  11567. if (methodMatch) {
  11568. fname = methodMatch[1];
  11569. var meth = methodMatch[2];
  11570. }
  11571. }
  11572. this._setFile(res, file);
  11573. if (ctor) {
  11574. res.constructor = true;
  11575. }
  11576. if (evalOrigin) {
  11577. res.evalOrigin = evalOrigin;
  11578. res.evalLine = evalLine;
  11579. res.evalColumn = evalCol;
  11580. res.evalFile = evalFile && evalFile.replace(/\\/g, '/');
  11581. }
  11582. if (native) {
  11583. res.native = true;
  11584. }
  11585. if (fname) {
  11586. res.function = fname;
  11587. }
  11588. if (meth && fname !== meth) {
  11589. res.method = meth;
  11590. }
  11591. return res;
  11592. };
  11593. var bound = new StackUtils();
  11594. Object.keys(StackUtils.prototype).forEach(function (key) {
  11595. StackUtils[key] = bound[key].bind(bound);
  11596. });
  11597. });
  11598. var stackUtils_1 = stackUtils.nodeInternals;
  11599. var stackUtils_2 = stackUtils.natives;
  11600. var build$5 = createCommonjsModule(function (module, exports) {
  11601. Object.defineProperty(exports, '__esModule', {
  11602. value: true
  11603. });
  11604. exports.separateMessageFromStack = exports.formatResultsErrors = exports.formatStackTrace = exports.getTopFrame = exports.getStackTraceLines = exports.formatExecError = undefined;
  11605. var _fs2 = _interopRequireDefault(crypto);
  11606. var _path2 = _interopRequireDefault(path$2);
  11607. var _chalk2 = _interopRequireDefault(fake_chalk);
  11608. var _micromatch2 = _interopRequireDefault(micromatch_1);
  11609. var _slash2 = _interopRequireDefault(slash);
  11610. var _stackUtils2 = _interopRequireDefault(stackUtils);
  11611. function _interopRequireDefault(obj) {
  11612. return obj && obj.__esModule ? obj : { default: obj };
  11613. }
  11614. // stack utils tries to create pretty stack by making paths relative.
  11615. var stackUtils$$1 = new _stackUtils2.default({
  11616. cwd: 'something which does not exist'
  11617. });
  11618. /**
  11619. * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
  11620. *
  11621. * This source code is licensed under the MIT license found in the
  11622. * LICENSE file in the root directory of this source tree.
  11623. *
  11624. *
  11625. */
  11626. var nodeInternals = [];
  11627. try {
  11628. nodeInternals = _stackUtils2.default.nodeInternals()
  11629. // this is to have the tests be the same in node 4 and node 6.
  11630. // TODO: Remove when we drop support for node 4
  11631. .concat(new RegExp('internal/process/next_tick.js'));
  11632. } catch (e) {
  11633. // `StackUtils.nodeInternals()` fails in browsers. We don't need to remove
  11634. // node internals in the browser though, so no issue.
  11635. }
  11636. var PATH_NODE_MODULES = _path2.default.sep + 'node_modules' + _path2.default.sep;
  11637. var PATH_JEST_PACKAGES = _path2.default.sep + 'jest' + _path2.default.sep + 'packages' + _path2.default.sep;
  11638. // filter for noisy stack trace lines
  11639. var JASMINE_IGNORE = /^\s+at(?:(?:.jasmine\-)|\s+jasmine\.buildExpectationResult)/;
  11640. var JEST_INTERNALS_IGNORE = /^\s+at.*?jest(-.*?)?(\/|\\)(build|node_modules|packages)(\/|\\)/;
  11641. var ANONYMOUS_FN_IGNORE = /^\s+at <anonymous>.*$/;
  11642. var ANONYMOUS_PROMISE_IGNORE = /^\s+at (new )?Promise \(<anonymous>\).*$/;
  11643. var ANONYMOUS_GENERATOR_IGNORE = /^\s+at Generator.next \(<anonymous>\).*$/;
  11644. var NATIVE_NEXT_IGNORE = /^\s+at next \(native\).*$/;
  11645. var TITLE_INDENT = ' ';
  11646. var MESSAGE_INDENT = ' ';
  11647. var STACK_INDENT = ' ';
  11648. var ANCESTRY_SEPARATOR = ' \u203A ';
  11649. var TITLE_BULLET = _chalk2.default.bold('\u25CF ');
  11650. var STACK_TRACE_COLOR = _chalk2.default.dim;
  11651. var STACK_PATH_REGEXP = /\s*at.*\(?(\:\d*\:\d*|native)\)?/;
  11652. var EXEC_ERROR_MESSAGE = 'Test suite failed to run';
  11653. var ERROR_TEXT = 'Error: ';
  11654. var indentAllLines = function indentAllLines(lines, indent) {
  11655. return lines.split('\n').map(function (line) {
  11656. return line ? indent + line : line;
  11657. }).join('\n');
  11658. };
  11659. var trim = function trim(string) {
  11660. return (string || '').trim();
  11661. };
  11662. // Some errors contain not only line numbers in stack traces
  11663. // e.g. SyntaxErrors can contain snippets of code, and we don't
  11664. // want to trim those, because they may have pointers to the column/character
  11665. // which will get misaligned.
  11666. var trimPaths = function trimPaths(string) {
  11667. return string.match(STACK_PATH_REGEXP) ? trim(string) : string;
  11668. };
  11669. var getRenderedCallsite = function getRenderedCallsite(fileContent, line, column) {
  11670. var renderedCallsite = (0, lib$2.codeFrameColumns)(fileContent, { start: { column: column, line: line } }, { highlightCode: true });
  11671. renderedCallsite = indentAllLines(renderedCallsite, MESSAGE_INDENT);
  11672. renderedCallsite = '\n' + renderedCallsite + '\n';
  11673. return renderedCallsite;
  11674. };
  11675. // ExecError is an error thrown outside of the test suite (not inside an `it` or
  11676. // `before/after each` hooks). If it's thrown, none of the tests in the file
  11677. // are executed.
  11678. var formatExecError = exports.formatExecError = function (error, config, options, testPath, reuseMessage) {
  11679. if (!error || typeof error === 'number') {
  11680. error = new Error('Expected an Error, but "' + String(error) + '" was thrown');
  11681. error.stack = '';
  11682. }
  11683. var message = void 0,
  11684. stack = void 0;
  11685. if (typeof error === 'string' || !error) {
  11686. error || (error = 'EMPTY ERROR');
  11687. message = '';
  11688. stack = error;
  11689. } else {
  11690. message = error.message;
  11691. stack = error.stack;
  11692. }
  11693. var separated = separateMessageFromStack(stack || '');
  11694. stack = separated.stack;
  11695. if (separated.message.indexOf(trim(message)) !== -1) {
  11696. // Often stack trace already contains the duplicate of the message
  11697. message = separated.message;
  11698. }
  11699. message = indentAllLines(message, MESSAGE_INDENT);
  11700. stack = stack && !options.noStackTrace ? '\n' + formatStackTrace(stack, config, options, testPath) : '';
  11701. if (message.match(/^\s*$/) && stack.match(/^\s*$/)) {
  11702. // this can happen if an empty object is thrown.
  11703. message = MESSAGE_INDENT + 'Error: No message was provided';
  11704. }
  11705. var messageToUse = void 0;
  11706. if (reuseMessage) {
  11707. messageToUse = ' ' + message.trim();
  11708. } else {
  11709. messageToUse = EXEC_ERROR_MESSAGE + '\n\n' + message;
  11710. }
  11711. return TITLE_INDENT + TITLE_BULLET + messageToUse + stack + '\n';
  11712. };
  11713. var removeInternalStackEntries = function removeInternalStackEntries(lines, options) {
  11714. var pathCounter = 0;
  11715. return lines.filter(function (line) {
  11716. if (ANONYMOUS_FN_IGNORE.test(line)) {
  11717. return false;
  11718. }
  11719. if (ANONYMOUS_PROMISE_IGNORE.test(line)) {
  11720. return false;
  11721. }
  11722. if (ANONYMOUS_GENERATOR_IGNORE.test(line)) {
  11723. return false;
  11724. }
  11725. if (NATIVE_NEXT_IGNORE.test(line)) {
  11726. return false;
  11727. }
  11728. if (nodeInternals.some(function (internal) {
  11729. return internal.test(line);
  11730. })) {
  11731. return false;
  11732. }
  11733. if (!STACK_PATH_REGEXP.test(line)) {
  11734. return true;
  11735. }
  11736. if (JASMINE_IGNORE.test(line)) {
  11737. return false;
  11738. }
  11739. if (++pathCounter === 1) {
  11740. return true; // always keep the first line even if it's from Jest
  11741. }
  11742. if (options.noStackTrace) {
  11743. return false;
  11744. }
  11745. if (JEST_INTERNALS_IGNORE.test(line)) {
  11746. return false;
  11747. }
  11748. return true;
  11749. });
  11750. };
  11751. var formatPaths = function formatPaths(config, relativeTestPath, line) {
  11752. // Extract the file path from the trace line.
  11753. var match = line.match(/(^\s*at .*?\(?)([^()]+)(:[0-9]+:[0-9]+\)?.*$)/);
  11754. if (!match) {
  11755. return line;
  11756. }
  11757. var filePath = (0, _slash2.default)(_path2.default.relative(config.rootDir, match[2]));
  11758. // highlight paths from the current test file
  11759. if (config.testMatch && config.testMatch.length && (0, _micromatch2.default)(filePath, config.testMatch) || filePath === relativeTestPath) {
  11760. filePath = _chalk2.default.reset.cyan(filePath);
  11761. }
  11762. return STACK_TRACE_COLOR(match[1]) + filePath + STACK_TRACE_COLOR(match[3]);
  11763. };
  11764. var getStackTraceLines = exports.getStackTraceLines = function (stack) {
  11765. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { noStackTrace: false };
  11766. return removeInternalStackEntries(stack.split(/\n/), options);
  11767. };
  11768. var getTopFrame = exports.getTopFrame = function (lines) {
  11769. var _iteratorNormalCompletion = true;
  11770. var _didIteratorError = false;
  11771. var _iteratorError = undefined;
  11772. try {
  11773. for (var _iterator = _getIterator(lines), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  11774. var line = _step.value;
  11775. if (line.includes(PATH_NODE_MODULES) || line.includes(PATH_JEST_PACKAGES)) {
  11776. continue;
  11777. }
  11778. var parsedFrame = stackUtils$$1.parseLine(line.trim());
  11779. if (parsedFrame && parsedFrame.file) {
  11780. return parsedFrame;
  11781. }
  11782. }
  11783. } catch (err) {
  11784. _didIteratorError = true;
  11785. _iteratorError = err;
  11786. } finally {
  11787. try {
  11788. if (!_iteratorNormalCompletion && _iterator.return) {
  11789. _iterator.return();
  11790. }
  11791. } finally {
  11792. if (_didIteratorError) {
  11793. throw _iteratorError;
  11794. }
  11795. }
  11796. }
  11797. return null;
  11798. };
  11799. var formatStackTrace = exports.formatStackTrace = function (stack, config, options, testPath) {
  11800. var lines = getStackTraceLines(stack, options);
  11801. var topFrame = getTopFrame(lines);
  11802. var renderedCallsite = '';
  11803. var relativeTestPath = testPath ? (0, _slash2.default)(_path2.default.relative(config.rootDir, testPath)) : null;
  11804. if (topFrame) {
  11805. var filename = topFrame.file;
  11806. if (_path2.default.isAbsolute(filename)) {
  11807. var fileContent = void 0;
  11808. try {
  11809. // TODO: check & read HasteFS instead of reading the filesystem:
  11810. // see: https://github.com/facebook/jest/pull/5405#discussion_r164281696
  11811. fileContent = _fs2.default.readFileSync(filename, 'utf8');
  11812. renderedCallsite = getRenderedCallsite(fileContent, topFrame.line, topFrame.column);
  11813. } catch (e) {
  11814. // the file does not exist or is inaccessible, we ignore
  11815. }
  11816. }
  11817. }
  11818. var stacktrace = lines.filter(Boolean).map(function (line) {
  11819. return STACK_INDENT + formatPaths(config, relativeTestPath, trimPaths(line));
  11820. }).join('\n');
  11821. return renderedCallsite + '\n' + stacktrace;
  11822. };
  11823. var formatResultsErrors = exports.formatResultsErrors = function (testResults, config, options, testPath) {
  11824. var failedResults = testResults.reduce(function (errors, result) {
  11825. result.failureMessages.forEach(function (content) {
  11826. return errors.push({ content: content, result: result });
  11827. });
  11828. return errors;
  11829. }, []);
  11830. if (!failedResults.length) {
  11831. return null;
  11832. }
  11833. return failedResults.map(function (_ref) {
  11834. var result = _ref.result,
  11835. content = _ref.content;
  11836. var _separateMessageFromS = separateMessageFromStack(content);
  11837. var message = _separateMessageFromS.message,
  11838. stack = _separateMessageFromS.stack;
  11839. stack = options.noStackTrace ? '' : STACK_TRACE_COLOR(formatStackTrace(stack, config, options, testPath)) + '\n';
  11840. message = indentAllLines(message, MESSAGE_INDENT);
  11841. var title = _chalk2.default.bold.red(TITLE_INDENT + TITLE_BULLET + result.ancestorTitles.join(ANCESTRY_SEPARATOR) + (result.ancestorTitles.length ? ANCESTRY_SEPARATOR : '') + result.title) + '\n';
  11842. return title + '\n' + message + '\n' + stack;
  11843. }).join('\n');
  11844. };
  11845. // jasmine and worker farm sometimes don't give us access to the actual
  11846. // Error object, so we have to regexp out the message from the stack string
  11847. // to format it.
  11848. var separateMessageFromStack = exports.separateMessageFromStack = function (content) {
  11849. if (!content) {
  11850. return { message: '', stack: '' };
  11851. }
  11852. var messageMatch = content.match(/(^(.|\n)*?(?=\n\s*at\s.*\:\d*\:\d*))/);
  11853. var message = messageMatch ? messageMatch[0] : 'Error';
  11854. var stack = messageMatch ? content.slice(message.length) : content;
  11855. // If the error is a plain error instead of a SyntaxError or TypeError
  11856. // we remove it from the message because it is generally not useful.
  11857. if (message.startsWith(ERROR_TEXT)) {
  11858. message = message.substr(ERROR_TEXT.length);
  11859. }
  11860. return { message: message, stack: stack };
  11861. };
  11862. });
  11863. unwrapExports(build$5);
  11864. var build_1$2 = build$5.separateMessageFromStack;
  11865. var build_2$2 = build$5.formatResultsErrors;
  11866. var build_3$2 = build$5.formatStackTrace;
  11867. var build_4$1 = build$5.getTopFrame;
  11868. var build_5$1 = build$5.getStackTraceLines;
  11869. var build_6$1 = build$5.formatExecError;
  11870. var createMatcher = function createMatcher(matcherName, fromPromise) {
  11871. return function (actual, expected) {
  11872. var value = expected;
  11873. var error = void 0;
  11874. if (fromPromise && isError(actual)) {
  11875. error = actual;
  11876. } else {
  11877. if (typeof actual !== 'function') {
  11878. if (!fromPromise) {
  11879. throw new Error(build_1(matcherName, 'function', build(value)) + '\n\n' + 'Received value must be a function, but instead ' + ('"' + build(actual) + '" was found'));
  11880. }
  11881. } else {
  11882. try {
  11883. actual();
  11884. } catch (e) {
  11885. error = e;
  11886. }
  11887. }
  11888. }
  11889. if (typeof expected === 'string') {
  11890. expected = new RegExp(build_2$1(expected));
  11891. }
  11892. if (typeof expected === 'function') {
  11893. return toThrowMatchingError(matcherName, error, expected);
  11894. } else if (expected && typeof expected.test === 'function') {
  11895. return toThrowMatchingStringOrRegexp(matcherName, error, expected, value);
  11896. } else if (expected && (typeof expected === 'undefined' ? 'undefined' : _typeof(expected)) === 'object') {
  11897. return toThrowMatchingErrorInstance(matcherName, error, expected);
  11898. } else if (expected === undefined) {
  11899. var pass = error !== undefined;
  11900. return {
  11901. message: pass ? function () {
  11902. return build_1('.not' + matcherName, 'function', '') + '\n\n' + 'Expected the function not to throw an error.\n' + printActualErrorMessage(error);
  11903. } : function () {
  11904. return build_1(matcherName, 'function', build(value)) + '\n\n' + 'Expected the function to throw an error.\n' + printActualErrorMessage(error);
  11905. },
  11906. pass: pass
  11907. };
  11908. } else {
  11909. throw new Error(build_1('.not' + matcherName, 'function', build(value)) + '\n\n' + 'Unexpected argument passed.\nExpected: ' + (build_8('string') + ', ' + build_8('Error (type)') + ' or ' + build_8('regexp') + '.\n') + build_7('Got', String(expected), build_8));
  11910. }
  11911. };
  11912. };
  11913. var matchers$1 = {
  11914. toThrow: createMatcher('.toThrow'),
  11915. toThrowError: createMatcher('.toThrowError')
  11916. };
  11917. var toThrowMatchingStringOrRegexp = function toThrowMatchingStringOrRegexp(name, error, pattern, value) {
  11918. if (error && !error.message && !error.name) {
  11919. error = new Error(error);
  11920. }
  11921. var pass = !!(error && error.message.match(pattern));
  11922. var message = pass ? function () {
  11923. return build_1('.not' + name, 'function', build(value)) + '\n\n' + 'Expected the function not to throw an error matching:\n' + (' ' + build_8(value) + '\n') + printActualErrorMessage(error);
  11924. } : function () {
  11925. return build_1(name, 'function', build(value)) + '\n\n' + 'Expected the function to throw an error matching:\n' + (' ' + build_8(value) + '\n') + printActualErrorMessage(error);
  11926. };
  11927. return { message: message, pass: pass };
  11928. };
  11929. var toThrowMatchingErrorInstance = function toThrowMatchingErrorInstance(name, error, expectedError) {
  11930. if (error && !error.message && !error.name) {
  11931. error = new Error(error);
  11932. }
  11933. var pass = equals(error, expectedError);
  11934. var message = pass ? function () {
  11935. return build_1('.not' + name, 'function', 'error') + '\n\n' + 'Expected the function not to throw an error matching:\n' + (' ' + build_8(expectedError) + '\n') + printActualErrorMessage(error);
  11936. } : function () {
  11937. return build_1(name, 'function', 'error') + '\n\n' + 'Expected the function to throw an error matching:\n' + (' ' + build_8(expectedError) + '\n') + printActualErrorMessage(error);
  11938. };
  11939. return { message: message, pass: pass };
  11940. };
  11941. var toThrowMatchingError = function toThrowMatchingError(name, error, ErrorClass) {
  11942. var pass = !!(error && error instanceof ErrorClass);
  11943. var message = pass ? function () {
  11944. return build_1('.not' + name, 'function', 'type') + '\n\n' + 'Expected the function not to throw an error of type:\n' + (' ' + build_8(ErrorClass.name) + '\n') + printActualErrorMessage(error);
  11945. } : function () {
  11946. return build_1(name, 'function', 'type') + '\n\n' + 'Expected the function to throw an error of type:\n' + (' ' + build_8(ErrorClass.name) + '\n') + printActualErrorMessage(error);
  11947. };
  11948. return { message: message, pass: pass };
  11949. };
  11950. var printActualErrorMessage = function printActualErrorMessage(error) {
  11951. if (error) {
  11952. var _separateMessageFromS = build_1$2(error.stack),
  11953. message = _separateMessageFromS.message,
  11954. stack = _separateMessageFromS.stack;
  11955. return 'Instead, it threw:\n' + build_14(' ' + build_10(message) + build_3$2(stack, {
  11956. rootDir: process$3.cwd(),
  11957. testMatch: []
  11958. }, {
  11959. noStackTrace: false
  11960. }));
  11961. }
  11962. return 'But it didn\'t throw anything.';
  11963. };
  11964. var createClass = createCommonjsModule(function (module, exports) {
  11965. exports.__esModule = true;
  11966. var _defineProperty2 = _interopRequireDefault(defineProperty$2);
  11967. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11968. exports.default = function () {
  11969. function defineProperties(target, props) {
  11970. for (var i = 0; i < props.length; i++) {
  11971. var descriptor = props[i];
  11972. descriptor.enumerable = descriptor.enumerable || false;
  11973. descriptor.configurable = true;
  11974. if ("value" in descriptor) descriptor.writable = true;
  11975. (0, _defineProperty2.default)(target, descriptor.key, descriptor);
  11976. }
  11977. }
  11978. return function (Constructor, protoProps, staticProps) {
  11979. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  11980. if (staticProps) defineProperties(Constructor, staticProps);
  11981. return Constructor;
  11982. };
  11983. }();
  11984. });
  11985. var _createClass = unwrapExports(createClass);
  11986. var AsymmetricMatcher = function AsymmetricMatcher() {
  11987. _classCallCheck(this, AsymmetricMatcher);
  11988. this.$$typeof = _Symbol$for('jest.asymmetricMatcher');
  11989. };
  11990. var Any = function (_AsymmetricMatcher) {
  11991. _inherits(Any, _AsymmetricMatcher);
  11992. function Any(sample) {
  11993. _classCallCheck(this, Any);
  11994. var _this = _possibleConstructorReturn(this, (Any.__proto__ || _Object$getPrototypeOf(Any)).call(this));
  11995. if (typeof sample === 'undefined') {
  11996. throw new TypeError('any() expects to be passed a constructor function. ' + 'Please pass one or use anything() to match any object.');
  11997. }
  11998. _this.sample = sample;
  11999. return _this;
  12000. }
  12001. _createClass(Any, [{
  12002. key: 'asymmetricMatch',
  12003. value: function asymmetricMatch(other) {
  12004. if (this.sample == String) {
  12005. return typeof other == 'string' || other instanceof String;
  12006. }
  12007. if (this.sample == Number) {
  12008. return typeof other == 'number' || other instanceof Number;
  12009. }
  12010. if (this.sample == Function) {
  12011. return typeof other == 'function' || other instanceof Function;
  12012. }
  12013. if (this.sample == Object) {
  12014. return (typeof other === 'undefined' ? 'undefined' : _typeof(other)) == 'object';
  12015. }
  12016. if (this.sample == Boolean) {
  12017. return typeof other == 'boolean';
  12018. }
  12019. return other instanceof this.sample;
  12020. }
  12021. }, {
  12022. key: 'toString',
  12023. value: function toString() {
  12024. return 'Any';
  12025. }
  12026. }, {
  12027. key: 'getExpectedType',
  12028. value: function getExpectedType() {
  12029. if (this.sample == String) {
  12030. return 'string';
  12031. }
  12032. if (this.sample == Number) {
  12033. return 'number';
  12034. }
  12035. if (this.sample == Function) {
  12036. return 'function';
  12037. }
  12038. if (this.sample == Object) {
  12039. return 'object';
  12040. }
  12041. if (this.sample == Boolean) {
  12042. return 'boolean';
  12043. }
  12044. return fnNameFor(this.sample);
  12045. }
  12046. }, {
  12047. key: 'toAsymmetricMatcher',
  12048. value: function toAsymmetricMatcher() {
  12049. return 'Any<' + fnNameFor(this.sample) + '>';
  12050. }
  12051. }]);
  12052. return Any;
  12053. }(AsymmetricMatcher);
  12054. var Anything = function (_AsymmetricMatcher2) {
  12055. _inherits(Anything, _AsymmetricMatcher2);
  12056. function Anything() {
  12057. _classCallCheck(this, Anything);
  12058. return _possibleConstructorReturn(this, (Anything.__proto__ || _Object$getPrototypeOf(Anything)).apply(this, arguments));
  12059. }
  12060. _createClass(Anything, [{
  12061. key: 'asymmetricMatch',
  12062. value: function asymmetricMatch(other) {
  12063. return !isUndefined(other) && other !== null;
  12064. }
  12065. }, {
  12066. key: 'toString',
  12067. value: function toString() {
  12068. return 'Anything';
  12069. }
  12070. // No getExpectedType method, because it matches either null or undefined.
  12071. }, {
  12072. key: 'toAsymmetricMatcher',
  12073. value: function toAsymmetricMatcher() {
  12074. return 'Anything';
  12075. }
  12076. }]);
  12077. return Anything;
  12078. }(AsymmetricMatcher);
  12079. var ArrayContaining = function (_AsymmetricMatcher3) {
  12080. _inherits(ArrayContaining, _AsymmetricMatcher3);
  12081. function ArrayContaining(sample) {
  12082. var inverse = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  12083. _classCallCheck(this, ArrayContaining);
  12084. var _this3 = _possibleConstructorReturn(this, (ArrayContaining.__proto__ || _Object$getPrototypeOf(ArrayContaining)).call(this));
  12085. _this3.sample = sample;
  12086. _this3.inverse = inverse;
  12087. return _this3;
  12088. }
  12089. _createClass(ArrayContaining, [{
  12090. key: 'asymmetricMatch',
  12091. value: function asymmetricMatch(other) {
  12092. if (!Array.isArray(this.sample)) {
  12093. throw new Error('You must provide an array to ' + this.toString() + ', not \'' + _typeof(this.sample) + "'.");
  12094. }
  12095. var result = this.sample.length === 0 || Array.isArray(other) && this.sample.every(function (item) {
  12096. return other.some(function (another) {
  12097. return equals(item, another);
  12098. });
  12099. });
  12100. return this.inverse ? !result : result;
  12101. }
  12102. }, {
  12103. key: 'toString',
  12104. value: function toString() {
  12105. return 'Array' + (this.inverse ? 'Not' : '') + 'Containing';
  12106. }
  12107. }, {
  12108. key: 'getExpectedType',
  12109. value: function getExpectedType() {
  12110. return 'array';
  12111. }
  12112. }]);
  12113. return ArrayContaining;
  12114. }(AsymmetricMatcher);
  12115. var ObjectContaining = function (_AsymmetricMatcher4) {
  12116. _inherits(ObjectContaining, _AsymmetricMatcher4);
  12117. function ObjectContaining(sample) {
  12118. var inverse = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  12119. _classCallCheck(this, ObjectContaining);
  12120. var _this4 = _possibleConstructorReturn(this, (ObjectContaining.__proto__ || _Object$getPrototypeOf(ObjectContaining)).call(this));
  12121. _this4.sample = sample;
  12122. _this4.inverse = inverse;
  12123. return _this4;
  12124. }
  12125. _createClass(ObjectContaining, [{
  12126. key: 'asymmetricMatch',
  12127. value: function asymmetricMatch(other) {
  12128. if (_typeof(this.sample) !== 'object') {
  12129. throw new Error('You must provide an object to ' + this.toString() + ', not \'' + _typeof(this.sample) + "'.");
  12130. }
  12131. if (this.inverse) {
  12132. for (var property in this.sample) {
  12133. if (hasProperty(other, property) && equals(this.sample[property], other[property]) && !emptyObject(this.sample[property]) && !emptyObject(other[property])) {
  12134. return false;
  12135. }
  12136. }
  12137. return true;
  12138. } else {
  12139. for (var _property in this.sample) {
  12140. if (!hasProperty(other, _property) || !equals(this.sample[_property], other[_property])) {
  12141. return false;
  12142. }
  12143. }
  12144. return true;
  12145. }
  12146. }
  12147. }, {
  12148. key: 'toString',
  12149. value: function toString() {
  12150. return 'Object' + (this.inverse ? 'Not' : '') + 'Containing';
  12151. }
  12152. }, {
  12153. key: 'getExpectedType',
  12154. value: function getExpectedType() {
  12155. return 'object';
  12156. }
  12157. }]);
  12158. return ObjectContaining;
  12159. }(AsymmetricMatcher);
  12160. var StringContaining = function (_AsymmetricMatcher5) {
  12161. _inherits(StringContaining, _AsymmetricMatcher5);
  12162. function StringContaining(sample) {
  12163. var inverse = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  12164. _classCallCheck(this, StringContaining);
  12165. var _this5 = _possibleConstructorReturn(this, (StringContaining.__proto__ || _Object$getPrototypeOf(StringContaining)).call(this));
  12166. if (!isA('String', sample)) {
  12167. throw new Error('Expected is not a string');
  12168. }
  12169. _this5.sample = sample;
  12170. _this5.inverse = inverse;
  12171. return _this5;
  12172. }
  12173. _createClass(StringContaining, [{
  12174. key: 'asymmetricMatch',
  12175. value: function asymmetricMatch(other) {
  12176. if (!isA('String', other)) {
  12177. throw new Error('Actual is not a string');
  12178. }
  12179. var result = other.includes(this.sample);
  12180. return this.inverse ? !result : result;
  12181. }
  12182. }, {
  12183. key: 'toString',
  12184. value: function toString() {
  12185. return 'String' + (this.inverse ? 'Not' : '') + 'Containing';
  12186. }
  12187. }, {
  12188. key: 'getExpectedType',
  12189. value: function getExpectedType() {
  12190. return 'string';
  12191. }
  12192. }]);
  12193. return StringContaining;
  12194. }(AsymmetricMatcher);
  12195. var StringMatching = function (_AsymmetricMatcher6) {
  12196. _inherits(StringMatching, _AsymmetricMatcher6);
  12197. function StringMatching(sample) {
  12198. var inverse = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  12199. _classCallCheck(this, StringMatching);
  12200. var _this6 = _possibleConstructorReturn(this, (StringMatching.__proto__ || _Object$getPrototypeOf(StringMatching)).call(this));
  12201. if (!isA('String', sample) && !isA('RegExp', sample)) {
  12202. throw new Error('Expected is not a String or a RegExp');
  12203. }
  12204. _this6.sample = new RegExp(sample);
  12205. _this6.inverse = inverse;
  12206. return _this6;
  12207. }
  12208. _createClass(StringMatching, [{
  12209. key: 'asymmetricMatch',
  12210. value: function asymmetricMatch(other) {
  12211. if (!isA('String', other)) {
  12212. throw new Error('Actual is not a string');
  12213. }
  12214. var result = this.sample.test(other);
  12215. return this.inverse ? !result : result;
  12216. }
  12217. }, {
  12218. key: 'toString',
  12219. value: function toString() {
  12220. return 'String' + (this.inverse ? 'Not' : '') + 'Matching';
  12221. }
  12222. }, {
  12223. key: 'getExpectedType',
  12224. value: function getExpectedType() {
  12225. return 'string';
  12226. }
  12227. }]);
  12228. return StringMatching;
  12229. }(AsymmetricMatcher);
  12230. var any$1 = function any(expectedObject) {
  12231. return new Any(expectedObject);
  12232. };
  12233. var anything = function anything() {
  12234. return new Anything();
  12235. };
  12236. var arrayContaining = function arrayContaining(sample) {
  12237. return new ArrayContaining(sample);
  12238. };
  12239. var arrayNotContaining = function arrayNotContaining(sample) {
  12240. return new ArrayContaining(sample, true);
  12241. };
  12242. var objectContaining = function objectContaining(sample) {
  12243. return new ObjectContaining(sample);
  12244. };
  12245. var objectNotContaining = function objectNotContaining(sample) {
  12246. return new ObjectContaining(sample, true);
  12247. };
  12248. var stringContaining = function stringContaining(expected) {
  12249. return new StringContaining(expected);
  12250. };
  12251. var stringNotContaining = function stringNotContaining(expected) {
  12252. return new StringContaining(expected, true);
  12253. };
  12254. var stringMatching = function stringMatching(expected) {
  12255. return new StringMatching(expected);
  12256. };
  12257. var stringNotMatching = function stringNotMatching(expected) {
  12258. return new StringMatching(expected, true);
  12259. };
  12260. var toConsumableArray = createCommonjsModule(function (module, exports) {
  12261. exports.__esModule = true;
  12262. var _from2 = _interopRequireDefault(from$1);
  12263. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  12264. exports.default = function (arr) {
  12265. if (Array.isArray(arr)) {
  12266. for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
  12267. arr2[i] = arr[i];
  12268. }
  12269. return arr2;
  12270. } else {
  12271. return (0, _from2.default)(arr);
  12272. }
  12273. };
  12274. });
  12275. var _toConsumableArray = unwrapExports(toConsumableArray);
  12276. // Global matchers object holds the list of available matchers and
  12277. // the state, that can hold matcher specific values that change over time.
  12278. var JEST_MATCHERS_OBJECT = _Symbol$for('$$jest-matchers-object');
  12279. // Notes a built-in/internal Jest matcher.
  12280. // Jest may override the stack trace of Errors thrown by internal matchers.
  12281. var INTERNAL_MATCHER_FLAG = _Symbol$for('$$jest-internal-matcher');
  12282. if (!global$1[JEST_MATCHERS_OBJECT]) {
  12283. _Object$defineProperty(global$1, JEST_MATCHERS_OBJECT, {
  12284. value: {
  12285. matchers: _Object$create(null),
  12286. state: {
  12287. assertionCalls: 0,
  12288. expectedAssertionsNumber: null,
  12289. isExpectingAssertions: false,
  12290. suppressedErrors: [] // errors that are not thrown immediately.
  12291. }
  12292. }
  12293. });
  12294. }
  12295. var getState = function getState() {
  12296. return global$1[JEST_MATCHERS_OBJECT].state;
  12297. };
  12298. var setState = function setState(state) {
  12299. _Object$assign(global$1[JEST_MATCHERS_OBJECT].state, state);
  12300. };
  12301. var getMatchers = function getMatchers() {
  12302. return global$1[JEST_MATCHERS_OBJECT].matchers;
  12303. };
  12304. var setMatchers = function setMatchers(matchers, isInternal, expect) {
  12305. _Object$keys(matchers).forEach(function (key) {
  12306. var matcher = matchers[key];
  12307. _Object$defineProperty(matcher, INTERNAL_MATCHER_FLAG, {
  12308. value: isInternal
  12309. });
  12310. if (!isInternal) {
  12311. // expect is defined
  12312. var CustomMatcher = function (_AsymmetricMatcher) {
  12313. _inherits(CustomMatcher, _AsymmetricMatcher);
  12314. function CustomMatcher() {
  12315. var inverse = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  12316. _classCallCheck(this, CustomMatcher);
  12317. var _this = _possibleConstructorReturn(this, (CustomMatcher.__proto__ || _Object$getPrototypeOf(CustomMatcher)).call(this));
  12318. _this.inverse = inverse;
  12319. for (var _len = arguments.length, sample = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  12320. sample[_key - 1] = arguments[_key];
  12321. }
  12322. _this.sample = sample;
  12323. return _this;
  12324. }
  12325. _createClass(CustomMatcher, [{
  12326. key: 'asymmetricMatch',
  12327. value: function asymmetricMatch(other) {
  12328. var _matcher = matcher.apply(undefined, [other].concat(_toConsumableArray(this.sample))),
  12329. pass = _matcher.pass;
  12330. return this.inverse ? !pass : pass;
  12331. }
  12332. }, {
  12333. key: 'toString',
  12334. value: function toString() {
  12335. return '' + (this.inverse ? 'not.' : '') + key;
  12336. }
  12337. }, {
  12338. key: 'getExpectedType',
  12339. value: function getExpectedType() {
  12340. return 'any';
  12341. }
  12342. }, {
  12343. key: 'toAsymmetricMatcher',
  12344. value: function toAsymmetricMatcher() {
  12345. return this.toString() + '<' + this.sample.join(', ') + '>';
  12346. }
  12347. }]);
  12348. return CustomMatcher;
  12349. }(AsymmetricMatcher);
  12350. expect[key] = function () {
  12351. for (var _len2 = arguments.length, sample = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  12352. sample[_key2] = arguments[_key2];
  12353. }
  12354. return new (Function.prototype.bind.apply(CustomMatcher, [null].concat([false], sample)))();
  12355. };
  12356. if (!expect.not) {
  12357. expect.not = {};
  12358. }
  12359. expect.not[key] = function () {
  12360. for (var _len3 = arguments.length, sample = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  12361. sample[_key3] = arguments[_key3];
  12362. }
  12363. return new (Function.prototype.bind.apply(CustomMatcher, [null].concat([true], sample)))();
  12364. };
  12365. }
  12366. });
  12367. _Object$assign(global$1[JEST_MATCHERS_OBJECT].matchers, matchers);
  12368. };
  12369. var resetAssertionsLocalState = function resetAssertionsLocalState() {
  12370. setState({
  12371. assertionCalls: 0,
  12372. expectedAssertionsNumber: null,
  12373. isExpectingAssertions: false
  12374. });
  12375. };
  12376. // Create and format all errors related to the mismatched number of `expect`
  12377. // calls and reset the matcher's state.
  12378. var extractExpectedAssertionsErrors = function extractExpectedAssertionsErrors() {
  12379. var result = [];
  12380. var _getState = getState(),
  12381. assertionCalls = _getState.assertionCalls,
  12382. expectedAssertionsNumber = _getState.expectedAssertionsNumber,
  12383. expectedAssertionsNumberError = _getState.expectedAssertionsNumberError,
  12384. isExpectingAssertions = _getState.isExpectingAssertions,
  12385. isExpectingAssertionsError = _getState.isExpectingAssertionsError;
  12386. resetAssertionsLocalState();
  12387. if (typeof expectedAssertionsNumber === 'number' && assertionCalls !== expectedAssertionsNumber) {
  12388. var numOfAssertionsExpected = build_15(build_2('assertion', expectedAssertionsNumber));
  12389. expectedAssertionsNumberError.message = build_1('.assertions', '', String(expectedAssertionsNumber), {
  12390. isDirectExpectCall: true
  12391. }) + '\n\n' + ('Expected ' + numOfAssertionsExpected + ' to be called but received ') + build_14(build_2('assertion call', assertionCalls || 0)) + '.';
  12392. result.push({
  12393. actual: assertionCalls,
  12394. error: expectedAssertionsNumberError,
  12395. expected: expectedAssertionsNumber
  12396. });
  12397. }
  12398. if (isExpectingAssertions && assertionCalls === 0) {
  12399. var expected = build_15('at least one assertion');
  12400. var received = build_14('received none');
  12401. isExpectingAssertionsError.message = build_1('.hasAssertions', '', '', {
  12402. isDirectExpectCall: true
  12403. }) + '\n\n' + ('Expected ' + expected + ' to be called but ' + received + '.');
  12404. result.push({
  12405. actual: 'none',
  12406. error: isExpectingAssertionsError,
  12407. expected: 'at least one'
  12408. });
  12409. }
  12410. return result;
  12411. };
  12412. var JestAssertionError = function (_Error) {
  12413. _inherits(JestAssertionError, _Error);
  12414. function JestAssertionError() {
  12415. _classCallCheck(this, JestAssertionError);
  12416. return _possibleConstructorReturn(this, (JestAssertionError.__proto__ || _Object$getPrototypeOf(JestAssertionError)).apply(this, arguments));
  12417. }
  12418. return JestAssertionError;
  12419. }(Error);
  12420. var isPromise = function isPromise(obj) {
  12421. return !!obj && ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
  12422. };
  12423. var createToThrowErrorMatchingSnapshotMatcher = function createToThrowErrorMatchingSnapshotMatcher(matcher) {
  12424. return function (received, testNameOrInlineSnapshot) {
  12425. return matcher.apply(this, [received, testNameOrInlineSnapshot, true]);
  12426. };
  12427. };
  12428. var getPromiseMatcher = function getPromiseMatcher(name, matcher) {
  12429. if (name === 'toThrow' || name === 'toThrowError') {
  12430. return createMatcher('.' + name, true);
  12431. } else if (name === 'toThrowErrorMatchingSnapshot' || name === 'toThrowErrorMatchingInlineSnapshot') {
  12432. return createToThrowErrorMatchingSnapshotMatcher(matcher);
  12433. }
  12434. return null;
  12435. };
  12436. var expect = function expect(actual) {
  12437. if ((arguments.length <= 1 ? 0 : arguments.length - 1) !== 0) {
  12438. throw new Error('Expect takes at most one argument.');
  12439. }
  12440. var allMatchers = getMatchers();
  12441. var expectation = {
  12442. not: {},
  12443. rejects: { not: {} },
  12444. resolves: { not: {} }
  12445. };
  12446. var err = new JestAssertionError();
  12447. _Object$keys(allMatchers).forEach(function (name) {
  12448. var matcher = allMatchers[name];
  12449. var promiseMatcher = getPromiseMatcher(name, matcher) || matcher;
  12450. expectation[name] = makeThrowingMatcher(matcher, false, actual);
  12451. expectation.not[name] = makeThrowingMatcher(matcher, true, actual);
  12452. expectation.resolves[name] = makeResolveMatcher(name, promiseMatcher, false, actual, err);
  12453. expectation.resolves.not[name] = makeResolveMatcher(name, promiseMatcher, true, actual, err);
  12454. expectation.rejects[name] = makeRejectMatcher(name, promiseMatcher, false, actual, err);
  12455. expectation.rejects.not[name] = makeRejectMatcher(name, promiseMatcher, true, actual, err);
  12456. });
  12457. return expectation;
  12458. };
  12459. var getMessage = function getMessage(message) {
  12460. return message && message() || build_14('No message was specified for this matcher.');
  12461. };
  12462. var makeResolveMatcher = function makeResolveMatcher(matcherName, matcher, isNot, actual, outerErr) {
  12463. return function () {
  12464. for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
  12465. args[_key] = arguments[_key];
  12466. }
  12467. var matcherStatement = '.resolves.' + (isNot ? 'not.' : '') + matcherName;
  12468. if (!isPromise(actual)) {
  12469. throw new JestAssertionError(build_1(matcherStatement, 'received', '') + '\n\n' + (build_14('received') + ' value must be a Promise.\n') + build_7('Received', actual, build_9));
  12470. }
  12471. var innerErr = new JestAssertionError();
  12472. return actual.then(function (result) {
  12473. return makeThrowingMatcher(matcher, isNot, result, innerErr).apply(null, args);
  12474. }, function (reason) {
  12475. outerErr.message = build_1(matcherStatement, 'received', '') + '\n\n' + ('Expected ' + build_14('received') + ' Promise to resolve, ') + 'instead it rejected to value\n' + (' ' + build_9(reason));
  12476. return _Promise.reject(outerErr);
  12477. });
  12478. };
  12479. };
  12480. var makeRejectMatcher = function makeRejectMatcher(matcherName, matcher, isNot, actual, outerErr) {
  12481. return function () {
  12482. for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  12483. args[_key2] = arguments[_key2];
  12484. }
  12485. var matcherStatement = '.rejects.' + (isNot ? 'not.' : '') + matcherName;
  12486. if (!isPromise(actual)) {
  12487. throw new JestAssertionError(build_1(matcherStatement, 'received', '') + '\n\n' + (build_14('received') + ' value must be a Promise.\n') + build_7('Received', actual, build_9));
  12488. }
  12489. var innerErr = new JestAssertionError();
  12490. return actual.then(function (result) {
  12491. outerErr.message = build_1(matcherStatement, 'received', '') + '\n\n' + ('Expected ' + build_14('received') + ' Promise to reject, ') + 'instead it resolved to value\n' + (' ' + build_9(result));
  12492. return _Promise.reject(outerErr);
  12493. }, function (reason) {
  12494. return makeThrowingMatcher(matcher, isNot, reason, innerErr).apply(null, args);
  12495. });
  12496. };
  12497. };
  12498. var makeThrowingMatcher = function makeThrowingMatcher(matcher, isNot, actual, err) {
  12499. return function throwingMatcher() {
  12500. var throws = true;
  12501. var utils = _Object$assign({}, matcherUtils, {
  12502. iterableEquality: iterableEquality,
  12503. subsetEquality: subsetEquality
  12504. });
  12505. var matcherContext = _Object$assign(
  12506. // When throws is disabled, the matcher will not throw errors during test
  12507. // execution but instead add them to the global matcher state. If a
  12508. // matcher throws, test execution is normally stopped immediately. The
  12509. // snapshot matcher uses it because we want to log all snapshot
  12510. // failures in a test.
  12511. { dontThrow: function dontThrow() {
  12512. return throws = false;
  12513. } }, getState(), {
  12514. equals: equals,
  12515. error: err,
  12516. isNot: isNot,
  12517. utils: utils
  12518. });
  12519. var processResult = function processResult(result) {
  12520. _validateResult(result);
  12521. getState().assertionCalls++;
  12522. if (result.pass && isNot || !result.pass && !isNot) {
  12523. // XOR
  12524. var message = getMessage(result.message);
  12525. var error = void 0;
  12526. if (err) {
  12527. error = err;
  12528. error.message = message;
  12529. } else {
  12530. error = new JestAssertionError(message);
  12531. // Try to remove this function from the stack trace frame.
  12532. // Guard for some environments (browsers) that do not support this feature.
  12533. if (Error.captureStackTrace) {
  12534. Error.captureStackTrace(error, throwingMatcher);
  12535. }
  12536. }
  12537. // Passing the result of the matcher with the error so that a custom
  12538. // reporter could access the actual and expected objects of the result
  12539. // for example in order to display a custom visual diff
  12540. error.matcherResult = result;
  12541. if (throws) {
  12542. throw error;
  12543. } else {
  12544. getState().suppressedErrors.push(error);
  12545. }
  12546. }
  12547. };
  12548. var handlError = function handlError(error) {
  12549. if (matcher[INTERNAL_MATCHER_FLAG] === true && !(error instanceof JestAssertionError) && error.name !== 'PrettyFormatPluginError' &&
  12550. // Guard for some environments (browsers) that do not support this feature.
  12551. Error.captureStackTrace) {
  12552. // Try to remove this and deeper functions from the stack trace frame.
  12553. Error.captureStackTrace(error, throwingMatcher);
  12554. }
  12555. throw error;
  12556. };
  12557. var potentialResult = void 0;
  12558. try {
  12559. for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  12560. args[_key3] = arguments[_key3];
  12561. }
  12562. potentialResult = matcher.apply(matcherContext, [actual].concat(args));
  12563. if (isPromise(potentialResult)) {
  12564. var asyncResult = potentialResult;
  12565. return asyncResult.then(function (aResult) {
  12566. return processResult(aResult);
  12567. }).catch(function (error) {
  12568. return handlError(error);
  12569. });
  12570. } else {
  12571. var syncResult = potentialResult;
  12572. return processResult(syncResult);
  12573. }
  12574. } catch (error) {
  12575. return handlError(error);
  12576. }
  12577. };
  12578. };
  12579. expect.extend = function (matchers$$1) {
  12580. return setMatchers(matchers$$1, false, expect);
  12581. };
  12582. expect.anything = anything;
  12583. expect.any = any$1;
  12584. expect.not = {
  12585. arrayContaining: arrayNotContaining,
  12586. objectContaining: objectNotContaining,
  12587. stringContaining: stringNotContaining,
  12588. stringMatching: stringNotMatching
  12589. };
  12590. expect.objectContaining = objectContaining;
  12591. expect.arrayContaining = arrayContaining;
  12592. expect.stringContaining = stringContaining;
  12593. expect.stringMatching = stringMatching;
  12594. var _validateResult = function _validateResult(result) {
  12595. if ((typeof result === 'undefined' ? 'undefined' : _typeof(result)) !== 'object' || typeof result.pass !== 'boolean' || result.message && typeof result.message !== 'string' && typeof result.message !== 'function') {
  12596. throw new Error('Unexpected return from a matcher function.\n' + 'Matcher functions should ' + 'return an object in the following format:\n' + ' {message?: string | function, pass: boolean}\n' + ('\'' + build_11(result) + '\' was returned'));
  12597. }
  12598. };
  12599. function assertions(expected) {
  12600. var error = new Error();
  12601. if (Error.captureStackTrace) {
  12602. Error.captureStackTrace(error, assertions);
  12603. }
  12604. getState().expectedAssertionsNumber = expected;
  12605. getState().expectedAssertionsNumberError = error;
  12606. }
  12607. function hasAssertions() {
  12608. var error = new Error();
  12609. if (Error.captureStackTrace) {
  12610. Error.captureStackTrace(error, hasAssertions);
  12611. }
  12612. build_6(arguments.length <= 0 ? undefined : arguments[0], '.hasAssertions');
  12613. getState().isExpectingAssertions = true;
  12614. getState().isExpectingAssertionsError = error;
  12615. }
  12616. // add default jest matchers
  12617. setMatchers(matchers, true, expect);
  12618. setMatchers(spyMatchers, true, expect);
  12619. setMatchers(matchers$1, true, expect);
  12620. expect.addSnapshotSerializer = function () {
  12621. return void 0;
  12622. };
  12623. expect.assertions = assertions;
  12624. expect.hasAssertions = hasAssertions;
  12625. expect.getState = getState;
  12626. expect.setState = setState;
  12627. expect.extractExpectedAssertionsErrors = extractExpectedAssertionsErrors;
  12628. module.exports = expect;
  12629. })));