index.js 1.3 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437
  1. 'use strict';
  2. function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
  3. var fs = _interopDefault(require('fs'));
  4. var os = _interopDefault(require('os'));
  5. var path = _interopDefault(require('path'));
  6. var assert = _interopDefault(require('assert'));
  7. var util = _interopDefault(require('util'));
  8. var events = _interopDefault(require('events'));
  9. var thirdParty = require('./third-party');
  10. var thirdParty__default = thirdParty['default'];
  11. var name = "prettier";
  12. var version$1 = "1.16.3";
  13. var description = "Prettier is an opinionated code formatter";
  14. var bin = {
  15. "prettier": "./bin/prettier.js"
  16. };
  17. var repository = "prettier/prettier";
  18. var homepage = "https://prettier.io";
  19. var author = "James Long";
  20. var license = "MIT";
  21. var main = "./index.js";
  22. var engines = {
  23. "node": ">=6"
  24. };
  25. var dependencies = {
  26. "@angular/compiler": "6.1.10",
  27. "@babel/code-frame": "7.0.0-beta.46",
  28. "@babel/parser": "7.2.0",
  29. "@glimmer/syntax": "0.30.3",
  30. "@iarna/toml": "2.0.0",
  31. "angular-estree-parser": "1.1.5",
  32. "angular-html-parser": "1.2.0",
  33. "camelcase": "4.1.0",
  34. "chalk": "2.1.0",
  35. "cjk-regex": "2.0.0",
  36. "cosmiconfig": "5.0.7",
  37. "dashify": "0.2.2",
  38. "dedent": "0.7.0",
  39. "diff": "3.2.0",
  40. "editorconfig": "0.15.2",
  41. "editorconfig-to-prettier": "0.1.1",
  42. "escape-string-regexp": "1.0.5",
  43. "esutils": "2.0.2",
  44. "find-parent-dir": "0.3.0",
  45. "find-project-root": "1.1.1",
  46. "flow-parser": "0.84.0",
  47. "get-stream": "3.0.0",
  48. "globby": "6.1.0",
  49. "graphql": "0.13.2",
  50. "html-element-attributes": "2.0.0",
  51. "html-styles": "1.0.0",
  52. "html-tag-names": "1.1.2",
  53. "ignore": "3.3.7",
  54. "is-ci": "2.0.0",
  55. "jest-docblock": "23.2.0",
  56. "json-stable-stringify": "1.0.1",
  57. "leven": "2.1.0",
  58. "lines-and-columns": "1.1.6",
  59. "linguist-languages": "6.2.1-dev.20180706",
  60. "lodash.uniqby": "4.7.0",
  61. "mem": "1.1.0",
  62. "minimatch": "3.0.4",
  63. "minimist": "1.2.0",
  64. "n-readlines": "1.0.0",
  65. "normalize-path": "3.0.0",
  66. "parse-srcset": "ikatyang/parse-srcset#54eb9c1cb21db5c62b4d0e275d7249516df6f0ee",
  67. "postcss-less": "1.1.5",
  68. "postcss-media-query-parser": "0.2.3",
  69. "postcss-scss": "2.0.0",
  70. "postcss-selector-parser": "2.2.3",
  71. "postcss-values-parser": "1.5.0",
  72. "regexp-util": "1.2.2",
  73. "remark-math": "1.0.4",
  74. "remark-parse": "5.0.0",
  75. "resolve": "1.5.0",
  76. "semver": "5.4.1",
  77. "string-width": "3.0.0",
  78. "typescript": "3.2.2",
  79. "typescript-estree": "18.0.0",
  80. "unicode-regex": "2.0.0",
  81. "unified": "6.1.6",
  82. "vnopts": "1.0.2",
  83. "yaml": "1.0.2",
  84. "yaml-unist-parser": "1.0.0"
  85. };
  86. var devDependencies = {
  87. "@babel/cli": "7.2.0",
  88. "@babel/core": "7.2.0",
  89. "@babel/preset-env": "7.2.0",
  90. "babel-loader": "8.0.4",
  91. "benchmark": "2.1.4",
  92. "builtin-modules": "2.0.0",
  93. "codecov": "codecov/codecov-node#e427d900309adb50746a39a50aa7d80071a5ddd0",
  94. "cross-env": "5.0.5",
  95. "eslint": "4.18.2",
  96. "eslint-config-prettier": "2.9.0",
  97. "eslint-friendly-formatter": "3.0.0",
  98. "eslint-plugin-import": "2.9.0",
  99. "eslint-plugin-prettier": "2.6.0",
  100. "eslint-plugin-react": "7.7.0",
  101. "execa": "0.10.0",
  102. "jest": "23.3.0",
  103. "jest-junit": "5.0.0",
  104. "jest-snapshot-serializer-ansi": "1.0.0",
  105. "jest-snapshot-serializer-raw": "1.1.0",
  106. "jest-watch-typeahead": "0.1.0",
  107. "mkdirp": "0.5.1",
  108. "prettier": "1.16.2",
  109. "prettylint": "1.0.0",
  110. "rimraf": "2.6.2",
  111. "rollup": "0.47.6",
  112. "rollup-plugin-alias": "1.4.0",
  113. "rollup-plugin-babel": "4.0.0-beta.4",
  114. "rollup-plugin-commonjs": "8.2.6",
  115. "rollup-plugin-json": "2.1.1",
  116. "rollup-plugin-node-builtins": "2.0.0",
  117. "rollup-plugin-node-globals": "1.1.0",
  118. "rollup-plugin-node-resolve": "2.0.0",
  119. "rollup-plugin-replace": "1.2.1",
  120. "rollup-plugin-uglify": "3.0.0",
  121. "shelljs": "0.8.1",
  122. "snapshot-diff": "0.4.0",
  123. "strip-ansi": "4.0.0",
  124. "tempy": "0.2.1",
  125. "webpack": "3.12.0"
  126. };
  127. var resolutions = {
  128. "@babel/code-frame": "7.0.0-beta.46"
  129. };
  130. var scripts = {
  131. "prepublishOnly": "echo \"Error: must publish from dist/\" && exit 1",
  132. "prepare-release": "yarn && yarn build && yarn test:dist",
  133. "test": "jest",
  134. "test:dist": "node ./scripts/test-dist.js",
  135. "test-integration": "jest tests_integration",
  136. "perf-repeat": "yarn && yarn build && cross-env NODE_ENV=production node ./dist/bin-prettier.js --debug-repeat ${PERF_REPEAT:-1000} --loglevel debug ${PERF_FILE:-./index.js} > /dev/null",
  137. "perf-repeat-inspect": "yarn && yarn build && cross-env NODE_ENV=production node --inspect-brk ./dist/bin-prettier.js --debug-repeat ${PERF_REPEAT:-1000} --loglevel debug ${PERF_FILE:-./index.js} > /dev/null",
  138. "perf-benchmark": "yarn && yarn build && cross-env NODE_ENV=production node ./dist/bin-prettier.js --debug-benchmark --loglevel debug ${PERF_FILE:-./index.js} > /dev/null",
  139. "lint": "cross-env EFF_NO_LINK_RULES=true eslint . --format node_modules/eslint-friendly-formatter",
  140. "lint-docs": "prettylint {.,docs,website,website/blog}/*.md",
  141. "lint-dist": "eslint --no-eslintrc --no-ignore --env=browser \"dist/!(bin-prettier|index|third-party).js\"",
  142. "build": "node --max-old-space-size=2048 ./scripts/build/build.js",
  143. "build-docs": "node ./scripts/build-docs.js",
  144. "check-deps": "node ./scripts/check-deps.js"
  145. };
  146. var _package = {
  147. name: name,
  148. version: version$1,
  149. description: description,
  150. bin: bin,
  151. repository: repository,
  152. homepage: homepage,
  153. author: author,
  154. license: license,
  155. main: main,
  156. engines: engines,
  157. dependencies: dependencies,
  158. devDependencies: devDependencies,
  159. resolutions: resolutions,
  160. scripts: scripts
  161. };
  162. var _package$1 = Object.freeze({
  163. name: name,
  164. version: version$1,
  165. description: description,
  166. bin: bin,
  167. repository: repository,
  168. homepage: homepage,
  169. author: author,
  170. license: license,
  171. main: main,
  172. engines: engines,
  173. dependencies: dependencies,
  174. devDependencies: devDependencies,
  175. resolutions: resolutions,
  176. scripts: scripts,
  177. default: _package
  178. });
  179. var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  180. function unwrapExports (x) {
  181. return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
  182. }
  183. function createCommonjsModule(fn, module) {
  184. return module = { exports: {} }, fn(module, module.exports), module.exports;
  185. }
  186. var base = createCommonjsModule(function (module, exports) {
  187. /*istanbul ignore start*/
  188. 'use strict';
  189. exports.__esModule = true;
  190. exports['default'] =
  191. /*istanbul ignore end*/
  192. Diff;
  193. function Diff() {}
  194. Diff.prototype = {
  195. /*istanbul ignore start*/
  196. /*istanbul ignore end*/
  197. diff: function diff(oldString, newString) {
  198. /*istanbul ignore start*/
  199. var
  200. /*istanbul ignore end*/
  201. options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
  202. var callback = options.callback;
  203. if (typeof options === 'function') {
  204. callback = options;
  205. options = {};
  206. }
  207. this.options = options;
  208. var self = this;
  209. function done(value) {
  210. if (callback) {
  211. setTimeout(function () {
  212. callback(undefined, value);
  213. }, 0);
  214. return true;
  215. } else {
  216. return value;
  217. }
  218. } // Allow subclasses to massage the input prior to running
  219. oldString = this.castInput(oldString);
  220. newString = this.castInput(newString);
  221. oldString = this.removeEmpty(this.tokenize(oldString));
  222. newString = this.removeEmpty(this.tokenize(newString));
  223. var newLen = newString.length,
  224. oldLen = oldString.length;
  225. var editLength = 1;
  226. var maxEditLength = newLen + oldLen;
  227. var bestPath = [{
  228. newPos: -1,
  229. components: []
  230. }]; // Seed editLength = 0, i.e. the content starts with the same values
  231. var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
  232. if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
  233. // Identity per the equality and tokenizer
  234. return done([{
  235. value: this.join(newString),
  236. count: newString.length
  237. }]);
  238. } // Main worker method. checks all permutations of a given edit length for acceptance.
  239. function execEditLength() {
  240. for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
  241. var basePath =
  242. /*istanbul ignore start*/
  243. void 0;
  244. var addPath = bestPath[diagonalPath - 1],
  245. removePath = bestPath[diagonalPath + 1],
  246. _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
  247. if (addPath) {
  248. // No one else is going to attempt to use this value, clear it
  249. bestPath[diagonalPath - 1] = undefined;
  250. }
  251. var canAdd = addPath && addPath.newPos + 1 < newLen,
  252. canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen;
  253. if (!canAdd && !canRemove) {
  254. // If this path is a terminal then prune
  255. bestPath[diagonalPath] = undefined;
  256. continue;
  257. } // Select the diagonal that we want to branch from. We select the prior
  258. // path whose position in the new string is the farthest from the origin
  259. // and does not pass the bounds of the diff graph
  260. if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
  261. basePath = clonePath(removePath);
  262. self.pushComponent(basePath.components, undefined, true);
  263. } else {
  264. basePath = addPath; // No need to clone, we've pulled it from the list
  265. basePath.newPos++;
  266. self.pushComponent(basePath.components, true, undefined);
  267. }
  268. _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath); // If we have hit the end of both strings, then we are done
  269. if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) {
  270. return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken));
  271. } else {
  272. // Otherwise track this path as a potential candidate and continue.
  273. bestPath[diagonalPath] = basePath;
  274. }
  275. }
  276. editLength++;
  277. } // Performs the length of edit iteration. Is a bit fugly as this has to support the
  278. // sync and async mode which is never fun. Loops over execEditLength until a value
  279. // is produced.
  280. if (callback) {
  281. (function exec() {
  282. setTimeout(function () {
  283. // This should not happen, but we want to be safe.
  284. /* istanbul ignore next */
  285. if (editLength > maxEditLength) {
  286. return callback();
  287. }
  288. if (!execEditLength()) {
  289. exec();
  290. }
  291. }, 0);
  292. })();
  293. } else {
  294. while (editLength <= maxEditLength) {
  295. var ret = execEditLength();
  296. if (ret) {
  297. return ret;
  298. }
  299. }
  300. }
  301. },
  302. /*istanbul ignore start*/
  303. /*istanbul ignore end*/
  304. pushComponent: function pushComponent(components, added, removed) {
  305. var last = components[components.length - 1];
  306. if (last && last.added === added && last.removed === removed) {
  307. // We need to clone here as the component clone operation is just
  308. // as shallow array clone
  309. components[components.length - 1] = {
  310. count: last.count + 1,
  311. added: added,
  312. removed: removed
  313. };
  314. } else {
  315. components.push({
  316. count: 1,
  317. added: added,
  318. removed: removed
  319. });
  320. }
  321. },
  322. /*istanbul ignore start*/
  323. /*istanbul ignore end*/
  324. extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
  325. var newLen = newString.length,
  326. oldLen = oldString.length,
  327. newPos = basePath.newPos,
  328. oldPos = newPos - diagonalPath,
  329. commonCount = 0;
  330. while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
  331. newPos++;
  332. oldPos++;
  333. commonCount++;
  334. }
  335. if (commonCount) {
  336. basePath.components.push({
  337. count: commonCount
  338. });
  339. }
  340. basePath.newPos = newPos;
  341. return oldPos;
  342. },
  343. /*istanbul ignore start*/
  344. /*istanbul ignore end*/
  345. equals: function equals(left, right) {
  346. return left === right;
  347. },
  348. /*istanbul ignore start*/
  349. /*istanbul ignore end*/
  350. removeEmpty: function removeEmpty(array) {
  351. var ret = [];
  352. for (var i = 0; i < array.length; i++) {
  353. if (array[i]) {
  354. ret.push(array[i]);
  355. }
  356. }
  357. return ret;
  358. },
  359. /*istanbul ignore start*/
  360. /*istanbul ignore end*/
  361. castInput: function castInput(value) {
  362. return value;
  363. },
  364. /*istanbul ignore start*/
  365. /*istanbul ignore end*/
  366. tokenize: function tokenize(value) {
  367. return value.split('');
  368. },
  369. /*istanbul ignore start*/
  370. /*istanbul ignore end*/
  371. join: function join(chars) {
  372. return chars.join('');
  373. }
  374. };
  375. function buildValues(diff, components, newString, oldString, useLongestToken) {
  376. var componentPos = 0,
  377. componentLen = components.length,
  378. newPos = 0,
  379. oldPos = 0;
  380. for (; componentPos < componentLen; componentPos++) {
  381. var component = components[componentPos];
  382. if (!component.removed) {
  383. if (!component.added && useLongestToken) {
  384. var value = newString.slice(newPos, newPos + component.count);
  385. value = value.map(function (value, i) {
  386. var oldValue = oldString[oldPos + i];
  387. return oldValue.length > value.length ? oldValue : value;
  388. });
  389. component.value = diff.join(value);
  390. } else {
  391. component.value = diff.join(newString.slice(newPos, newPos + component.count));
  392. }
  393. newPos += component.count; // Common case
  394. if (!component.added) {
  395. oldPos += component.count;
  396. }
  397. } else {
  398. component.value = diff.join(oldString.slice(oldPos, oldPos + component.count));
  399. oldPos += component.count; // Reverse add and remove so removes are output first to match common convention
  400. // The diffing algorithm is tied to add then remove output and this is the simplest
  401. // route to get the desired output with minimal overhead.
  402. if (componentPos && components[componentPos - 1].added) {
  403. var tmp = components[componentPos - 1];
  404. components[componentPos - 1] = components[componentPos];
  405. components[componentPos] = tmp;
  406. }
  407. }
  408. } // Special case handle for when one terminal is ignored. For this case we merge the
  409. // terminal into the prior string and drop the change.
  410. var lastComponent = components[componentLen - 1];
  411. if (componentLen > 1 && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) {
  412. components[componentLen - 2].value += lastComponent.value;
  413. components.pop();
  414. }
  415. return components;
  416. }
  417. function clonePath(path$$1) {
  418. return {
  419. newPos: path$$1.newPos,
  420. components: path$$1.components.slice(0)
  421. };
  422. }
  423. });
  424. unwrapExports(base);
  425. var character = createCommonjsModule(function (module, exports) {
  426. /*istanbul ignore start*/
  427. 'use strict';
  428. exports.__esModule = true;
  429. exports.characterDiff = undefined;
  430. exports.
  431. /*istanbul ignore end*/
  432. diffChars = diffChars;
  433. /*istanbul ignore start*/
  434. var _base2 = _interopRequireDefault(base);
  435. function _interopRequireDefault(obj) {
  436. return obj && obj.__esModule ? obj : {
  437. 'default': obj
  438. };
  439. }
  440. /*istanbul ignore end*/
  441. var characterDiff =
  442. /*istanbul ignore start*/
  443. exports.
  444. /*istanbul ignore end*/
  445. characterDiff = new
  446. /*istanbul ignore start*/
  447. _base2['default']();
  448. function diffChars(oldStr, newStr, callback) {
  449. return characterDiff.diff(oldStr, newStr, callback);
  450. }
  451. });
  452. unwrapExports(character);
  453. var params = createCommonjsModule(function (module, exports) {
  454. /*istanbul ignore start*/
  455. 'use strict';
  456. exports.__esModule = true;
  457. exports.
  458. /*istanbul ignore end*/
  459. generateOptions = generateOptions;
  460. function generateOptions(options, defaults) {
  461. if (typeof options === 'function') {
  462. defaults.callback = options;
  463. } else if (options) {
  464. for (var name in options) {
  465. /* istanbul ignore else */
  466. if (options.hasOwnProperty(name)) {
  467. defaults[name] = options[name];
  468. }
  469. }
  470. }
  471. return defaults;
  472. }
  473. });
  474. unwrapExports(params);
  475. var word = createCommonjsModule(function (module, exports) {
  476. /*istanbul ignore start*/
  477. 'use strict';
  478. exports.__esModule = true;
  479. exports.wordDiff = undefined;
  480. exports.
  481. /*istanbul ignore end*/
  482. diffWords = diffWords;
  483. /*istanbul ignore start*/
  484. exports.
  485. /*istanbul ignore end*/
  486. diffWordsWithSpace = diffWordsWithSpace;
  487. /*istanbul ignore start*/
  488. var _base2 = _interopRequireDefault(base);
  489. /*istanbul ignore end*/
  490. /*istanbul ignore start*/
  491. function _interopRequireDefault(obj) {
  492. return obj && obj.__esModule ? obj : {
  493. 'default': obj
  494. };
  495. }
  496. /*istanbul ignore end*/
  497. // Based on https://en.wikipedia.org/wiki/Latin_script_in_Unicode
  498. //
  499. // Ranges and exceptions:
  500. // Latin-1 Supplement, 0080–00FF
  501. // - U+00D7 × Multiplication sign
  502. // - U+00F7 ÷ Division sign
  503. // Latin Extended-A, 0100–017F
  504. // Latin Extended-B, 0180–024F
  505. // IPA Extensions, 0250–02AF
  506. // Spacing Modifier Letters, 02B0–02FF
  507. // - U+02C7 ˇ &#711; Caron
  508. // - U+02D8 ˘ &#728; Breve
  509. // - U+02D9 ˙ &#729; Dot Above
  510. // - U+02DA ˚ &#730; Ring Above
  511. // - U+02DB ˛ &#731; Ogonek
  512. // - U+02DC ˜ &#732; Small Tilde
  513. // - U+02DD ˝ &#733; Double Acute Accent
  514. // Latin Extended Additional, 1E00–1EFF
  515. var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/;
  516. var reWhitespace = /\S/;
  517. var wordDiff =
  518. /*istanbul ignore start*/
  519. exports.
  520. /*istanbul ignore end*/
  521. wordDiff = new
  522. /*istanbul ignore start*/
  523. _base2['default']();
  524. wordDiff.equals = function (left, right) {
  525. return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right);
  526. };
  527. wordDiff.tokenize = function (value) {
  528. var tokens = value.split(/(\s+|\b)/); // Join the boundary splits that we do not consider to be boundaries. This is primarily the extended Latin character set.
  529. for (var i = 0; i < tokens.length - 1; i++) {
  530. // If we have an empty string in the next field and we have only word chars before and after, merge
  531. if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) {
  532. tokens[i] += tokens[i + 2];
  533. tokens.splice(i + 1, 2);
  534. i--;
  535. }
  536. }
  537. return tokens;
  538. };
  539. function diffWords(oldStr, newStr, callback) {
  540. var options =
  541. /*istanbul ignore start*/
  542. (0, params.generateOptions
  543. /*istanbul ignore end*/
  544. )(callback, {
  545. ignoreWhitespace: true
  546. });
  547. return wordDiff.diff(oldStr, newStr, options);
  548. }
  549. function diffWordsWithSpace(oldStr, newStr, callback) {
  550. return wordDiff.diff(oldStr, newStr, callback);
  551. }
  552. });
  553. unwrapExports(word);
  554. var line = createCommonjsModule(function (module, exports) {
  555. /*istanbul ignore start*/
  556. 'use strict';
  557. exports.__esModule = true;
  558. exports.lineDiff = undefined;
  559. exports.
  560. /*istanbul ignore end*/
  561. diffLines = diffLines;
  562. /*istanbul ignore start*/
  563. exports.
  564. /*istanbul ignore end*/
  565. diffTrimmedLines = diffTrimmedLines;
  566. /*istanbul ignore start*/
  567. var _base2 = _interopRequireDefault(base);
  568. /*istanbul ignore end*/
  569. /*istanbul ignore start*/
  570. function _interopRequireDefault(obj) {
  571. return obj && obj.__esModule ? obj : {
  572. 'default': obj
  573. };
  574. }
  575. /*istanbul ignore end*/
  576. var lineDiff =
  577. /*istanbul ignore start*/
  578. exports.
  579. /*istanbul ignore end*/
  580. lineDiff = new
  581. /*istanbul ignore start*/
  582. _base2['default']();
  583. lineDiff.tokenize = function (value) {
  584. var retLines = [],
  585. linesAndNewlines = value.split(/(\n|\r\n)/); // Ignore the final empty token that occurs if the string ends with a new line
  586. if (!linesAndNewlines[linesAndNewlines.length - 1]) {
  587. linesAndNewlines.pop();
  588. } // Merge the content and line separators into single tokens
  589. for (var i = 0; i < linesAndNewlines.length; i++) {
  590. var line = linesAndNewlines[i];
  591. if (i % 2 && !this.options.newlineIsToken) {
  592. retLines[retLines.length - 1] += line;
  593. } else {
  594. if (this.options.ignoreWhitespace) {
  595. line = line.trim();
  596. }
  597. retLines.push(line);
  598. }
  599. }
  600. return retLines;
  601. };
  602. function diffLines(oldStr, newStr, callback) {
  603. return lineDiff.diff(oldStr, newStr, callback);
  604. }
  605. function diffTrimmedLines(oldStr, newStr, callback) {
  606. var options =
  607. /*istanbul ignore start*/
  608. (0, params.generateOptions
  609. /*istanbul ignore end*/
  610. )(callback, {
  611. ignoreWhitespace: true
  612. });
  613. return lineDiff.diff(oldStr, newStr, options);
  614. }
  615. });
  616. unwrapExports(line);
  617. var sentence = createCommonjsModule(function (module, exports) {
  618. /*istanbul ignore start*/
  619. 'use strict';
  620. exports.__esModule = true;
  621. exports.sentenceDiff = undefined;
  622. exports.
  623. /*istanbul ignore end*/
  624. diffSentences = diffSentences;
  625. /*istanbul ignore start*/
  626. var _base2 = _interopRequireDefault(base);
  627. function _interopRequireDefault(obj) {
  628. return obj && obj.__esModule ? obj : {
  629. 'default': obj
  630. };
  631. }
  632. /*istanbul ignore end*/
  633. var sentenceDiff =
  634. /*istanbul ignore start*/
  635. exports.
  636. /*istanbul ignore end*/
  637. sentenceDiff = new
  638. /*istanbul ignore start*/
  639. _base2['default']();
  640. sentenceDiff.tokenize = function (value) {
  641. return value.split(/(\S.+?[.!?])(?=\s+|$)/);
  642. };
  643. function diffSentences(oldStr, newStr, callback) {
  644. return sentenceDiff.diff(oldStr, newStr, callback);
  645. }
  646. });
  647. unwrapExports(sentence);
  648. var css = createCommonjsModule(function (module, exports) {
  649. /*istanbul ignore start*/
  650. 'use strict';
  651. exports.__esModule = true;
  652. exports.cssDiff = undefined;
  653. exports.
  654. /*istanbul ignore end*/
  655. diffCss = diffCss;
  656. /*istanbul ignore start*/
  657. var _base2 = _interopRequireDefault(base);
  658. function _interopRequireDefault(obj) {
  659. return obj && obj.__esModule ? obj : {
  660. 'default': obj
  661. };
  662. }
  663. /*istanbul ignore end*/
  664. var cssDiff =
  665. /*istanbul ignore start*/
  666. exports.
  667. /*istanbul ignore end*/
  668. cssDiff = new
  669. /*istanbul ignore start*/
  670. _base2['default']();
  671. cssDiff.tokenize = function (value) {
  672. return value.split(/([{}:;,]|\s+)/);
  673. };
  674. function diffCss(oldStr, newStr, callback) {
  675. return cssDiff.diff(oldStr, newStr, callback);
  676. }
  677. });
  678. unwrapExports(css);
  679. var json = createCommonjsModule(function (module, exports) {
  680. /*istanbul ignore start*/
  681. 'use strict';
  682. exports.__esModule = true;
  683. exports.jsonDiff = undefined;
  684. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
  685. return typeof obj;
  686. } : function (obj) {
  687. return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj;
  688. };
  689. exports.
  690. /*istanbul ignore end*/
  691. diffJson = diffJson;
  692. /*istanbul ignore start*/
  693. exports.
  694. /*istanbul ignore end*/
  695. canonicalize = canonicalize;
  696. /*istanbul ignore start*/
  697. var _base2 = _interopRequireDefault(base);
  698. /*istanbul ignore end*/
  699. /*istanbul ignore start*/
  700. function _interopRequireDefault(obj) {
  701. return obj && obj.__esModule ? obj : {
  702. 'default': obj
  703. };
  704. }
  705. /*istanbul ignore end*/
  706. var objectPrototypeToString = Object.prototype.toString;
  707. var jsonDiff =
  708. /*istanbul ignore start*/
  709. exports.
  710. /*istanbul ignore end*/
  711. jsonDiff = new
  712. /*istanbul ignore start*/
  713. _base2['default'](); // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
  714. // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
  715. jsonDiff.useLongestToken = true;
  716. jsonDiff.tokenize =
  717. /*istanbul ignore start*/
  718. line.lineDiff.
  719. /*istanbul ignore end*/
  720. tokenize;
  721. jsonDiff.castInput = function (value) {
  722. /*istanbul ignore start*/
  723. var
  724. /*istanbul ignore end*/
  725. undefinedReplacement = this.options.undefinedReplacement;
  726. return typeof value === 'string' ? value : JSON.stringify(canonicalize(value), function (k, v) {
  727. if (typeof v === 'undefined') {
  728. return undefinedReplacement;
  729. }
  730. return v;
  731. }, ' ');
  732. };
  733. jsonDiff.equals = function (left, right) {
  734. return (
  735. /*istanbul ignore start*/
  736. _base2['default'].
  737. /*istanbul ignore end*/
  738. prototype.equals(left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'))
  739. );
  740. };
  741. function diffJson(oldObj, newObj, options) {
  742. return jsonDiff.diff(oldObj, newObj, options);
  743. } // This function handles the presence of circular references by bailing out when encountering an
  744. // object that is already on the "stack" of items being processed.
  745. function canonicalize(obj, stack, replacementStack) {
  746. stack = stack || [];
  747. replacementStack = replacementStack || [];
  748. var i =
  749. /*istanbul ignore start*/
  750. void 0;
  751. for (i = 0; i < stack.length; i += 1) {
  752. if (stack[i] === obj) {
  753. return replacementStack[i];
  754. }
  755. }
  756. var canonicalizedObj =
  757. /*istanbul ignore start*/
  758. void 0;
  759. if ('[object Array]' === objectPrototypeToString.call(obj)) {
  760. stack.push(obj);
  761. canonicalizedObj = new Array(obj.length);
  762. replacementStack.push(canonicalizedObj);
  763. for (i = 0; i < obj.length; i += 1) {
  764. canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack);
  765. }
  766. stack.pop();
  767. replacementStack.pop();
  768. return canonicalizedObj;
  769. }
  770. if (obj && obj.toJSON) {
  771. obj = obj.toJSON();
  772. }
  773. if (
  774. /*istanbul ignore start*/
  775. (typeof
  776. /*istanbul ignore end*/
  777. obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && obj !== null) {
  778. stack.push(obj);
  779. canonicalizedObj = {};
  780. replacementStack.push(canonicalizedObj);
  781. var sortedKeys = [],
  782. key =
  783. /*istanbul ignore start*/
  784. void 0;
  785. for (key in obj) {
  786. /* istanbul ignore else */
  787. if (obj.hasOwnProperty(key)) {
  788. sortedKeys.push(key);
  789. }
  790. }
  791. sortedKeys.sort();
  792. for (i = 0; i < sortedKeys.length; i += 1) {
  793. key = sortedKeys[i];
  794. canonicalizedObj[key] = canonicalize(obj[key], stack, replacementStack);
  795. }
  796. stack.pop();
  797. replacementStack.pop();
  798. } else {
  799. canonicalizedObj = obj;
  800. }
  801. return canonicalizedObj;
  802. }
  803. });
  804. unwrapExports(json);
  805. var array = createCommonjsModule(function (module, exports) {
  806. /*istanbul ignore start*/
  807. 'use strict';
  808. exports.__esModule = true;
  809. exports.arrayDiff = undefined;
  810. exports.
  811. /*istanbul ignore end*/
  812. diffArrays = diffArrays;
  813. /*istanbul ignore start*/
  814. var _base2 = _interopRequireDefault(base);
  815. function _interopRequireDefault(obj) {
  816. return obj && obj.__esModule ? obj : {
  817. 'default': obj
  818. };
  819. }
  820. /*istanbul ignore end*/
  821. var arrayDiff =
  822. /*istanbul ignore start*/
  823. exports.
  824. /*istanbul ignore end*/
  825. arrayDiff = new
  826. /*istanbul ignore start*/
  827. _base2['default']();
  828. arrayDiff.tokenize = arrayDiff.join = function (value) {
  829. return value.slice();
  830. };
  831. function diffArrays(oldArr, newArr, callback) {
  832. return arrayDiff.diff(oldArr, newArr, callback);
  833. }
  834. });
  835. unwrapExports(array);
  836. var parse = createCommonjsModule(function (module, exports) {
  837. /*istanbul ignore start*/
  838. 'use strict';
  839. exports.__esModule = true;
  840. exports.
  841. /*istanbul ignore end*/
  842. parsePatch = parsePatch;
  843. function parsePatch(uniDiff) {
  844. /*istanbul ignore start*/
  845. var
  846. /*istanbul ignore end*/
  847. options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  848. var diffstr = uniDiff.split(/\r\n|[\n\v\f\r\x85]/),
  849. delimiters = uniDiff.match(/\r\n|[\n\v\f\r\x85]/g) || [],
  850. list = [],
  851. i = 0;
  852. function parseIndex() {
  853. var index = {};
  854. list.push(index); // Parse diff metadata
  855. while (i < diffstr.length) {
  856. var line = diffstr[i]; // File header found, end parsing diff metadata
  857. if (/^(\-\-\-|\+\+\+|@@)\s/.test(line)) {
  858. break;
  859. } // Diff index
  860. var header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line);
  861. if (header) {
  862. index.index = header[1];
  863. }
  864. i++;
  865. } // Parse file headers if they are defined. Unified diff requires them, but
  866. // there's no technical issues to have an isolated hunk without file header
  867. parseFileHeader(index);
  868. parseFileHeader(index); // Parse hunks
  869. index.hunks = [];
  870. while (i < diffstr.length) {
  871. var _line = diffstr[i];
  872. if (/^(Index:|diff|\-\-\-|\+\+\+)\s/.test(_line)) {
  873. break;
  874. } else if (/^@@/.test(_line)) {
  875. index.hunks.push(parseHunk());
  876. } else if (_line && options.strict) {
  877. // Ignore unexpected content unless in strict mode
  878. throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(_line));
  879. } else {
  880. i++;
  881. }
  882. }
  883. } // Parses the --- and +++ headers, if none are found, no lines
  884. // are consumed.
  885. function parseFileHeader(index) {
  886. var headerPattern = /^(---|\+\+\+)\s+([\S ]*)(?:\t(.*?)\s*)?$/;
  887. var fileHeader = headerPattern.exec(diffstr[i]);
  888. if (fileHeader) {
  889. var keyPrefix = fileHeader[1] === '---' ? 'old' : 'new';
  890. index[keyPrefix + 'FileName'] = fileHeader[2];
  891. index[keyPrefix + 'Header'] = fileHeader[3];
  892. i++;
  893. }
  894. } // Parses a hunk
  895. // This assumes that we are at the start of a hunk.
  896. function parseHunk() {
  897. var chunkHeaderIndex = i,
  898. chunkHeaderLine = diffstr[i++],
  899. chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
  900. var hunk = {
  901. oldStart: +chunkHeader[1],
  902. oldLines: +chunkHeader[2] || 1,
  903. newStart: +chunkHeader[3],
  904. newLines: +chunkHeader[4] || 1,
  905. lines: [],
  906. linedelimiters: []
  907. };
  908. var addCount = 0,
  909. removeCount = 0;
  910. for (; i < diffstr.length; i++) {
  911. // Lines starting with '---' could be mistaken for the "remove line" operation
  912. // But they could be the header for the next file. Therefore prune such cases out.
  913. if (diffstr[i].indexOf('--- ') === 0 && i + 2 < diffstr.length && diffstr[i + 1].indexOf('+++ ') === 0 && diffstr[i + 2].indexOf('@@') === 0) {
  914. break;
  915. }
  916. var operation = diffstr[i][0];
  917. if (operation === '+' || operation === '-' || operation === ' ' || operation === '\\') {
  918. hunk.lines.push(diffstr[i]);
  919. hunk.linedelimiters.push(delimiters[i] || '\n');
  920. if (operation === '+') {
  921. addCount++;
  922. } else if (operation === '-') {
  923. removeCount++;
  924. } else if (operation === ' ') {
  925. addCount++;
  926. removeCount++;
  927. }
  928. } else {
  929. break;
  930. }
  931. } // Handle the empty block count case
  932. if (!addCount && hunk.newLines === 1) {
  933. hunk.newLines = 0;
  934. }
  935. if (!removeCount && hunk.oldLines === 1) {
  936. hunk.oldLines = 0;
  937. } // Perform optional sanity checking
  938. if (options.strict) {
  939. if (addCount !== hunk.newLines) {
  940. throw new Error('Added line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
  941. }
  942. if (removeCount !== hunk.oldLines) {
  943. throw new Error('Removed line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
  944. }
  945. }
  946. return hunk;
  947. }
  948. while (i < diffstr.length) {
  949. parseIndex();
  950. }
  951. return list;
  952. }
  953. });
  954. unwrapExports(parse);
  955. var distanceIterator = createCommonjsModule(function (module, exports) {
  956. /*istanbul ignore start*/
  957. "use strict";
  958. exports.__esModule = true;
  959. exports["default"] =
  960. /*istanbul ignore end*/
  961. function (start, minLine, maxLine) {
  962. var wantForward = true,
  963. backwardExhausted = false,
  964. forwardExhausted = false,
  965. localOffset = 1;
  966. return function iterator() {
  967. if (wantForward && !forwardExhausted) {
  968. if (backwardExhausted) {
  969. localOffset++;
  970. } else {
  971. wantForward = false;
  972. } // Check if trying to fit beyond text length, and if not, check it fits
  973. // after offset location (or desired location on first iteration)
  974. if (start + localOffset <= maxLine) {
  975. return localOffset;
  976. }
  977. forwardExhausted = true;
  978. }
  979. if (!backwardExhausted) {
  980. if (!forwardExhausted) {
  981. wantForward = true;
  982. } // Check if trying to fit before text beginning, and if not, check it fits
  983. // before offset location
  984. if (minLine <= start - localOffset) {
  985. return -localOffset++;
  986. }
  987. backwardExhausted = true;
  988. return iterator();
  989. } // We tried to fit hunk before text beginning and beyond text lenght, then
  990. // hunk can't fit on the text. Return undefined
  991. };
  992. };
  993. });
  994. unwrapExports(distanceIterator);
  995. var apply = createCommonjsModule(function (module, exports) {
  996. /*istanbul ignore start*/
  997. 'use strict';
  998. exports.__esModule = true;
  999. exports.
  1000. /*istanbul ignore end*/
  1001. applyPatch = applyPatch;
  1002. /*istanbul ignore start*/
  1003. exports.
  1004. /*istanbul ignore end*/
  1005. applyPatches = applyPatches;
  1006. /*istanbul ignore start*/
  1007. var _distanceIterator2 = _interopRequireDefault(distanceIterator);
  1008. function _interopRequireDefault(obj) {
  1009. return obj && obj.__esModule ? obj : {
  1010. 'default': obj
  1011. };
  1012. }
  1013. /*istanbul ignore end*/
  1014. function applyPatch(source, uniDiff) {
  1015. /*istanbul ignore start*/
  1016. var
  1017. /*istanbul ignore end*/
  1018. options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
  1019. if (typeof uniDiff === 'string') {
  1020. uniDiff =
  1021. /*istanbul ignore start*/
  1022. (0, parse.parsePatch
  1023. /*istanbul ignore end*/
  1024. )(uniDiff);
  1025. }
  1026. if (Array.isArray(uniDiff)) {
  1027. if (uniDiff.length > 1) {
  1028. throw new Error('applyPatch only works with a single input.');
  1029. }
  1030. uniDiff = uniDiff[0];
  1031. } // Apply the diff to the input
  1032. var lines = source.split(/\r\n|[\n\v\f\r\x85]/),
  1033. delimiters = source.match(/\r\n|[\n\v\f\r\x85]/g) || [],
  1034. hunks = uniDiff.hunks,
  1035. compareLine = options.compareLine || function (lineNumber, line, operation, patchContent)
  1036. /*istanbul ignore start*/
  1037. {
  1038. return (
  1039. /*istanbul ignore end*/
  1040. line === patchContent
  1041. );
  1042. },
  1043. errorCount = 0,
  1044. fuzzFactor = options.fuzzFactor || 0,
  1045. minLine = 0,
  1046. offset = 0,
  1047. removeEOFNL =
  1048. /*istanbul ignore start*/
  1049. void 0
  1050. /*istanbul ignore end*/
  1051. ,
  1052. addEOFNL =
  1053. /*istanbul ignore start*/
  1054. void 0;
  1055. /**
  1056. * Checks if the hunk exactly fits on the provided location
  1057. */
  1058. function hunkFits(hunk, toPos) {
  1059. for (var j = 0; j < hunk.lines.length; j++) {
  1060. var line = hunk.lines[j],
  1061. operation = line[0],
  1062. content = line.substr(1);
  1063. if (operation === ' ' || operation === '-') {
  1064. // Context sanity check
  1065. if (!compareLine(toPos + 1, lines[toPos], operation, content)) {
  1066. errorCount++;
  1067. if (errorCount > fuzzFactor) {
  1068. return false;
  1069. }
  1070. }
  1071. toPos++;
  1072. }
  1073. }
  1074. return true;
  1075. } // Search best fit offsets for each hunk based on the previous ones
  1076. for (var i = 0; i < hunks.length; i++) {
  1077. var hunk = hunks[i],
  1078. maxLine = lines.length - hunk.oldLines,
  1079. localOffset = 0,
  1080. toPos = offset + hunk.oldStart - 1;
  1081. var iterator =
  1082. /*istanbul ignore start*/
  1083. (0, _distanceIterator2['default']
  1084. /*istanbul ignore end*/
  1085. )(toPos, minLine, maxLine);
  1086. for (; localOffset !== undefined; localOffset = iterator()) {
  1087. if (hunkFits(hunk, toPos + localOffset)) {
  1088. hunk.offset = offset += localOffset;
  1089. break;
  1090. }
  1091. }
  1092. if (localOffset === undefined) {
  1093. return false;
  1094. } // Set lower text limit to end of the current hunk, so next ones don't try
  1095. // to fit over already patched text
  1096. minLine = hunk.offset + hunk.oldStart + hunk.oldLines;
  1097. } // Apply patch hunks
  1098. for (var _i = 0; _i < hunks.length; _i++) {
  1099. var _hunk = hunks[_i],
  1100. _toPos = _hunk.offset + _hunk.newStart - 1;
  1101. if (_hunk.newLines == 0) {
  1102. _toPos++;
  1103. }
  1104. for (var j = 0; j < _hunk.lines.length; j++) {
  1105. var line = _hunk.lines[j],
  1106. operation = line[0],
  1107. content = line.substr(1),
  1108. delimiter = _hunk.linedelimiters[j];
  1109. if (operation === ' ') {
  1110. _toPos++;
  1111. } else if (operation === '-') {
  1112. lines.splice(_toPos, 1);
  1113. delimiters.splice(_toPos, 1);
  1114. /* istanbul ignore else */
  1115. } else if (operation === '+') {
  1116. lines.splice(_toPos, 0, content);
  1117. delimiters.splice(_toPos, 0, delimiter);
  1118. _toPos++;
  1119. } else if (operation === '\\') {
  1120. var previousOperation = _hunk.lines[j - 1] ? _hunk.lines[j - 1][0] : null;
  1121. if (previousOperation === '+') {
  1122. removeEOFNL = true;
  1123. } else if (previousOperation === '-') {
  1124. addEOFNL = true;
  1125. }
  1126. }
  1127. }
  1128. } // Handle EOFNL insertion/removal
  1129. if (removeEOFNL) {
  1130. while (!lines[lines.length - 1]) {
  1131. lines.pop();
  1132. delimiters.pop();
  1133. }
  1134. } else if (addEOFNL) {
  1135. lines.push('');
  1136. delimiters.push('\n');
  1137. }
  1138. for (var _k = 0; _k < lines.length - 1; _k++) {
  1139. lines[_k] = lines[_k] + delimiters[_k];
  1140. }
  1141. return lines.join('');
  1142. } // Wrapper that supports multiple file patches via callbacks.
  1143. function applyPatches(uniDiff, options) {
  1144. if (typeof uniDiff === 'string') {
  1145. uniDiff =
  1146. /*istanbul ignore start*/
  1147. (0, parse.parsePatch
  1148. /*istanbul ignore end*/
  1149. )(uniDiff);
  1150. }
  1151. var currentIndex = 0;
  1152. function processIndex() {
  1153. var index = uniDiff[currentIndex++];
  1154. if (!index) {
  1155. return options.complete();
  1156. }
  1157. options.loadFile(index, function (err, data) {
  1158. if (err) {
  1159. return options.complete(err);
  1160. }
  1161. var updatedContent = applyPatch(data, index, options);
  1162. options.patched(index, updatedContent, function (err) {
  1163. if (err) {
  1164. return options.complete(err);
  1165. }
  1166. processIndex();
  1167. });
  1168. });
  1169. }
  1170. processIndex();
  1171. }
  1172. });
  1173. unwrapExports(apply);
  1174. var create = createCommonjsModule(function (module, exports) {
  1175. /*istanbul ignore start*/
  1176. 'use strict';
  1177. exports.__esModule = true;
  1178. exports.
  1179. /*istanbul ignore end*/
  1180. structuredPatch = structuredPatch;
  1181. /*istanbul ignore start*/
  1182. exports.
  1183. /*istanbul ignore end*/
  1184. createTwoFilesPatch = createTwoFilesPatch;
  1185. /*istanbul ignore start*/
  1186. exports.
  1187. /*istanbul ignore end*/
  1188. createPatch = createPatch;
  1189. /*istanbul ignore start*/
  1190. function _toConsumableArray(arr) {
  1191. if (Array.isArray(arr)) {
  1192. for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
  1193. arr2[i] = arr[i];
  1194. }
  1195. return arr2;
  1196. } else {
  1197. return Array.from(arr);
  1198. }
  1199. }
  1200. /*istanbul ignore end*/
  1201. function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
  1202. if (!options) {
  1203. options = {};
  1204. }
  1205. if (typeof options.context === 'undefined') {
  1206. options.context = 4;
  1207. }
  1208. var diff =
  1209. /*istanbul ignore start*/
  1210. (0, line.diffLines
  1211. /*istanbul ignore end*/
  1212. )(oldStr, newStr, options);
  1213. diff.push({
  1214. value: '',
  1215. lines: []
  1216. }); // Append an empty value to make cleanup easier
  1217. function contextLines(lines) {
  1218. return lines.map(function (entry) {
  1219. return ' ' + entry;
  1220. });
  1221. }
  1222. var hunks = [];
  1223. var oldRangeStart = 0,
  1224. newRangeStart = 0,
  1225. curRange = [],
  1226. oldLine = 1,
  1227. newLine = 1;
  1228. /*istanbul ignore start*/
  1229. var _loop = function _loop(
  1230. /*istanbul ignore end*/
  1231. i) {
  1232. var current = diff[i],
  1233. lines = current.lines || current.value.replace(/\n$/, '').split('\n');
  1234. current.lines = lines;
  1235. if (current.added || current.removed) {
  1236. /*istanbul ignore start*/
  1237. var _curRange;
  1238. /*istanbul ignore end*/
  1239. // If we have previous context, start with that
  1240. if (!oldRangeStart) {
  1241. var prev = diff[i - 1];
  1242. oldRangeStart = oldLine;
  1243. newRangeStart = newLine;
  1244. if (prev) {
  1245. curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
  1246. oldRangeStart -= curRange.length;
  1247. newRangeStart -= curRange.length;
  1248. }
  1249. } // Output our changes
  1250. /*istanbul ignore start*/
  1251. (_curRange =
  1252. /*istanbul ignore end*/
  1253. curRange).push.
  1254. /*istanbul ignore start*/
  1255. apply
  1256. /*istanbul ignore end*/
  1257. (
  1258. /*istanbul ignore start*/
  1259. _curRange
  1260. /*istanbul ignore end*/
  1261. ,
  1262. /*istanbul ignore start*/
  1263. _toConsumableArray(
  1264. /*istanbul ignore end*/
  1265. lines.map(function (entry) {
  1266. return (current.added ? '+' : '-') + entry;
  1267. }))); // Track the updated file position
  1268. if (current.added) {
  1269. newLine += lines.length;
  1270. } else {
  1271. oldLine += lines.length;
  1272. }
  1273. } else {
  1274. // Identical context lines. Track line changes
  1275. if (oldRangeStart) {
  1276. // Close out any changes that have been output (or join overlapping)
  1277. if (lines.length <= options.context * 2 && i < diff.length - 2) {
  1278. /*istanbul ignore start*/
  1279. var _curRange2;
  1280. /*istanbul ignore end*/
  1281. // Overlapping
  1282. /*istanbul ignore start*/
  1283. (_curRange2 =
  1284. /*istanbul ignore end*/
  1285. curRange).push.
  1286. /*istanbul ignore start*/
  1287. apply
  1288. /*istanbul ignore end*/
  1289. (
  1290. /*istanbul ignore start*/
  1291. _curRange2
  1292. /*istanbul ignore end*/
  1293. ,
  1294. /*istanbul ignore start*/
  1295. _toConsumableArray(
  1296. /*istanbul ignore end*/
  1297. contextLines(lines)));
  1298. } else {
  1299. /*istanbul ignore start*/
  1300. var _curRange3;
  1301. /*istanbul ignore end*/
  1302. // end the range and output
  1303. var contextSize = Math.min(lines.length, options.context);
  1304. /*istanbul ignore start*/
  1305. (_curRange3 =
  1306. /*istanbul ignore end*/
  1307. curRange).push.
  1308. /*istanbul ignore start*/
  1309. apply
  1310. /*istanbul ignore end*/
  1311. (
  1312. /*istanbul ignore start*/
  1313. _curRange3
  1314. /*istanbul ignore end*/
  1315. ,
  1316. /*istanbul ignore start*/
  1317. _toConsumableArray(
  1318. /*istanbul ignore end*/
  1319. contextLines(lines.slice(0, contextSize))));
  1320. var hunk = {
  1321. oldStart: oldRangeStart,
  1322. oldLines: oldLine - oldRangeStart + contextSize,
  1323. newStart: newRangeStart,
  1324. newLines: newLine - newRangeStart + contextSize,
  1325. lines: curRange
  1326. };
  1327. if (i >= diff.length - 2 && lines.length <= options.context) {
  1328. // EOF is inside this hunk
  1329. var oldEOFNewline = /\n$/.test(oldStr);
  1330. var newEOFNewline = /\n$/.test(newStr);
  1331. if (lines.length == 0 && !oldEOFNewline) {
  1332. // special case: old has no eol and no trailing context; no-nl can end up before adds
  1333. curRange.splice(hunk.oldLines, 0, '\\ No newline at end of file');
  1334. } else if (!oldEOFNewline || !newEOFNewline) {
  1335. curRange.push('\\ No newline at end of file');
  1336. }
  1337. }
  1338. hunks.push(hunk);
  1339. oldRangeStart = 0;
  1340. newRangeStart = 0;
  1341. curRange = [];
  1342. }
  1343. }
  1344. oldLine += lines.length;
  1345. newLine += lines.length;
  1346. }
  1347. };
  1348. for (var i = 0; i < diff.length; i++) {
  1349. /*istanbul ignore start*/
  1350. _loop(
  1351. /*istanbul ignore end*/
  1352. i);
  1353. }
  1354. return {
  1355. oldFileName: oldFileName,
  1356. newFileName: newFileName,
  1357. oldHeader: oldHeader,
  1358. newHeader: newHeader,
  1359. hunks: hunks
  1360. };
  1361. }
  1362. function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
  1363. var diff = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
  1364. var ret = [];
  1365. if (oldFileName == newFileName) {
  1366. ret.push('Index: ' + oldFileName);
  1367. }
  1368. ret.push('===================================================================');
  1369. ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader));
  1370. ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader));
  1371. for (var i = 0; i < diff.hunks.length; i++) {
  1372. var hunk = diff.hunks[i];
  1373. ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@');
  1374. ret.push.apply(ret, hunk.lines);
  1375. }
  1376. return ret.join('\n') + '\n';
  1377. }
  1378. function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
  1379. return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);
  1380. }
  1381. });
  1382. unwrapExports(create);
  1383. var dmp = createCommonjsModule(function (module, exports) {
  1384. /*istanbul ignore start*/
  1385. "use strict";
  1386. exports.__esModule = true;
  1387. exports.
  1388. /*istanbul ignore end*/
  1389. convertChangesToDMP = convertChangesToDMP; // See: http://code.google.com/p/google-diff-match-patch/wiki/API
  1390. function convertChangesToDMP(changes) {
  1391. var ret = [],
  1392. change =
  1393. /*istanbul ignore start*/
  1394. void 0
  1395. /*istanbul ignore end*/
  1396. ,
  1397. operation =
  1398. /*istanbul ignore start*/
  1399. void 0;
  1400. for (var i = 0; i < changes.length; i++) {
  1401. change = changes[i];
  1402. if (change.added) {
  1403. operation = 1;
  1404. } else if (change.removed) {
  1405. operation = -1;
  1406. } else {
  1407. operation = 0;
  1408. }
  1409. ret.push([operation, change.value]);
  1410. }
  1411. return ret;
  1412. }
  1413. });
  1414. unwrapExports(dmp);
  1415. var xml = createCommonjsModule(function (module, exports) {
  1416. /*istanbul ignore start*/
  1417. 'use strict';
  1418. exports.__esModule = true;
  1419. exports.
  1420. /*istanbul ignore end*/
  1421. convertChangesToXML = convertChangesToXML;
  1422. function convertChangesToXML(changes) {
  1423. var ret = [];
  1424. for (var i = 0; i < changes.length; i++) {
  1425. var change = changes[i];
  1426. if (change.added) {
  1427. ret.push('<ins>');
  1428. } else if (change.removed) {
  1429. ret.push('<del>');
  1430. }
  1431. ret.push(escapeHTML(change.value));
  1432. if (change.added) {
  1433. ret.push('</ins>');
  1434. } else if (change.removed) {
  1435. ret.push('</del>');
  1436. }
  1437. }
  1438. return ret.join('');
  1439. }
  1440. function escapeHTML(s) {
  1441. var n = s;
  1442. n = n.replace(/&/g, '&amp;');
  1443. n = n.replace(/</g, '&lt;');
  1444. n = n.replace(/>/g, '&gt;');
  1445. n = n.replace(/"/g, '&quot;');
  1446. return n;
  1447. }
  1448. });
  1449. unwrapExports(xml);
  1450. var lib = createCommonjsModule(function (module, exports) {
  1451. /*istanbul ignore start*/
  1452. 'use strict';
  1453. exports.__esModule = true;
  1454. exports.canonicalize = exports.convertChangesToXML = exports.convertChangesToDMP = 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;
  1455. /*istanbul ignore end*/
  1456. /*istanbul ignore start*/
  1457. var _base2 = _interopRequireDefault(base);
  1458. /*istanbul ignore end*/
  1459. /*istanbul ignore start*/
  1460. function _interopRequireDefault(obj) {
  1461. return obj && obj.__esModule ? obj : {
  1462. 'default': obj
  1463. };
  1464. }
  1465. exports.
  1466. /*istanbul ignore end*/
  1467. Diff = _base2['default'];
  1468. /*istanbul ignore start*/
  1469. exports.
  1470. /*istanbul ignore end*/
  1471. diffChars = character.diffChars;
  1472. /*istanbul ignore start*/
  1473. exports.
  1474. /*istanbul ignore end*/
  1475. diffWords = word.diffWords;
  1476. /*istanbul ignore start*/
  1477. exports.
  1478. /*istanbul ignore end*/
  1479. diffWordsWithSpace = word.diffWordsWithSpace;
  1480. /*istanbul ignore start*/
  1481. exports.
  1482. /*istanbul ignore end*/
  1483. diffLines = line.diffLines;
  1484. /*istanbul ignore start*/
  1485. exports.
  1486. /*istanbul ignore end*/
  1487. diffTrimmedLines = line.diffTrimmedLines;
  1488. /*istanbul ignore start*/
  1489. exports.
  1490. /*istanbul ignore end*/
  1491. diffSentences = sentence.diffSentences;
  1492. /*istanbul ignore start*/
  1493. exports.
  1494. /*istanbul ignore end*/
  1495. diffCss = css.diffCss;
  1496. /*istanbul ignore start*/
  1497. exports.
  1498. /*istanbul ignore end*/
  1499. diffJson = json.diffJson;
  1500. /*istanbul ignore start*/
  1501. exports.
  1502. /*istanbul ignore end*/
  1503. diffArrays = array.diffArrays;
  1504. /*istanbul ignore start*/
  1505. exports.
  1506. /*istanbul ignore end*/
  1507. structuredPatch = create.structuredPatch;
  1508. /*istanbul ignore start*/
  1509. exports.
  1510. /*istanbul ignore end*/
  1511. createTwoFilesPatch = create.createTwoFilesPatch;
  1512. /*istanbul ignore start*/
  1513. exports.
  1514. /*istanbul ignore end*/
  1515. createPatch = create.createPatch;
  1516. /*istanbul ignore start*/
  1517. exports.
  1518. /*istanbul ignore end*/
  1519. applyPatch = apply.applyPatch;
  1520. /*istanbul ignore start*/
  1521. exports.
  1522. /*istanbul ignore end*/
  1523. applyPatches = apply.applyPatches;
  1524. /*istanbul ignore start*/
  1525. exports.
  1526. /*istanbul ignore end*/
  1527. parsePatch = parse.parsePatch;
  1528. /*istanbul ignore start*/
  1529. exports.
  1530. /*istanbul ignore end*/
  1531. convertChangesToDMP = dmp.convertChangesToDMP;
  1532. /*istanbul ignore start*/
  1533. exports.
  1534. /*istanbul ignore end*/
  1535. convertChangesToXML = xml.convertChangesToXML;
  1536. /*istanbul ignore start*/
  1537. exports.
  1538. /*istanbul ignore end*/
  1539. canonicalize = json.canonicalize;
  1540. /* See LICENSE file for terms of use */
  1541. /*
  1542. * Text diff implementation.
  1543. *
  1544. * This library supports the following APIS:
  1545. * JsDiff.diffChars: Character by character diff
  1546. * JsDiff.diffWords: Word (as defined by \b regex) diff which ignores whitespace
  1547. * JsDiff.diffLines: Line based diff
  1548. *
  1549. * JsDiff.diffCss: Diff targeted at CSS content
  1550. *
  1551. * These methods are based on the implementation proposed in
  1552. * "An O(ND) Difference Algorithm and its Variations" (Myers, 1986).
  1553. * http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927
  1554. */
  1555. });
  1556. unwrapExports(lib);
  1557. /*!
  1558. * normalize-path <https://github.com/jonschlinkert/normalize-path>
  1559. *
  1560. * Copyright (c) 2014-2018, Jon Schlinkert.
  1561. * Released under the MIT License.
  1562. */
  1563. var normalizePath = function normalizePath(path$$1, stripTrailing) {
  1564. if (typeof path$$1 !== 'string') {
  1565. throw new TypeError('expected path to be a string');
  1566. }
  1567. if (path$$1 === '\\' || path$$1 === '/') return '/';
  1568. var len = path$$1.length;
  1569. if (len <= 1) return path$$1; // ensure that win32 namespaces has two leading slashes, so that the path is
  1570. // handled properly by the win32 version of path.parse() after being normalized
  1571. // https://msdn.microsoft.com/library/windows/desktop/aa365247(v=vs.85).aspx#namespaces
  1572. var prefix = '';
  1573. if (len > 4 && path$$1[3] === '\\') {
  1574. var ch = path$$1[2];
  1575. if ((ch === '?' || ch === '.') && path$$1.slice(0, 2) === '\\\\') {
  1576. path$$1 = path$$1.slice(2);
  1577. prefix = '//';
  1578. }
  1579. }
  1580. var segs = path$$1.split(/[/\\]+/);
  1581. if (stripTrailing !== false && segs[segs.length - 1] === '') {
  1582. segs.pop();
  1583. }
  1584. return prefix + segs.join('/');
  1585. };
  1586. function _classCallCheck(instance, Constructor) {
  1587. if (!(instance instanceof Constructor)) {
  1588. throw new TypeError("Cannot call a class as a function");
  1589. }
  1590. }
  1591. function _defineProperties(target, props) {
  1592. for (var i = 0; i < props.length; i++) {
  1593. var descriptor = props[i];
  1594. descriptor.enumerable = descriptor.enumerable || false;
  1595. descriptor.configurable = true;
  1596. if ("value" in descriptor) descriptor.writable = true;
  1597. Object.defineProperty(target, descriptor.key, descriptor);
  1598. }
  1599. }
  1600. function _createClass(Constructor, protoProps, staticProps) {
  1601. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  1602. if (staticProps) _defineProperties(Constructor, staticProps);
  1603. return Constructor;
  1604. }
  1605. function _inherits(subClass, superClass) {
  1606. if (typeof superClass !== "function" && superClass !== null) {
  1607. throw new TypeError("Super expression must either be null or a function");
  1608. }
  1609. subClass.prototype = Object.create(superClass && superClass.prototype, {
  1610. constructor: {
  1611. value: subClass,
  1612. writable: true,
  1613. configurable: true
  1614. }
  1615. });
  1616. if (superClass) _setPrototypeOf(subClass, superClass);
  1617. }
  1618. function _getPrototypeOf(o) {
  1619. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
  1620. return o.__proto__ || Object.getPrototypeOf(o);
  1621. };
  1622. return _getPrototypeOf(o);
  1623. }
  1624. function _setPrototypeOf(o, p) {
  1625. _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  1626. o.__proto__ = p;
  1627. return o;
  1628. };
  1629. return _setPrototypeOf(o, p);
  1630. }
  1631. function isNativeReflectConstruct() {
  1632. if (typeof Reflect === "undefined" || !Reflect.construct) return false;
  1633. if (Reflect.construct.sham) return false;
  1634. if (typeof Proxy === "function") return true;
  1635. try {
  1636. Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
  1637. return true;
  1638. } catch (e) {
  1639. return false;
  1640. }
  1641. }
  1642. function _construct(Parent, args, Class) {
  1643. if (isNativeReflectConstruct()) {
  1644. _construct = Reflect.construct;
  1645. } else {
  1646. _construct = function _construct(Parent, args, Class) {
  1647. var a = [null];
  1648. a.push.apply(a, args);
  1649. var Constructor = Function.bind.apply(Parent, a);
  1650. var instance = new Constructor();
  1651. if (Class) _setPrototypeOf(instance, Class.prototype);
  1652. return instance;
  1653. };
  1654. }
  1655. return _construct.apply(null, arguments);
  1656. }
  1657. function _isNativeFunction(fn) {
  1658. return Function.toString.call(fn).indexOf("[native code]") !== -1;
  1659. }
  1660. function _wrapNativeSuper(Class) {
  1661. var _cache = typeof Map === "function" ? new Map() : undefined;
  1662. _wrapNativeSuper = function _wrapNativeSuper(Class) {
  1663. if (Class === null || !_isNativeFunction(Class)) return Class;
  1664. if (typeof Class !== "function") {
  1665. throw new TypeError("Super expression must either be null or a function");
  1666. }
  1667. if (typeof _cache !== "undefined") {
  1668. if (_cache.has(Class)) return _cache.get(Class);
  1669. _cache.set(Class, Wrapper);
  1670. }
  1671. function Wrapper() {
  1672. return _construct(Class, arguments, _getPrototypeOf(this).constructor);
  1673. }
  1674. Wrapper.prototype = Object.create(Class.prototype, {
  1675. constructor: {
  1676. value: Wrapper,
  1677. enumerable: false,
  1678. writable: true,
  1679. configurable: true
  1680. }
  1681. });
  1682. return _setPrototypeOf(Wrapper, Class);
  1683. };
  1684. return _wrapNativeSuper(Class);
  1685. }
  1686. function _assertThisInitialized(self) {
  1687. if (self === void 0) {
  1688. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  1689. }
  1690. return self;
  1691. }
  1692. function _possibleConstructorReturn(self, call) {
  1693. if (call && (typeof call === "object" || typeof call === "function")) {
  1694. return call;
  1695. }
  1696. return _assertThisInitialized(self);
  1697. }
  1698. function _superPropBase(object, property) {
  1699. while (!Object.prototype.hasOwnProperty.call(object, property)) {
  1700. object = _getPrototypeOf(object);
  1701. if (object === null) break;
  1702. }
  1703. return object;
  1704. }
  1705. function _get(target, property, receiver) {
  1706. if (typeof Reflect !== "undefined" && Reflect.get) {
  1707. _get = Reflect.get;
  1708. } else {
  1709. _get = function _get(target, property, receiver) {
  1710. var base = _superPropBase(target, property);
  1711. if (!base) return;
  1712. var desc = Object.getOwnPropertyDescriptor(base, property);
  1713. if (desc.get) {
  1714. return desc.get.call(receiver);
  1715. }
  1716. return desc.value;
  1717. };
  1718. }
  1719. return _get(target, property, receiver || target);
  1720. }
  1721. function _slicedToArray(arr, i) {
  1722. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
  1723. }
  1724. function _toArray(arr) {
  1725. return _arrayWithHoles(arr) || _iterableToArray(arr) || _nonIterableRest();
  1726. }
  1727. function _toConsumableArray(arr) {
  1728. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
  1729. }
  1730. function _arrayWithoutHoles(arr) {
  1731. if (Array.isArray(arr)) {
  1732. for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
  1733. return arr2;
  1734. }
  1735. }
  1736. function _arrayWithHoles(arr) {
  1737. if (Array.isArray(arr)) return arr;
  1738. }
  1739. function _iterableToArray(iter) {
  1740. if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
  1741. }
  1742. function _iterableToArrayLimit(arr, i) {
  1743. var _arr = [];
  1744. var _n = true;
  1745. var _d = false;
  1746. var _e = undefined;
  1747. try {
  1748. for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
  1749. _arr.push(_s.value);
  1750. if (i && _arr.length === i) break;
  1751. }
  1752. } catch (err) {
  1753. _d = true;
  1754. _e = err;
  1755. } finally {
  1756. try {
  1757. if (!_n && _i["return"] != null) _i["return"]();
  1758. } finally {
  1759. if (_d) throw _e;
  1760. }
  1761. }
  1762. return _arr;
  1763. }
  1764. function _nonIterableSpread() {
  1765. throw new TypeError("Invalid attempt to spread non-iterable instance");
  1766. }
  1767. function _nonIterableRest() {
  1768. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  1769. }
  1770. function _toPrimitive(input, hint) {
  1771. if (typeof input !== "object" || input === null) return input;
  1772. var prim = input[Symbol.toPrimitive];
  1773. if (prim !== undefined) {
  1774. var res = prim.call(input, hint || "default");
  1775. if (typeof res !== "object") return res;
  1776. throw new TypeError("@@toPrimitive must return a primitive value.");
  1777. }
  1778. return (hint === "string" ? String : Number)(input);
  1779. }
  1780. function _toPropertyKey(arg) {
  1781. var key = _toPrimitive(arg, "string");
  1782. return typeof key === "symbol" ? key : String(key);
  1783. }
  1784. function _addElementPlacement(element, placements, silent) {
  1785. var keys = placements[element.placement];
  1786. if (!silent && keys.indexOf(element.key) !== -1) {
  1787. throw new TypeError("Duplicated element (" + element.key + ")");
  1788. }
  1789. keys.push(element.key);
  1790. }
  1791. function _fromElementDescriptor(element) {
  1792. var obj = {
  1793. kind: element.kind,
  1794. key: element.key,
  1795. placement: element.placement,
  1796. descriptor: element.descriptor
  1797. };
  1798. var desc = {
  1799. value: "Descriptor",
  1800. configurable: true
  1801. };
  1802. Object.defineProperty(obj, Symbol.toStringTag, desc);
  1803. if (element.kind === "field") obj.initializer = element.initializer;
  1804. return obj;
  1805. }
  1806. function _toElementDescriptors(elementObjects) {
  1807. if (elementObjects === undefined) return;
  1808. return _toArray(elementObjects).map(function (elementObject) {
  1809. var element = _toElementDescriptor(elementObject);
  1810. _disallowProperty(elementObject, "finisher", "An element descriptor");
  1811. _disallowProperty(elementObject, "extras", "An element descriptor");
  1812. return element;
  1813. });
  1814. }
  1815. function _toElementDescriptor(elementObject) {
  1816. var kind = String(elementObject.kind);
  1817. if (kind !== "method" && kind !== "field") {
  1818. throw new TypeError('An element descriptor\'s .kind property must be either "method" or' + ' "field", but a decorator created an element descriptor with' + ' .kind "' + kind + '"');
  1819. }
  1820. var key = _toPropertyKey(elementObject.key);
  1821. var placement = String(elementObject.placement);
  1822. if (placement !== "static" && placement !== "prototype" && placement !== "own") {
  1823. throw new TypeError('An element descriptor\'s .placement property must be one of "static",' + ' "prototype" or "own", but a decorator created an element descriptor' + ' with .placement "' + placement + '"');
  1824. }
  1825. var descriptor = elementObject.descriptor;
  1826. _disallowProperty(elementObject, "elements", "An element descriptor");
  1827. var element = {
  1828. kind: kind,
  1829. key: key,
  1830. placement: placement,
  1831. descriptor: Object.assign({}, descriptor)
  1832. };
  1833. if (kind !== "field") {
  1834. _disallowProperty(elementObject, "initializer", "A method descriptor");
  1835. } else {
  1836. _disallowProperty(descriptor, "get", "The property descriptor of a field descriptor");
  1837. _disallowProperty(descriptor, "set", "The property descriptor of a field descriptor");
  1838. _disallowProperty(descriptor, "value", "The property descriptor of a field descriptor");
  1839. element.initializer = elementObject.initializer;
  1840. }
  1841. return element;
  1842. }
  1843. function _toElementFinisherExtras(elementObject) {
  1844. var element = _toElementDescriptor(elementObject);
  1845. var finisher = _optionalCallableProperty(elementObject, "finisher");
  1846. var extras = _toElementDescriptors(elementObject.extras);
  1847. return {
  1848. element: element,
  1849. finisher: finisher,
  1850. extras: extras
  1851. };
  1852. }
  1853. function _fromClassDescriptor(elements) {
  1854. var obj = {
  1855. kind: "class",
  1856. elements: elements.map(_fromElementDescriptor)
  1857. };
  1858. var desc = {
  1859. value: "Descriptor",
  1860. configurable: true
  1861. };
  1862. Object.defineProperty(obj, Symbol.toStringTag, desc);
  1863. return obj;
  1864. }
  1865. function _toClassDescriptor(obj) {
  1866. var kind = String(obj.kind);
  1867. if (kind !== "class") {
  1868. throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator' + ' created a class descriptor with .kind "' + kind + '"');
  1869. }
  1870. _disallowProperty(obj, "key", "A class descriptor");
  1871. _disallowProperty(obj, "placement", "A class descriptor");
  1872. _disallowProperty(obj, "descriptor", "A class descriptor");
  1873. _disallowProperty(obj, "initializer", "A class descriptor");
  1874. _disallowProperty(obj, "extras", "A class descriptor");
  1875. var finisher = _optionalCallableProperty(obj, "finisher");
  1876. var elements = _toElementDescriptors(obj.elements);
  1877. return {
  1878. elements: elements,
  1879. finisher: finisher
  1880. };
  1881. }
  1882. function _disallowProperty(obj, name, objectType) {
  1883. if (obj[name] !== undefined) {
  1884. throw new TypeError(objectType + " can't have a ." + name + " property.");
  1885. }
  1886. }
  1887. function _optionalCallableProperty(obj, name) {
  1888. var value = obj[name];
  1889. if (value !== undefined && typeof value !== "function") {
  1890. throw new TypeError("Expected '" + name + "' to be a function");
  1891. }
  1892. return value;
  1893. }
  1894. /**
  1895. * @class
  1896. */
  1897. var LineByLine =
  1898. /*#__PURE__*/
  1899. function () {
  1900. function LineByLine(file, options) {
  1901. _classCallCheck(this, LineByLine);
  1902. options = options || {};
  1903. if (!options.readChunk) options.readChunk = 1024;
  1904. if (!options.newLineCharacter) {
  1905. options.newLineCharacter = 0x0a; //linux line ending
  1906. } else {
  1907. options.newLineCharacter = options.newLineCharacter.charCodeAt(0);
  1908. }
  1909. if (typeof file === 'number') {
  1910. this.fd = file;
  1911. } else {
  1912. this.fd = fs.openSync(file, 'r');
  1913. }
  1914. this.options = options;
  1915. this.newLineCharacter = options.newLineCharacter;
  1916. this.reset();
  1917. }
  1918. _createClass(LineByLine, [{
  1919. key: "_searchInBuffer",
  1920. value: function _searchInBuffer(buffer, hexNeedle) {
  1921. var found = -1;
  1922. for (var i = 0; i <= buffer.length; i++) {
  1923. var b_byte = buffer[i];
  1924. if (b_byte === hexNeedle) {
  1925. found = i;
  1926. break;
  1927. }
  1928. }
  1929. return found;
  1930. }
  1931. }, {
  1932. key: "reset",
  1933. value: function reset() {
  1934. this.eofReached = false;
  1935. this.linesCache = [];
  1936. this.fdPosition = 0;
  1937. }
  1938. }, {
  1939. key: "close",
  1940. value: function close() {
  1941. fs.closeSync(this.fd);
  1942. this.fd = null;
  1943. }
  1944. }, {
  1945. key: "_extractLines",
  1946. value: function _extractLines(buffer) {
  1947. var line;
  1948. var lines = [];
  1949. var bufferPosition = 0;
  1950. var lastNewLineBufferPosition = 0;
  1951. while (true) {
  1952. var bufferPositionValue = buffer[bufferPosition++];
  1953. if (bufferPositionValue === this.newLineCharacter) {
  1954. line = buffer.slice(lastNewLineBufferPosition, bufferPosition);
  1955. lines.push(line);
  1956. lastNewLineBufferPosition = bufferPosition;
  1957. } else if (!bufferPositionValue) {
  1958. break;
  1959. }
  1960. }
  1961. var leftovers = buffer.slice(lastNewLineBufferPosition, bufferPosition);
  1962. if (leftovers.length) {
  1963. lines.push(leftovers);
  1964. }
  1965. return lines;
  1966. }
  1967. }, {
  1968. key: "_readChunk",
  1969. value: function _readChunk(lineLeftovers) {
  1970. var totalBytesRead = 0;
  1971. var bytesRead;
  1972. var buffers = [];
  1973. do {
  1974. var readBuffer = new Buffer(this.options.readChunk);
  1975. bytesRead = fs.readSync(this.fd, readBuffer, 0, this.options.readChunk, this.fdPosition);
  1976. totalBytesRead = totalBytesRead + bytesRead;
  1977. this.fdPosition = this.fdPosition + bytesRead;
  1978. buffers.push(readBuffer);
  1979. } while (bytesRead && this._searchInBuffer(buffers[buffers.length - 1], this.options.newLineCharacter) === -1);
  1980. var bufferData = Buffer.concat(buffers);
  1981. if (bytesRead < this.options.readChunk) {
  1982. this.eofReached = true;
  1983. bufferData = bufferData.slice(0, totalBytesRead);
  1984. }
  1985. if (totalBytesRead) {
  1986. this.linesCache = this._extractLines(bufferData);
  1987. if (lineLeftovers) {
  1988. this.linesCache[0] = Buffer.concat([lineLeftovers, this.linesCache[0]]);
  1989. }
  1990. }
  1991. return totalBytesRead;
  1992. }
  1993. }, {
  1994. key: "next",
  1995. value: function next() {
  1996. if (!this.fd) return false;
  1997. var line = false;
  1998. if (this.eofReached && this.linesCache.length === 0) {
  1999. return line;
  2000. }
  2001. var bytesRead;
  2002. if (!this.linesCache.length) {
  2003. bytesRead = this._readChunk();
  2004. }
  2005. if (this.linesCache.length) {
  2006. line = this.linesCache.shift();
  2007. var lastLineCharacter = line[line.length - 1];
  2008. if (lastLineCharacter !== 0x0a) {
  2009. bytesRead = this._readChunk(line);
  2010. if (bytesRead) {
  2011. line = this.linesCache.shift();
  2012. }
  2013. }
  2014. }
  2015. if (this.eofReached && this.linesCache.length === 0) {
  2016. this.close();
  2017. }
  2018. if (line && line[line.length - 1] === this.newLineCharacter) {
  2019. line = line.slice(0, line.length - 1);
  2020. }
  2021. return line;
  2022. }
  2023. }]);
  2024. return LineByLine;
  2025. }();
  2026. var readlines = LineByLine;
  2027. var ConfigError =
  2028. /*#__PURE__*/
  2029. function (_Error) {
  2030. _inherits(ConfigError, _Error);
  2031. function ConfigError() {
  2032. _classCallCheck(this, ConfigError);
  2033. return _possibleConstructorReturn(this, _getPrototypeOf(ConfigError).apply(this, arguments));
  2034. }
  2035. return ConfigError;
  2036. }(_wrapNativeSuper(Error));
  2037. var DebugError =
  2038. /*#__PURE__*/
  2039. function (_Error2) {
  2040. _inherits(DebugError, _Error2);
  2041. function DebugError() {
  2042. _classCallCheck(this, DebugError);
  2043. return _possibleConstructorReturn(this, _getPrototypeOf(DebugError).apply(this, arguments));
  2044. }
  2045. return DebugError;
  2046. }(_wrapNativeSuper(Error));
  2047. var UndefinedParserError$1 =
  2048. /*#__PURE__*/
  2049. function (_Error3) {
  2050. _inherits(UndefinedParserError, _Error3);
  2051. function UndefinedParserError() {
  2052. _classCallCheck(this, UndefinedParserError);
  2053. return _possibleConstructorReturn(this, _getPrototypeOf(UndefinedParserError).apply(this, arguments));
  2054. }
  2055. return UndefinedParserError;
  2056. }(_wrapNativeSuper(Error));
  2057. var errors = {
  2058. ConfigError,
  2059. DebugError,
  2060. UndefinedParserError: UndefinedParserError$1
  2061. };
  2062. var semver = createCommonjsModule(function (module, exports) {
  2063. exports = module.exports = SemVer; // The debug function is excluded entirely from the minified version.
  2064. /* nomin */
  2065. var debug;
  2066. /* nomin */
  2067. if (typeof process === 'object' &&
  2068. /* nomin */
  2069. process.env &&
  2070. /* nomin */
  2071. process.env.NODE_DEBUG &&
  2072. /* nomin */
  2073. /\bsemver\b/i.test(process.env.NODE_DEBUG))
  2074. /* nomin */
  2075. debug = function debug() {
  2076. /* nomin */
  2077. var args = Array.prototype.slice.call(arguments, 0);
  2078. /* nomin */
  2079. args.unshift('SEMVER');
  2080. /* nomin */
  2081. console.log.apply(console, args);
  2082. /* nomin */
  2083. };
  2084. /* nomin */
  2085. else
  2086. /* nomin */
  2087. debug = function debug() {}; // Note: this is the semver.org version of the spec that it implements
  2088. // Not necessarily the package version of this code.
  2089. exports.SEMVER_SPEC_VERSION = '2.0.0';
  2090. var MAX_LENGTH = 256;
  2091. var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991; // The actual regexps go on exports.re
  2092. var re = exports.re = [];
  2093. var src = exports.src = [];
  2094. var R = 0; // The following Regular Expressions can be used for tokenizing,
  2095. // validating, and parsing SemVer version strings.
  2096. // ## Numeric Identifier
  2097. // A single `0`, or a non-zero digit followed by zero or more digits.
  2098. var NUMERICIDENTIFIER = R++;
  2099. src[NUMERICIDENTIFIER] = '0|[1-9]\\d*';
  2100. var NUMERICIDENTIFIERLOOSE = R++;
  2101. src[NUMERICIDENTIFIERLOOSE] = '[0-9]+'; // ## Non-numeric Identifier
  2102. // Zero or more digits, followed by a letter or hyphen, and then zero or
  2103. // more letters, digits, or hyphens.
  2104. var NONNUMERICIDENTIFIER = R++;
  2105. src[NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*'; // ## Main Version
  2106. // Three dot-separated numeric identifiers.
  2107. var MAINVERSION = R++;
  2108. src[MAINVERSION] = '(' + src[NUMERICIDENTIFIER] + ')\\.' + '(' + src[NUMERICIDENTIFIER] + ')\\.' + '(' + src[NUMERICIDENTIFIER] + ')';
  2109. var MAINVERSIONLOOSE = R++;
  2110. src[MAINVERSIONLOOSE] = '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' + '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' + '(' + src[NUMERICIDENTIFIERLOOSE] + ')'; // ## Pre-release Version Identifier
  2111. // A numeric identifier, or a non-numeric identifier.
  2112. var PRERELEASEIDENTIFIER = R++;
  2113. src[PRERELEASEIDENTIFIER] = '(?:' + src[NUMERICIDENTIFIER] + '|' + src[NONNUMERICIDENTIFIER] + ')';
  2114. var PRERELEASEIDENTIFIERLOOSE = R++;
  2115. src[PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[NUMERICIDENTIFIERLOOSE] + '|' + src[NONNUMERICIDENTIFIER] + ')'; // ## Pre-release Version
  2116. // Hyphen, followed by one or more dot-separated pre-release version
  2117. // identifiers.
  2118. var PRERELEASE = R++;
  2119. src[PRERELEASE] = '(?:-(' + src[PRERELEASEIDENTIFIER] + '(?:\\.' + src[PRERELEASEIDENTIFIER] + ')*))';
  2120. var PRERELEASELOOSE = R++;
  2121. src[PRERELEASELOOSE] = '(?:-?(' + src[PRERELEASEIDENTIFIERLOOSE] + '(?:\\.' + src[PRERELEASEIDENTIFIERLOOSE] + ')*))'; // ## Build Metadata Identifier
  2122. // Any combination of digits, letters, or hyphens.
  2123. var BUILDIDENTIFIER = R++;
  2124. src[BUILDIDENTIFIER] = '[0-9A-Za-z-]+'; // ## Build Metadata
  2125. // Plus sign, followed by one or more period-separated build metadata
  2126. // identifiers.
  2127. var BUILD = R++;
  2128. src[BUILD] = '(?:\\+(' + src[BUILDIDENTIFIER] + '(?:\\.' + src[BUILDIDENTIFIER] + ')*))'; // ## Full Version String
  2129. // A main version, followed optionally by a pre-release version and
  2130. // build metadata.
  2131. // Note that the only major, minor, patch, and pre-release sections of
  2132. // the version string are capturing groups. The build metadata is not a
  2133. // capturing group, because it should not ever be used in version
  2134. // comparison.
  2135. var FULL = R++;
  2136. var FULLPLAIN = 'v?' + src[MAINVERSION] + src[PRERELEASE] + '?' + src[BUILD] + '?';
  2137. src[FULL] = '^' + FULLPLAIN + '$'; // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
  2138. // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
  2139. // common in the npm registry.
  2140. var LOOSEPLAIN = '[v=\\s]*' + src[MAINVERSIONLOOSE] + src[PRERELEASELOOSE] + '?' + src[BUILD] + '?';
  2141. var LOOSE = R++;
  2142. src[LOOSE] = '^' + LOOSEPLAIN + '$';
  2143. var GTLT = R++;
  2144. src[GTLT] = '((?:<|>)?=?)'; // Something like "2.*" or "1.2.x".
  2145. // Note that "x.x" is a valid xRange identifer, meaning "any version"
  2146. // Only the first item is strictly required.
  2147. var XRANGEIDENTIFIERLOOSE = R++;
  2148. src[XRANGEIDENTIFIERLOOSE] = src[NUMERICIDENTIFIERLOOSE] + '|x|X|\\*';
  2149. var XRANGEIDENTIFIER = R++;
  2150. src[XRANGEIDENTIFIER] = src[NUMERICIDENTIFIER] + '|x|X|\\*';
  2151. var XRANGEPLAIN = R++;
  2152. src[XRANGEPLAIN] = '[v=\\s]*(' + src[XRANGEIDENTIFIER] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' + '(?:' + src[PRERELEASE] + ')?' + src[BUILD] + '?' + ')?)?';
  2153. var XRANGEPLAINLOOSE = R++;
  2154. src[XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:' + src[PRERELEASELOOSE] + ')?' + src[BUILD] + '?' + ')?)?';
  2155. var XRANGE = R++;
  2156. src[XRANGE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAIN] + '$';
  2157. var XRANGELOOSE = R++;
  2158. src[XRANGELOOSE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAINLOOSE] + '$'; // Tilde ranges.
  2159. // Meaning is "reasonably at or greater than"
  2160. var LONETILDE = R++;
  2161. src[LONETILDE] = '(?:~>?)';
  2162. var TILDETRIM = R++;
  2163. src[TILDETRIM] = '(\\s*)' + src[LONETILDE] + '\\s+';
  2164. re[TILDETRIM] = new RegExp(src[TILDETRIM], 'g');
  2165. var tildeTrimReplace = '$1~';
  2166. var TILDE = R++;
  2167. src[TILDE] = '^' + src[LONETILDE] + src[XRANGEPLAIN] + '$';
  2168. var TILDELOOSE = R++;
  2169. src[TILDELOOSE] = '^' + src[LONETILDE] + src[XRANGEPLAINLOOSE] + '$'; // Caret ranges.
  2170. // Meaning is "at least and backwards compatible with"
  2171. var LONECARET = R++;
  2172. src[LONECARET] = '(?:\\^)';
  2173. var CARETTRIM = R++;
  2174. src[CARETTRIM] = '(\\s*)' + src[LONECARET] + '\\s+';
  2175. re[CARETTRIM] = new RegExp(src[CARETTRIM], 'g');
  2176. var caretTrimReplace = '$1^';
  2177. var CARET = R++;
  2178. src[CARET] = '^' + src[LONECARET] + src[XRANGEPLAIN] + '$';
  2179. var CARETLOOSE = R++;
  2180. src[CARETLOOSE] = '^' + src[LONECARET] + src[XRANGEPLAINLOOSE] + '$'; // A simple gt/lt/eq thing, or just "" to indicate "any version"
  2181. var COMPARATORLOOSE = R++;
  2182. src[COMPARATORLOOSE] = '^' + src[GTLT] + '\\s*(' + LOOSEPLAIN + ')$|^$';
  2183. var COMPARATOR = R++;
  2184. src[COMPARATOR] = '^' + src[GTLT] + '\\s*(' + FULLPLAIN + ')$|^$'; // An expression to strip any whitespace between the gtlt and the thing
  2185. // it modifies, so that `> 1.2.3` ==> `>1.2.3`
  2186. var COMPARATORTRIM = R++;
  2187. src[COMPARATORTRIM] = '(\\s*)' + src[GTLT] + '\\s*(' + LOOSEPLAIN + '|' + src[XRANGEPLAIN] + ')'; // this one has to use the /g flag
  2188. re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], 'g');
  2189. var comparatorTrimReplace = '$1$2$3'; // Something like `1.2.3 - 1.2.4`
  2190. // Note that these all use the loose form, because they'll be
  2191. // checked against either the strict or loose comparator form
  2192. // later.
  2193. var HYPHENRANGE = R++;
  2194. src[HYPHENRANGE] = '^\\s*(' + src[XRANGEPLAIN] + ')' + '\\s+-\\s+' + '(' + src[XRANGEPLAIN] + ')' + '\\s*$';
  2195. var HYPHENRANGELOOSE = R++;
  2196. src[HYPHENRANGELOOSE] = '^\\s*(' + src[XRANGEPLAINLOOSE] + ')' + '\\s+-\\s+' + '(' + src[XRANGEPLAINLOOSE] + ')' + '\\s*$'; // Star ranges basically just allow anything at all.
  2197. var STAR = R++;
  2198. src[STAR] = '(<|>)?=?\\s*\\*'; // Compile to actual regexp objects.
  2199. // All are flag-free, unless they were created above with a flag.
  2200. for (var i = 0; i < R; i++) {
  2201. debug(i, src[i]);
  2202. if (!re[i]) re[i] = new RegExp(src[i]);
  2203. }
  2204. exports.parse = parse;
  2205. function parse(version, loose) {
  2206. if (version instanceof SemVer) return version;
  2207. if (typeof version !== 'string') return null;
  2208. if (version.length > MAX_LENGTH) return null;
  2209. var r = loose ? re[LOOSE] : re[FULL];
  2210. if (!r.test(version)) return null;
  2211. try {
  2212. return new SemVer(version, loose);
  2213. } catch (er) {
  2214. return null;
  2215. }
  2216. }
  2217. exports.valid = valid;
  2218. function valid(version, loose) {
  2219. var v = parse(version, loose);
  2220. return v ? v.version : null;
  2221. }
  2222. exports.clean = clean;
  2223. function clean(version, loose) {
  2224. var s = parse(version.trim().replace(/^[=v]+/, ''), loose);
  2225. return s ? s.version : null;
  2226. }
  2227. exports.SemVer = SemVer;
  2228. function SemVer(version, loose) {
  2229. if (version instanceof SemVer) {
  2230. if (version.loose === loose) return version;else version = version.version;
  2231. } else if (typeof version !== 'string') {
  2232. throw new TypeError('Invalid Version: ' + version);
  2233. }
  2234. if (version.length > MAX_LENGTH) throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters');
  2235. if (!(this instanceof SemVer)) return new SemVer(version, loose);
  2236. debug('SemVer', version, loose);
  2237. this.loose = loose;
  2238. var m = version.trim().match(loose ? re[LOOSE] : re[FULL]);
  2239. if (!m) throw new TypeError('Invalid Version: ' + version);
  2240. this.raw = version; // these are actually numbers
  2241. this.major = +m[1];
  2242. this.minor = +m[2];
  2243. this.patch = +m[3];
  2244. if (this.major > MAX_SAFE_INTEGER || this.major < 0) throw new TypeError('Invalid major version');
  2245. if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) throw new TypeError('Invalid minor version');
  2246. if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) throw new TypeError('Invalid patch version'); // numberify any prerelease numeric ids
  2247. if (!m[4]) this.prerelease = [];else this.prerelease = m[4].split('.').map(function (id) {
  2248. if (/^[0-9]+$/.test(id)) {
  2249. var num = +id;
  2250. if (num >= 0 && num < MAX_SAFE_INTEGER) return num;
  2251. }
  2252. return id;
  2253. });
  2254. this.build = m[5] ? m[5].split('.') : [];
  2255. this.format();
  2256. }
  2257. SemVer.prototype.format = function () {
  2258. this.version = this.major + '.' + this.minor + '.' + this.patch;
  2259. if (this.prerelease.length) this.version += '-' + this.prerelease.join('.');
  2260. return this.version;
  2261. };
  2262. SemVer.prototype.toString = function () {
  2263. return this.version;
  2264. };
  2265. SemVer.prototype.compare = function (other) {
  2266. debug('SemVer.compare', this.version, this.loose, other);
  2267. if (!(other instanceof SemVer)) other = new SemVer(other, this.loose);
  2268. return this.compareMain(other) || this.comparePre(other);
  2269. };
  2270. SemVer.prototype.compareMain = function (other) {
  2271. if (!(other instanceof SemVer)) other = new SemVer(other, this.loose);
  2272. return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
  2273. };
  2274. SemVer.prototype.comparePre = function (other) {
  2275. if (!(other instanceof SemVer)) other = new SemVer(other, this.loose); // NOT having a prerelease is > having one
  2276. if (this.prerelease.length && !other.prerelease.length) return -1;else if (!this.prerelease.length && other.prerelease.length) return 1;else if (!this.prerelease.length && !other.prerelease.length) return 0;
  2277. var i = 0;
  2278. do {
  2279. var a = this.prerelease[i];
  2280. var b = other.prerelease[i];
  2281. debug('prerelease compare', i, a, b);
  2282. if (a === undefined && b === undefined) return 0;else if (b === undefined) return 1;else if (a === undefined) return -1;else if (a === b) continue;else return compareIdentifiers(a, b);
  2283. } while (++i);
  2284. }; // preminor will bump the version up to the next minor release, and immediately
  2285. // down to pre-release. premajor and prepatch work the same way.
  2286. SemVer.prototype.inc = function (release, identifier) {
  2287. switch (release) {
  2288. case 'premajor':
  2289. this.prerelease.length = 0;
  2290. this.patch = 0;
  2291. this.minor = 0;
  2292. this.major++;
  2293. this.inc('pre', identifier);
  2294. break;
  2295. case 'preminor':
  2296. this.prerelease.length = 0;
  2297. this.patch = 0;
  2298. this.minor++;
  2299. this.inc('pre', identifier);
  2300. break;
  2301. case 'prepatch':
  2302. // If this is already a prerelease, it will bump to the next version
  2303. // drop any prereleases that might already exist, since they are not
  2304. // relevant at this point.
  2305. this.prerelease.length = 0;
  2306. this.inc('patch', identifier);
  2307. this.inc('pre', identifier);
  2308. break;
  2309. // If the input is a non-prerelease version, this acts the same as
  2310. // prepatch.
  2311. case 'prerelease':
  2312. if (this.prerelease.length === 0) this.inc('patch', identifier);
  2313. this.inc('pre', identifier);
  2314. break;
  2315. case 'major':
  2316. // If this is a pre-major version, bump up to the same major version.
  2317. // Otherwise increment major.
  2318. // 1.0.0-5 bumps to 1.0.0
  2319. // 1.1.0 bumps to 2.0.0
  2320. if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) this.major++;
  2321. this.minor = 0;
  2322. this.patch = 0;
  2323. this.prerelease = [];
  2324. break;
  2325. case 'minor':
  2326. // If this is a pre-minor version, bump up to the same minor version.
  2327. // Otherwise increment minor.
  2328. // 1.2.0-5 bumps to 1.2.0
  2329. // 1.2.1 bumps to 1.3.0
  2330. if (this.patch !== 0 || this.prerelease.length === 0) this.minor++;
  2331. this.patch = 0;
  2332. this.prerelease = [];
  2333. break;
  2334. case 'patch':
  2335. // If this is not a pre-release version, it will increment the patch.
  2336. // If it is a pre-release it will bump up to the same patch version.
  2337. // 1.2.0-5 patches to 1.2.0
  2338. // 1.2.0 patches to 1.2.1
  2339. if (this.prerelease.length === 0) this.patch++;
  2340. this.prerelease = [];
  2341. break;
  2342. // This probably shouldn't be used publicly.
  2343. // 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
  2344. case 'pre':
  2345. if (this.prerelease.length === 0) this.prerelease = [0];else {
  2346. var i = this.prerelease.length;
  2347. while (--i >= 0) {
  2348. if (typeof this.prerelease[i] === 'number') {
  2349. this.prerelease[i]++;
  2350. i = -2;
  2351. }
  2352. }
  2353. if (i === -1) // didn't increment anything
  2354. this.prerelease.push(0);
  2355. }
  2356. if (identifier) {
  2357. // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
  2358. // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
  2359. if (this.prerelease[0] === identifier) {
  2360. if (isNaN(this.prerelease[1])) this.prerelease = [identifier, 0];
  2361. } else this.prerelease = [identifier, 0];
  2362. }
  2363. break;
  2364. default:
  2365. throw new Error('invalid increment argument: ' + release);
  2366. }
  2367. this.format();
  2368. this.raw = this.version;
  2369. return this;
  2370. };
  2371. exports.inc = inc;
  2372. function inc(version, release, loose, identifier) {
  2373. if (typeof loose === 'string') {
  2374. identifier = loose;
  2375. loose = undefined;
  2376. }
  2377. try {
  2378. return new SemVer(version, loose).inc(release, identifier).version;
  2379. } catch (er) {
  2380. return null;
  2381. }
  2382. }
  2383. exports.diff = diff;
  2384. function diff(version1, version2) {
  2385. if (eq(version1, version2)) {
  2386. return null;
  2387. } else {
  2388. var v1 = parse(version1);
  2389. var v2 = parse(version2);
  2390. if (v1.prerelease.length || v2.prerelease.length) {
  2391. for (var key in v1) {
  2392. if (key === 'major' || key === 'minor' || key === 'patch') {
  2393. if (v1[key] !== v2[key]) {
  2394. return 'pre' + key;
  2395. }
  2396. }
  2397. }
  2398. return 'prerelease';
  2399. }
  2400. for (var key in v1) {
  2401. if (key === 'major' || key === 'minor' || key === 'patch') {
  2402. if (v1[key] !== v2[key]) {
  2403. return key;
  2404. }
  2405. }
  2406. }
  2407. }
  2408. }
  2409. exports.compareIdentifiers = compareIdentifiers;
  2410. var numeric = /^[0-9]+$/;
  2411. function compareIdentifiers(a, b) {
  2412. var anum = numeric.test(a);
  2413. var bnum = numeric.test(b);
  2414. if (anum && bnum) {
  2415. a = +a;
  2416. b = +b;
  2417. }
  2418. return anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : a > b ? 1 : 0;
  2419. }
  2420. exports.rcompareIdentifiers = rcompareIdentifiers;
  2421. function rcompareIdentifiers(a, b) {
  2422. return compareIdentifiers(b, a);
  2423. }
  2424. exports.major = major;
  2425. function major(a, loose) {
  2426. return new SemVer(a, loose).major;
  2427. }
  2428. exports.minor = minor;
  2429. function minor(a, loose) {
  2430. return new SemVer(a, loose).minor;
  2431. }
  2432. exports.patch = patch;
  2433. function patch(a, loose) {
  2434. return new SemVer(a, loose).patch;
  2435. }
  2436. exports.compare = compare;
  2437. function compare(a, b, loose) {
  2438. return new SemVer(a, loose).compare(new SemVer(b, loose));
  2439. }
  2440. exports.compareLoose = compareLoose;
  2441. function compareLoose(a, b) {
  2442. return compare(a, b, true);
  2443. }
  2444. exports.rcompare = rcompare;
  2445. function rcompare(a, b, loose) {
  2446. return compare(b, a, loose);
  2447. }
  2448. exports.sort = sort;
  2449. function sort(list, loose) {
  2450. return list.sort(function (a, b) {
  2451. return exports.compare(a, b, loose);
  2452. });
  2453. }
  2454. exports.rsort = rsort;
  2455. function rsort(list, loose) {
  2456. return list.sort(function (a, b) {
  2457. return exports.rcompare(a, b, loose);
  2458. });
  2459. }
  2460. exports.gt = gt;
  2461. function gt(a, b, loose) {
  2462. return compare(a, b, loose) > 0;
  2463. }
  2464. exports.lt = lt;
  2465. function lt(a, b, loose) {
  2466. return compare(a, b, loose) < 0;
  2467. }
  2468. exports.eq = eq;
  2469. function eq(a, b, loose) {
  2470. return compare(a, b, loose) === 0;
  2471. }
  2472. exports.neq = neq;
  2473. function neq(a, b, loose) {
  2474. return compare(a, b, loose) !== 0;
  2475. }
  2476. exports.gte = gte;
  2477. function gte(a, b, loose) {
  2478. return compare(a, b, loose) >= 0;
  2479. }
  2480. exports.lte = lte;
  2481. function lte(a, b, loose) {
  2482. return compare(a, b, loose) <= 0;
  2483. }
  2484. exports.cmp = cmp;
  2485. function cmp(a, op, b, loose) {
  2486. var ret;
  2487. switch (op) {
  2488. case '===':
  2489. if (typeof a === 'object') a = a.version;
  2490. if (typeof b === 'object') b = b.version;
  2491. ret = a === b;
  2492. break;
  2493. case '!==':
  2494. if (typeof a === 'object') a = a.version;
  2495. if (typeof b === 'object') b = b.version;
  2496. ret = a !== b;
  2497. break;
  2498. case '':
  2499. case '=':
  2500. case '==':
  2501. ret = eq(a, b, loose);
  2502. break;
  2503. case '!=':
  2504. ret = neq(a, b, loose);
  2505. break;
  2506. case '>':
  2507. ret = gt(a, b, loose);
  2508. break;
  2509. case '>=':
  2510. ret = gte(a, b, loose);
  2511. break;
  2512. case '<':
  2513. ret = lt(a, b, loose);
  2514. break;
  2515. case '<=':
  2516. ret = lte(a, b, loose);
  2517. break;
  2518. default:
  2519. throw new TypeError('Invalid operator: ' + op);
  2520. }
  2521. return ret;
  2522. }
  2523. exports.Comparator = Comparator;
  2524. function Comparator(comp, loose) {
  2525. if (comp instanceof Comparator) {
  2526. if (comp.loose === loose) return comp;else comp = comp.value;
  2527. }
  2528. if (!(this instanceof Comparator)) return new Comparator(comp, loose);
  2529. debug('comparator', comp, loose);
  2530. this.loose = loose;
  2531. this.parse(comp);
  2532. if (this.semver === ANY) this.value = '';else this.value = this.operator + this.semver.version;
  2533. debug('comp', this);
  2534. }
  2535. var ANY = {};
  2536. Comparator.prototype.parse = function (comp) {
  2537. var r = this.loose ? re[COMPARATORLOOSE] : re[COMPARATOR];
  2538. var m = comp.match(r);
  2539. if (!m) throw new TypeError('Invalid comparator: ' + comp);
  2540. this.operator = m[1];
  2541. if (this.operator === '=') this.operator = ''; // if it literally is just '>' or '' then allow anything.
  2542. if (!m[2]) this.semver = ANY;else this.semver = new SemVer(m[2], this.loose);
  2543. };
  2544. Comparator.prototype.toString = function () {
  2545. return this.value;
  2546. };
  2547. Comparator.prototype.test = function (version) {
  2548. debug('Comparator.test', version, this.loose);
  2549. if (this.semver === ANY) return true;
  2550. if (typeof version === 'string') version = new SemVer(version, this.loose);
  2551. return cmp(version, this.operator, this.semver, this.loose);
  2552. };
  2553. Comparator.prototype.intersects = function (comp, loose) {
  2554. if (!(comp instanceof Comparator)) {
  2555. throw new TypeError('a Comparator is required');
  2556. }
  2557. var rangeTmp;
  2558. if (this.operator === '') {
  2559. rangeTmp = new Range(comp.value, loose);
  2560. return satisfies(this.value, rangeTmp, loose);
  2561. } else if (comp.operator === '') {
  2562. rangeTmp = new Range(this.value, loose);
  2563. return satisfies(comp.semver, rangeTmp, loose);
  2564. }
  2565. var sameDirectionIncreasing = (this.operator === '>=' || this.operator === '>') && (comp.operator === '>=' || comp.operator === '>');
  2566. var sameDirectionDecreasing = (this.operator === '<=' || this.operator === '<') && (comp.operator === '<=' || comp.operator === '<');
  2567. var sameSemVer = this.semver.version === comp.semver.version;
  2568. var differentDirectionsInclusive = (this.operator === '>=' || this.operator === '<=') && (comp.operator === '>=' || comp.operator === '<=');
  2569. var oppositeDirectionsLessThan = cmp(this.semver, '<', comp.semver, loose) && (this.operator === '>=' || this.operator === '>') && (comp.operator === '<=' || comp.operator === '<');
  2570. var oppositeDirectionsGreaterThan = cmp(this.semver, '>', comp.semver, loose) && (this.operator === '<=' || this.operator === '<') && (comp.operator === '>=' || comp.operator === '>');
  2571. return sameDirectionIncreasing || sameDirectionDecreasing || sameSemVer && differentDirectionsInclusive || oppositeDirectionsLessThan || oppositeDirectionsGreaterThan;
  2572. };
  2573. exports.Range = Range;
  2574. function Range(range, loose) {
  2575. if (range instanceof Range) {
  2576. if (range.loose === loose) {
  2577. return range;
  2578. } else {
  2579. return new Range(range.raw, loose);
  2580. }
  2581. }
  2582. if (range instanceof Comparator) {
  2583. return new Range(range.value, loose);
  2584. }
  2585. if (!(this instanceof Range)) return new Range(range, loose);
  2586. this.loose = loose; // First, split based on boolean or ||
  2587. this.raw = range;
  2588. this.set = range.split(/\s*\|\|\s*/).map(function (range) {
  2589. return this.parseRange(range.trim());
  2590. }, this).filter(function (c) {
  2591. // throw out any that are not relevant for whatever reason
  2592. return c.length;
  2593. });
  2594. if (!this.set.length) {
  2595. throw new TypeError('Invalid SemVer Range: ' + range);
  2596. }
  2597. this.format();
  2598. }
  2599. Range.prototype.format = function () {
  2600. this.range = this.set.map(function (comps) {
  2601. return comps.join(' ').trim();
  2602. }).join('||').trim();
  2603. return this.range;
  2604. };
  2605. Range.prototype.toString = function () {
  2606. return this.range;
  2607. };
  2608. Range.prototype.parseRange = function (range) {
  2609. var loose = this.loose;
  2610. range = range.trim();
  2611. debug('range', range, loose); // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
  2612. var hr = loose ? re[HYPHENRANGELOOSE] : re[HYPHENRANGE];
  2613. range = range.replace(hr, hyphenReplace);
  2614. debug('hyphen replace', range); // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
  2615. range = range.replace(re[COMPARATORTRIM], comparatorTrimReplace);
  2616. debug('comparator trim', range, re[COMPARATORTRIM]); // `~ 1.2.3` => `~1.2.3`
  2617. range = range.replace(re[TILDETRIM], tildeTrimReplace); // `^ 1.2.3` => `^1.2.3`
  2618. range = range.replace(re[CARETTRIM], caretTrimReplace); // normalize spaces
  2619. range = range.split(/\s+/).join(' '); // At this point, the range is completely trimmed and
  2620. // ready to be split into comparators.
  2621. var compRe = loose ? re[COMPARATORLOOSE] : re[COMPARATOR];
  2622. var set = range.split(' ').map(function (comp) {
  2623. return parseComparator(comp, loose);
  2624. }).join(' ').split(/\s+/);
  2625. if (this.loose) {
  2626. // in loose mode, throw out any that are not valid comparators
  2627. set = set.filter(function (comp) {
  2628. return !!comp.match(compRe);
  2629. });
  2630. }
  2631. set = set.map(function (comp) {
  2632. return new Comparator(comp, loose);
  2633. });
  2634. return set;
  2635. };
  2636. Range.prototype.intersects = function (range, loose) {
  2637. if (!(range instanceof Range)) {
  2638. throw new TypeError('a Range is required');
  2639. }
  2640. return this.set.some(function (thisComparators) {
  2641. return thisComparators.every(function (thisComparator) {
  2642. return range.set.some(function (rangeComparators) {
  2643. return rangeComparators.every(function (rangeComparator) {
  2644. return thisComparator.intersects(rangeComparator, loose);
  2645. });
  2646. });
  2647. });
  2648. });
  2649. }; // Mostly just for testing and legacy API reasons
  2650. exports.toComparators = toComparators;
  2651. function toComparators(range, loose) {
  2652. return new Range(range, loose).set.map(function (comp) {
  2653. return comp.map(function (c) {
  2654. return c.value;
  2655. }).join(' ').trim().split(' ');
  2656. });
  2657. } // comprised of xranges, tildes, stars, and gtlt's at this point.
  2658. // already replaced the hyphen ranges
  2659. // turn into a set of JUST comparators.
  2660. function parseComparator(comp, loose) {
  2661. debug('comp', comp);
  2662. comp = replaceCarets(comp, loose);
  2663. debug('caret', comp);
  2664. comp = replaceTildes(comp, loose);
  2665. debug('tildes', comp);
  2666. comp = replaceXRanges(comp, loose);
  2667. debug('xrange', comp);
  2668. comp = replaceStars(comp, loose);
  2669. debug('stars', comp);
  2670. return comp;
  2671. }
  2672. function isX(id) {
  2673. return !id || id.toLowerCase() === 'x' || id === '*';
  2674. } // ~, ~> --> * (any, kinda silly)
  2675. // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
  2676. // ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
  2677. // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
  2678. // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
  2679. // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
  2680. function replaceTildes(comp, loose) {
  2681. return comp.trim().split(/\s+/).map(function (comp) {
  2682. return replaceTilde(comp, loose);
  2683. }).join(' ');
  2684. }
  2685. function replaceTilde(comp, loose) {
  2686. var r = loose ? re[TILDELOOSE] : re[TILDE];
  2687. return comp.replace(r, function (_, M, m, p, pr) {
  2688. debug('tilde', comp, _, M, m, p, pr);
  2689. var ret;
  2690. if (isX(M)) ret = '';else if (isX(m)) ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';else if (isX(p)) // ~1.2 == >=1.2.0 <1.3.0
  2691. ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';else if (pr) {
  2692. debug('replaceTilde pr', pr);
  2693. if (pr.charAt(0) !== '-') pr = '-' + pr;
  2694. ret = '>=' + M + '.' + m + '.' + p + pr + ' <' + M + '.' + (+m + 1) + '.0';
  2695. } else // ~1.2.3 == >=1.2.3 <1.3.0
  2696. ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + (+m + 1) + '.0';
  2697. debug('tilde return', ret);
  2698. return ret;
  2699. });
  2700. } // ^ --> * (any, kinda silly)
  2701. // ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0
  2702. // ^2.0, ^2.0.x --> >=2.0.0 <3.0.0
  2703. // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
  2704. // ^1.2.3 --> >=1.2.3 <2.0.0
  2705. // ^1.2.0 --> >=1.2.0 <2.0.0
  2706. function replaceCarets(comp, loose) {
  2707. return comp.trim().split(/\s+/).map(function (comp) {
  2708. return replaceCaret(comp, loose);
  2709. }).join(' ');
  2710. }
  2711. function replaceCaret(comp, loose) {
  2712. debug('caret', comp, loose);
  2713. var r = loose ? re[CARETLOOSE] : re[CARET];
  2714. return comp.replace(r, function (_, M, m, p, pr) {
  2715. debug('caret', comp, _, M, m, p, pr);
  2716. var ret;
  2717. if (isX(M)) ret = '';else if (isX(m)) ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';else if (isX(p)) {
  2718. if (M === '0') ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';else ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0';
  2719. } else if (pr) {
  2720. debug('replaceCaret pr', pr);
  2721. if (pr.charAt(0) !== '-') pr = '-' + pr;
  2722. if (M === '0') {
  2723. if (m === '0') ret = '>=' + M + '.' + m + '.' + p + pr + ' <' + M + '.' + m + '.' + (+p + 1);else ret = '>=' + M + '.' + m + '.' + p + pr + ' <' + M + '.' + (+m + 1) + '.0';
  2724. } else ret = '>=' + M + '.' + m + '.' + p + pr + ' <' + (+M + 1) + '.0.0';
  2725. } else {
  2726. debug('no pr');
  2727. if (M === '0') {
  2728. if (m === '0') ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + m + '.' + (+p + 1);else ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + (+m + 1) + '.0';
  2729. } else ret = '>=' + M + '.' + m + '.' + p + ' <' + (+M + 1) + '.0.0';
  2730. }
  2731. debug('caret return', ret);
  2732. return ret;
  2733. });
  2734. }
  2735. function replaceXRanges(comp, loose) {
  2736. debug('replaceXRanges', comp, loose);
  2737. return comp.split(/\s+/).map(function (comp) {
  2738. return replaceXRange(comp, loose);
  2739. }).join(' ');
  2740. }
  2741. function replaceXRange(comp, loose) {
  2742. comp = comp.trim();
  2743. var r = loose ? re[XRANGELOOSE] : re[XRANGE];
  2744. return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
  2745. debug('xRange', comp, ret, gtlt, M, m, p, pr);
  2746. var xM = isX(M);
  2747. var xm = xM || isX(m);
  2748. var xp = xm || isX(p);
  2749. var anyX = xp;
  2750. if (gtlt === '=' && anyX) gtlt = '';
  2751. if (xM) {
  2752. if (gtlt === '>' || gtlt === '<') {
  2753. // nothing is allowed
  2754. ret = '<0.0.0';
  2755. } else {
  2756. // nothing is forbidden
  2757. ret = '*';
  2758. }
  2759. } else if (gtlt && anyX) {
  2760. // replace X with 0
  2761. if (xm) m = 0;
  2762. if (xp) p = 0;
  2763. if (gtlt === '>') {
  2764. // >1 => >=2.0.0
  2765. // >1.2 => >=1.3.0
  2766. // >1.2.3 => >= 1.2.4
  2767. gtlt = '>=';
  2768. if (xm) {
  2769. M = +M + 1;
  2770. m = 0;
  2771. p = 0;
  2772. } else if (xp) {
  2773. m = +m + 1;
  2774. p = 0;
  2775. }
  2776. } else if (gtlt === '<=') {
  2777. // <=0.7.x is actually <0.8.0, since any 0.7.x should
  2778. // pass. Similarly, <=7.x is actually <8.0.0, etc.
  2779. gtlt = '<';
  2780. if (xm) M = +M + 1;else m = +m + 1;
  2781. }
  2782. ret = gtlt + M + '.' + m + '.' + p;
  2783. } else if (xm) {
  2784. ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
  2785. } else if (xp) {
  2786. ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
  2787. }
  2788. debug('xRange return', ret);
  2789. return ret;
  2790. });
  2791. } // Because * is AND-ed with everything else in the comparator,
  2792. // and '' means "any version", just remove the *s entirely.
  2793. function replaceStars(comp, loose) {
  2794. debug('replaceStars', comp, loose); // Looseness is ignored here. star is always as loose as it gets!
  2795. return comp.trim().replace(re[STAR], '');
  2796. } // This function is passed to string.replace(re[HYPHENRANGE])
  2797. // M, m, patch, prerelease, build
  2798. // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
  2799. // 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
  2800. // 1.2 - 3.4 => >=1.2.0 <3.5.0
  2801. function hyphenReplace($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) {
  2802. if (isX(fM)) from = '';else if (isX(fm)) from = '>=' + fM + '.0.0';else if (isX(fp)) from = '>=' + fM + '.' + fm + '.0';else from = '>=' + from;
  2803. if (isX(tM)) to = '';else if (isX(tm)) to = '<' + (+tM + 1) + '.0.0';else if (isX(tp)) to = '<' + tM + '.' + (+tm + 1) + '.0';else if (tpr) to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr;else to = '<=' + to;
  2804. return (from + ' ' + to).trim();
  2805. } // if ANY of the sets match ALL of its comparators, then pass
  2806. Range.prototype.test = function (version) {
  2807. if (!version) return false;
  2808. if (typeof version === 'string') version = new SemVer(version, this.loose);
  2809. for (var i = 0; i < this.set.length; i++) {
  2810. if (testSet(this.set[i], version)) return true;
  2811. }
  2812. return false;
  2813. };
  2814. function testSet(set, version) {
  2815. for (var i = 0; i < set.length; i++) {
  2816. if (!set[i].test(version)) return false;
  2817. }
  2818. if (version.prerelease.length) {
  2819. // Find the set of versions that are allowed to have prereleases
  2820. // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
  2821. // That should allow `1.2.3-pr.2` to pass.
  2822. // However, `1.2.4-alpha.notready` should NOT be allowed,
  2823. // even though it's within the range set by the comparators.
  2824. for (var i = 0; i < set.length; i++) {
  2825. debug(set[i].semver);
  2826. if (set[i].semver === ANY) continue;
  2827. if (set[i].semver.prerelease.length > 0) {
  2828. var allowed = set[i].semver;
  2829. if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) return true;
  2830. }
  2831. } // Version has a -pre, but it's not one of the ones we like.
  2832. return false;
  2833. }
  2834. return true;
  2835. }
  2836. exports.satisfies = satisfies;
  2837. function satisfies(version, range, loose) {
  2838. try {
  2839. range = new Range(range, loose);
  2840. } catch (er) {
  2841. return false;
  2842. }
  2843. return range.test(version);
  2844. }
  2845. exports.maxSatisfying = maxSatisfying;
  2846. function maxSatisfying(versions, range, loose) {
  2847. var max = null;
  2848. var maxSV = null;
  2849. try {
  2850. var rangeObj = new Range(range, loose);
  2851. } catch (er) {
  2852. return null;
  2853. }
  2854. versions.forEach(function (v) {
  2855. if (rangeObj.test(v)) {
  2856. // satisfies(v, range, loose)
  2857. if (!max || maxSV.compare(v) === -1) {
  2858. // compare(max, v, true)
  2859. max = v;
  2860. maxSV = new SemVer(max, loose);
  2861. }
  2862. }
  2863. });
  2864. return max;
  2865. }
  2866. exports.minSatisfying = minSatisfying;
  2867. function minSatisfying(versions, range, loose) {
  2868. var min = null;
  2869. var minSV = null;
  2870. try {
  2871. var rangeObj = new Range(range, loose);
  2872. } catch (er) {
  2873. return null;
  2874. }
  2875. versions.forEach(function (v) {
  2876. if (rangeObj.test(v)) {
  2877. // satisfies(v, range, loose)
  2878. if (!min || minSV.compare(v) === 1) {
  2879. // compare(min, v, true)
  2880. min = v;
  2881. minSV = new SemVer(min, loose);
  2882. }
  2883. }
  2884. });
  2885. return min;
  2886. }
  2887. exports.validRange = validRange;
  2888. function validRange(range, loose) {
  2889. try {
  2890. // Return '*' instead of '' so that truthiness works.
  2891. // This will throw if it's invalid anyway
  2892. return new Range(range, loose).range || '*';
  2893. } catch (er) {
  2894. return null;
  2895. }
  2896. } // Determine if version is less than all the versions possible in the range
  2897. exports.ltr = ltr;
  2898. function ltr(version, range, loose) {
  2899. return outside(version, range, '<', loose);
  2900. } // Determine if version is greater than all the versions possible in the range.
  2901. exports.gtr = gtr;
  2902. function gtr(version, range, loose) {
  2903. return outside(version, range, '>', loose);
  2904. }
  2905. exports.outside = outside;
  2906. function outside(version, range, hilo, loose) {
  2907. version = new SemVer(version, loose);
  2908. range = new Range(range, loose);
  2909. var gtfn, ltefn, ltfn, comp, ecomp;
  2910. switch (hilo) {
  2911. case '>':
  2912. gtfn = gt;
  2913. ltefn = lte;
  2914. ltfn = lt;
  2915. comp = '>';
  2916. ecomp = '>=';
  2917. break;
  2918. case '<':
  2919. gtfn = lt;
  2920. ltefn = gte;
  2921. ltfn = gt;
  2922. comp = '<';
  2923. ecomp = '<=';
  2924. break;
  2925. default:
  2926. throw new TypeError('Must provide a hilo val of "<" or ">"');
  2927. } // If it satisifes the range it is not outside
  2928. if (satisfies(version, range, loose)) {
  2929. return false;
  2930. } // From now on, variable terms are as if we're in "gtr" mode.
  2931. // but note that everything is flipped for the "ltr" function.
  2932. for (var i = 0; i < range.set.length; ++i) {
  2933. var comparators = range.set[i];
  2934. var high = null;
  2935. var low = null;
  2936. comparators.forEach(function (comparator) {
  2937. if (comparator.semver === ANY) {
  2938. comparator = new Comparator('>=0.0.0');
  2939. }
  2940. high = high || comparator;
  2941. low = low || comparator;
  2942. if (gtfn(comparator.semver, high.semver, loose)) {
  2943. high = comparator;
  2944. } else if (ltfn(comparator.semver, low.semver, loose)) {
  2945. low = comparator;
  2946. }
  2947. }); // If the edge version comparator has a operator then our version
  2948. // isn't outside it
  2949. if (high.operator === comp || high.operator === ecomp) {
  2950. return false;
  2951. } // If the lowest version comparator has an operator and our version
  2952. // is less than it then it isn't higher than the range
  2953. if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
  2954. return false;
  2955. } else if (low.operator === ecomp && ltfn(version, low.semver)) {
  2956. return false;
  2957. }
  2958. }
  2959. return true;
  2960. }
  2961. exports.prerelease = prerelease;
  2962. function prerelease(version, loose) {
  2963. var parsed = parse(version, loose);
  2964. return parsed && parsed.prerelease.length ? parsed.prerelease : null;
  2965. }
  2966. exports.intersects = intersects;
  2967. function intersects(r1, r2, loose) {
  2968. r1 = new Range(r1, loose);
  2969. r2 = new Range(r2, loose);
  2970. return r1.intersects(r2);
  2971. }
  2972. });
  2973. var arrayify = function arrayify(object, keyName) {
  2974. return Object.keys(object).reduce(function (array, key) {
  2975. return array.concat(Object.assign({
  2976. [keyName]: key
  2977. }, object[key]));
  2978. }, []);
  2979. };
  2980. var dedent_1 = createCommonjsModule(function (module) {
  2981. "use strict";
  2982. function dedent(strings) {
  2983. var raw = void 0;
  2984. if (typeof strings === "string") {
  2985. // dedent can be used as a plain function
  2986. raw = [strings];
  2987. } else {
  2988. raw = strings.raw;
  2989. } // first, perform interpolation
  2990. var result = "";
  2991. for (var i = 0; i < raw.length; i++) {
  2992. result += raw[i]. // join lines when there is a suppressed newline
  2993. replace(/\\\n[ \t]*/g, ""). // handle escaped backticks
  2994. replace(/\\`/g, "`");
  2995. if (i < (arguments.length <= 1 ? 0 : arguments.length - 1)) {
  2996. result += arguments.length <= i + 1 ? undefined : arguments[i + 1];
  2997. }
  2998. } // now strip indentation
  2999. var lines = result.split("\n");
  3000. var mindent = null;
  3001. lines.forEach(function (l) {
  3002. var m = l.match(/^(\s+)\S+/);
  3003. if (m) {
  3004. var indent = m[1].length;
  3005. if (!mindent) {
  3006. // this is the first indented line
  3007. mindent = indent;
  3008. } else {
  3009. mindent = Math.min(mindent, indent);
  3010. }
  3011. }
  3012. });
  3013. if (mindent !== null) {
  3014. result = lines.map(function (l) {
  3015. return l[0] === " " ? l.slice(mindent) : l;
  3016. }).join("\n");
  3017. } // dedent eats leading and trailing whitespace too
  3018. result = result.trim(); // handle escaped newlines at the end to ensure they don't get stripped too
  3019. return result.replace(/\\n/g, "\n");
  3020. }
  3021. {
  3022. module.exports = dedent;
  3023. }
  3024. });
  3025. var CATEGORY_CONFIG = "Config";
  3026. var CATEGORY_EDITOR = "Editor";
  3027. var CATEGORY_FORMAT = "Format";
  3028. var CATEGORY_OTHER = "Other";
  3029. var CATEGORY_OUTPUT = "Output";
  3030. var CATEGORY_GLOBAL = "Global";
  3031. var CATEGORY_SPECIAL = "Special";
  3032. /**
  3033. * @typedef {Object} OptionInfo
  3034. * @property {string} since - available since version
  3035. * @property {string} category
  3036. * @property {'int' | 'boolean' | 'choice' | 'path'} type
  3037. * @property {boolean} array - indicate it's an array of the specified type
  3038. * @property {boolean?} deprecated - deprecated since version
  3039. * @property {OptionRedirectInfo?} redirect - redirect deprecated option
  3040. * @property {string} description
  3041. * @property {string?} oppositeDescription - for `false` option
  3042. * @property {OptionValueInfo} default
  3043. * @property {OptionRangeInfo?} range - for type int
  3044. * @property {OptionChoiceInfo?} choices - for type choice
  3045. * @property {(value: any) => boolean} exception
  3046. *
  3047. * @typedef {number | boolean | string} OptionValue
  3048. * @typedef {OptionValue | [{ value: OptionValue[] }] | Array<{ since: string, value: OptionValue}>} OptionValueInfo
  3049. *
  3050. * @typedef {Object} OptionRedirectInfo
  3051. * @property {string} option
  3052. * @property {OptionValue} value
  3053. *
  3054. * @typedef {Object} OptionRangeInfo
  3055. * @property {number} start - recommended range start
  3056. * @property {number} end - recommended range end
  3057. * @property {number} step - recommended range step
  3058. *
  3059. * @typedef {Object} OptionChoiceInfo
  3060. * @property {boolean | string} value - boolean for the option that is originally boolean type
  3061. * @property {string?} description - undefined if redirect
  3062. * @property {string?} since - undefined if available since the first version of the option
  3063. * @property {string?} deprecated - deprecated since version
  3064. * @property {OptionValueInfo?} redirect - redirect deprecated value
  3065. *
  3066. * @property {string?} cliName
  3067. * @property {string?} cliCategory
  3068. * @property {string?} cliDescription
  3069. */
  3070. /** @type {{ [name: string]: OptionInfo } */
  3071. var options$2 = {
  3072. cursorOffset: {
  3073. since: "1.4.0",
  3074. category: CATEGORY_SPECIAL,
  3075. type: "int",
  3076. default: -1,
  3077. range: {
  3078. start: -1,
  3079. end: Infinity,
  3080. step: 1
  3081. },
  3082. description: dedent_1`
  3083. Print (to stderr) where a cursor at the given position would move to after formatting.
  3084. This option cannot be used with --range-start and --range-end.
  3085. `,
  3086. cliCategory: CATEGORY_EDITOR
  3087. },
  3088. endOfLine: {
  3089. since: "1.15.0",
  3090. category: CATEGORY_GLOBAL,
  3091. type: "choice",
  3092. default: "auto",
  3093. description: "Which end of line characters to apply.",
  3094. choices: [{
  3095. value: "auto",
  3096. description: dedent_1`
  3097. Maintain existing
  3098. (mixed values within one file are normalised by looking at what's used after the first line)
  3099. `
  3100. }, {
  3101. value: "lf",
  3102. description: "Line Feed only (\\n), common on Linux and macOS as well as inside git repos"
  3103. }, {
  3104. value: "crlf",
  3105. description: "Carriage Return + Line Feed characters (\\r\\n), common on Windows"
  3106. }, {
  3107. value: "cr",
  3108. description: "Carriage Return character only (\\r), used very rarely"
  3109. }]
  3110. },
  3111. filepath: {
  3112. since: "1.4.0",
  3113. category: CATEGORY_SPECIAL,
  3114. type: "path",
  3115. description: "Specify the input filepath. This will be used to do parser inference.",
  3116. cliName: "stdin-filepath",
  3117. cliCategory: CATEGORY_OTHER,
  3118. cliDescription: "Path to the file to pretend that stdin comes from."
  3119. },
  3120. insertPragma: {
  3121. since: "1.8.0",
  3122. category: CATEGORY_SPECIAL,
  3123. type: "boolean",
  3124. default: false,
  3125. description: "Insert @format pragma into file's first docblock comment.",
  3126. cliCategory: CATEGORY_OTHER
  3127. },
  3128. parser: {
  3129. since: "0.0.10",
  3130. category: CATEGORY_GLOBAL,
  3131. type: "choice",
  3132. default: [{
  3133. since: "0.0.10",
  3134. value: "babylon"
  3135. }, {
  3136. since: "1.13.0",
  3137. value: undefined
  3138. }],
  3139. description: "Which parser to use.",
  3140. exception: function exception(value) {
  3141. return typeof value === "string" || typeof value === "function";
  3142. },
  3143. choices: [{
  3144. value: "flow",
  3145. description: "Flow"
  3146. }, {
  3147. value: "babylon",
  3148. description: "JavaScript",
  3149. deprecated: "1.16.0",
  3150. redirect: "babel"
  3151. }, {
  3152. value: "babel",
  3153. since: "1.16.0",
  3154. description: "JavaScript"
  3155. }, {
  3156. value: "babel-flow",
  3157. since: "1.16.0",
  3158. description: "Flow"
  3159. }, {
  3160. value: "typescript",
  3161. since: "1.4.0",
  3162. description: "TypeScript"
  3163. }, {
  3164. value: "css",
  3165. since: "1.7.1",
  3166. description: "CSS"
  3167. }, {
  3168. value: "postcss",
  3169. since: "1.4.0",
  3170. description: "CSS/Less/SCSS",
  3171. deprecated: "1.7.1",
  3172. redirect: "css"
  3173. }, {
  3174. value: "less",
  3175. since: "1.7.1",
  3176. description: "Less"
  3177. }, {
  3178. value: "scss",
  3179. since: "1.7.1",
  3180. description: "SCSS"
  3181. }, {
  3182. value: "json",
  3183. since: "1.5.0",
  3184. description: "JSON"
  3185. }, {
  3186. value: "json5",
  3187. since: "1.13.0",
  3188. description: "JSON5"
  3189. }, {
  3190. value: "json-stringify",
  3191. since: "1.13.0",
  3192. description: "JSON.stringify"
  3193. }, {
  3194. value: "graphql",
  3195. since: "1.5.0",
  3196. description: "GraphQL"
  3197. }, {
  3198. value: "markdown",
  3199. since: "1.8.0",
  3200. description: "Markdown"
  3201. }, {
  3202. value: "mdx",
  3203. since: "1.15.0",
  3204. description: "MDX"
  3205. }, {
  3206. value: "vue",
  3207. since: "1.10.0",
  3208. description: "Vue"
  3209. }, {
  3210. value: "yaml",
  3211. since: "1.14.0",
  3212. description: "YAML"
  3213. }, {
  3214. value: "glimmer",
  3215. since: null,
  3216. description: "Handlebars"
  3217. }, {
  3218. value: "html",
  3219. since: "1.15.0",
  3220. description: "HTML"
  3221. }, {
  3222. value: "angular",
  3223. since: "1.15.0",
  3224. description: "Angular"
  3225. }]
  3226. },
  3227. plugins: {
  3228. since: "1.10.0",
  3229. type: "path",
  3230. array: true,
  3231. default: [{
  3232. value: []
  3233. }],
  3234. category: CATEGORY_GLOBAL,
  3235. description: "Add a plugin. Multiple plugins can be passed as separate `--plugin`s.",
  3236. exception: function exception(value) {
  3237. return typeof value === "string" || typeof value === "object";
  3238. },
  3239. cliName: "plugin",
  3240. cliCategory: CATEGORY_CONFIG
  3241. },
  3242. pluginSearchDirs: {
  3243. since: "1.13.0",
  3244. type: "path",
  3245. array: true,
  3246. default: [{
  3247. value: []
  3248. }],
  3249. category: CATEGORY_GLOBAL,
  3250. description: dedent_1`
  3251. Custom directory that contains prettier plugins in node_modules subdirectory.
  3252. Overrides default behavior when plugins are searched relatively to the location of Prettier.
  3253. Multiple values are accepted.
  3254. `,
  3255. exception: function exception(value) {
  3256. return typeof value === "string" || typeof value === "object";
  3257. },
  3258. cliName: "plugin-search-dir",
  3259. cliCategory: CATEGORY_CONFIG
  3260. },
  3261. printWidth: {
  3262. since: "0.0.0",
  3263. category: CATEGORY_GLOBAL,
  3264. type: "int",
  3265. default: 80,
  3266. description: "The line length where Prettier will try wrap.",
  3267. range: {
  3268. start: 0,
  3269. end: Infinity,
  3270. step: 1
  3271. }
  3272. },
  3273. rangeEnd: {
  3274. since: "1.4.0",
  3275. category: CATEGORY_SPECIAL,
  3276. type: "int",
  3277. default: Infinity,
  3278. range: {
  3279. start: 0,
  3280. end: Infinity,
  3281. step: 1
  3282. },
  3283. description: dedent_1`
  3284. Format code ending at a given character offset (exclusive).
  3285. The range will extend forwards to the end of the selected statement.
  3286. This option cannot be used with --cursor-offset.
  3287. `,
  3288. cliCategory: CATEGORY_EDITOR
  3289. },
  3290. rangeStart: {
  3291. since: "1.4.0",
  3292. category: CATEGORY_SPECIAL,
  3293. type: "int",
  3294. default: 0,
  3295. range: {
  3296. start: 0,
  3297. end: Infinity,
  3298. step: 1
  3299. },
  3300. description: dedent_1`
  3301. Format code starting at a given character offset.
  3302. The range will extend backwards to the start of the first line containing the selected statement.
  3303. This option cannot be used with --cursor-offset.
  3304. `,
  3305. cliCategory: CATEGORY_EDITOR
  3306. },
  3307. requirePragma: {
  3308. since: "1.7.0",
  3309. category: CATEGORY_SPECIAL,
  3310. type: "boolean",
  3311. default: false,
  3312. description: dedent_1`
  3313. Require either '@prettier' or '@format' to be present in the file's first docblock comment
  3314. in order for it to be formatted.
  3315. `,
  3316. cliCategory: CATEGORY_OTHER
  3317. },
  3318. tabWidth: {
  3319. type: "int",
  3320. category: CATEGORY_GLOBAL,
  3321. default: 2,
  3322. description: "Number of spaces per indentation level.",
  3323. range: {
  3324. start: 0,
  3325. end: Infinity,
  3326. step: 1
  3327. }
  3328. },
  3329. useFlowParser: {
  3330. since: "0.0.0",
  3331. category: CATEGORY_GLOBAL,
  3332. type: "boolean",
  3333. default: [{
  3334. since: "0.0.0",
  3335. value: false
  3336. }, {
  3337. since: "1.15.0",
  3338. value: undefined
  3339. }],
  3340. deprecated: "0.0.10",
  3341. description: "Use flow parser.",
  3342. redirect: {
  3343. option: "parser",
  3344. value: "flow"
  3345. },
  3346. cliName: "flow-parser"
  3347. },
  3348. useTabs: {
  3349. since: "1.0.0",
  3350. category: CATEGORY_GLOBAL,
  3351. type: "boolean",
  3352. default: false,
  3353. description: "Indent with tabs instead of spaces."
  3354. }
  3355. };
  3356. var coreOptions$1 = {
  3357. CATEGORY_CONFIG,
  3358. CATEGORY_EDITOR,
  3359. CATEGORY_FORMAT,
  3360. CATEGORY_OTHER,
  3361. CATEGORY_OUTPUT,
  3362. CATEGORY_GLOBAL,
  3363. CATEGORY_SPECIAL,
  3364. options: options$2
  3365. };
  3366. var require$$0 = ( _package$1 && _package ) || _package$1;
  3367. var currentVersion = require$$0.version;
  3368. var coreOptions = coreOptions$1.options;
  3369. function getSupportInfo$2(version, opts) {
  3370. opts = Object.assign({
  3371. plugins: [],
  3372. showUnreleased: false,
  3373. showDeprecated: false,
  3374. showInternal: false
  3375. }, opts);
  3376. if (!version) {
  3377. // pre-release version is smaller than the normal version in semver,
  3378. // we need to treat it as the normal one so as to test new features.
  3379. version = currentVersion.split("-", 1)[0];
  3380. }
  3381. var plugins = opts.plugins;
  3382. var options = arrayify(Object.assign(plugins.reduce(function (currentOptions, plugin) {
  3383. return Object.assign(currentOptions, plugin.options);
  3384. }, {}), coreOptions), "name").sort(function (a, b) {
  3385. return a.name === b.name ? 0 : a.name < b.name ? -1 : 1;
  3386. }).filter(filterSince).filter(filterDeprecated).map(mapDeprecated).map(mapInternal).map(function (option) {
  3387. var newOption = Object.assign({}, option);
  3388. if (Array.isArray(newOption.default)) {
  3389. newOption.default = newOption.default.length === 1 ? newOption.default[0].value : newOption.default.filter(filterSince).sort(function (info1, info2) {
  3390. return semver.compare(info2.since, info1.since);
  3391. })[0].value;
  3392. }
  3393. if (Array.isArray(newOption.choices)) {
  3394. newOption.choices = newOption.choices.filter(filterSince).filter(filterDeprecated).map(mapDeprecated);
  3395. }
  3396. return newOption;
  3397. }).map(function (option) {
  3398. var filteredPlugins = plugins.filter(function (plugin) {
  3399. return plugin.defaultOptions && plugin.defaultOptions[option.name];
  3400. });
  3401. var pluginDefaults = filteredPlugins.reduce(function (reduced, plugin) {
  3402. reduced[plugin.name] = plugin.defaultOptions[option.name];
  3403. return reduced;
  3404. }, {});
  3405. return Object.assign(option, {
  3406. pluginDefaults
  3407. });
  3408. });
  3409. var usePostCssParser = semver.lt(version, "1.7.1");
  3410. var languages = plugins.reduce(function (all, plugin) {
  3411. return all.concat(plugin.languages || []);
  3412. }, []).filter(filterSince).map(function (language) {
  3413. // Prevent breaking changes
  3414. if (language.name === "Markdown") {
  3415. return Object.assign({}, language, {
  3416. parsers: ["markdown"]
  3417. });
  3418. }
  3419. if (language.name === "TypeScript") {
  3420. return Object.assign({}, language, {
  3421. parsers: ["typescript"]
  3422. });
  3423. }
  3424. if (usePostCssParser && (language.name === "CSS" || language.group === "CSS")) {
  3425. return Object.assign({}, language, {
  3426. parsers: ["postcss"]
  3427. });
  3428. }
  3429. return language;
  3430. });
  3431. return {
  3432. languages,
  3433. options
  3434. };
  3435. function filterSince(object) {
  3436. return opts.showUnreleased || !("since" in object) || object.since && semver.gte(version, object.since);
  3437. }
  3438. function filterDeprecated(object) {
  3439. return opts.showDeprecated || !("deprecated" in object) || object.deprecated && semver.lt(version, object.deprecated);
  3440. }
  3441. function mapDeprecated(object) {
  3442. if (!object.deprecated || opts.showDeprecated) {
  3443. return object;
  3444. }
  3445. var newObject = Object.assign({}, object);
  3446. delete newObject.deprecated;
  3447. delete newObject.redirect;
  3448. return newObject;
  3449. }
  3450. function mapInternal(object) {
  3451. if (opts.showInternal) {
  3452. return object;
  3453. }
  3454. var newObject = Object.assign({}, object);
  3455. delete newObject.cliName;
  3456. delete newObject.cliCategory;
  3457. delete newObject.cliDescription;
  3458. return newObject;
  3459. }
  3460. }
  3461. var support = {
  3462. getSupportInfo: getSupportInfo$2
  3463. };
  3464. /*! *****************************************************************************
  3465. Copyright (c) Microsoft Corporation. All rights reserved.
  3466. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  3467. this file except in compliance with the License. You may obtain a copy of the
  3468. License at http://www.apache.org/licenses/LICENSE-2.0
  3469. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  3470. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  3471. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  3472. MERCHANTABLITY OR NON-INFRINGEMENT.
  3473. See the Apache Version 2.0 License for specific language governing permissions
  3474. and limitations under the License.
  3475. ***************************************************************************** */
  3476. /* global Reflect, Promise */
  3477. var _extendStatics = function extendStatics(d, b) {
  3478. _extendStatics = Object.setPrototypeOf || {
  3479. __proto__: []
  3480. } instanceof Array && function (d, b) {
  3481. d.__proto__ = b;
  3482. } || function (d, b) {
  3483. for (var p in b) {
  3484. if (b.hasOwnProperty(p)) d[p] = b[p];
  3485. }
  3486. };
  3487. return _extendStatics(d, b);
  3488. };
  3489. function __extends(d, b) {
  3490. _extendStatics(d, b);
  3491. function __() {
  3492. this.constructor = d;
  3493. }
  3494. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3495. }
  3496. var _assign = function __assign() {
  3497. _assign = Object.assign || function __assign(t) {
  3498. for (var s, i = 1, n = arguments.length; i < n; i++) {
  3499. s = arguments[i];
  3500. for (var p in s) {
  3501. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  3502. }
  3503. }
  3504. return t;
  3505. };
  3506. return _assign.apply(this, arguments);
  3507. };
  3508. function __rest(s, e) {
  3509. var t = {};
  3510. for (var p in s) {
  3511. if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
  3512. }
  3513. if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  3514. if (e.indexOf(p[i]) < 0) t[p[i]] = s[p[i]];
  3515. }
  3516. return t;
  3517. }
  3518. function __decorate(decorators, target, key, desc) {
  3519. var c = arguments.length,
  3520. r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
  3521. d;
  3522. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) {
  3523. if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  3524. }
  3525. return c > 3 && r && Object.defineProperty(target, key, r), r;
  3526. }
  3527. function __param(paramIndex, decorator) {
  3528. return function (target, key) {
  3529. decorator(target, key, paramIndex);
  3530. };
  3531. }
  3532. function __metadata(metadataKey, metadataValue) {
  3533. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  3534. }
  3535. function __awaiter(thisArg, _arguments, P, generator) {
  3536. return new (P || (P = Promise))(function (resolve, reject) {
  3537. function fulfilled(value) {
  3538. try {
  3539. step(generator.next(value));
  3540. } catch (e) {
  3541. reject(e);
  3542. }
  3543. }
  3544. function rejected(value) {
  3545. try {
  3546. step(generator["throw"](value));
  3547. } catch (e) {
  3548. reject(e);
  3549. }
  3550. }
  3551. function step(result) {
  3552. result.done ? resolve(result.value) : new P(function (resolve) {
  3553. resolve(result.value);
  3554. }).then(fulfilled, rejected);
  3555. }
  3556. step((generator = generator.apply(thisArg, _arguments || [])).next());
  3557. });
  3558. }
  3559. function __generator(thisArg, body) {
  3560. var _ = {
  3561. label: 0,
  3562. sent: function sent() {
  3563. if (t[0] & 1) throw t[1];
  3564. return t[1];
  3565. },
  3566. trys: [],
  3567. ops: []
  3568. },
  3569. f,
  3570. y,
  3571. t,
  3572. g;
  3573. return g = {
  3574. next: verb(0),
  3575. "throw": verb(1),
  3576. "return": verb(2)
  3577. }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
  3578. return this;
  3579. }), g;
  3580. function verb(n) {
  3581. return function (v) {
  3582. return step([n, v]);
  3583. };
  3584. }
  3585. function step(op) {
  3586. if (f) throw new TypeError("Generator is already executing.");
  3587. while (_) {
  3588. try {
  3589. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  3590. if (y = 0, t) op = [op[0] & 2, t.value];
  3591. switch (op[0]) {
  3592. case 0:
  3593. case 1:
  3594. t = op;
  3595. break;
  3596. case 4:
  3597. _.label++;
  3598. return {
  3599. value: op[1],
  3600. done: false
  3601. };
  3602. case 5:
  3603. _.label++;
  3604. y = op[1];
  3605. op = [0];
  3606. continue;
  3607. case 7:
  3608. op = _.ops.pop();
  3609. _.trys.pop();
  3610. continue;
  3611. default:
  3612. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
  3613. _ = 0;
  3614. continue;
  3615. }
  3616. if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
  3617. _.label = op[1];
  3618. break;
  3619. }
  3620. if (op[0] === 6 && _.label < t[1]) {
  3621. _.label = t[1];
  3622. t = op;
  3623. break;
  3624. }
  3625. if (t && _.label < t[2]) {
  3626. _.label = t[2];
  3627. _.ops.push(op);
  3628. break;
  3629. }
  3630. if (t[2]) _.ops.pop();
  3631. _.trys.pop();
  3632. continue;
  3633. }
  3634. op = body.call(thisArg, _);
  3635. } catch (e) {
  3636. op = [6, e];
  3637. y = 0;
  3638. } finally {
  3639. f = t = 0;
  3640. }
  3641. }
  3642. if (op[0] & 5) throw op[1];
  3643. return {
  3644. value: op[0] ? op[1] : void 0,
  3645. done: true
  3646. };
  3647. }
  3648. }
  3649. function __exportStar(m, exports) {
  3650. for (var p in m) {
  3651. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  3652. }
  3653. }
  3654. function __values(o) {
  3655. var m = typeof Symbol === "function" && o[Symbol.iterator],
  3656. i = 0;
  3657. if (m) return m.call(o);
  3658. return {
  3659. next: function next() {
  3660. if (o && i >= o.length) o = void 0;
  3661. return {
  3662. value: o && o[i++],
  3663. done: !o
  3664. };
  3665. }
  3666. };
  3667. }
  3668. function __read(o, n) {
  3669. var m = typeof Symbol === "function" && o[Symbol.iterator];
  3670. if (!m) return o;
  3671. var i = m.call(o),
  3672. r,
  3673. ar = [],
  3674. e;
  3675. try {
  3676. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
  3677. ar.push(r.value);
  3678. }
  3679. } catch (error) {
  3680. e = {
  3681. error: error
  3682. };
  3683. } finally {
  3684. try {
  3685. if (r && !r.done && (m = i["return"])) m.call(i);
  3686. } finally {
  3687. if (e) throw e.error;
  3688. }
  3689. }
  3690. return ar;
  3691. }
  3692. function __spread() {
  3693. for (var ar = [], i = 0; i < arguments.length; i++) {
  3694. ar = ar.concat(__read(arguments[i]));
  3695. }
  3696. return ar;
  3697. }
  3698. function __await(v) {
  3699. return this instanceof __await ? (this.v = v, this) : new __await(v);
  3700. }
  3701. function __asyncGenerator(thisArg, _arguments, generator) {
  3702. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  3703. var g = generator.apply(thisArg, _arguments || []),
  3704. i,
  3705. q = [];
  3706. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () {
  3707. return this;
  3708. }, i;
  3709. function verb(n) {
  3710. if (g[n]) i[n] = function (v) {
  3711. return new Promise(function (a, b) {
  3712. q.push([n, v, a, b]) > 1 || resume(n, v);
  3713. });
  3714. };
  3715. }
  3716. function resume(n, v) {
  3717. try {
  3718. step(g[n](v));
  3719. } catch (e) {
  3720. settle(q[0][3], e);
  3721. }
  3722. }
  3723. function step(r) {
  3724. r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
  3725. }
  3726. function fulfill(value) {
  3727. resume("next", value);
  3728. }
  3729. function reject(value) {
  3730. resume("throw", value);
  3731. }
  3732. function settle(f, v) {
  3733. if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]);
  3734. }
  3735. }
  3736. function __asyncDelegator(o) {
  3737. var i, p;
  3738. return i = {}, verb("next"), verb("throw", function (e) {
  3739. throw e;
  3740. }), verb("return"), i[Symbol.iterator] = function () {
  3741. return this;
  3742. }, i;
  3743. function verb(n, f) {
  3744. i[n] = o[n] ? function (v) {
  3745. return (p = !p) ? {
  3746. value: __await(o[n](v)),
  3747. done: n === "return"
  3748. } : f ? f(v) : v;
  3749. } : f;
  3750. }
  3751. }
  3752. function __asyncValues(o) {
  3753. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  3754. var m = o[Symbol.asyncIterator],
  3755. i;
  3756. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () {
  3757. return this;
  3758. }, i);
  3759. function verb(n) {
  3760. i[n] = o[n] && function (v) {
  3761. return new Promise(function (resolve, reject) {
  3762. v = o[n](v), settle(resolve, reject, v.done, v.value);
  3763. });
  3764. };
  3765. }
  3766. function settle(resolve, reject, d, v) {
  3767. Promise.resolve(v).then(function (v) {
  3768. resolve({
  3769. value: v,
  3770. done: d
  3771. });
  3772. }, reject);
  3773. }
  3774. }
  3775. function __makeTemplateObject(cooked, raw) {
  3776. if (Object.defineProperty) {
  3777. Object.defineProperty(cooked, "raw", {
  3778. value: raw
  3779. });
  3780. } else {
  3781. cooked.raw = raw;
  3782. }
  3783. return cooked;
  3784. }
  3785. function __importStar(mod) {
  3786. if (mod && mod.__esModule) return mod;
  3787. var result = {};
  3788. if (mod != null) for (var k in mod) {
  3789. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  3790. }
  3791. result.default = mod;
  3792. return result;
  3793. }
  3794. function __importDefault(mod) {
  3795. return mod && mod.__esModule ? mod : {
  3796. default: mod
  3797. };
  3798. }
  3799. var tslib_1 = Object.freeze({
  3800. __extends: __extends,
  3801. get __assign () { return _assign; },
  3802. __rest: __rest,
  3803. __decorate: __decorate,
  3804. __param: __param,
  3805. __metadata: __metadata,
  3806. __awaiter: __awaiter,
  3807. __generator: __generator,
  3808. __exportStar: __exportStar,
  3809. __values: __values,
  3810. __read: __read,
  3811. __spread: __spread,
  3812. __await: __await,
  3813. __asyncGenerator: __asyncGenerator,
  3814. __asyncDelegator: __asyncDelegator,
  3815. __asyncValues: __asyncValues,
  3816. __makeTemplateObject: __makeTemplateObject,
  3817. __importStar: __importStar,
  3818. __importDefault: __importDefault
  3819. });
  3820. var api = createCommonjsModule(function (module, exports) {
  3821. "use strict";
  3822. Object.defineProperty(exports, "__esModule", {
  3823. value: true
  3824. });
  3825. exports.apiDescriptor = {
  3826. key: function key(_key) {
  3827. return /^[$_a-zA-Z][$_a-zA-Z0-9]*$/.test(_key) ? _key : JSON.stringify(_key);
  3828. },
  3829. value(value) {
  3830. if (value === null || typeof value !== 'object') {
  3831. return JSON.stringify(value);
  3832. }
  3833. if (Array.isArray(value)) {
  3834. return `[${value.map(function (subValue) {
  3835. return exports.apiDescriptor.value(subValue);
  3836. }).join(', ')}]`;
  3837. }
  3838. var keys = Object.keys(value);
  3839. return keys.length === 0 ? '{}' : `{ ${keys.map(function (key) {
  3840. return `${exports.apiDescriptor.key(key)}: ${exports.apiDescriptor.value(value[key])}`;
  3841. }).join(', ')} }`;
  3842. },
  3843. pair: function pair(_ref) {
  3844. var key = _ref.key,
  3845. value = _ref.value;
  3846. return exports.apiDescriptor.value({
  3847. [key]: value
  3848. });
  3849. }
  3850. };
  3851. });
  3852. unwrapExports(api);
  3853. var descriptors = createCommonjsModule(function (module, exports) {
  3854. "use strict";
  3855. Object.defineProperty(exports, "__esModule", {
  3856. value: true
  3857. });
  3858. tslib_1.__exportStar(api, exports);
  3859. });
  3860. unwrapExports(descriptors);
  3861. var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
  3862. var escapeStringRegexp = function escapeStringRegexp(str) {
  3863. if (typeof str !== 'string') {
  3864. throw new TypeError('Expected a string');
  3865. }
  3866. return str.replace(matchOperatorsRe, '\\$&');
  3867. };
  3868. var colorName = {
  3869. "aliceblue": [240, 248, 255],
  3870. "antiquewhite": [250, 235, 215],
  3871. "aqua": [0, 255, 255],
  3872. "aquamarine": [127, 255, 212],
  3873. "azure": [240, 255, 255],
  3874. "beige": [245, 245, 220],
  3875. "bisque": [255, 228, 196],
  3876. "black": [0, 0, 0],
  3877. "blanchedalmond": [255, 235, 205],
  3878. "blue": [0, 0, 255],
  3879. "blueviolet": [138, 43, 226],
  3880. "brown": [165, 42, 42],
  3881. "burlywood": [222, 184, 135],
  3882. "cadetblue": [95, 158, 160],
  3883. "chartreuse": [127, 255, 0],
  3884. "chocolate": [210, 105, 30],
  3885. "coral": [255, 127, 80],
  3886. "cornflowerblue": [100, 149, 237],
  3887. "cornsilk": [255, 248, 220],
  3888. "crimson": [220, 20, 60],
  3889. "cyan": [0, 255, 255],
  3890. "darkblue": [0, 0, 139],
  3891. "darkcyan": [0, 139, 139],
  3892. "darkgoldenrod": [184, 134, 11],
  3893. "darkgray": [169, 169, 169],
  3894. "darkgreen": [0, 100, 0],
  3895. "darkgrey": [169, 169, 169],
  3896. "darkkhaki": [189, 183, 107],
  3897. "darkmagenta": [139, 0, 139],
  3898. "darkolivegreen": [85, 107, 47],
  3899. "darkorange": [255, 140, 0],
  3900. "darkorchid": [153, 50, 204],
  3901. "darkred": [139, 0, 0],
  3902. "darksalmon": [233, 150, 122],
  3903. "darkseagreen": [143, 188, 143],
  3904. "darkslateblue": [72, 61, 139],
  3905. "darkslategray": [47, 79, 79],
  3906. "darkslategrey": [47, 79, 79],
  3907. "darkturquoise": [0, 206, 209],
  3908. "darkviolet": [148, 0, 211],
  3909. "deeppink": [255, 20, 147],
  3910. "deepskyblue": [0, 191, 255],
  3911. "dimgray": [105, 105, 105],
  3912. "dimgrey": [105, 105, 105],
  3913. "dodgerblue": [30, 144, 255],
  3914. "firebrick": [178, 34, 34],
  3915. "floralwhite": [255, 250, 240],
  3916. "forestgreen": [34, 139, 34],
  3917. "fuchsia": [255, 0, 255],
  3918. "gainsboro": [220, 220, 220],
  3919. "ghostwhite": [248, 248, 255],
  3920. "gold": [255, 215, 0],
  3921. "goldenrod": [218, 165, 32],
  3922. "gray": [128, 128, 128],
  3923. "green": [0, 128, 0],
  3924. "greenyellow": [173, 255, 47],
  3925. "grey": [128, 128, 128],
  3926. "honeydew": [240, 255, 240],
  3927. "hotpink": [255, 105, 180],
  3928. "indianred": [205, 92, 92],
  3929. "indigo": [75, 0, 130],
  3930. "ivory": [255, 255, 240],
  3931. "khaki": [240, 230, 140],
  3932. "lavender": [230, 230, 250],
  3933. "lavenderblush": [255, 240, 245],
  3934. "lawngreen": [124, 252, 0],
  3935. "lemonchiffon": [255, 250, 205],
  3936. "lightblue": [173, 216, 230],
  3937. "lightcoral": [240, 128, 128],
  3938. "lightcyan": [224, 255, 255],
  3939. "lightgoldenrodyellow": [250, 250, 210],
  3940. "lightgray": [211, 211, 211],
  3941. "lightgreen": [144, 238, 144],
  3942. "lightgrey": [211, 211, 211],
  3943. "lightpink": [255, 182, 193],
  3944. "lightsalmon": [255, 160, 122],
  3945. "lightseagreen": [32, 178, 170],
  3946. "lightskyblue": [135, 206, 250],
  3947. "lightslategray": [119, 136, 153],
  3948. "lightslategrey": [119, 136, 153],
  3949. "lightsteelblue": [176, 196, 222],
  3950. "lightyellow": [255, 255, 224],
  3951. "lime": [0, 255, 0],
  3952. "limegreen": [50, 205, 50],
  3953. "linen": [250, 240, 230],
  3954. "magenta": [255, 0, 255],
  3955. "maroon": [128, 0, 0],
  3956. "mediumaquamarine": [102, 205, 170],
  3957. "mediumblue": [0, 0, 205],
  3958. "mediumorchid": [186, 85, 211],
  3959. "mediumpurple": [147, 112, 219],
  3960. "mediumseagreen": [60, 179, 113],
  3961. "mediumslateblue": [123, 104, 238],
  3962. "mediumspringgreen": [0, 250, 154],
  3963. "mediumturquoise": [72, 209, 204],
  3964. "mediumvioletred": [199, 21, 133],
  3965. "midnightblue": [25, 25, 112],
  3966. "mintcream": [245, 255, 250],
  3967. "mistyrose": [255, 228, 225],
  3968. "moccasin": [255, 228, 181],
  3969. "navajowhite": [255, 222, 173],
  3970. "navy": [0, 0, 128],
  3971. "oldlace": [253, 245, 230],
  3972. "olive": [128, 128, 0],
  3973. "olivedrab": [107, 142, 35],
  3974. "orange": [255, 165, 0],
  3975. "orangered": [255, 69, 0],
  3976. "orchid": [218, 112, 214],
  3977. "palegoldenrod": [238, 232, 170],
  3978. "palegreen": [152, 251, 152],
  3979. "paleturquoise": [175, 238, 238],
  3980. "palevioletred": [219, 112, 147],
  3981. "papayawhip": [255, 239, 213],
  3982. "peachpuff": [255, 218, 185],
  3983. "peru": [205, 133, 63],
  3984. "pink": [255, 192, 203],
  3985. "plum": [221, 160, 221],
  3986. "powderblue": [176, 224, 230],
  3987. "purple": [128, 0, 128],
  3988. "rebeccapurple": [102, 51, 153],
  3989. "red": [255, 0, 0],
  3990. "rosybrown": [188, 143, 143],
  3991. "royalblue": [65, 105, 225],
  3992. "saddlebrown": [139, 69, 19],
  3993. "salmon": [250, 128, 114],
  3994. "sandybrown": [244, 164, 96],
  3995. "seagreen": [46, 139, 87],
  3996. "seashell": [255, 245, 238],
  3997. "sienna": [160, 82, 45],
  3998. "silver": [192, 192, 192],
  3999. "skyblue": [135, 206, 235],
  4000. "slateblue": [106, 90, 205],
  4001. "slategray": [112, 128, 144],
  4002. "slategrey": [112, 128, 144],
  4003. "snow": [255, 250, 250],
  4004. "springgreen": [0, 255, 127],
  4005. "steelblue": [70, 130, 180],
  4006. "tan": [210, 180, 140],
  4007. "teal": [0, 128, 128],
  4008. "thistle": [216, 191, 216],
  4009. "tomato": [255, 99, 71],
  4010. "turquoise": [64, 224, 208],
  4011. "violet": [238, 130, 238],
  4012. "wheat": [245, 222, 179],
  4013. "white": [255, 255, 255],
  4014. "whitesmoke": [245, 245, 245],
  4015. "yellow": [255, 255, 0],
  4016. "yellowgreen": [154, 205, 50]
  4017. };
  4018. var conversions = createCommonjsModule(function (module) {
  4019. /* MIT license */
  4020. // NOTE: conversions should only return primitive values (i.e. arrays, or
  4021. // values that give correct `typeof` results).
  4022. // do not use box values types (i.e. Number(), String(), etc.)
  4023. var reverseKeywords = {};
  4024. for (var key in colorName) {
  4025. if (colorName.hasOwnProperty(key)) {
  4026. reverseKeywords[colorName[key]] = key;
  4027. }
  4028. }
  4029. var convert = module.exports = {
  4030. rgb: {
  4031. channels: 3,
  4032. labels: 'rgb'
  4033. },
  4034. hsl: {
  4035. channels: 3,
  4036. labels: 'hsl'
  4037. },
  4038. hsv: {
  4039. channels: 3,
  4040. labels: 'hsv'
  4041. },
  4042. hwb: {
  4043. channels: 3,
  4044. labels: 'hwb'
  4045. },
  4046. cmyk: {
  4047. channels: 4,
  4048. labels: 'cmyk'
  4049. },
  4050. xyz: {
  4051. channels: 3,
  4052. labels: 'xyz'
  4053. },
  4054. lab: {
  4055. channels: 3,
  4056. labels: 'lab'
  4057. },
  4058. lch: {
  4059. channels: 3,
  4060. labels: 'lch'
  4061. },
  4062. hex: {
  4063. channels: 1,
  4064. labels: ['hex']
  4065. },
  4066. keyword: {
  4067. channels: 1,
  4068. labels: ['keyword']
  4069. },
  4070. ansi16: {
  4071. channels: 1,
  4072. labels: ['ansi16']
  4073. },
  4074. ansi256: {
  4075. channels: 1,
  4076. labels: ['ansi256']
  4077. },
  4078. hcg: {
  4079. channels: 3,
  4080. labels: ['h', 'c', 'g']
  4081. },
  4082. apple: {
  4083. channels: 3,
  4084. labels: ['r16', 'g16', 'b16']
  4085. },
  4086. gray: {
  4087. channels: 1,
  4088. labels: ['gray']
  4089. }
  4090. }; // hide .channels and .labels properties
  4091. for (var model in convert) {
  4092. if (convert.hasOwnProperty(model)) {
  4093. if (!('channels' in convert[model])) {
  4094. throw new Error('missing channels property: ' + model);
  4095. }
  4096. if (!('labels' in convert[model])) {
  4097. throw new Error('missing channel labels property: ' + model);
  4098. }
  4099. if (convert[model].labels.length !== convert[model].channels) {
  4100. throw new Error('channel and label counts mismatch: ' + model);
  4101. }
  4102. var channels = convert[model].channels;
  4103. var labels = convert[model].labels;
  4104. delete convert[model].channels;
  4105. delete convert[model].labels;
  4106. Object.defineProperty(convert[model], 'channels', {
  4107. value: channels
  4108. });
  4109. Object.defineProperty(convert[model], 'labels', {
  4110. value: labels
  4111. });
  4112. }
  4113. }
  4114. convert.rgb.hsl = function (rgb) {
  4115. var r = rgb[0] / 255;
  4116. var g = rgb[1] / 255;
  4117. var b = rgb[2] / 255;
  4118. var min = Math.min(r, g, b);
  4119. var max = Math.max(r, g, b);
  4120. var delta = max - min;
  4121. var h;
  4122. var s;
  4123. var l;
  4124. if (max === min) {
  4125. h = 0;
  4126. } else if (r === max) {
  4127. h = (g - b) / delta;
  4128. } else if (g === max) {
  4129. h = 2 + (b - r) / delta;
  4130. } else if (b === max) {
  4131. h = 4 + (r - g) / delta;
  4132. }
  4133. h = Math.min(h * 60, 360);
  4134. if (h < 0) {
  4135. h += 360;
  4136. }
  4137. l = (min + max) / 2;
  4138. if (max === min) {
  4139. s = 0;
  4140. } else if (l <= 0.5) {
  4141. s = delta / (max + min);
  4142. } else {
  4143. s = delta / (2 - max - min);
  4144. }
  4145. return [h, s * 100, l * 100];
  4146. };
  4147. convert.rgb.hsv = function (rgb) {
  4148. var r = rgb[0];
  4149. var g = rgb[1];
  4150. var b = rgb[2];
  4151. var min = Math.min(r, g, b);
  4152. var max = Math.max(r, g, b);
  4153. var delta = max - min;
  4154. var h;
  4155. var s;
  4156. var v;
  4157. if (max === 0) {
  4158. s = 0;
  4159. } else {
  4160. s = delta / max * 1000 / 10;
  4161. }
  4162. if (max === min) {
  4163. h = 0;
  4164. } else if (r === max) {
  4165. h = (g - b) / delta;
  4166. } else if (g === max) {
  4167. h = 2 + (b - r) / delta;
  4168. } else if (b === max) {
  4169. h = 4 + (r - g) / delta;
  4170. }
  4171. h = Math.min(h * 60, 360);
  4172. if (h < 0) {
  4173. h += 360;
  4174. }
  4175. v = max / 255 * 1000 / 10;
  4176. return [h, s, v];
  4177. };
  4178. convert.rgb.hwb = function (rgb) {
  4179. var r = rgb[0];
  4180. var g = rgb[1];
  4181. var b = rgb[2];
  4182. var h = convert.rgb.hsl(rgb)[0];
  4183. var w = 1 / 255 * Math.min(r, Math.min(g, b));
  4184. b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
  4185. return [h, w * 100, b * 100];
  4186. };
  4187. convert.rgb.cmyk = function (rgb) {
  4188. var r = rgb[0] / 255;
  4189. var g = rgb[1] / 255;
  4190. var b = rgb[2] / 255;
  4191. var c;
  4192. var m;
  4193. var y;
  4194. var k;
  4195. k = Math.min(1 - r, 1 - g, 1 - b);
  4196. c = (1 - r - k) / (1 - k) || 0;
  4197. m = (1 - g - k) / (1 - k) || 0;
  4198. y = (1 - b - k) / (1 - k) || 0;
  4199. return [c * 100, m * 100, y * 100, k * 100];
  4200. };
  4201. /**
  4202. * See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
  4203. * */
  4204. function comparativeDistance(x, y) {
  4205. return Math.pow(x[0] - y[0], 2) + Math.pow(x[1] - y[1], 2) + Math.pow(x[2] - y[2], 2);
  4206. }
  4207. convert.rgb.keyword = function (rgb) {
  4208. var reversed = reverseKeywords[rgb];
  4209. if (reversed) {
  4210. return reversed;
  4211. }
  4212. var currentClosestDistance = Infinity;
  4213. var currentClosestKeyword;
  4214. for (var keyword in colorName) {
  4215. if (colorName.hasOwnProperty(keyword)) {
  4216. var value = colorName[keyword]; // Compute comparative distance
  4217. var distance = comparativeDistance(rgb, value); // Check if its less, if so set as closest
  4218. if (distance < currentClosestDistance) {
  4219. currentClosestDistance = distance;
  4220. currentClosestKeyword = keyword;
  4221. }
  4222. }
  4223. }
  4224. return currentClosestKeyword;
  4225. };
  4226. convert.keyword.rgb = function (keyword) {
  4227. return colorName[keyword];
  4228. };
  4229. convert.rgb.xyz = function (rgb) {
  4230. var r = rgb[0] / 255;
  4231. var g = rgb[1] / 255;
  4232. var b = rgb[2] / 255; // assume sRGB
  4233. r = r > 0.04045 ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;
  4234. g = g > 0.04045 ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;
  4235. b = b > 0.04045 ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;
  4236. var x = r * 0.4124 + g * 0.3576 + b * 0.1805;
  4237. var y = r * 0.2126 + g * 0.7152 + b * 0.0722;
  4238. var z = r * 0.0193 + g * 0.1192 + b * 0.9505;
  4239. return [x * 100, y * 100, z * 100];
  4240. };
  4241. convert.rgb.lab = function (rgb) {
  4242. var xyz = convert.rgb.xyz(rgb);
  4243. var x = xyz[0];
  4244. var y = xyz[1];
  4245. var z = xyz[2];
  4246. var l;
  4247. var a;
  4248. var b;
  4249. x /= 95.047;
  4250. y /= 100;
  4251. z /= 108.883;
  4252. x = x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
  4253. y = y > 0.008856 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
  4254. z = z > 0.008856 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
  4255. l = 116 * y - 16;
  4256. a = 500 * (x - y);
  4257. b = 200 * (y - z);
  4258. return [l, a, b];
  4259. };
  4260. convert.hsl.rgb = function (hsl) {
  4261. var h = hsl[0] / 360;
  4262. var s = hsl[1] / 100;
  4263. var l = hsl[2] / 100;
  4264. var t1;
  4265. var t2;
  4266. var t3;
  4267. var rgb;
  4268. var val;
  4269. if (s === 0) {
  4270. val = l * 255;
  4271. return [val, val, val];
  4272. }
  4273. if (l < 0.5) {
  4274. t2 = l * (1 + s);
  4275. } else {
  4276. t2 = l + s - l * s;
  4277. }
  4278. t1 = 2 * l - t2;
  4279. rgb = [0, 0, 0];
  4280. for (var i = 0; i < 3; i++) {
  4281. t3 = h + 1 / 3 * -(i - 1);
  4282. if (t3 < 0) {
  4283. t3++;
  4284. }
  4285. if (t3 > 1) {
  4286. t3--;
  4287. }
  4288. if (6 * t3 < 1) {
  4289. val = t1 + (t2 - t1) * 6 * t3;
  4290. } else if (2 * t3 < 1) {
  4291. val = t2;
  4292. } else if (3 * t3 < 2) {
  4293. val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
  4294. } else {
  4295. val = t1;
  4296. }
  4297. rgb[i] = val * 255;
  4298. }
  4299. return rgb;
  4300. };
  4301. convert.hsl.hsv = function (hsl) {
  4302. var h = hsl[0];
  4303. var s = hsl[1] / 100;
  4304. var l = hsl[2] / 100;
  4305. var smin = s;
  4306. var lmin = Math.max(l, 0.01);
  4307. var sv;
  4308. var v;
  4309. l *= 2;
  4310. s *= l <= 1 ? l : 2 - l;
  4311. smin *= lmin <= 1 ? lmin : 2 - lmin;
  4312. v = (l + s) / 2;
  4313. sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
  4314. return [h, sv * 100, v * 100];
  4315. };
  4316. convert.hsv.rgb = function (hsv) {
  4317. var h = hsv[0] / 60;
  4318. var s = hsv[1] / 100;
  4319. var v = hsv[2] / 100;
  4320. var hi = Math.floor(h) % 6;
  4321. var f = h - Math.floor(h);
  4322. var p = 255 * v * (1 - s);
  4323. var q = 255 * v * (1 - s * f);
  4324. var t = 255 * v * (1 - s * (1 - f));
  4325. v *= 255;
  4326. switch (hi) {
  4327. case 0:
  4328. return [v, t, p];
  4329. case 1:
  4330. return [q, v, p];
  4331. case 2:
  4332. return [p, v, t];
  4333. case 3:
  4334. return [p, q, v];
  4335. case 4:
  4336. return [t, p, v];
  4337. case 5:
  4338. return [v, p, q];
  4339. }
  4340. };
  4341. convert.hsv.hsl = function (hsv) {
  4342. var h = hsv[0];
  4343. var s = hsv[1] / 100;
  4344. var v = hsv[2] / 100;
  4345. var vmin = Math.max(v, 0.01);
  4346. var lmin;
  4347. var sl;
  4348. var l;
  4349. l = (2 - s) * v;
  4350. lmin = (2 - s) * vmin;
  4351. sl = s * vmin;
  4352. sl /= lmin <= 1 ? lmin : 2 - lmin;
  4353. sl = sl || 0;
  4354. l /= 2;
  4355. return [h, sl * 100, l * 100];
  4356. }; // http://dev.w3.org/csswg/css-color/#hwb-to-rgb
  4357. convert.hwb.rgb = function (hwb) {
  4358. var h = hwb[0] / 360;
  4359. var wh = hwb[1] / 100;
  4360. var bl = hwb[2] / 100;
  4361. var ratio = wh + bl;
  4362. var i;
  4363. var v;
  4364. var f;
  4365. var n; // wh + bl cant be > 1
  4366. if (ratio > 1) {
  4367. wh /= ratio;
  4368. bl /= ratio;
  4369. }
  4370. i = Math.floor(6 * h);
  4371. v = 1 - bl;
  4372. f = 6 * h - i;
  4373. if ((i & 0x01) !== 0) {
  4374. f = 1 - f;
  4375. }
  4376. n = wh + f * (v - wh); // linear interpolation
  4377. var r;
  4378. var g;
  4379. var b;
  4380. switch (i) {
  4381. default:
  4382. case 6:
  4383. case 0:
  4384. r = v;
  4385. g = n;
  4386. b = wh;
  4387. break;
  4388. case 1:
  4389. r = n;
  4390. g = v;
  4391. b = wh;
  4392. break;
  4393. case 2:
  4394. r = wh;
  4395. g = v;
  4396. b = n;
  4397. break;
  4398. case 3:
  4399. r = wh;
  4400. g = n;
  4401. b = v;
  4402. break;
  4403. case 4:
  4404. r = n;
  4405. g = wh;
  4406. b = v;
  4407. break;
  4408. case 5:
  4409. r = v;
  4410. g = wh;
  4411. b = n;
  4412. break;
  4413. }
  4414. return [r * 255, g * 255, b * 255];
  4415. };
  4416. convert.cmyk.rgb = function (cmyk) {
  4417. var c = cmyk[0] / 100;
  4418. var m = cmyk[1] / 100;
  4419. var y = cmyk[2] / 100;
  4420. var k = cmyk[3] / 100;
  4421. var r;
  4422. var g;
  4423. var b;
  4424. r = 1 - Math.min(1, c * (1 - k) + k);
  4425. g = 1 - Math.min(1, m * (1 - k) + k);
  4426. b = 1 - Math.min(1, y * (1 - k) + k);
  4427. return [r * 255, g * 255, b * 255];
  4428. };
  4429. convert.xyz.rgb = function (xyz) {
  4430. var x = xyz[0] / 100;
  4431. var y = xyz[1] / 100;
  4432. var z = xyz[2] / 100;
  4433. var r;
  4434. var g;
  4435. var b;
  4436. r = x * 3.2406 + y * -1.5372 + z * -0.4986;
  4437. g = x * -0.9689 + y * 1.8758 + z * 0.0415;
  4438. b = x * 0.0557 + y * -0.2040 + z * 1.0570; // assume sRGB
  4439. r = r > 0.0031308 ? 1.055 * Math.pow(r, 1.0 / 2.4) - 0.055 : r * 12.92;
  4440. g = g > 0.0031308 ? 1.055 * Math.pow(g, 1.0 / 2.4) - 0.055 : g * 12.92;
  4441. b = b > 0.0031308 ? 1.055 * Math.pow(b, 1.0 / 2.4) - 0.055 : b * 12.92;
  4442. r = Math.min(Math.max(0, r), 1);
  4443. g = Math.min(Math.max(0, g), 1);
  4444. b = Math.min(Math.max(0, b), 1);
  4445. return [r * 255, g * 255, b * 255];
  4446. };
  4447. convert.xyz.lab = function (xyz) {
  4448. var x = xyz[0];
  4449. var y = xyz[1];
  4450. var z = xyz[2];
  4451. var l;
  4452. var a;
  4453. var b;
  4454. x /= 95.047;
  4455. y /= 100;
  4456. z /= 108.883;
  4457. x = x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
  4458. y = y > 0.008856 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
  4459. z = z > 0.008856 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
  4460. l = 116 * y - 16;
  4461. a = 500 * (x - y);
  4462. b = 200 * (y - z);
  4463. return [l, a, b];
  4464. };
  4465. convert.lab.xyz = function (lab) {
  4466. var l = lab[0];
  4467. var a = lab[1];
  4468. var b = lab[2];
  4469. var x;
  4470. var y;
  4471. var z;
  4472. y = (l + 16) / 116;
  4473. x = a / 500 + y;
  4474. z = y - b / 200;
  4475. var y2 = Math.pow(y, 3);
  4476. var x2 = Math.pow(x, 3);
  4477. var z2 = Math.pow(z, 3);
  4478. y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
  4479. x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
  4480. z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
  4481. x *= 95.047;
  4482. y *= 100;
  4483. z *= 108.883;
  4484. return [x, y, z];
  4485. };
  4486. convert.lab.lch = function (lab) {
  4487. var l = lab[0];
  4488. var a = lab[1];
  4489. var b = lab[2];
  4490. var hr;
  4491. var h;
  4492. var c;
  4493. hr = Math.atan2(b, a);
  4494. h = hr * 360 / 2 / Math.PI;
  4495. if (h < 0) {
  4496. h += 360;
  4497. }
  4498. c = Math.sqrt(a * a + b * b);
  4499. return [l, c, h];
  4500. };
  4501. convert.lch.lab = function (lch) {
  4502. var l = lch[0];
  4503. var c = lch[1];
  4504. var h = lch[2];
  4505. var a;
  4506. var b;
  4507. var hr;
  4508. hr = h / 360 * 2 * Math.PI;
  4509. a = c * Math.cos(hr);
  4510. b = c * Math.sin(hr);
  4511. return [l, a, b];
  4512. };
  4513. convert.rgb.ansi16 = function (args) {
  4514. var r = args[0];
  4515. var g = args[1];
  4516. var b = args[2];
  4517. var value = 1 in arguments ? arguments[1] : convert.rgb.hsv(args)[2]; // hsv -> ansi16 optimization
  4518. value = Math.round(value / 50);
  4519. if (value === 0) {
  4520. return 30;
  4521. }
  4522. var ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
  4523. if (value === 2) {
  4524. ansi += 60;
  4525. }
  4526. return ansi;
  4527. };
  4528. convert.hsv.ansi16 = function (args) {
  4529. // optimization here; we already know the value and don't need to get
  4530. // it converted for us.
  4531. return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
  4532. };
  4533. convert.rgb.ansi256 = function (args) {
  4534. var r = args[0];
  4535. var g = args[1];
  4536. var b = args[2]; // we use the extended greyscale palette here, with the exception of
  4537. // black and white. normal palette only has 4 greyscale shades.
  4538. if (r === g && g === b) {
  4539. if (r < 8) {
  4540. return 16;
  4541. }
  4542. if (r > 248) {
  4543. return 231;
  4544. }
  4545. return Math.round((r - 8) / 247 * 24) + 232;
  4546. }
  4547. var ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
  4548. return ansi;
  4549. };
  4550. convert.ansi16.rgb = function (args) {
  4551. var color = args % 10; // handle greyscale
  4552. if (color === 0 || color === 7) {
  4553. if (args > 50) {
  4554. color += 3.5;
  4555. }
  4556. color = color / 10.5 * 255;
  4557. return [color, color, color];
  4558. }
  4559. var mult = (~~(args > 50) + 1) * 0.5;
  4560. var r = (color & 1) * mult * 255;
  4561. var g = (color >> 1 & 1) * mult * 255;
  4562. var b = (color >> 2 & 1) * mult * 255;
  4563. return [r, g, b];
  4564. };
  4565. convert.ansi256.rgb = function (args) {
  4566. // handle greyscale
  4567. if (args >= 232) {
  4568. var c = (args - 232) * 10 + 8;
  4569. return [c, c, c];
  4570. }
  4571. args -= 16;
  4572. var rem;
  4573. var r = Math.floor(args / 36) / 5 * 255;
  4574. var g = Math.floor((rem = args % 36) / 6) / 5 * 255;
  4575. var b = rem % 6 / 5 * 255;
  4576. return [r, g, b];
  4577. };
  4578. convert.rgb.hex = function (args) {
  4579. var integer = ((Math.round(args[0]) & 0xFF) << 16) + ((Math.round(args[1]) & 0xFF) << 8) + (Math.round(args[2]) & 0xFF);
  4580. var string = integer.toString(16).toUpperCase();
  4581. return '000000'.substring(string.length) + string;
  4582. };
  4583. convert.hex.rgb = function (args) {
  4584. var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
  4585. if (!match) {
  4586. return [0, 0, 0];
  4587. }
  4588. var colorString = match[0];
  4589. if (match[0].length === 3) {
  4590. colorString = colorString.split('').map(function (char) {
  4591. return char + char;
  4592. }).join('');
  4593. }
  4594. var integer = parseInt(colorString, 16);
  4595. var r = integer >> 16 & 0xFF;
  4596. var g = integer >> 8 & 0xFF;
  4597. var b = integer & 0xFF;
  4598. return [r, g, b];
  4599. };
  4600. convert.rgb.hcg = function (rgb) {
  4601. var r = rgb[0] / 255;
  4602. var g = rgb[1] / 255;
  4603. var b = rgb[2] / 255;
  4604. var max = Math.max(Math.max(r, g), b);
  4605. var min = Math.min(Math.min(r, g), b);
  4606. var chroma = max - min;
  4607. var grayscale;
  4608. var hue;
  4609. if (chroma < 1) {
  4610. grayscale = min / (1 - chroma);
  4611. } else {
  4612. grayscale = 0;
  4613. }
  4614. if (chroma <= 0) {
  4615. hue = 0;
  4616. } else if (max === r) {
  4617. hue = (g - b) / chroma % 6;
  4618. } else if (max === g) {
  4619. hue = 2 + (b - r) / chroma;
  4620. } else {
  4621. hue = 4 + (r - g) / chroma + 4;
  4622. }
  4623. hue /= 6;
  4624. hue %= 1;
  4625. return [hue * 360, chroma * 100, grayscale * 100];
  4626. };
  4627. convert.hsl.hcg = function (hsl) {
  4628. var s = hsl[1] / 100;
  4629. var l = hsl[2] / 100;
  4630. var c = 1;
  4631. var f = 0;
  4632. if (l < 0.5) {
  4633. c = 2.0 * s * l;
  4634. } else {
  4635. c = 2.0 * s * (1.0 - l);
  4636. }
  4637. if (c < 1.0) {
  4638. f = (l - 0.5 * c) / (1.0 - c);
  4639. }
  4640. return [hsl[0], c * 100, f * 100];
  4641. };
  4642. convert.hsv.hcg = function (hsv) {
  4643. var s = hsv[1] / 100;
  4644. var v = hsv[2] / 100;
  4645. var c = s * v;
  4646. var f = 0;
  4647. if (c < 1.0) {
  4648. f = (v - c) / (1 - c);
  4649. }
  4650. return [hsv[0], c * 100, f * 100];
  4651. };
  4652. convert.hcg.rgb = function (hcg) {
  4653. var h = hcg[0] / 360;
  4654. var c = hcg[1] / 100;
  4655. var g = hcg[2] / 100;
  4656. if (c === 0.0) {
  4657. return [g * 255, g * 255, g * 255];
  4658. }
  4659. var pure = [0, 0, 0];
  4660. var hi = h % 1 * 6;
  4661. var v = hi % 1;
  4662. var w = 1 - v;
  4663. var mg = 0;
  4664. switch (Math.floor(hi)) {
  4665. case 0:
  4666. pure[0] = 1;
  4667. pure[1] = v;
  4668. pure[2] = 0;
  4669. break;
  4670. case 1:
  4671. pure[0] = w;
  4672. pure[1] = 1;
  4673. pure[2] = 0;
  4674. break;
  4675. case 2:
  4676. pure[0] = 0;
  4677. pure[1] = 1;
  4678. pure[2] = v;
  4679. break;
  4680. case 3:
  4681. pure[0] = 0;
  4682. pure[1] = w;
  4683. pure[2] = 1;
  4684. break;
  4685. case 4:
  4686. pure[0] = v;
  4687. pure[1] = 0;
  4688. pure[2] = 1;
  4689. break;
  4690. default:
  4691. pure[0] = 1;
  4692. pure[1] = 0;
  4693. pure[2] = w;
  4694. }
  4695. mg = (1.0 - c) * g;
  4696. return [(c * pure[0] + mg) * 255, (c * pure[1] + mg) * 255, (c * pure[2] + mg) * 255];
  4697. };
  4698. convert.hcg.hsv = function (hcg) {
  4699. var c = hcg[1] / 100;
  4700. var g = hcg[2] / 100;
  4701. var v = c + g * (1.0 - c);
  4702. var f = 0;
  4703. if (v > 0.0) {
  4704. f = c / v;
  4705. }
  4706. return [hcg[0], f * 100, v * 100];
  4707. };
  4708. convert.hcg.hsl = function (hcg) {
  4709. var c = hcg[1] / 100;
  4710. var g = hcg[2] / 100;
  4711. var l = g * (1.0 - c) + 0.5 * c;
  4712. var s = 0;
  4713. if (l > 0.0 && l < 0.5) {
  4714. s = c / (2 * l);
  4715. } else if (l >= 0.5 && l < 1.0) {
  4716. s = c / (2 * (1 - l));
  4717. }
  4718. return [hcg[0], s * 100, l * 100];
  4719. };
  4720. convert.hcg.hwb = function (hcg) {
  4721. var c = hcg[1] / 100;
  4722. var g = hcg[2] / 100;
  4723. var v = c + g * (1.0 - c);
  4724. return [hcg[0], (v - c) * 100, (1 - v) * 100];
  4725. };
  4726. convert.hwb.hcg = function (hwb) {
  4727. var w = hwb[1] / 100;
  4728. var b = hwb[2] / 100;
  4729. var v = 1 - b;
  4730. var c = v - w;
  4731. var g = 0;
  4732. if (c < 1) {
  4733. g = (v - c) / (1 - c);
  4734. }
  4735. return [hwb[0], c * 100, g * 100];
  4736. };
  4737. convert.apple.rgb = function (apple) {
  4738. return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
  4739. };
  4740. convert.rgb.apple = function (rgb) {
  4741. return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
  4742. };
  4743. convert.gray.rgb = function (args) {
  4744. return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
  4745. };
  4746. convert.gray.hsl = convert.gray.hsv = function (args) {
  4747. return [0, 0, args[0]];
  4748. };
  4749. convert.gray.hwb = function (gray) {
  4750. return [0, 100, gray[0]];
  4751. };
  4752. convert.gray.cmyk = function (gray) {
  4753. return [0, 0, 0, gray[0]];
  4754. };
  4755. convert.gray.lab = function (gray) {
  4756. return [gray[0], 0, 0];
  4757. };
  4758. convert.gray.hex = function (gray) {
  4759. var val = Math.round(gray[0] / 100 * 255) & 0xFF;
  4760. var integer = (val << 16) + (val << 8) + val;
  4761. var string = integer.toString(16).toUpperCase();
  4762. return '000000'.substring(string.length) + string;
  4763. };
  4764. convert.rgb.gray = function (rgb) {
  4765. var val = (rgb[0] + rgb[1] + rgb[2]) / 3;
  4766. return [val / 255 * 100];
  4767. };
  4768. });
  4769. /*
  4770. this function routes a model to all other models.
  4771. all functions that are routed have a property `.conversion` attached
  4772. to the returned synthetic function. This property is an array
  4773. of strings, each with the steps in between the 'from' and 'to'
  4774. color models (inclusive).
  4775. conversions that are not possible simply are not included.
  4776. */
  4777. // https://jsperf.com/object-keys-vs-for-in-with-closure/3
  4778. var models$1 = Object.keys(conversions);
  4779. function buildGraph() {
  4780. var graph = {};
  4781. for (var len = models$1.length, i = 0; i < len; i++) {
  4782. graph[models$1[i]] = {
  4783. // http://jsperf.com/1-vs-infinity
  4784. // micro-opt, but this is simple.
  4785. distance: -1,
  4786. parent: null
  4787. };
  4788. }
  4789. return graph;
  4790. } // https://en.wikipedia.org/wiki/Breadth-first_search
  4791. function deriveBFS(fromModel) {
  4792. var graph = buildGraph();
  4793. var queue = [fromModel]; // unshift -> queue -> pop
  4794. graph[fromModel].distance = 0;
  4795. while (queue.length) {
  4796. var current = queue.pop();
  4797. var adjacents = Object.keys(conversions[current]);
  4798. for (var len = adjacents.length, i = 0; i < len; i++) {
  4799. var adjacent = adjacents[i];
  4800. var node = graph[adjacent];
  4801. if (node.distance === -1) {
  4802. node.distance = graph[current].distance + 1;
  4803. node.parent = current;
  4804. queue.unshift(adjacent);
  4805. }
  4806. }
  4807. }
  4808. return graph;
  4809. }
  4810. function link(from, to) {
  4811. return function (args) {
  4812. return to(from(args));
  4813. };
  4814. }
  4815. function wrapConversion(toModel, graph) {
  4816. var path$$1 = [graph[toModel].parent, toModel];
  4817. var fn = conversions[graph[toModel].parent][toModel];
  4818. var cur = graph[toModel].parent;
  4819. while (graph[cur].parent) {
  4820. path$$1.unshift(graph[cur].parent);
  4821. fn = link(conversions[graph[cur].parent][cur], fn);
  4822. cur = graph[cur].parent;
  4823. }
  4824. fn.conversion = path$$1;
  4825. return fn;
  4826. }
  4827. var route = function route(fromModel) {
  4828. var graph = deriveBFS(fromModel);
  4829. var conversion = {};
  4830. var models = Object.keys(graph);
  4831. for (var len = models.length, i = 0; i < len; i++) {
  4832. var toModel = models[i];
  4833. var node = graph[toModel];
  4834. if (node.parent === null) {
  4835. // no possible conversion, or this node is the source model.
  4836. continue;
  4837. }
  4838. conversion[toModel] = wrapConversion(toModel, graph);
  4839. }
  4840. return conversion;
  4841. };
  4842. var convert = {};
  4843. var models = Object.keys(conversions);
  4844. function wrapRaw(fn) {
  4845. var wrappedFn = function wrappedFn(args) {
  4846. if (args === undefined || args === null) {
  4847. return args;
  4848. }
  4849. if (arguments.length > 1) {
  4850. args = Array.prototype.slice.call(arguments);
  4851. }
  4852. return fn(args);
  4853. }; // preserve .conversion property if there is one
  4854. if ('conversion' in fn) {
  4855. wrappedFn.conversion = fn.conversion;
  4856. }
  4857. return wrappedFn;
  4858. }
  4859. function wrapRounded(fn) {
  4860. var wrappedFn = function wrappedFn(args) {
  4861. if (args === undefined || args === null) {
  4862. return args;
  4863. }
  4864. if (arguments.length > 1) {
  4865. args = Array.prototype.slice.call(arguments);
  4866. }
  4867. var result = fn(args); // we're assuming the result is an array here.
  4868. // see notice in conversions.js; don't use box types
  4869. // in conversion functions.
  4870. if (typeof result === 'object') {
  4871. for (var len = result.length, i = 0; i < len; i++) {
  4872. result[i] = Math.round(result[i]);
  4873. }
  4874. }
  4875. return result;
  4876. }; // preserve .conversion property if there is one
  4877. if ('conversion' in fn) {
  4878. wrappedFn.conversion = fn.conversion;
  4879. }
  4880. return wrappedFn;
  4881. }
  4882. models.forEach(function (fromModel) {
  4883. convert[fromModel] = {};
  4884. Object.defineProperty(convert[fromModel], 'channels', {
  4885. value: conversions[fromModel].channels
  4886. });
  4887. Object.defineProperty(convert[fromModel], 'labels', {
  4888. value: conversions[fromModel].labels
  4889. });
  4890. var routes = route(fromModel);
  4891. var routeModels = Object.keys(routes);
  4892. routeModels.forEach(function (toModel) {
  4893. var fn = routes[toModel];
  4894. convert[fromModel][toModel] = wrapRounded(fn);
  4895. convert[fromModel][toModel].raw = wrapRaw(fn);
  4896. });
  4897. });
  4898. var colorConvert = convert;
  4899. var ansiStyles = createCommonjsModule(function (module) {
  4900. 'use strict';
  4901. var wrapAnsi16 = function wrapAnsi16(fn, offset) {
  4902. return function () {
  4903. var code = fn.apply(colorConvert, arguments);
  4904. return `\u001B[${code + offset}m`;
  4905. };
  4906. };
  4907. var wrapAnsi256 = function wrapAnsi256(fn, offset) {
  4908. return function () {
  4909. var code = fn.apply(colorConvert, arguments);
  4910. return `\u001B[${38 + offset};5;${code}m`;
  4911. };
  4912. };
  4913. var wrapAnsi16m = function wrapAnsi16m(fn, offset) {
  4914. return function () {
  4915. var rgb = fn.apply(colorConvert, arguments);
  4916. return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
  4917. };
  4918. };
  4919. function assembleStyles() {
  4920. var codes = new Map();
  4921. var styles = {
  4922. modifier: {
  4923. reset: [0, 0],
  4924. // 21 isn't widely supported and 22 does the same thing
  4925. bold: [1, 22],
  4926. dim: [2, 22],
  4927. italic: [3, 23],
  4928. underline: [4, 24],
  4929. inverse: [7, 27],
  4930. hidden: [8, 28],
  4931. strikethrough: [9, 29]
  4932. },
  4933. color: {
  4934. black: [30, 39],
  4935. red: [31, 39],
  4936. green: [32, 39],
  4937. yellow: [33, 39],
  4938. blue: [34, 39],
  4939. magenta: [35, 39],
  4940. cyan: [36, 39],
  4941. white: [37, 39],
  4942. gray: [90, 39],
  4943. // Bright color
  4944. redBright: [91, 39],
  4945. greenBright: [92, 39],
  4946. yellowBright: [93, 39],
  4947. blueBright: [94, 39],
  4948. magentaBright: [95, 39],
  4949. cyanBright: [96, 39],
  4950. whiteBright: [97, 39]
  4951. },
  4952. bgColor: {
  4953. bgBlack: [40, 49],
  4954. bgRed: [41, 49],
  4955. bgGreen: [42, 49],
  4956. bgYellow: [43, 49],
  4957. bgBlue: [44, 49],
  4958. bgMagenta: [45, 49],
  4959. bgCyan: [46, 49],
  4960. bgWhite: [47, 49],
  4961. // Bright color
  4962. bgBlackBright: [100, 49],
  4963. bgRedBright: [101, 49],
  4964. bgGreenBright: [102, 49],
  4965. bgYellowBright: [103, 49],
  4966. bgBlueBright: [104, 49],
  4967. bgMagentaBright: [105, 49],
  4968. bgCyanBright: [106, 49],
  4969. bgWhiteBright: [107, 49]
  4970. }
  4971. }; // Fix humans
  4972. styles.color.grey = styles.color.gray;
  4973. var _arr = Object.keys(styles);
  4974. for (var _i = 0; _i < _arr.length; _i++) {
  4975. var groupName = _arr[_i];
  4976. var group = styles[groupName];
  4977. var _arr3 = Object.keys(group);
  4978. for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
  4979. var styleName = _arr3[_i3];
  4980. var style = group[styleName];
  4981. styles[styleName] = {
  4982. open: `\u001B[${style[0]}m`,
  4983. close: `\u001B[${style[1]}m`
  4984. };
  4985. group[styleName] = styles[styleName];
  4986. codes.set(style[0], style[1]);
  4987. }
  4988. Object.defineProperty(styles, groupName, {
  4989. value: group,
  4990. enumerable: false
  4991. });
  4992. Object.defineProperty(styles, 'codes', {
  4993. value: codes,
  4994. enumerable: false
  4995. });
  4996. }
  4997. var ansi2ansi = function ansi2ansi(n) {
  4998. return n;
  4999. };
  5000. var rgb2rgb = function rgb2rgb(r, g, b) {
  5001. return [r, g, b];
  5002. };
  5003. styles.color.close = '\u001B[39m';
  5004. styles.bgColor.close = '\u001B[49m';
  5005. styles.color.ansi = {
  5006. ansi: wrapAnsi16(ansi2ansi, 0)
  5007. };
  5008. styles.color.ansi256 = {
  5009. ansi256: wrapAnsi256(ansi2ansi, 0)
  5010. };
  5011. styles.color.ansi16m = {
  5012. rgb: wrapAnsi16m(rgb2rgb, 0)
  5013. };
  5014. styles.bgColor.ansi = {
  5015. ansi: wrapAnsi16(ansi2ansi, 10)
  5016. };
  5017. styles.bgColor.ansi256 = {
  5018. ansi256: wrapAnsi256(ansi2ansi, 10)
  5019. };
  5020. styles.bgColor.ansi16m = {
  5021. rgb: wrapAnsi16m(rgb2rgb, 10)
  5022. };
  5023. var _arr2 = Object.keys(colorConvert);
  5024. for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
  5025. var key = _arr2[_i2];
  5026. if (typeof colorConvert[key] !== 'object') {
  5027. continue;
  5028. }
  5029. var suite = colorConvert[key];
  5030. if (key === 'ansi16') {
  5031. key = 'ansi';
  5032. }
  5033. if ('ansi16' in suite) {
  5034. styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0);
  5035. styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10);
  5036. }
  5037. if ('ansi256' in suite) {
  5038. styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0);
  5039. styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10);
  5040. }
  5041. if ('rgb' in suite) {
  5042. styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0);
  5043. styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10);
  5044. }
  5045. }
  5046. return styles;
  5047. } // Make the export immutable
  5048. Object.defineProperty(module, 'exports', {
  5049. enumerable: true,
  5050. get: assembleStyles
  5051. });
  5052. });
  5053. var hasFlag = createCommonjsModule(function (module) {
  5054. 'use strict';
  5055. module.exports = function (flag, argv) {
  5056. argv = argv || process.argv;
  5057. var prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
  5058. var pos = argv.indexOf(prefix + flag);
  5059. var terminatorPos = argv.indexOf('--');
  5060. return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
  5061. };
  5062. });
  5063. var env = process.env;
  5064. var forceColor;
  5065. if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false')) {
  5066. forceColor = false;
  5067. } else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) {
  5068. forceColor = true;
  5069. }
  5070. if ('FORCE_COLOR' in env) {
  5071. forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0;
  5072. }
  5073. function translateLevel(level) {
  5074. if (level === 0) {
  5075. return false;
  5076. }
  5077. return {
  5078. level,
  5079. hasBasic: true,
  5080. has256: level >= 2,
  5081. has16m: level >= 3
  5082. };
  5083. }
  5084. function supportsColor(stream) {
  5085. if (forceColor === false) {
  5086. return 0;
  5087. }
  5088. if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) {
  5089. return 3;
  5090. }
  5091. if (hasFlag('color=256')) {
  5092. return 2;
  5093. }
  5094. if (stream && !stream.isTTY && forceColor !== true) {
  5095. return 0;
  5096. }
  5097. var min = forceColor ? 1 : 0;
  5098. if (process.platform === 'win32') {
  5099. // Node.js 7.5.0 is the first version of Node.js to include a patch to
  5100. // libuv that enables 256 color output on Windows. Anything earlier and it
  5101. // won't work. However, here we target Node.js 8 at minimum as it is an LTS
  5102. // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
  5103. // release that supports 256 colors. Windows 10 build 14931 is the first release
  5104. // that supports 16m/TrueColor.
  5105. var osRelease = os.release().split('.');
  5106. if (Number(process.versions.node.split('.')[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
  5107. return Number(osRelease[2]) >= 14931 ? 3 : 2;
  5108. }
  5109. return 1;
  5110. }
  5111. if ('CI' in env) {
  5112. if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(function (sign) {
  5113. return sign in env;
  5114. }) || env.CI_NAME === 'codeship') {
  5115. return 1;
  5116. }
  5117. return min;
  5118. }
  5119. if ('TEAMCITY_VERSION' in env) {
  5120. return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
  5121. }
  5122. if (env.COLORTERM === 'truecolor') {
  5123. return 3;
  5124. }
  5125. if ('TERM_PROGRAM' in env) {
  5126. var version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
  5127. switch (env.TERM_PROGRAM) {
  5128. case 'iTerm.app':
  5129. return version >= 3 ? 3 : 2;
  5130. case 'Apple_Terminal':
  5131. return 2;
  5132. // No default
  5133. }
  5134. }
  5135. if (/-256(color)?$/i.test(env.TERM)) {
  5136. return 2;
  5137. }
  5138. if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
  5139. return 1;
  5140. }
  5141. if ('COLORTERM' in env) {
  5142. return 1;
  5143. }
  5144. if (env.TERM === 'dumb') {
  5145. return min;
  5146. }
  5147. return min;
  5148. }
  5149. function getSupportLevel(stream) {
  5150. var level = supportsColor(stream);
  5151. return translateLevel(level);
  5152. }
  5153. var supportsColor_1 = {
  5154. supportsColor: getSupportLevel,
  5155. stdout: getSupportLevel(process.stdout),
  5156. stderr: getSupportLevel(process.stderr)
  5157. };
  5158. var templates = createCommonjsModule(function (module) {
  5159. 'use strict';
  5160. var TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
  5161. var STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
  5162. var STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
  5163. var ESCAPE_REGEX = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi;
  5164. var ESCAPES = new Map([['n', '\n'], ['r', '\r'], ['t', '\t'], ['b', '\b'], ['f', '\f'], ['v', '\v'], ['0', '\0'], ['\\', '\\'], ['e', '\u001B'], ['a', '\u0007']]);
  5165. function unescape(c) {
  5166. if (c[0] === 'u' && c.length === 5 || c[0] === 'x' && c.length === 3) {
  5167. return String.fromCharCode(parseInt(c.slice(1), 16));
  5168. }
  5169. return ESCAPES.get(c) || c;
  5170. }
  5171. function parseArguments(name, args) {
  5172. var results = [];
  5173. var chunks = args.trim().split(/\s*,\s*/g);
  5174. var matches;
  5175. var _iteratorNormalCompletion = true;
  5176. var _didIteratorError = false;
  5177. var _iteratorError = undefined;
  5178. try {
  5179. for (var _iterator = chunks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  5180. var chunk = _step.value;
  5181. if (!isNaN(chunk)) {
  5182. results.push(Number(chunk));
  5183. } else if (matches = chunk.match(STRING_REGEX)) {
  5184. results.push(matches[2].replace(ESCAPE_REGEX, function (m, escape, chr) {
  5185. return escape ? unescape(escape) : chr;
  5186. }));
  5187. } else {
  5188. throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
  5189. }
  5190. }
  5191. } catch (err) {
  5192. _didIteratorError = true;
  5193. _iteratorError = err;
  5194. } finally {
  5195. try {
  5196. if (!_iteratorNormalCompletion && _iterator.return != null) {
  5197. _iterator.return();
  5198. }
  5199. } finally {
  5200. if (_didIteratorError) {
  5201. throw _iteratorError;
  5202. }
  5203. }
  5204. }
  5205. return results;
  5206. }
  5207. function parseStyle(style) {
  5208. STYLE_REGEX.lastIndex = 0;
  5209. var results = [];
  5210. var matches;
  5211. while ((matches = STYLE_REGEX.exec(style)) !== null) {
  5212. var name = matches[1];
  5213. if (matches[2]) {
  5214. var args = parseArguments(name, matches[2]);
  5215. results.push([name].concat(args));
  5216. } else {
  5217. results.push([name]);
  5218. }
  5219. }
  5220. return results;
  5221. }
  5222. function buildStyle(chalk, styles) {
  5223. var enabled = {};
  5224. var _iteratorNormalCompletion2 = true;
  5225. var _didIteratorError2 = false;
  5226. var _iteratorError2 = undefined;
  5227. try {
  5228. for (var _iterator2 = styles[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  5229. var layer = _step2.value;
  5230. var _iteratorNormalCompletion3 = true;
  5231. var _didIteratorError3 = false;
  5232. var _iteratorError3 = undefined;
  5233. try {
  5234. for (var _iterator3 = layer.styles[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  5235. var style = _step3.value;
  5236. enabled[style[0]] = layer.inverse ? null : style.slice(1);
  5237. }
  5238. } catch (err) {
  5239. _didIteratorError3 = true;
  5240. _iteratorError3 = err;
  5241. } finally {
  5242. try {
  5243. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  5244. _iterator3.return();
  5245. }
  5246. } finally {
  5247. if (_didIteratorError3) {
  5248. throw _iteratorError3;
  5249. }
  5250. }
  5251. }
  5252. }
  5253. } catch (err) {
  5254. _didIteratorError2 = true;
  5255. _iteratorError2 = err;
  5256. } finally {
  5257. try {
  5258. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  5259. _iterator2.return();
  5260. }
  5261. } finally {
  5262. if (_didIteratorError2) {
  5263. throw _iteratorError2;
  5264. }
  5265. }
  5266. }
  5267. var current = chalk;
  5268. var _arr = Object.keys(enabled);
  5269. for (var _i = 0; _i < _arr.length; _i++) {
  5270. var styleName = _arr[_i];
  5271. if (Array.isArray(enabled[styleName])) {
  5272. if (!(styleName in current)) {
  5273. throw new Error(`Unknown Chalk style: ${styleName}`);
  5274. }
  5275. if (enabled[styleName].length > 0) {
  5276. current = current[styleName].apply(current, enabled[styleName]);
  5277. } else {
  5278. current = current[styleName];
  5279. }
  5280. }
  5281. }
  5282. return current;
  5283. }
  5284. module.exports = function (chalk, tmp) {
  5285. var styles = [];
  5286. var chunks = [];
  5287. var chunk = []; // eslint-disable-next-line max-params
  5288. tmp.replace(TEMPLATE_REGEX, function (m, escapeChar, inverse, style, close, chr) {
  5289. if (escapeChar) {
  5290. chunk.push(unescape(escapeChar));
  5291. } else if (style) {
  5292. var str = chunk.join('');
  5293. chunk = [];
  5294. chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str));
  5295. styles.push({
  5296. inverse,
  5297. styles: parseStyle(style)
  5298. });
  5299. } else if (close) {
  5300. if (styles.length === 0) {
  5301. throw new Error('Found extraneous } in Chalk template literal');
  5302. }
  5303. chunks.push(buildStyle(chalk, styles)(chunk.join('')));
  5304. chunk = [];
  5305. styles.pop();
  5306. } else {
  5307. chunk.push(chr);
  5308. }
  5309. });
  5310. chunks.push(chunk.join(''));
  5311. if (styles.length > 0) {
  5312. var errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
  5313. throw new Error(errMsg);
  5314. }
  5315. return chunks.join('');
  5316. };
  5317. });
  5318. var chalk = createCommonjsModule(function (module) {
  5319. 'use strict';
  5320. var stdoutColor = supportsColor_1.stdout;
  5321. var isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm'); // `supportsColor.level` → `ansiStyles.color[name]` mapping
  5322. var levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m']; // `color-convert` models to exclude from the Chalk API due to conflicts and such
  5323. var skipModels = new Set(['gray']);
  5324. var styles = Object.create(null);
  5325. function applyOptions(obj, options) {
  5326. options = options || {}; // Detect level if not set manually
  5327. var scLevel = stdoutColor ? stdoutColor.level : 0;
  5328. obj.level = options.level === undefined ? scLevel : options.level;
  5329. obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
  5330. }
  5331. function Chalk(options) {
  5332. // We check for this.template here since calling `chalk.constructor()`
  5333. // by itself will have a `this` of a previously constructed chalk object
  5334. if (!this || !(this instanceof Chalk) || this.template) {
  5335. var _chalk = {};
  5336. applyOptions(_chalk, options);
  5337. _chalk.template = function () {
  5338. var args = [].slice.call(arguments);
  5339. return chalkTag.apply(null, [_chalk.template].concat(args));
  5340. };
  5341. Object.setPrototypeOf(_chalk, Chalk.prototype);
  5342. Object.setPrototypeOf(_chalk.template, _chalk);
  5343. _chalk.template.constructor = Chalk;
  5344. return _chalk.template;
  5345. }
  5346. applyOptions(this, options);
  5347. } // Use bright blue on Windows as the normal blue color is illegible
  5348. if (isSimpleWindowsTerm) {
  5349. ansiStyles.blue.open = '\u001B[94m';
  5350. }
  5351. var _arr = Object.keys(ansiStyles);
  5352. var _loop = function _loop() {
  5353. var key = _arr[_i];
  5354. ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
  5355. styles[key] = {
  5356. get() {
  5357. var codes = ansiStyles[key];
  5358. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);
  5359. }
  5360. };
  5361. };
  5362. for (var _i = 0; _i < _arr.length; _i++) {
  5363. _loop();
  5364. }
  5365. styles.visible = {
  5366. get() {
  5367. return build.call(this, this._styles || [], true, 'visible');
  5368. }
  5369. };
  5370. ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g');
  5371. var _arr2 = Object.keys(ansiStyles.color.ansi);
  5372. var _loop2 = function _loop2() {
  5373. var model = _arr2[_i2];
  5374. if (skipModels.has(model)) {
  5375. return "continue";
  5376. }
  5377. styles[model] = {
  5378. get() {
  5379. var level = this.level;
  5380. return function () {
  5381. var open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments);
  5382. var codes = {
  5383. open,
  5384. close: ansiStyles.color.close,
  5385. closeRe: ansiStyles.color.closeRe
  5386. };
  5387. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
  5388. };
  5389. }
  5390. };
  5391. };
  5392. for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
  5393. var _ret = _loop2();
  5394. if (_ret === "continue") continue;
  5395. }
  5396. ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), 'g');
  5397. var _arr3 = Object.keys(ansiStyles.bgColor.ansi);
  5398. var _loop3 = function _loop3() {
  5399. var model = _arr3[_i3];
  5400. if (skipModels.has(model)) {
  5401. return "continue";
  5402. }
  5403. var bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
  5404. styles[bgModel] = {
  5405. get() {
  5406. var level = this.level;
  5407. return function () {
  5408. var open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments);
  5409. var codes = {
  5410. open,
  5411. close: ansiStyles.bgColor.close,
  5412. closeRe: ansiStyles.bgColor.closeRe
  5413. };
  5414. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
  5415. };
  5416. }
  5417. };
  5418. };
  5419. for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
  5420. var _ret2 = _loop3();
  5421. if (_ret2 === "continue") continue;
  5422. }
  5423. var proto = Object.defineProperties(function () {}, styles);
  5424. function build(_styles, _empty, key) {
  5425. var builder = function builder() {
  5426. return applyStyle.apply(builder, arguments);
  5427. };
  5428. builder._styles = _styles;
  5429. builder._empty = _empty;
  5430. var self = this;
  5431. Object.defineProperty(builder, 'level', {
  5432. enumerable: true,
  5433. get() {
  5434. return self.level;
  5435. },
  5436. set(level) {
  5437. self.level = level;
  5438. }
  5439. });
  5440. Object.defineProperty(builder, 'enabled', {
  5441. enumerable: true,
  5442. get() {
  5443. return self.enabled;
  5444. },
  5445. set(enabled) {
  5446. self.enabled = enabled;
  5447. }
  5448. }); // See below for fix regarding invisible grey/dim combination on Windows
  5449. builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey'; // `__proto__` is used because we must return a function, but there is
  5450. // no way to create a function with a different prototype
  5451. builder.__proto__ = proto; // eslint-disable-line no-proto
  5452. return builder;
  5453. }
  5454. function applyStyle() {
  5455. // Support varags, but simply cast to string in case there's only one arg
  5456. var args = arguments;
  5457. var argsLen = args.length;
  5458. var str = String(arguments[0]);
  5459. if (argsLen === 0) {
  5460. return '';
  5461. }
  5462. if (argsLen > 1) {
  5463. // Don't slice `arguments`, it prevents V8 optimizations
  5464. for (var a = 1; a < argsLen; a++) {
  5465. str += ' ' + args[a];
  5466. }
  5467. }
  5468. if (!this.enabled || this.level <= 0 || !str) {
  5469. return this._empty ? '' : str;
  5470. } // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
  5471. // see https://github.com/chalk/chalk/issues/58
  5472. // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
  5473. var originalDim = ansiStyles.dim.open;
  5474. if (isSimpleWindowsTerm && this.hasGrey) {
  5475. ansiStyles.dim.open = '';
  5476. }
  5477. var _iteratorNormalCompletion = true;
  5478. var _didIteratorError = false;
  5479. var _iteratorError = undefined;
  5480. try {
  5481. for (var _iterator = this._styles.slice().reverse()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  5482. var code = _step.value;
  5483. // Replace any instances already present with a re-opening code
  5484. // otherwise only the part of the string until said closing code
  5485. // will be colored, and the rest will simply be 'plain'.
  5486. str = code.open + str.replace(code.closeRe, code.open) + code.close; // Close the styling before a linebreak and reopen
  5487. // after next line to fix a bleed issue on macOS
  5488. // https://github.com/chalk/chalk/pull/92
  5489. str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`);
  5490. } // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue
  5491. } catch (err) {
  5492. _didIteratorError = true;
  5493. _iteratorError = err;
  5494. } finally {
  5495. try {
  5496. if (!_iteratorNormalCompletion && _iterator.return != null) {
  5497. _iterator.return();
  5498. }
  5499. } finally {
  5500. if (_didIteratorError) {
  5501. throw _iteratorError;
  5502. }
  5503. }
  5504. }
  5505. ansiStyles.dim.open = originalDim;
  5506. return str;
  5507. }
  5508. function chalkTag(chalk, strings) {
  5509. if (!Array.isArray(strings)) {
  5510. // If chalk() was called by itself or with a string,
  5511. // return the string itself as a string.
  5512. return [].slice.call(arguments, 1).join(' ');
  5513. }
  5514. var args = [].slice.call(arguments, 2);
  5515. var parts = [strings.raw[0]];
  5516. for (var i = 1; i < strings.length; i++) {
  5517. parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&'));
  5518. parts.push(String(strings.raw[i]));
  5519. }
  5520. return templates(chalk, parts.join(''));
  5521. }
  5522. Object.defineProperties(Chalk.prototype, styles);
  5523. module.exports = Chalk(); // eslint-disable-line new-cap
  5524. module.exports.supportsColor = stdoutColor;
  5525. module.exports.default = module.exports; // For TypeScript
  5526. });
  5527. var common = createCommonjsModule(function (module, exports) {
  5528. "use strict";
  5529. Object.defineProperty(exports, "__esModule", {
  5530. value: true
  5531. });
  5532. exports.commonDeprecatedHandler = function (keyOrPair, redirectTo, _ref) {
  5533. var descriptor = _ref.descriptor;
  5534. var messages = [`${chalk.default.yellow(typeof keyOrPair === 'string' ? descriptor.key(keyOrPair) : descriptor.pair(keyOrPair))} is deprecated`];
  5535. if (redirectTo) {
  5536. messages.push(`we now treat it as ${chalk.default.blue(typeof redirectTo === 'string' ? descriptor.key(redirectTo) : descriptor.pair(redirectTo))}`);
  5537. }
  5538. return messages.join('; ') + '.';
  5539. };
  5540. });
  5541. unwrapExports(common);
  5542. var deprecated = createCommonjsModule(function (module, exports) {
  5543. "use strict";
  5544. Object.defineProperty(exports, "__esModule", {
  5545. value: true
  5546. });
  5547. tslib_1.__exportStar(common, exports);
  5548. });
  5549. unwrapExports(deprecated);
  5550. var common$2 = createCommonjsModule(function (module, exports) {
  5551. "use strict";
  5552. Object.defineProperty(exports, "__esModule", {
  5553. value: true
  5554. });
  5555. exports.commonInvalidHandler = function (key, value, utils) {
  5556. return [`Invalid ${chalk.default.red(utils.descriptor.key(key))} value.`, `Expected ${chalk.default.blue(utils.schemas[key].expected(utils))},`, `but received ${chalk.default.red(utils.descriptor.value(value))}.`].join(' ');
  5557. };
  5558. });
  5559. unwrapExports(common$2);
  5560. var invalid = createCommonjsModule(function (module, exports) {
  5561. "use strict";
  5562. Object.defineProperty(exports, "__esModule", {
  5563. value: true
  5564. });
  5565. tslib_1.__exportStar(common$2, exports);
  5566. });
  5567. unwrapExports(invalid);
  5568. /* eslint-disable no-nested-ternary */
  5569. var arr = [];
  5570. var charCodeCache = [];
  5571. var leven$1 = function leven(a, b) {
  5572. if (a === b) {
  5573. return 0;
  5574. }
  5575. var swap = a; // Swapping the strings if `a` is longer than `b` so we know which one is the
  5576. // shortest & which one is the longest
  5577. if (a.length > b.length) {
  5578. a = b;
  5579. b = swap;
  5580. }
  5581. var aLen = a.length;
  5582. var bLen = b.length;
  5583. if (aLen === 0) {
  5584. return bLen;
  5585. }
  5586. if (bLen === 0) {
  5587. return aLen;
  5588. } // Performing suffix trimming:
  5589. // We can linearly drop suffix common to both strings since they
  5590. // don't increase distance at all
  5591. // Note: `~-` is the bitwise way to perform a `- 1` operation
  5592. while (aLen > 0 && a.charCodeAt(~-aLen) === b.charCodeAt(~-bLen)) {
  5593. aLen--;
  5594. bLen--;
  5595. }
  5596. if (aLen === 0) {
  5597. return bLen;
  5598. } // Performing prefix trimming
  5599. // We can linearly drop prefix common to both strings since they
  5600. // don't increase distance at all
  5601. var start = 0;
  5602. while (start < aLen && a.charCodeAt(start) === b.charCodeAt(start)) {
  5603. start++;
  5604. }
  5605. aLen -= start;
  5606. bLen -= start;
  5607. if (aLen === 0) {
  5608. return bLen;
  5609. }
  5610. var bCharCode;
  5611. var ret;
  5612. var tmp;
  5613. var tmp2;
  5614. var i = 0;
  5615. var j = 0;
  5616. while (i < aLen) {
  5617. charCodeCache[start + i] = a.charCodeAt(start + i);
  5618. arr[i] = ++i;
  5619. }
  5620. while (j < bLen) {
  5621. bCharCode = b.charCodeAt(start + j);
  5622. tmp = j++;
  5623. ret = j;
  5624. for (i = 0; i < aLen; i++) {
  5625. tmp2 = bCharCode === charCodeCache[start + i] ? tmp : tmp + 1;
  5626. tmp = arr[i];
  5627. ret = arr[i] = tmp > ret ? tmp2 > ret ? ret + 1 : tmp2 : tmp2 > tmp ? tmp + 1 : tmp2;
  5628. }
  5629. }
  5630. return ret;
  5631. };
  5632. var leven_1 = createCommonjsModule(function (module, exports) {
  5633. "use strict";
  5634. Object.defineProperty(exports, "__esModule", {
  5635. value: true
  5636. });
  5637. exports.levenUnknownHandler = function (key, value, _ref) {
  5638. var descriptor = _ref.descriptor,
  5639. logger = _ref.logger,
  5640. schemas = _ref.schemas;
  5641. var messages = [`Ignored unknown option ${chalk.default.yellow(descriptor.pair({
  5642. key,
  5643. value
  5644. }))}.`];
  5645. var suggestion = Object.keys(schemas).sort().find(function (knownKey) {
  5646. return leven$1(key, knownKey) < 3;
  5647. });
  5648. if (suggestion) {
  5649. messages.push(`Did you mean ${chalk.default.blue(descriptor.key(suggestion))}?`);
  5650. }
  5651. logger.warn(messages.join(' '));
  5652. };
  5653. });
  5654. unwrapExports(leven_1);
  5655. var unknown = createCommonjsModule(function (module, exports) {
  5656. "use strict";
  5657. Object.defineProperty(exports, "__esModule", {
  5658. value: true
  5659. });
  5660. tslib_1.__exportStar(leven_1, exports);
  5661. });
  5662. unwrapExports(unknown);
  5663. var handlers = createCommonjsModule(function (module, exports) {
  5664. "use strict";
  5665. Object.defineProperty(exports, "__esModule", {
  5666. value: true
  5667. });
  5668. tslib_1.__exportStar(deprecated, exports);
  5669. tslib_1.__exportStar(invalid, exports);
  5670. tslib_1.__exportStar(unknown, exports);
  5671. });
  5672. unwrapExports(handlers);
  5673. var schema = createCommonjsModule(function (module, exports) {
  5674. "use strict";
  5675. Object.defineProperty(exports, "__esModule", {
  5676. value: true
  5677. });
  5678. var HANDLER_KEYS = ['default', 'expected', 'validate', 'deprecated', 'forward', 'redirect', 'overlap', 'preprocess', 'postprocess'];
  5679. function createSchema(SchemaConstructor, parameters) {
  5680. var schema = new SchemaConstructor(parameters);
  5681. var subSchema = Object.create(schema);
  5682. for (var _i = 0; _i < HANDLER_KEYS.length; _i++) {
  5683. var handlerKey = HANDLER_KEYS[_i];
  5684. if (handlerKey in parameters) {
  5685. subSchema[handlerKey] = normalizeHandler(parameters[handlerKey], schema, Schema.prototype[handlerKey].length);
  5686. }
  5687. }
  5688. return subSchema;
  5689. }
  5690. exports.createSchema = createSchema;
  5691. var Schema =
  5692. /*#__PURE__*/
  5693. function () {
  5694. function Schema(parameters) {
  5695. _classCallCheck(this, Schema);
  5696. this.name = parameters.name;
  5697. }
  5698. _createClass(Schema, [{
  5699. key: "default",
  5700. value: function _default(_utils) {
  5701. return undefined;
  5702. } // istanbul ignore next: this is actually an abstract method but we need a placeholder to get `function.length`
  5703. }, {
  5704. key: "expected",
  5705. value: function expected(_utils) {
  5706. return 'nothing';
  5707. } // istanbul ignore next: this is actually an abstract method but we need a placeholder to get `function.length`
  5708. }, {
  5709. key: "validate",
  5710. value: function validate(_value, _utils) {
  5711. return false;
  5712. }
  5713. }, {
  5714. key: "deprecated",
  5715. value: function deprecated(_value, _utils) {
  5716. return false;
  5717. }
  5718. }, {
  5719. key: "forward",
  5720. value: function forward(_value, _utils) {
  5721. return undefined;
  5722. }
  5723. }, {
  5724. key: "redirect",
  5725. value: function redirect(_value, _utils) {
  5726. return undefined;
  5727. }
  5728. }, {
  5729. key: "overlap",
  5730. value: function overlap(currentValue, _newValue, _utils) {
  5731. return currentValue;
  5732. }
  5733. }, {
  5734. key: "preprocess",
  5735. value: function preprocess(value, _utils) {
  5736. return value;
  5737. }
  5738. }, {
  5739. key: "postprocess",
  5740. value: function postprocess(value, _utils) {
  5741. return value;
  5742. }
  5743. }], [{
  5744. key: "create",
  5745. value: function create(parameters) {
  5746. // @ts-ignore: https://github.com/Microsoft/TypeScript/issues/5863
  5747. return createSchema(this, parameters);
  5748. }
  5749. }]);
  5750. return Schema;
  5751. }();
  5752. exports.Schema = Schema;
  5753. function normalizeHandler(handler, superSchema, handlerArgumentsLength) {
  5754. return typeof handler === 'function' ? function () {
  5755. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  5756. args[_key] = arguments[_key];
  5757. }
  5758. return handler.apply(void 0, _toConsumableArray(args.slice(0, handlerArgumentsLength - 1)).concat([superSchema], _toConsumableArray(args.slice(handlerArgumentsLength - 1))));
  5759. } : function () {
  5760. return handler;
  5761. };
  5762. }
  5763. });
  5764. unwrapExports(schema);
  5765. var alias = createCommonjsModule(function (module, exports) {
  5766. "use strict";
  5767. Object.defineProperty(exports, "__esModule", {
  5768. value: true
  5769. });
  5770. var AliasSchema =
  5771. /*#__PURE__*/
  5772. function (_schema_1$Schema) {
  5773. _inherits(AliasSchema, _schema_1$Schema);
  5774. function AliasSchema(parameters) {
  5775. var _this;
  5776. _classCallCheck(this, AliasSchema);
  5777. _this = _possibleConstructorReturn(this, _getPrototypeOf(AliasSchema).call(this, parameters));
  5778. _this._sourceName = parameters.sourceName;
  5779. return _this;
  5780. }
  5781. _createClass(AliasSchema, [{
  5782. key: "expected",
  5783. value: function expected(utils) {
  5784. return utils.schemas[this._sourceName].expected(utils);
  5785. }
  5786. }, {
  5787. key: "validate",
  5788. value: function validate(value, utils) {
  5789. return utils.schemas[this._sourceName].validate(value, utils);
  5790. }
  5791. }, {
  5792. key: "redirect",
  5793. value: function redirect(_value, _utils) {
  5794. return this._sourceName;
  5795. }
  5796. }]);
  5797. return AliasSchema;
  5798. }(schema.Schema);
  5799. exports.AliasSchema = AliasSchema;
  5800. });
  5801. unwrapExports(alias);
  5802. var any = createCommonjsModule(function (module, exports) {
  5803. "use strict";
  5804. Object.defineProperty(exports, "__esModule", {
  5805. value: true
  5806. });
  5807. var AnySchema =
  5808. /*#__PURE__*/
  5809. function (_schema_1$Schema) {
  5810. _inherits(AnySchema, _schema_1$Schema);
  5811. function AnySchema() {
  5812. _classCallCheck(this, AnySchema);
  5813. return _possibleConstructorReturn(this, _getPrototypeOf(AnySchema).apply(this, arguments));
  5814. }
  5815. _createClass(AnySchema, [{
  5816. key: "expected",
  5817. value: function expected() {
  5818. return 'anything';
  5819. }
  5820. }, {
  5821. key: "validate",
  5822. value: function validate() {
  5823. return true;
  5824. }
  5825. }]);
  5826. return AnySchema;
  5827. }(schema.Schema);
  5828. exports.AnySchema = AnySchema;
  5829. });
  5830. unwrapExports(any);
  5831. var array$2 = createCommonjsModule(function (module, exports) {
  5832. "use strict";
  5833. Object.defineProperty(exports, "__esModule", {
  5834. value: true
  5835. });
  5836. var ArraySchema =
  5837. /*#__PURE__*/
  5838. function (_schema_1$Schema) {
  5839. _inherits(ArraySchema, _schema_1$Schema);
  5840. function ArraySchema(_a) {
  5841. var _this;
  5842. _classCallCheck(this, ArraySchema);
  5843. var valueSchema = _a.valueSchema,
  5844. _a$name = _a.name,
  5845. name = _a$name === void 0 ? valueSchema.name : _a$name,
  5846. handlers = tslib_1.__rest(_a, ["valueSchema", "name"]);
  5847. _this = _possibleConstructorReturn(this, _getPrototypeOf(ArraySchema).call(this, Object.assign({}, handlers, {
  5848. name
  5849. })));
  5850. _this._valueSchema = valueSchema;
  5851. return _this;
  5852. }
  5853. _createClass(ArraySchema, [{
  5854. key: "expected",
  5855. value: function expected(utils) {
  5856. return `an array of ${this._valueSchema.expected(utils)}`;
  5857. }
  5858. }, {
  5859. key: "validate",
  5860. value: function validate(value, utils) {
  5861. if (!Array.isArray(value)) {
  5862. return false;
  5863. }
  5864. var invalidValues = [];
  5865. var _iteratorNormalCompletion = true;
  5866. var _didIteratorError = false;
  5867. var _iteratorError = undefined;
  5868. try {
  5869. for (var _iterator = value[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  5870. var subValue = _step.value;
  5871. var subValidateResult = utils.normalizeValidateResult(this._valueSchema.validate(subValue, utils), subValue);
  5872. if (subValidateResult !== true) {
  5873. invalidValues.push(subValidateResult.value);
  5874. }
  5875. }
  5876. } catch (err) {
  5877. _didIteratorError = true;
  5878. _iteratorError = err;
  5879. } finally {
  5880. try {
  5881. if (!_iteratorNormalCompletion && _iterator.return != null) {
  5882. _iterator.return();
  5883. }
  5884. } finally {
  5885. if (_didIteratorError) {
  5886. throw _iteratorError;
  5887. }
  5888. }
  5889. }
  5890. return invalidValues.length === 0 ? true : {
  5891. value: invalidValues
  5892. };
  5893. }
  5894. }, {
  5895. key: "deprecated",
  5896. value: function deprecated(value, utils) {
  5897. var deprecatedResult = [];
  5898. var _iteratorNormalCompletion2 = true;
  5899. var _didIteratorError2 = false;
  5900. var _iteratorError2 = undefined;
  5901. try {
  5902. for (var _iterator2 = value[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  5903. var subValue = _step2.value;
  5904. var subDeprecatedResult = utils.normalizeDeprecatedResult(this._valueSchema.deprecated(subValue, utils), subValue);
  5905. if (subDeprecatedResult !== false) {
  5906. deprecatedResult.push.apply(deprecatedResult, _toConsumableArray(subDeprecatedResult.map(function (_ref) {
  5907. var deprecatedValue = _ref.value;
  5908. return {
  5909. value: [deprecatedValue]
  5910. };
  5911. })));
  5912. }
  5913. }
  5914. } catch (err) {
  5915. _didIteratorError2 = true;
  5916. _iteratorError2 = err;
  5917. } finally {
  5918. try {
  5919. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  5920. _iterator2.return();
  5921. }
  5922. } finally {
  5923. if (_didIteratorError2) {
  5924. throw _iteratorError2;
  5925. }
  5926. }
  5927. }
  5928. return deprecatedResult;
  5929. }
  5930. }, {
  5931. key: "forward",
  5932. value: function forward(value, utils) {
  5933. var forwardResult = [];
  5934. var _iteratorNormalCompletion3 = true;
  5935. var _didIteratorError3 = false;
  5936. var _iteratorError3 = undefined;
  5937. try {
  5938. for (var _iterator3 = value[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  5939. var subValue = _step3.value;
  5940. var subForwardResult = utils.normalizeForwardResult(this._valueSchema.forward(subValue, utils), subValue);
  5941. forwardResult.push.apply(forwardResult, _toConsumableArray(subForwardResult.map(wrapTransferResult)));
  5942. }
  5943. } catch (err) {
  5944. _didIteratorError3 = true;
  5945. _iteratorError3 = err;
  5946. } finally {
  5947. try {
  5948. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  5949. _iterator3.return();
  5950. }
  5951. } finally {
  5952. if (_didIteratorError3) {
  5953. throw _iteratorError3;
  5954. }
  5955. }
  5956. }
  5957. return forwardResult;
  5958. }
  5959. }, {
  5960. key: "redirect",
  5961. value: function redirect(value, utils) {
  5962. var remain = [];
  5963. var redirect = [];
  5964. var _iteratorNormalCompletion4 = true;
  5965. var _didIteratorError4 = false;
  5966. var _iteratorError4 = undefined;
  5967. try {
  5968. for (var _iterator4 = value[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
  5969. var subValue = _step4.value;
  5970. var subRedirectResult = utils.normalizeRedirectResult(this._valueSchema.redirect(subValue, utils), subValue);
  5971. if ('remain' in subRedirectResult) {
  5972. remain.push(subRedirectResult.remain);
  5973. }
  5974. redirect.push.apply(redirect, _toConsumableArray(subRedirectResult.redirect.map(wrapTransferResult)));
  5975. }
  5976. } catch (err) {
  5977. _didIteratorError4 = true;
  5978. _iteratorError4 = err;
  5979. } finally {
  5980. try {
  5981. if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
  5982. _iterator4.return();
  5983. }
  5984. } finally {
  5985. if (_didIteratorError4) {
  5986. throw _iteratorError4;
  5987. }
  5988. }
  5989. }
  5990. return remain.length === 0 ? {
  5991. redirect
  5992. } : {
  5993. redirect,
  5994. remain
  5995. };
  5996. }
  5997. }, {
  5998. key: "overlap",
  5999. value: function overlap(currentValue, newValue) {
  6000. return currentValue.concat(newValue);
  6001. }
  6002. }]);
  6003. return ArraySchema;
  6004. }(schema.Schema);
  6005. exports.ArraySchema = ArraySchema;
  6006. function wrapTransferResult(_ref2) {
  6007. var from = _ref2.from,
  6008. to = _ref2.to;
  6009. return {
  6010. from: [from],
  6011. to
  6012. };
  6013. }
  6014. });
  6015. unwrapExports(array$2);
  6016. var boolean_1 = createCommonjsModule(function (module, exports) {
  6017. "use strict";
  6018. Object.defineProperty(exports, "__esModule", {
  6019. value: true
  6020. });
  6021. var BooleanSchema =
  6022. /*#__PURE__*/
  6023. function (_schema_1$Schema) {
  6024. _inherits(BooleanSchema, _schema_1$Schema);
  6025. function BooleanSchema() {
  6026. _classCallCheck(this, BooleanSchema);
  6027. return _possibleConstructorReturn(this, _getPrototypeOf(BooleanSchema).apply(this, arguments));
  6028. }
  6029. _createClass(BooleanSchema, [{
  6030. key: "expected",
  6031. value: function expected() {
  6032. return 'true or false';
  6033. }
  6034. }, {
  6035. key: "validate",
  6036. value: function validate(value) {
  6037. return typeof value === 'boolean';
  6038. }
  6039. }]);
  6040. return BooleanSchema;
  6041. }(schema.Schema);
  6042. exports.BooleanSchema = BooleanSchema;
  6043. });
  6044. unwrapExports(boolean_1);
  6045. var utils = createCommonjsModule(function (module, exports) {
  6046. "use strict";
  6047. Object.defineProperty(exports, "__esModule", {
  6048. value: true
  6049. });
  6050. function recordFromArray(array, mainKey) {
  6051. var record = Object.create(null);
  6052. var _iteratorNormalCompletion = true;
  6053. var _didIteratorError = false;
  6054. var _iteratorError = undefined;
  6055. try {
  6056. for (var _iterator = array[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  6057. var value = _step.value;
  6058. var key = value[mainKey]; // istanbul ignore next
  6059. if (record[key]) {
  6060. throw new Error(`Duplicate ${mainKey} ${JSON.stringify(key)}`);
  6061. } // @ts-ignore
  6062. record[key] = value;
  6063. }
  6064. } catch (err) {
  6065. _didIteratorError = true;
  6066. _iteratorError = err;
  6067. } finally {
  6068. try {
  6069. if (!_iteratorNormalCompletion && _iterator.return != null) {
  6070. _iterator.return();
  6071. }
  6072. } finally {
  6073. if (_didIteratorError) {
  6074. throw _iteratorError;
  6075. }
  6076. }
  6077. }
  6078. return record;
  6079. }
  6080. exports.recordFromArray = recordFromArray;
  6081. function mapFromArray(array, mainKey) {
  6082. var map = new Map();
  6083. var _iteratorNormalCompletion2 = true;
  6084. var _didIteratorError2 = false;
  6085. var _iteratorError2 = undefined;
  6086. try {
  6087. for (var _iterator2 = array[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  6088. var value = _step2.value;
  6089. var key = value[mainKey]; // istanbul ignore next
  6090. if (map.has(key)) {
  6091. throw new Error(`Duplicate ${mainKey} ${JSON.stringify(key)}`);
  6092. }
  6093. map.set(key, value);
  6094. }
  6095. } catch (err) {
  6096. _didIteratorError2 = true;
  6097. _iteratorError2 = err;
  6098. } finally {
  6099. try {
  6100. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  6101. _iterator2.return();
  6102. }
  6103. } finally {
  6104. if (_didIteratorError2) {
  6105. throw _iteratorError2;
  6106. }
  6107. }
  6108. }
  6109. return map;
  6110. }
  6111. exports.mapFromArray = mapFromArray;
  6112. function createAutoChecklist() {
  6113. var map = Object.create(null);
  6114. return function (id) {
  6115. var idString = JSON.stringify(id);
  6116. if (map[idString]) {
  6117. return true;
  6118. }
  6119. map[idString] = true;
  6120. return false;
  6121. };
  6122. }
  6123. exports.createAutoChecklist = createAutoChecklist;
  6124. function partition(array, predicate) {
  6125. var trueArray = [];
  6126. var falseArray = [];
  6127. var _iteratorNormalCompletion3 = true;
  6128. var _didIteratorError3 = false;
  6129. var _iteratorError3 = undefined;
  6130. try {
  6131. for (var _iterator3 = array[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  6132. var value = _step3.value;
  6133. if (predicate(value)) {
  6134. trueArray.push(value);
  6135. } else {
  6136. falseArray.push(value);
  6137. }
  6138. }
  6139. } catch (err) {
  6140. _didIteratorError3 = true;
  6141. _iteratorError3 = err;
  6142. } finally {
  6143. try {
  6144. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  6145. _iterator3.return();
  6146. }
  6147. } finally {
  6148. if (_didIteratorError3) {
  6149. throw _iteratorError3;
  6150. }
  6151. }
  6152. }
  6153. return [trueArray, falseArray];
  6154. }
  6155. exports.partition = partition;
  6156. function isInt(value) {
  6157. return value === Math.floor(value);
  6158. }
  6159. exports.isInt = isInt;
  6160. function comparePrimitive(a, b) {
  6161. if (a === b) {
  6162. return 0;
  6163. }
  6164. var typeofA = typeof a;
  6165. var typeofB = typeof b;
  6166. var orders = ['undefined', 'object', 'boolean', 'number', 'string'];
  6167. if (typeofA !== typeofB) {
  6168. return orders.indexOf(typeofA) - orders.indexOf(typeofB);
  6169. }
  6170. if (typeofA !== 'string') {
  6171. return Number(a) - Number(b);
  6172. }
  6173. return a.localeCompare(b);
  6174. }
  6175. exports.comparePrimitive = comparePrimitive;
  6176. function normalizeDefaultResult(result) {
  6177. return result === undefined ? {} : result;
  6178. }
  6179. exports.normalizeDefaultResult = normalizeDefaultResult;
  6180. function normalizeValidateResult(result, value) {
  6181. return result === true ? true : result === false ? {
  6182. value
  6183. } : result;
  6184. }
  6185. exports.normalizeValidateResult = normalizeValidateResult;
  6186. function normalizeDeprecatedResult(result, value) {
  6187. var doNotNormalizeTrue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  6188. return result === false ? false : result === true ? doNotNormalizeTrue ? true : [{
  6189. value
  6190. }] : 'value' in result ? [result] : result.length === 0 ? false : result;
  6191. }
  6192. exports.normalizeDeprecatedResult = normalizeDeprecatedResult;
  6193. function normalizeTransferResult(result, value) {
  6194. return typeof result === 'string' || 'key' in result ? {
  6195. from: value,
  6196. to: result
  6197. } : 'from' in result ? {
  6198. from: result.from,
  6199. to: result.to
  6200. } : {
  6201. from: value,
  6202. to: result.to
  6203. };
  6204. }
  6205. exports.normalizeTransferResult = normalizeTransferResult;
  6206. function normalizeForwardResult(result, value) {
  6207. return result === undefined ? [] : Array.isArray(result) ? result.map(function (transferResult) {
  6208. return normalizeTransferResult(transferResult, value);
  6209. }) : [normalizeTransferResult(result, value)];
  6210. }
  6211. exports.normalizeForwardResult = normalizeForwardResult;
  6212. function normalizeRedirectResult(result, value) {
  6213. var redirect = normalizeForwardResult(typeof result === 'object' && 'redirect' in result ? result.redirect : result, value);
  6214. return redirect.length === 0 ? {
  6215. remain: value,
  6216. redirect
  6217. } : typeof result === 'object' && 'remain' in result ? {
  6218. remain: result.remain,
  6219. redirect
  6220. } : {
  6221. redirect
  6222. };
  6223. }
  6224. exports.normalizeRedirectResult = normalizeRedirectResult;
  6225. });
  6226. unwrapExports(utils);
  6227. var choice = createCommonjsModule(function (module, exports) {
  6228. "use strict";
  6229. Object.defineProperty(exports, "__esModule", {
  6230. value: true
  6231. });
  6232. var ChoiceSchema =
  6233. /*#__PURE__*/
  6234. function (_schema_1$Schema) {
  6235. _inherits(ChoiceSchema, _schema_1$Schema);
  6236. function ChoiceSchema(parameters) {
  6237. var _this;
  6238. _classCallCheck(this, ChoiceSchema);
  6239. _this = _possibleConstructorReturn(this, _getPrototypeOf(ChoiceSchema).call(this, parameters));
  6240. _this._choices = utils.mapFromArray(parameters.choices.map(function (choice) {
  6241. return choice && typeof choice === 'object' ? choice : {
  6242. value: choice
  6243. };
  6244. }), 'value');
  6245. return _this;
  6246. }
  6247. _createClass(ChoiceSchema, [{
  6248. key: "expected",
  6249. value: function expected(_ref) {
  6250. var _this2 = this;
  6251. var descriptor = _ref.descriptor;
  6252. var choiceValues = Array.from(this._choices.keys()).map(function (value) {
  6253. return _this2._choices.get(value);
  6254. }).filter(function (choiceInfo) {
  6255. return !choiceInfo.deprecated;
  6256. }).map(function (choiceInfo) {
  6257. return choiceInfo.value;
  6258. }).sort(utils.comparePrimitive).map(descriptor.value);
  6259. var head = choiceValues.slice(0, -2);
  6260. var tail = choiceValues.slice(-2);
  6261. return head.concat(tail.join(' or ')).join(', ');
  6262. }
  6263. }, {
  6264. key: "validate",
  6265. value: function validate(value) {
  6266. return this._choices.has(value);
  6267. }
  6268. }, {
  6269. key: "deprecated",
  6270. value: function deprecated(value) {
  6271. var choiceInfo = this._choices.get(value);
  6272. return choiceInfo && choiceInfo.deprecated ? {
  6273. value
  6274. } : false;
  6275. }
  6276. }, {
  6277. key: "forward",
  6278. value: function forward(value) {
  6279. var choiceInfo = this._choices.get(value);
  6280. return choiceInfo ? choiceInfo.forward : undefined;
  6281. }
  6282. }, {
  6283. key: "redirect",
  6284. value: function redirect(value) {
  6285. var choiceInfo = this._choices.get(value);
  6286. return choiceInfo ? choiceInfo.redirect : undefined;
  6287. }
  6288. }]);
  6289. return ChoiceSchema;
  6290. }(schema.Schema);
  6291. exports.ChoiceSchema = ChoiceSchema;
  6292. });
  6293. unwrapExports(choice);
  6294. var number = createCommonjsModule(function (module, exports) {
  6295. "use strict";
  6296. Object.defineProperty(exports, "__esModule", {
  6297. value: true
  6298. });
  6299. var NumberSchema =
  6300. /*#__PURE__*/
  6301. function (_schema_1$Schema) {
  6302. _inherits(NumberSchema, _schema_1$Schema);
  6303. function NumberSchema() {
  6304. _classCallCheck(this, NumberSchema);
  6305. return _possibleConstructorReturn(this, _getPrototypeOf(NumberSchema).apply(this, arguments));
  6306. }
  6307. _createClass(NumberSchema, [{
  6308. key: "expected",
  6309. value: function expected() {
  6310. return 'a number';
  6311. }
  6312. }, {
  6313. key: "validate",
  6314. value: function validate(value, _utils) {
  6315. return typeof value === 'number';
  6316. }
  6317. }]);
  6318. return NumberSchema;
  6319. }(schema.Schema);
  6320. exports.NumberSchema = NumberSchema;
  6321. });
  6322. unwrapExports(number);
  6323. var integer = createCommonjsModule(function (module, exports) {
  6324. "use strict";
  6325. Object.defineProperty(exports, "__esModule", {
  6326. value: true
  6327. });
  6328. var IntegerSchema =
  6329. /*#__PURE__*/
  6330. function (_number_1$NumberSchem) {
  6331. _inherits(IntegerSchema, _number_1$NumberSchem);
  6332. function IntegerSchema() {
  6333. _classCallCheck(this, IntegerSchema);
  6334. return _possibleConstructorReturn(this, _getPrototypeOf(IntegerSchema).apply(this, arguments));
  6335. }
  6336. _createClass(IntegerSchema, [{
  6337. key: "expected",
  6338. value: function expected() {
  6339. return 'an integer';
  6340. }
  6341. }, {
  6342. key: "validate",
  6343. value: function validate(value, utils$$2) {
  6344. return utils$$2.normalizeValidateResult(_get(_getPrototypeOf(IntegerSchema.prototype), "validate", this).call(this, value, utils$$2), value) === true && utils.isInt(value);
  6345. }
  6346. }]);
  6347. return IntegerSchema;
  6348. }(number.NumberSchema);
  6349. exports.IntegerSchema = IntegerSchema;
  6350. });
  6351. unwrapExports(integer);
  6352. var string = createCommonjsModule(function (module, exports) {
  6353. "use strict";
  6354. Object.defineProperty(exports, "__esModule", {
  6355. value: true
  6356. });
  6357. var StringSchema =
  6358. /*#__PURE__*/
  6359. function (_schema_1$Schema) {
  6360. _inherits(StringSchema, _schema_1$Schema);
  6361. function StringSchema() {
  6362. _classCallCheck(this, StringSchema);
  6363. return _possibleConstructorReturn(this, _getPrototypeOf(StringSchema).apply(this, arguments));
  6364. }
  6365. _createClass(StringSchema, [{
  6366. key: "expected",
  6367. value: function expected() {
  6368. return 'a string';
  6369. }
  6370. }, {
  6371. key: "validate",
  6372. value: function validate(value) {
  6373. return typeof value === 'string';
  6374. }
  6375. }]);
  6376. return StringSchema;
  6377. }(schema.Schema);
  6378. exports.StringSchema = StringSchema;
  6379. });
  6380. unwrapExports(string);
  6381. var schemas = createCommonjsModule(function (module, exports) {
  6382. "use strict";
  6383. Object.defineProperty(exports, "__esModule", {
  6384. value: true
  6385. });
  6386. tslib_1.__exportStar(alias, exports);
  6387. tslib_1.__exportStar(any, exports);
  6388. tslib_1.__exportStar(array$2, exports);
  6389. tslib_1.__exportStar(boolean_1, exports);
  6390. tslib_1.__exportStar(choice, exports);
  6391. tslib_1.__exportStar(integer, exports);
  6392. tslib_1.__exportStar(number, exports);
  6393. tslib_1.__exportStar(string, exports);
  6394. });
  6395. unwrapExports(schemas);
  6396. var defaults = createCommonjsModule(function (module, exports) {
  6397. "use strict";
  6398. Object.defineProperty(exports, "__esModule", {
  6399. value: true
  6400. });
  6401. exports.defaultDescriptor = api.apiDescriptor;
  6402. exports.defaultUnknownHandler = leven_1.levenUnknownHandler;
  6403. exports.defaultInvalidHandler = invalid.commonInvalidHandler;
  6404. exports.defaultDeprecatedHandler = common.commonDeprecatedHandler;
  6405. });
  6406. unwrapExports(defaults);
  6407. var normalize$1 = createCommonjsModule(function (module, exports) {
  6408. "use strict";
  6409. Object.defineProperty(exports, "__esModule", {
  6410. value: true
  6411. });
  6412. exports.normalize = function (options, schemas, opts) {
  6413. return new Normalizer(schemas, opts).normalize(options);
  6414. };
  6415. var Normalizer =
  6416. /*#__PURE__*/
  6417. function () {
  6418. function Normalizer(schemas, opts) {
  6419. _classCallCheck(this, Normalizer);
  6420. // istanbul ignore next
  6421. var _ref = opts || {},
  6422. _ref$logger = _ref.logger,
  6423. logger = _ref$logger === void 0 ? console : _ref$logger,
  6424. _ref$descriptor = _ref.descriptor,
  6425. descriptor = _ref$descriptor === void 0 ? defaults.defaultDescriptor : _ref$descriptor,
  6426. _ref$unknown = _ref.unknown,
  6427. unknown = _ref$unknown === void 0 ? defaults.defaultUnknownHandler : _ref$unknown,
  6428. _ref$invalid = _ref.invalid,
  6429. invalid = _ref$invalid === void 0 ? defaults.defaultInvalidHandler : _ref$invalid,
  6430. _ref$deprecated = _ref.deprecated,
  6431. deprecated = _ref$deprecated === void 0 ? defaults.defaultDeprecatedHandler : _ref$deprecated;
  6432. this._utils = {
  6433. descriptor,
  6434. logger:
  6435. /* istanbul ignore next */
  6436. logger || {
  6437. warn: function warn() {}
  6438. },
  6439. schemas: utils.recordFromArray(schemas, 'name'),
  6440. normalizeDefaultResult: utils.normalizeDefaultResult,
  6441. normalizeDeprecatedResult: utils.normalizeDeprecatedResult,
  6442. normalizeForwardResult: utils.normalizeForwardResult,
  6443. normalizeRedirectResult: utils.normalizeRedirectResult,
  6444. normalizeValidateResult: utils.normalizeValidateResult
  6445. };
  6446. this._unknownHandler = unknown;
  6447. this._invalidHandler = invalid;
  6448. this._deprecatedHandler = deprecated;
  6449. this.cleanHistory();
  6450. }
  6451. _createClass(Normalizer, [{
  6452. key: "cleanHistory",
  6453. value: function cleanHistory() {
  6454. this._hasDeprecationWarned = utils.createAutoChecklist();
  6455. }
  6456. }, {
  6457. key: "normalize",
  6458. value: function normalize(options) {
  6459. var _this = this;
  6460. var normalized = {};
  6461. var restOptionsArray = [options];
  6462. var applyNormalization = function applyNormalization() {
  6463. while (restOptionsArray.length !== 0) {
  6464. var currentOptions = restOptionsArray.shift();
  6465. var transferredOptionsArray = _this._applyNormalization(currentOptions, normalized);
  6466. restOptionsArray.push.apply(restOptionsArray, _toConsumableArray(transferredOptionsArray));
  6467. }
  6468. };
  6469. applyNormalization();
  6470. var _arr = Object.keys(this._utils.schemas);
  6471. for (var _i = 0; _i < _arr.length; _i++) {
  6472. var key = _arr[_i];
  6473. var schema = this._utils.schemas[key];
  6474. if (!(key in normalized)) {
  6475. var defaultResult = utils.normalizeDefaultResult(schema.default(this._utils));
  6476. if ('value' in defaultResult) {
  6477. restOptionsArray.push({
  6478. [key]: defaultResult.value
  6479. });
  6480. }
  6481. }
  6482. }
  6483. applyNormalization();
  6484. var _arr2 = Object.keys(this._utils.schemas);
  6485. for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
  6486. var _key = _arr2[_i2];
  6487. var _schema = this._utils.schemas[_key];
  6488. if (_key in normalized) {
  6489. normalized[_key] = _schema.postprocess(normalized[_key], this._utils);
  6490. }
  6491. }
  6492. return normalized;
  6493. }
  6494. }, {
  6495. key: "_applyNormalization",
  6496. value: function _applyNormalization(options, normalized) {
  6497. var _this2 = this;
  6498. var transferredOptionsArray = [];
  6499. var _utils_1$partition = utils.partition(Object.keys(options), function (key) {
  6500. return key in _this2._utils.schemas;
  6501. }),
  6502. _utils_1$partition2 = _slicedToArray(_utils_1$partition, 2),
  6503. knownOptionNames = _utils_1$partition2[0],
  6504. unknownOptionNames = _utils_1$partition2[1];
  6505. var _iteratorNormalCompletion = true;
  6506. var _didIteratorError = false;
  6507. var _iteratorError = undefined;
  6508. try {
  6509. var _loop = function _loop() {
  6510. var key = _step.value;
  6511. var schema = _this2._utils.schemas[key];
  6512. var value = schema.preprocess(options[key], _this2._utils);
  6513. var validateResult = utils.normalizeValidateResult(schema.validate(value, _this2._utils), value);
  6514. if (validateResult !== true) {
  6515. var invalidValue = validateResult.value;
  6516. var errorMessageOrError = _this2._invalidHandler(key, invalidValue, _this2._utils);
  6517. throw typeof errorMessageOrError === 'string' ? new Error(errorMessageOrError) :
  6518. /* istanbul ignore next*/
  6519. errorMessageOrError;
  6520. }
  6521. var appendTransferredOptions = function appendTransferredOptions(_ref2) {
  6522. var from = _ref2.from,
  6523. to = _ref2.to;
  6524. transferredOptionsArray.push(typeof to === 'string' ? {
  6525. [to]: from
  6526. } : {
  6527. [to.key]: to.value
  6528. });
  6529. };
  6530. var warnDeprecated = function warnDeprecated(_ref3) {
  6531. var currentValue = _ref3.value,
  6532. redirectTo = _ref3.redirectTo;
  6533. var deprecatedResult = utils.normalizeDeprecatedResult(schema.deprecated(currentValue, _this2._utils), value,
  6534. /* doNotNormalizeTrue */
  6535. true);
  6536. if (deprecatedResult === false) {
  6537. return;
  6538. }
  6539. if (deprecatedResult === true) {
  6540. if (!_this2._hasDeprecationWarned(key)) {
  6541. _this2._utils.logger.warn(_this2._deprecatedHandler(key, redirectTo, _this2._utils));
  6542. }
  6543. } else {
  6544. var _iteratorNormalCompletion3 = true;
  6545. var _didIteratorError3 = false;
  6546. var _iteratorError3 = undefined;
  6547. try {
  6548. for (var _iterator3 = deprecatedResult[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  6549. var deprecatedValue = _step3.value.value;
  6550. var pair = {
  6551. key,
  6552. value: deprecatedValue
  6553. };
  6554. if (!_this2._hasDeprecationWarned(pair)) {
  6555. var redirectToPair = typeof redirectTo === 'string' ? {
  6556. key: redirectTo,
  6557. value: deprecatedValue
  6558. } : redirectTo;
  6559. _this2._utils.logger.warn(_this2._deprecatedHandler(pair, redirectToPair, _this2._utils));
  6560. }
  6561. }
  6562. } catch (err) {
  6563. _didIteratorError3 = true;
  6564. _iteratorError3 = err;
  6565. } finally {
  6566. try {
  6567. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  6568. _iterator3.return();
  6569. }
  6570. } finally {
  6571. if (_didIteratorError3) {
  6572. throw _iteratorError3;
  6573. }
  6574. }
  6575. }
  6576. }
  6577. };
  6578. var forwardResult = utils.normalizeForwardResult(schema.forward(value, _this2._utils), value);
  6579. forwardResult.forEach(appendTransferredOptions);
  6580. var redirectResult = utils.normalizeRedirectResult(schema.redirect(value, _this2._utils), value);
  6581. redirectResult.redirect.forEach(appendTransferredOptions);
  6582. if ('remain' in redirectResult) {
  6583. var remainingValue = redirectResult.remain;
  6584. normalized[key] = key in normalized ? schema.overlap(normalized[key], remainingValue, _this2._utils) : remainingValue;
  6585. warnDeprecated({
  6586. value: remainingValue
  6587. });
  6588. }
  6589. var _iteratorNormalCompletion4 = true;
  6590. var _didIteratorError4 = false;
  6591. var _iteratorError4 = undefined;
  6592. try {
  6593. for (var _iterator4 = redirectResult.redirect[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
  6594. var _step4$value = _step4.value,
  6595. from = _step4$value.from,
  6596. to = _step4$value.to;
  6597. warnDeprecated({
  6598. value: from,
  6599. redirectTo: to
  6600. });
  6601. }
  6602. } catch (err) {
  6603. _didIteratorError4 = true;
  6604. _iteratorError4 = err;
  6605. } finally {
  6606. try {
  6607. if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
  6608. _iterator4.return();
  6609. }
  6610. } finally {
  6611. if (_didIteratorError4) {
  6612. throw _iteratorError4;
  6613. }
  6614. }
  6615. }
  6616. };
  6617. for (var _iterator = knownOptionNames[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  6618. _loop();
  6619. }
  6620. } catch (err) {
  6621. _didIteratorError = true;
  6622. _iteratorError = err;
  6623. } finally {
  6624. try {
  6625. if (!_iteratorNormalCompletion && _iterator.return != null) {
  6626. _iterator.return();
  6627. }
  6628. } finally {
  6629. if (_didIteratorError) {
  6630. throw _iteratorError;
  6631. }
  6632. }
  6633. }
  6634. var _iteratorNormalCompletion2 = true;
  6635. var _didIteratorError2 = false;
  6636. var _iteratorError2 = undefined;
  6637. try {
  6638. for (var _iterator2 = unknownOptionNames[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  6639. var key = _step2.value;
  6640. var value = options[key];
  6641. var unknownResult = this._unknownHandler(key, value, this._utils);
  6642. if (unknownResult) {
  6643. var _arr3 = Object.keys(unknownResult);
  6644. for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
  6645. var unknownKey = _arr3[_i3];
  6646. var unknownOption = {
  6647. [unknownKey]: unknownResult[unknownKey]
  6648. };
  6649. if (unknownKey in this._utils.schemas) {
  6650. transferredOptionsArray.push(unknownOption);
  6651. } else {
  6652. Object.assign(normalized, unknownOption);
  6653. }
  6654. }
  6655. }
  6656. }
  6657. } catch (err) {
  6658. _didIteratorError2 = true;
  6659. _iteratorError2 = err;
  6660. } finally {
  6661. try {
  6662. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  6663. _iterator2.return();
  6664. }
  6665. } finally {
  6666. if (_didIteratorError2) {
  6667. throw _iteratorError2;
  6668. }
  6669. }
  6670. }
  6671. return transferredOptionsArray;
  6672. }
  6673. }]);
  6674. return Normalizer;
  6675. }();
  6676. exports.Normalizer = Normalizer;
  6677. });
  6678. unwrapExports(normalize$1);
  6679. var lib$1 = createCommonjsModule(function (module, exports) {
  6680. "use strict";
  6681. Object.defineProperty(exports, "__esModule", {
  6682. value: true
  6683. });
  6684. tslib_1.__exportStar(descriptors, exports);
  6685. tslib_1.__exportStar(handlers, exports);
  6686. tslib_1.__exportStar(schemas, exports);
  6687. tslib_1.__exportStar(normalize$1, exports);
  6688. tslib_1.__exportStar(schema, exports);
  6689. });
  6690. unwrapExports(lib$1);
  6691. var hasFlag$3 = function hasFlag(flag, argv) {
  6692. argv = argv || process.argv;
  6693. var terminatorPos = argv.indexOf('--');
  6694. var prefix = /^-{1,2}/.test(flag) ? '' : '--';
  6695. var pos = argv.indexOf(prefix + flag);
  6696. return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
  6697. };
  6698. var supportsColor$1 = createCommonjsModule(function (module) {
  6699. 'use strict';
  6700. var env = process.env;
  6701. var support = function support(level) {
  6702. if (level === 0) {
  6703. return false;
  6704. }
  6705. return {
  6706. level,
  6707. hasBasic: true,
  6708. has256: level >= 2,
  6709. has16m: level >= 3
  6710. };
  6711. };
  6712. var supportLevel = function () {
  6713. if (hasFlag$3('no-color') || hasFlag$3('no-colors') || hasFlag$3('color=false')) {
  6714. return 0;
  6715. }
  6716. if (hasFlag$3('color=16m') || hasFlag$3('color=full') || hasFlag$3('color=truecolor')) {
  6717. return 3;
  6718. }
  6719. if (hasFlag$3('color=256')) {
  6720. return 2;
  6721. }
  6722. if (hasFlag$3('color') || hasFlag$3('colors') || hasFlag$3('color=true') || hasFlag$3('color=always')) {
  6723. return 1;
  6724. }
  6725. if (process.stdout && !process.stdout.isTTY) {
  6726. return 0;
  6727. }
  6728. if (process.platform === 'win32') {
  6729. // Node.js 7.5.0 is the first version of Node.js to include a patch to
  6730. // libuv that enables 256 color output on Windows. Anything earlier and it
  6731. // won't work. However, here we target Node.js 8 at minimum as it is an LTS
  6732. // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
  6733. // release that supports 256 colors.
  6734. var osRelease = os.release().split('.');
  6735. if (Number(process.versions.node.split('.')[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
  6736. return 2;
  6737. }
  6738. return 1;
  6739. }
  6740. if ('CI' in env) {
  6741. if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(function (sign) {
  6742. return sign in env;
  6743. }) || env.CI_NAME === 'codeship') {
  6744. return 1;
  6745. }
  6746. return 0;
  6747. }
  6748. if ('TEAMCITY_VERSION' in env) {
  6749. return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
  6750. }
  6751. if ('TERM_PROGRAM' in env) {
  6752. var version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
  6753. switch (env.TERM_PROGRAM) {
  6754. case 'iTerm.app':
  6755. return version >= 3 ? 3 : 2;
  6756. case 'Hyper':
  6757. return 3;
  6758. case 'Apple_Terminal':
  6759. return 2;
  6760. // No default
  6761. }
  6762. }
  6763. if (/-256(color)?$/i.test(env.TERM)) {
  6764. return 2;
  6765. }
  6766. if (/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
  6767. return 1;
  6768. }
  6769. if ('COLORTERM' in env) {
  6770. return 1;
  6771. }
  6772. if (env.TERM === 'dumb') {
  6773. return 0;
  6774. }
  6775. return 0;
  6776. }();
  6777. if ('FORCE_COLOR' in env) {
  6778. supportLevel = parseInt(env.FORCE_COLOR, 10) === 0 ? 0 : supportLevel || 1;
  6779. }
  6780. module.exports = process && support(supportLevel);
  6781. });
  6782. var templates$2 = createCommonjsModule(function (module) {
  6783. 'use strict';
  6784. var TEMPLATE_REGEX = /(?:\\(u[a-f0-9]{4}|x[a-f0-9]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
  6785. var STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
  6786. var STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
  6787. var ESCAPE_REGEX = /\\(u[0-9a-f]{4}|x[0-9a-f]{2}|.)|([^\\])/gi;
  6788. var ESCAPES = {
  6789. n: '\n',
  6790. r: '\r',
  6791. t: '\t',
  6792. b: '\b',
  6793. f: '\f',
  6794. v: '\v',
  6795. 0: '\0',
  6796. '\\': '\\',
  6797. e: '\u001b',
  6798. a: '\u0007'
  6799. };
  6800. function unescape(c) {
  6801. if (c[0] === 'u' && c.length === 5 || c[0] === 'x' && c.length === 3) {
  6802. return String.fromCharCode(parseInt(c.slice(1), 16));
  6803. }
  6804. return ESCAPES[c] || c;
  6805. }
  6806. function parseArguments(name, args) {
  6807. var results = [];
  6808. var chunks = args.trim().split(/\s*,\s*/g);
  6809. var matches;
  6810. var _iteratorNormalCompletion = true;
  6811. var _didIteratorError = false;
  6812. var _iteratorError = undefined;
  6813. try {
  6814. for (var _iterator = chunks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  6815. var chunk = _step.value;
  6816. if (!isNaN(chunk)) {
  6817. results.push(Number(chunk));
  6818. } else if (matches = chunk.match(STRING_REGEX)) {
  6819. results.push(matches[2].replace(ESCAPE_REGEX, function (m, escape, chr) {
  6820. return escape ? unescape(escape) : chr;
  6821. }));
  6822. } else {
  6823. throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
  6824. }
  6825. }
  6826. } catch (err) {
  6827. _didIteratorError = true;
  6828. _iteratorError = err;
  6829. } finally {
  6830. try {
  6831. if (!_iteratorNormalCompletion && _iterator.return != null) {
  6832. _iterator.return();
  6833. }
  6834. } finally {
  6835. if (_didIteratorError) {
  6836. throw _iteratorError;
  6837. }
  6838. }
  6839. }
  6840. return results;
  6841. }
  6842. function parseStyle(style) {
  6843. STYLE_REGEX.lastIndex = 0;
  6844. var results = [];
  6845. var matches;
  6846. while ((matches = STYLE_REGEX.exec(style)) !== null) {
  6847. var name = matches[1];
  6848. if (matches[2]) {
  6849. var args = parseArguments(name, matches[2]);
  6850. results.push([name].concat(args));
  6851. } else {
  6852. results.push([name]);
  6853. }
  6854. }
  6855. return results;
  6856. }
  6857. function buildStyle(chalk, styles) {
  6858. var enabled = {};
  6859. var _iteratorNormalCompletion2 = true;
  6860. var _didIteratorError2 = false;
  6861. var _iteratorError2 = undefined;
  6862. try {
  6863. for (var _iterator2 = styles[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  6864. var layer = _step2.value;
  6865. var _iteratorNormalCompletion3 = true;
  6866. var _didIteratorError3 = false;
  6867. var _iteratorError3 = undefined;
  6868. try {
  6869. for (var _iterator3 = layer.styles[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  6870. var style = _step3.value;
  6871. enabled[style[0]] = layer.inverse ? null : style.slice(1);
  6872. }
  6873. } catch (err) {
  6874. _didIteratorError3 = true;
  6875. _iteratorError3 = err;
  6876. } finally {
  6877. try {
  6878. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  6879. _iterator3.return();
  6880. }
  6881. } finally {
  6882. if (_didIteratorError3) {
  6883. throw _iteratorError3;
  6884. }
  6885. }
  6886. }
  6887. }
  6888. } catch (err) {
  6889. _didIteratorError2 = true;
  6890. _iteratorError2 = err;
  6891. } finally {
  6892. try {
  6893. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  6894. _iterator2.return();
  6895. }
  6896. } finally {
  6897. if (_didIteratorError2) {
  6898. throw _iteratorError2;
  6899. }
  6900. }
  6901. }
  6902. var current = chalk;
  6903. var _arr = Object.keys(enabled);
  6904. for (var _i = 0; _i < _arr.length; _i++) {
  6905. var styleName = _arr[_i];
  6906. if (Array.isArray(enabled[styleName])) {
  6907. if (!(styleName in current)) {
  6908. throw new Error(`Unknown Chalk style: ${styleName}`);
  6909. }
  6910. if (enabled[styleName].length > 0) {
  6911. current = current[styleName].apply(current, enabled[styleName]);
  6912. } else {
  6913. current = current[styleName];
  6914. }
  6915. }
  6916. }
  6917. return current;
  6918. }
  6919. module.exports = function (chalk, tmp) {
  6920. var styles = [];
  6921. var chunks = [];
  6922. var chunk = []; // eslint-disable-next-line max-params
  6923. tmp.replace(TEMPLATE_REGEX, function (m, escapeChar, inverse, style, close, chr) {
  6924. if (escapeChar) {
  6925. chunk.push(unescape(escapeChar));
  6926. } else if (style) {
  6927. var str = chunk.join('');
  6928. chunk = [];
  6929. chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str));
  6930. styles.push({
  6931. inverse,
  6932. styles: parseStyle(style)
  6933. });
  6934. } else if (close) {
  6935. if (styles.length === 0) {
  6936. throw new Error('Found extraneous } in Chalk template literal');
  6937. }
  6938. chunks.push(buildStyle(chalk, styles)(chunk.join('')));
  6939. chunk = [];
  6940. styles.pop();
  6941. } else {
  6942. chunk.push(chr);
  6943. }
  6944. });
  6945. chunks.push(chunk.join(''));
  6946. if (styles.length > 0) {
  6947. var errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
  6948. throw new Error(errMsg);
  6949. }
  6950. return chunks.join('');
  6951. };
  6952. });
  6953. var isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm'); // `supportsColor.level` → `ansiStyles.color[name]` mapping
  6954. var levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m']; // `color-convert` models to exclude from the Chalk API due to conflicts and such
  6955. var skipModels = new Set(['gray']);
  6956. var styles = Object.create(null);
  6957. function applyOptions(obj, options) {
  6958. options = options || {}; // Detect level if not set manually
  6959. var scLevel = supportsColor$1 ? supportsColor$1.level : 0;
  6960. obj.level = options.level === undefined ? scLevel : options.level;
  6961. obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
  6962. }
  6963. function Chalk(options) {
  6964. // We check for this.template here since calling `chalk.constructor()`
  6965. // by itself will have a `this` of a previously constructed chalk object
  6966. if (!this || !(this instanceof Chalk) || this.template) {
  6967. var _chalk = {};
  6968. applyOptions(_chalk, options);
  6969. _chalk.template = function () {
  6970. var args = [].slice.call(arguments);
  6971. return chalkTag.apply(null, [_chalk.template].concat(args));
  6972. };
  6973. Object.setPrototypeOf(_chalk, Chalk.prototype);
  6974. Object.setPrototypeOf(_chalk.template, _chalk);
  6975. _chalk.template.constructor = Chalk;
  6976. return _chalk.template;
  6977. }
  6978. applyOptions(this, options);
  6979. } // Use bright blue on Windows as the normal blue color is illegible
  6980. if (isSimpleWindowsTerm) {
  6981. ansiStyles.blue.open = '\u001B[94m';
  6982. }
  6983. var _arr = Object.keys(ansiStyles);
  6984. var _loop = function _loop() {
  6985. var key = _arr[_i];
  6986. ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
  6987. styles[key] = {
  6988. get() {
  6989. var codes = ansiStyles[key];
  6990. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], key);
  6991. }
  6992. };
  6993. };
  6994. for (var _i = 0; _i < _arr.length; _i++) {
  6995. _loop();
  6996. }
  6997. ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g');
  6998. var _arr2 = Object.keys(ansiStyles.color.ansi);
  6999. var _loop2 = function _loop2() {
  7000. var model = _arr2[_i2];
  7001. if (skipModels.has(model)) {
  7002. return "continue";
  7003. }
  7004. styles[model] = {
  7005. get() {
  7006. var level = this.level;
  7007. return function () {
  7008. var open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments);
  7009. var codes = {
  7010. open,
  7011. close: ansiStyles.color.close,
  7012. closeRe: ansiStyles.color.closeRe
  7013. };
  7014. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], model);
  7015. };
  7016. }
  7017. };
  7018. };
  7019. for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
  7020. var _ret = _loop2();
  7021. if (_ret === "continue") continue;
  7022. }
  7023. ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), 'g');
  7024. var _arr3 = Object.keys(ansiStyles.bgColor.ansi);
  7025. var _loop3 = function _loop3() {
  7026. var model = _arr3[_i3];
  7027. if (skipModels.has(model)) {
  7028. return "continue";
  7029. }
  7030. var bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
  7031. styles[bgModel] = {
  7032. get() {
  7033. var level = this.level;
  7034. return function () {
  7035. var open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments);
  7036. var codes = {
  7037. open,
  7038. close: ansiStyles.bgColor.close,
  7039. closeRe: ansiStyles.bgColor.closeRe
  7040. };
  7041. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], model);
  7042. };
  7043. }
  7044. };
  7045. };
  7046. for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
  7047. var _ret2 = _loop3();
  7048. if (_ret2 === "continue") continue;
  7049. }
  7050. var proto = Object.defineProperties(function () {}, styles);
  7051. function build(_styles, key) {
  7052. var builder = function builder() {
  7053. return applyStyle.apply(builder, arguments);
  7054. };
  7055. builder._styles = _styles;
  7056. var self = this;
  7057. Object.defineProperty(builder, 'level', {
  7058. enumerable: true,
  7059. get() {
  7060. return self.level;
  7061. },
  7062. set(level) {
  7063. self.level = level;
  7064. }
  7065. });
  7066. Object.defineProperty(builder, 'enabled', {
  7067. enumerable: true,
  7068. get() {
  7069. return self.enabled;
  7070. },
  7071. set(enabled) {
  7072. self.enabled = enabled;
  7073. }
  7074. }); // See below for fix regarding invisible grey/dim combination on Windows
  7075. builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey'; // `__proto__` is used because we must return a function, but there is
  7076. // no way to create a function with a different prototype
  7077. builder.__proto__ = proto; // eslint-disable-line no-proto
  7078. return builder;
  7079. }
  7080. function applyStyle() {
  7081. // Support varags, but simply cast to string in case there's only one arg
  7082. var args = arguments;
  7083. var argsLen = args.length;
  7084. var str = String(arguments[0]);
  7085. if (argsLen === 0) {
  7086. return '';
  7087. }
  7088. if (argsLen > 1) {
  7089. // Don't slice `arguments`, it prevents V8 optimizations
  7090. for (var a = 1; a < argsLen; a++) {
  7091. str += ' ' + args[a];
  7092. }
  7093. }
  7094. if (!this.enabled || this.level <= 0 || !str) {
  7095. return str;
  7096. } // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
  7097. // see https://github.com/chalk/chalk/issues/58
  7098. // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
  7099. var originalDim = ansiStyles.dim.open;
  7100. if (isSimpleWindowsTerm && this.hasGrey) {
  7101. ansiStyles.dim.open = '';
  7102. }
  7103. var _iteratorNormalCompletion = true;
  7104. var _didIteratorError = false;
  7105. var _iteratorError = undefined;
  7106. try {
  7107. for (var _iterator = this._styles.slice().reverse()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  7108. var code = _step.value;
  7109. // Replace any instances already present with a re-opening code
  7110. // otherwise only the part of the string until said closing code
  7111. // will be colored, and the rest will simply be 'plain'.
  7112. str = code.open + str.replace(code.closeRe, code.open) + code.close; // Close the styling before a linebreak and reopen
  7113. // after next line to fix a bleed issue on macOS
  7114. // https://github.com/chalk/chalk/pull/92
  7115. str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`);
  7116. } // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue
  7117. } catch (err) {
  7118. _didIteratorError = true;
  7119. _iteratorError = err;
  7120. } finally {
  7121. try {
  7122. if (!_iteratorNormalCompletion && _iterator.return != null) {
  7123. _iterator.return();
  7124. }
  7125. } finally {
  7126. if (_didIteratorError) {
  7127. throw _iteratorError;
  7128. }
  7129. }
  7130. }
  7131. ansiStyles.dim.open = originalDim;
  7132. return str;
  7133. }
  7134. function chalkTag(chalk, strings) {
  7135. if (!Array.isArray(strings)) {
  7136. // If chalk() was called by itself or with a string,
  7137. // return the string itself as a string.
  7138. return [].slice.call(arguments, 1).join(' ');
  7139. }
  7140. var args = [].slice.call(arguments, 2);
  7141. var parts = [strings.raw[0]];
  7142. for (var i = 1; i < strings.length; i++) {
  7143. parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&'));
  7144. parts.push(String(strings.raw[i]));
  7145. }
  7146. return templates$2(chalk, parts.join(''));
  7147. }
  7148. Object.defineProperties(Chalk.prototype, styles);
  7149. var chalk$2 = Chalk(); // eslint-disable-line new-cap
  7150. var supportsColor_1$2 = supportsColor$1;
  7151. chalk$2.supportsColor = supportsColor_1$2;
  7152. var cliDescriptor = {
  7153. key: function key(_key) {
  7154. return _key.length === 1 ? `-${_key}` : `--${_key}`;
  7155. },
  7156. value: function value(_value) {
  7157. return lib$1.apiDescriptor.value(_value);
  7158. },
  7159. pair: function pair(_ref) {
  7160. var key = _ref.key,
  7161. value = _ref.value;
  7162. return value === false ? `--no-${key}` : value === true ? cliDescriptor.key(key) : value === "" ? `${cliDescriptor.key(key)} without an argument` : `${cliDescriptor.key(key)}=${value}`;
  7163. }
  7164. };
  7165. var FlagSchema =
  7166. /*#__PURE__*/
  7167. function (_vnopts$ChoiceSchema) {
  7168. _inherits(FlagSchema, _vnopts$ChoiceSchema);
  7169. function FlagSchema(_ref2) {
  7170. var _this;
  7171. var name = _ref2.name,
  7172. flags = _ref2.flags;
  7173. _classCallCheck(this, FlagSchema);
  7174. _this = _possibleConstructorReturn(this, _getPrototypeOf(FlagSchema).call(this, {
  7175. name,
  7176. choices: flags
  7177. }));
  7178. _this._flags = flags.slice().sort();
  7179. return _this;
  7180. }
  7181. _createClass(FlagSchema, [{
  7182. key: "preprocess",
  7183. value: function preprocess(value, utils) {
  7184. if (typeof value === "string" && value.length !== 0 && this._flags.indexOf(value) === -1) {
  7185. var suggestion = this._flags.find(function (flag) {
  7186. return leven$1(flag, value) < 3;
  7187. });
  7188. if (suggestion) {
  7189. utils.logger.warn([`Unknown flag ${chalk$2.yellow(utils.descriptor.value(value))},`, `did you mean ${chalk$2.blue(utils.descriptor.value(suggestion))}?`].join(" "));
  7190. return suggestion;
  7191. }
  7192. }
  7193. return value;
  7194. }
  7195. }, {
  7196. key: "expected",
  7197. value: function expected() {
  7198. return "a flag";
  7199. }
  7200. }]);
  7201. return FlagSchema;
  7202. }(lib$1.ChoiceSchema);
  7203. var hasDeprecationWarned;
  7204. function normalizeOptions$1(options, optionInfos) {
  7205. var _ref3 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
  7206. logger = _ref3.logger,
  7207. _ref3$isCLI = _ref3.isCLI,
  7208. isCLI = _ref3$isCLI === void 0 ? false : _ref3$isCLI,
  7209. _ref3$passThrough = _ref3.passThrough,
  7210. passThrough = _ref3$passThrough === void 0 ? false : _ref3$passThrough;
  7211. var unknown = !passThrough ? lib$1.levenUnknownHandler : Array.isArray(passThrough) ? function (key, value) {
  7212. return passThrough.indexOf(key) === -1 ? undefined : {
  7213. [key]: value
  7214. };
  7215. } : function (key, value) {
  7216. return {
  7217. [key]: value
  7218. };
  7219. };
  7220. var descriptor = isCLI ? cliDescriptor : lib$1.apiDescriptor;
  7221. var schemas = optionInfosToSchemas(optionInfos, {
  7222. isCLI
  7223. });
  7224. var normalizer = new lib$1.Normalizer(schemas, {
  7225. logger,
  7226. unknown,
  7227. descriptor
  7228. });
  7229. var shouldSuppressDuplicateDeprecationWarnings = logger !== false;
  7230. if (shouldSuppressDuplicateDeprecationWarnings && hasDeprecationWarned) {
  7231. normalizer._hasDeprecationWarned = hasDeprecationWarned;
  7232. }
  7233. var normalized = normalizer.normalize(options);
  7234. if (shouldSuppressDuplicateDeprecationWarnings) {
  7235. hasDeprecationWarned = normalizer._hasDeprecationWarned;
  7236. }
  7237. return normalized;
  7238. }
  7239. function optionInfosToSchemas(optionInfos, _ref4) {
  7240. var isCLI = _ref4.isCLI;
  7241. var schemas = [];
  7242. if (isCLI) {
  7243. schemas.push(lib$1.AnySchema.create({
  7244. name: "_"
  7245. }));
  7246. }
  7247. var _iteratorNormalCompletion = true;
  7248. var _didIteratorError = false;
  7249. var _iteratorError = undefined;
  7250. try {
  7251. for (var _iterator = optionInfos[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  7252. var optionInfo = _step.value;
  7253. schemas.push(optionInfoToSchema(optionInfo, {
  7254. isCLI,
  7255. optionInfos
  7256. }));
  7257. if (optionInfo.alias && isCLI) {
  7258. schemas.push(lib$1.AliasSchema.create({
  7259. name: optionInfo.alias,
  7260. sourceName: optionInfo.name
  7261. }));
  7262. }
  7263. }
  7264. } catch (err) {
  7265. _didIteratorError = true;
  7266. _iteratorError = err;
  7267. } finally {
  7268. try {
  7269. if (!_iteratorNormalCompletion && _iterator.return != null) {
  7270. _iterator.return();
  7271. }
  7272. } finally {
  7273. if (_didIteratorError) {
  7274. throw _iteratorError;
  7275. }
  7276. }
  7277. }
  7278. return schemas;
  7279. }
  7280. function optionInfoToSchema(optionInfo, _ref5) {
  7281. var isCLI = _ref5.isCLI,
  7282. optionInfos = _ref5.optionInfos;
  7283. var SchemaConstructor;
  7284. var parameters = {
  7285. name: optionInfo.name
  7286. };
  7287. var handlers = {};
  7288. switch (optionInfo.type) {
  7289. case "int":
  7290. SchemaConstructor = lib$1.IntegerSchema;
  7291. if (isCLI) {
  7292. parameters.preprocess = function (value) {
  7293. return Number(value);
  7294. };
  7295. }
  7296. break;
  7297. case "choice":
  7298. SchemaConstructor = lib$1.ChoiceSchema;
  7299. parameters.choices = optionInfo.choices.map(function (choiceInfo) {
  7300. return typeof choiceInfo === "object" && choiceInfo.redirect ? Object.assign({}, choiceInfo, {
  7301. redirect: {
  7302. to: {
  7303. key: optionInfo.name,
  7304. value: choiceInfo.redirect
  7305. }
  7306. }
  7307. }) : choiceInfo;
  7308. });
  7309. break;
  7310. case "boolean":
  7311. SchemaConstructor = lib$1.BooleanSchema;
  7312. break;
  7313. case "flag":
  7314. SchemaConstructor = FlagSchema;
  7315. parameters.flags = optionInfos.map(function (optionInfo) {
  7316. return [].concat(optionInfo.alias || [], optionInfo.description ? optionInfo.name : [], optionInfo.oppositeDescription ? `no-${optionInfo.name}` : []);
  7317. }).reduce(function (a, b) {
  7318. return a.concat(b);
  7319. }, []);
  7320. break;
  7321. case "path":
  7322. SchemaConstructor = lib$1.StringSchema;
  7323. break;
  7324. default:
  7325. throw new Error(`Unexpected type ${optionInfo.type}`);
  7326. }
  7327. if (optionInfo.exception) {
  7328. parameters.validate = function (value, schema, utils) {
  7329. return optionInfo.exception(value) || schema.validate(value, utils);
  7330. };
  7331. } else {
  7332. parameters.validate = function (value, schema, utils) {
  7333. return value === undefined || schema.validate(value, utils);
  7334. };
  7335. }
  7336. if (optionInfo.redirect) {
  7337. handlers.redirect = function (value) {
  7338. return !value ? undefined : {
  7339. to: {
  7340. key: optionInfo.redirect.option,
  7341. value: optionInfo.redirect.value
  7342. }
  7343. };
  7344. };
  7345. }
  7346. if (optionInfo.deprecated) {
  7347. handlers.deprecated = true;
  7348. } // allow CLI overriding, e.g., prettier package.json --tab-width 1 --tab-width 2
  7349. if (isCLI && !optionInfo.array) {
  7350. var originalPreprocess = parameters.preprocess || function (x) {
  7351. return x;
  7352. };
  7353. parameters.preprocess = function (value, schema, utils) {
  7354. return schema.preprocess(originalPreprocess(Array.isArray(value) ? value[value.length - 1] : value), utils);
  7355. };
  7356. }
  7357. return optionInfo.array ? lib$1.ArraySchema.create(Object.assign(isCLI ? {
  7358. preprocess: function preprocess(v) {
  7359. return [].concat(v);
  7360. }
  7361. } : {}, handlers, {
  7362. valueSchema: SchemaConstructor.create(parameters)
  7363. })) : SchemaConstructor.create(Object.assign({}, parameters, handlers));
  7364. }
  7365. function normalizeApiOptions(options, optionInfos, opts) {
  7366. return normalizeOptions$1(options, optionInfos, opts);
  7367. }
  7368. function normalizeCliOptions(options, optionInfos, opts) {
  7369. return normalizeOptions$1(options, optionInfos, Object.assign({
  7370. isCLI: true
  7371. }, opts));
  7372. }
  7373. var optionsNormalizer = {
  7374. normalizeApiOptions,
  7375. normalizeCliOptions
  7376. };
  7377. var getLast = function getLast(arr) {
  7378. return arr.length > 0 ? arr[arr.length - 1] : null;
  7379. };
  7380. function locStart$1(node, opts) {
  7381. opts = opts || {}; // Handle nodes with decorators. They should start at the first decorator
  7382. if (!opts.ignoreDecorators && node.declaration && node.declaration.decorators && node.declaration.decorators.length > 0) {
  7383. return locStart$1(node.declaration.decorators[0]);
  7384. }
  7385. if (!opts.ignoreDecorators && node.decorators && node.decorators.length > 0) {
  7386. return locStart$1(node.decorators[0]);
  7387. }
  7388. if (node.__location) {
  7389. return node.__location.startOffset;
  7390. }
  7391. if (node.range) {
  7392. return node.range[0];
  7393. }
  7394. if (typeof node.start === "number") {
  7395. return node.start;
  7396. }
  7397. if (node.loc) {
  7398. return node.loc.start;
  7399. }
  7400. return null;
  7401. }
  7402. function locEnd$1(node) {
  7403. var endNode = node.nodes && getLast(node.nodes);
  7404. if (endNode && node.source && !node.source.end) {
  7405. node = endNode;
  7406. }
  7407. if (node.__location) {
  7408. return node.__location.endOffset;
  7409. }
  7410. var loc = node.range ? node.range[1] : typeof node.end === "number" ? node.end : null;
  7411. if (node.typeAnnotation) {
  7412. return Math.max(loc, locEnd$1(node.typeAnnotation));
  7413. }
  7414. if (node.loc && !loc) {
  7415. return node.loc.end;
  7416. }
  7417. return loc;
  7418. }
  7419. var loc = {
  7420. locStart: locStart$1,
  7421. locEnd: locEnd$1
  7422. };
  7423. var jsTokens = createCommonjsModule(function (module, exports) {
  7424. // Copyright 2014, 2015, 2016, 2017 Simon Lydell
  7425. // License: MIT. (See LICENSE.)
  7426. Object.defineProperty(exports, "__esModule", {
  7427. value: true
  7428. }); // This regex comes from regex.coffee, and is inserted here by generate-index.js
  7429. // (run `npm run build`).
  7430. 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;
  7431. exports.matchToToken = function (match) {
  7432. var token = {
  7433. type: "invalid",
  7434. value: match[0]
  7435. };
  7436. if (match[1]) token.type = "string", token.closed = !!(match[3] || match[4]);else if (match[5]) token.type = "comment";else if (match[6]) token.type = "comment", token.closed = !!match[7];else if (match[8]) token.type = "regex";else if (match[9]) token.type = "number";else if (match[10]) token.type = "name";else if (match[11]) token.type = "punctuator";else if (match[12]) token.type = "whitespace";
  7437. return token;
  7438. };
  7439. });
  7440. unwrapExports(jsTokens);
  7441. var ast = createCommonjsModule(function (module) {
  7442. /*
  7443. Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
  7444. Redistribution and use in source and binary forms, with or without
  7445. modification, are permitted provided that the following conditions are met:
  7446. * Redistributions of source code must retain the above copyright
  7447. notice, this list of conditions and the following disclaimer.
  7448. * Redistributions in binary form must reproduce the above copyright
  7449. notice, this list of conditions and the following disclaimer in the
  7450. documentation and/or other materials provided with the distribution.
  7451. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
  7452. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  7453. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  7454. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  7455. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  7456. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  7457. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  7458. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  7459. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  7460. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  7461. */
  7462. (function () {
  7463. 'use strict';
  7464. function isExpression(node) {
  7465. if (node == null) {
  7466. return false;
  7467. }
  7468. switch (node.type) {
  7469. case 'ArrayExpression':
  7470. case 'AssignmentExpression':
  7471. case 'BinaryExpression':
  7472. case 'CallExpression':
  7473. case 'ConditionalExpression':
  7474. case 'FunctionExpression':
  7475. case 'Identifier':
  7476. case 'Literal':
  7477. case 'LogicalExpression':
  7478. case 'MemberExpression':
  7479. case 'NewExpression':
  7480. case 'ObjectExpression':
  7481. case 'SequenceExpression':
  7482. case 'ThisExpression':
  7483. case 'UnaryExpression':
  7484. case 'UpdateExpression':
  7485. return true;
  7486. }
  7487. return false;
  7488. }
  7489. function isIterationStatement(node) {
  7490. if (node == null) {
  7491. return false;
  7492. }
  7493. switch (node.type) {
  7494. case 'DoWhileStatement':
  7495. case 'ForInStatement':
  7496. case 'ForStatement':
  7497. case 'WhileStatement':
  7498. return true;
  7499. }
  7500. return false;
  7501. }
  7502. function isStatement(node) {
  7503. if (node == null) {
  7504. return false;
  7505. }
  7506. switch (node.type) {
  7507. case 'BlockStatement':
  7508. case 'BreakStatement':
  7509. case 'ContinueStatement':
  7510. case 'DebuggerStatement':
  7511. case 'DoWhileStatement':
  7512. case 'EmptyStatement':
  7513. case 'ExpressionStatement':
  7514. case 'ForInStatement':
  7515. case 'ForStatement':
  7516. case 'IfStatement':
  7517. case 'LabeledStatement':
  7518. case 'ReturnStatement':
  7519. case 'SwitchStatement':
  7520. case 'ThrowStatement':
  7521. case 'TryStatement':
  7522. case 'VariableDeclaration':
  7523. case 'WhileStatement':
  7524. case 'WithStatement':
  7525. return true;
  7526. }
  7527. return false;
  7528. }
  7529. function isSourceElement(node) {
  7530. return isStatement(node) || node != null && node.type === 'FunctionDeclaration';
  7531. }
  7532. function trailingStatement(node) {
  7533. switch (node.type) {
  7534. case 'IfStatement':
  7535. if (node.alternate != null) {
  7536. return node.alternate;
  7537. }
  7538. return node.consequent;
  7539. case 'LabeledStatement':
  7540. case 'ForStatement':
  7541. case 'ForInStatement':
  7542. case 'WhileStatement':
  7543. case 'WithStatement':
  7544. return node.body;
  7545. }
  7546. return null;
  7547. }
  7548. function isProblematicIfStatement(node) {
  7549. var current;
  7550. if (node.type !== 'IfStatement') {
  7551. return false;
  7552. }
  7553. if (node.alternate == null) {
  7554. return false;
  7555. }
  7556. current = node.consequent;
  7557. do {
  7558. if (current.type === 'IfStatement') {
  7559. if (current.alternate == null) {
  7560. return true;
  7561. }
  7562. }
  7563. current = trailingStatement(current);
  7564. } while (current);
  7565. return false;
  7566. }
  7567. module.exports = {
  7568. isExpression: isExpression,
  7569. isStatement: isStatement,
  7570. isIterationStatement: isIterationStatement,
  7571. isSourceElement: isSourceElement,
  7572. isProblematicIfStatement: isProblematicIfStatement,
  7573. trailingStatement: trailingStatement
  7574. };
  7575. })();
  7576. /* vim: set sw=4 ts=4 et tw=80 : */
  7577. });
  7578. var code = createCommonjsModule(function (module) {
  7579. /*
  7580. Copyright (C) 2013-2014 Yusuke Suzuki <utatane.tea@gmail.com>
  7581. Copyright (C) 2014 Ivan Nikulin <ifaaan@gmail.com>
  7582. Redistribution and use in source and binary forms, with or without
  7583. modification, are permitted provided that the following conditions are met:
  7584. * Redistributions of source code must retain the above copyright
  7585. notice, this list of conditions and the following disclaimer.
  7586. * Redistributions in binary form must reproduce the above copyright
  7587. notice, this list of conditions and the following disclaimer in the
  7588. documentation and/or other materials provided with the distribution.
  7589. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  7590. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  7591. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  7592. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  7593. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  7594. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  7595. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  7596. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  7597. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  7598. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  7599. */
  7600. (function () {
  7601. 'use strict';
  7602. var ES6Regex, ES5Regex, NON_ASCII_WHITESPACES, IDENTIFIER_START, IDENTIFIER_PART, ch; // See `tools/generate-identifier-regex.js`.
  7603. ES5Regex = {
  7604. // ECMAScript 5.1/Unicode v7.0.0 NonAsciiIdentifierStart:
  7605. 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]/,
  7606. // ECMAScript 5.1/Unicode v7.0.0 NonAsciiIdentifierPart:
  7607. 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]/
  7608. };
  7609. ES6Regex = {
  7610. // ECMAScript 6/Unicode v7.0.0 NonAsciiIdentifierStart:
  7611. 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]/,
  7612. // ECMAScript 6/Unicode v7.0.0 NonAsciiIdentifierPart:
  7613. 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]/
  7614. };
  7615. function isDecimalDigit(ch) {
  7616. return 0x30 <= ch && ch <= 0x39; // 0..9
  7617. }
  7618. function isHexDigit(ch) {
  7619. return 0x30 <= ch && ch <= 0x39 || // 0..9
  7620. 0x61 <= ch && ch <= 0x66 || // a..f
  7621. 0x41 <= ch && ch <= 0x46; // A..F
  7622. }
  7623. function isOctalDigit(ch) {
  7624. return ch >= 0x30 && ch <= 0x37; // 0..7
  7625. } // 7.2 White Space
  7626. NON_ASCII_WHITESPACES = [0x1680, 0x180E, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, 0xFEFF];
  7627. function isWhiteSpace(ch) {
  7628. return ch === 0x20 || ch === 0x09 || ch === 0x0B || ch === 0x0C || ch === 0xA0 || ch >= 0x1680 && NON_ASCII_WHITESPACES.indexOf(ch) >= 0;
  7629. } // 7.3 Line Terminators
  7630. function isLineTerminator(ch) {
  7631. return ch === 0x0A || ch === 0x0D || ch === 0x2028 || ch === 0x2029;
  7632. } // 7.6 Identifier Names and Identifiers
  7633. function fromCodePoint(cp) {
  7634. if (cp <= 0xFFFF) {
  7635. return String.fromCharCode(cp);
  7636. }
  7637. var cu1 = String.fromCharCode(Math.floor((cp - 0x10000) / 0x400) + 0xD800);
  7638. var cu2 = String.fromCharCode((cp - 0x10000) % 0x400 + 0xDC00);
  7639. return cu1 + cu2;
  7640. }
  7641. IDENTIFIER_START = new Array(0x80);
  7642. for (ch = 0; ch < 0x80; ++ch) {
  7643. IDENTIFIER_START[ch] = ch >= 0x61 && ch <= 0x7A || // a..z
  7644. ch >= 0x41 && ch <= 0x5A || // A..Z
  7645. ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore)
  7646. }
  7647. IDENTIFIER_PART = new Array(0x80);
  7648. for (ch = 0; ch < 0x80; ++ch) {
  7649. IDENTIFIER_PART[ch] = ch >= 0x61 && ch <= 0x7A || // a..z
  7650. ch >= 0x41 && ch <= 0x5A || // A..Z
  7651. ch >= 0x30 && ch <= 0x39 || // 0..9
  7652. ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore)
  7653. }
  7654. function isIdentifierStartES5(ch) {
  7655. return ch < 0x80 ? IDENTIFIER_START[ch] : ES5Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch));
  7656. }
  7657. function isIdentifierPartES5(ch) {
  7658. return ch < 0x80 ? IDENTIFIER_PART[ch] : ES5Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch));
  7659. }
  7660. function isIdentifierStartES6(ch) {
  7661. return ch < 0x80 ? IDENTIFIER_START[ch] : ES6Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch));
  7662. }
  7663. function isIdentifierPartES6(ch) {
  7664. return ch < 0x80 ? IDENTIFIER_PART[ch] : ES6Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch));
  7665. }
  7666. module.exports = {
  7667. isDecimalDigit: isDecimalDigit,
  7668. isHexDigit: isHexDigit,
  7669. isOctalDigit: isOctalDigit,
  7670. isWhiteSpace: isWhiteSpace,
  7671. isLineTerminator: isLineTerminator,
  7672. isIdentifierStartES5: isIdentifierStartES5,
  7673. isIdentifierPartES5: isIdentifierPartES5,
  7674. isIdentifierStartES6: isIdentifierStartES6,
  7675. isIdentifierPartES6: isIdentifierPartES6
  7676. };
  7677. })();
  7678. /* vim: set sw=4 ts=4 et tw=80 : */
  7679. });
  7680. var keyword = createCommonjsModule(function (module) {
  7681. /*
  7682. Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
  7683. Redistribution and use in source and binary forms, with or without
  7684. modification, are permitted provided that the following conditions are met:
  7685. * Redistributions of source code must retain the above copyright
  7686. notice, this list of conditions and the following disclaimer.
  7687. * Redistributions in binary form must reproduce the above copyright
  7688. notice, this list of conditions and the following disclaimer in the
  7689. documentation and/or other materials provided with the distribution.
  7690. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  7691. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  7692. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  7693. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  7694. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  7695. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  7696. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  7697. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  7698. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  7699. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  7700. */
  7701. (function () {
  7702. 'use strict';
  7703. var code$$1 = code;
  7704. function isStrictModeReservedWordES6(id) {
  7705. switch (id) {
  7706. case 'implements':
  7707. case 'interface':
  7708. case 'package':
  7709. case 'private':
  7710. case 'protected':
  7711. case 'public':
  7712. case 'static':
  7713. case 'let':
  7714. return true;
  7715. default:
  7716. return false;
  7717. }
  7718. }
  7719. function isKeywordES5(id, strict) {
  7720. // yield should not be treated as keyword under non-strict mode.
  7721. if (!strict && id === 'yield') {
  7722. return false;
  7723. }
  7724. return isKeywordES6(id, strict);
  7725. }
  7726. function isKeywordES6(id, strict) {
  7727. if (strict && isStrictModeReservedWordES6(id)) {
  7728. return true;
  7729. }
  7730. switch (id.length) {
  7731. case 2:
  7732. return id === 'if' || id === 'in' || id === 'do';
  7733. case 3:
  7734. return id === 'var' || id === 'for' || id === 'new' || id === 'try';
  7735. case 4:
  7736. return id === 'this' || id === 'else' || id === 'case' || id === 'void' || id === 'with' || id === 'enum';
  7737. case 5:
  7738. return id === 'while' || id === 'break' || id === 'catch' || id === 'throw' || id === 'const' || id === 'yield' || id === 'class' || id === 'super';
  7739. case 6:
  7740. return id === 'return' || id === 'typeof' || id === 'delete' || id === 'switch' || id === 'export' || id === 'import';
  7741. case 7:
  7742. return id === 'default' || id === 'finally' || id === 'extends';
  7743. case 8:
  7744. return id === 'function' || id === 'continue' || id === 'debugger';
  7745. case 10:
  7746. return id === 'instanceof';
  7747. default:
  7748. return false;
  7749. }
  7750. }
  7751. function isReservedWordES5(id, strict) {
  7752. return id === 'null' || id === 'true' || id === 'false' || isKeywordES5(id, strict);
  7753. }
  7754. function isReservedWordES6(id, strict) {
  7755. return id === 'null' || id === 'true' || id === 'false' || isKeywordES6(id, strict);
  7756. }
  7757. function isRestrictedWord(id) {
  7758. return id === 'eval' || id === 'arguments';
  7759. }
  7760. function isIdentifierNameES5(id) {
  7761. var i, iz, ch;
  7762. if (id.length === 0) {
  7763. return false;
  7764. }
  7765. ch = id.charCodeAt(0);
  7766. if (!code$$1.isIdentifierStartES5(ch)) {
  7767. return false;
  7768. }
  7769. for (i = 1, iz = id.length; i < iz; ++i) {
  7770. ch = id.charCodeAt(i);
  7771. if (!code$$1.isIdentifierPartES5(ch)) {
  7772. return false;
  7773. }
  7774. }
  7775. return true;
  7776. }
  7777. function decodeUtf16(lead, trail) {
  7778. return (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
  7779. }
  7780. function isIdentifierNameES6(id) {
  7781. var i, iz, ch, lowCh, check;
  7782. if (id.length === 0) {
  7783. return false;
  7784. }
  7785. check = code$$1.isIdentifierStartES6;
  7786. for (i = 0, iz = id.length; i < iz; ++i) {
  7787. ch = id.charCodeAt(i);
  7788. if (0xD800 <= ch && ch <= 0xDBFF) {
  7789. ++i;
  7790. if (i >= iz) {
  7791. return false;
  7792. }
  7793. lowCh = id.charCodeAt(i);
  7794. if (!(0xDC00 <= lowCh && lowCh <= 0xDFFF)) {
  7795. return false;
  7796. }
  7797. ch = decodeUtf16(ch, lowCh);
  7798. }
  7799. if (!check(ch)) {
  7800. return false;
  7801. }
  7802. check = code$$1.isIdentifierPartES6;
  7803. }
  7804. return true;
  7805. }
  7806. function isIdentifierES5(id, strict) {
  7807. return isIdentifierNameES5(id) && !isReservedWordES5(id, strict);
  7808. }
  7809. function isIdentifierES6(id, strict) {
  7810. return isIdentifierNameES6(id) && !isReservedWordES6(id, strict);
  7811. }
  7812. module.exports = {
  7813. isKeywordES5: isKeywordES5,
  7814. isKeywordES6: isKeywordES6,
  7815. isReservedWordES5: isReservedWordES5,
  7816. isReservedWordES6: isReservedWordES6,
  7817. isRestrictedWord: isRestrictedWord,
  7818. isIdentifierNameES5: isIdentifierNameES5,
  7819. isIdentifierNameES6: isIdentifierNameES6,
  7820. isIdentifierES5: isIdentifierES5,
  7821. isIdentifierES6: isIdentifierES6
  7822. };
  7823. })();
  7824. /* vim: set sw=4 ts=4 et tw=80 : */
  7825. });
  7826. var utils$2 = createCommonjsModule(function (module, exports) {
  7827. /*
  7828. Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
  7829. Redistribution and use in source and binary forms, with or without
  7830. modification, are permitted provided that the following conditions are met:
  7831. * Redistributions of source code must retain the above copyright
  7832. notice, this list of conditions and the following disclaimer.
  7833. * Redistributions in binary form must reproduce the above copyright
  7834. notice, this list of conditions and the following disclaimer in the
  7835. documentation and/or other materials provided with the distribution.
  7836. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  7837. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  7838. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  7839. ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  7840. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  7841. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  7842. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  7843. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  7844. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  7845. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  7846. */
  7847. (function () {
  7848. 'use strict';
  7849. exports.ast = ast;
  7850. exports.code = code;
  7851. exports.keyword = keyword;
  7852. })();
  7853. /* vim: set sw=4 ts=4 et tw=80 : */
  7854. });
  7855. var hasFlag$6 = createCommonjsModule(function (module) {
  7856. 'use strict';
  7857. module.exports = function (flag, argv) {
  7858. argv = argv || process.argv;
  7859. var prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
  7860. var pos = argv.indexOf(prefix + flag);
  7861. var terminatorPos = argv.indexOf('--');
  7862. return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
  7863. };
  7864. });
  7865. var env$1 = process.env;
  7866. var forceColor$1;
  7867. if (hasFlag$6('no-color') || hasFlag$6('no-colors') || hasFlag$6('color=false')) {
  7868. forceColor$1 = false;
  7869. } else if (hasFlag$6('color') || hasFlag$6('colors') || hasFlag$6('color=true') || hasFlag$6('color=always')) {
  7870. forceColor$1 = true;
  7871. }
  7872. if ('FORCE_COLOR' in env$1) {
  7873. forceColor$1 = env$1.FORCE_COLOR.length === 0 || parseInt(env$1.FORCE_COLOR, 10) !== 0;
  7874. }
  7875. function translateLevel$1(level) {
  7876. if (level === 0) {
  7877. return false;
  7878. }
  7879. return {
  7880. level,
  7881. hasBasic: true,
  7882. has256: level >= 2,
  7883. has16m: level >= 3
  7884. };
  7885. }
  7886. function supportsColor$4(stream) {
  7887. if (forceColor$1 === false) {
  7888. return 0;
  7889. }
  7890. if (hasFlag$6('color=16m') || hasFlag$6('color=full') || hasFlag$6('color=truecolor')) {
  7891. return 3;
  7892. }
  7893. if (hasFlag$6('color=256')) {
  7894. return 2;
  7895. }
  7896. if (stream && !stream.isTTY && forceColor$1 !== true) {
  7897. return 0;
  7898. }
  7899. var min = forceColor$1 ? 1 : 0;
  7900. if (process.platform === 'win32') {
  7901. // Node.js 7.5.0 is the first version of Node.js to include a patch to
  7902. // libuv that enables 256 color output on Windows. Anything earlier and it
  7903. // won't work. However, here we target Node.js 8 at minimum as it is an LTS
  7904. // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
  7905. // release that supports 256 colors. Windows 10 build 14931 is the first release
  7906. // that supports 16m/TrueColor.
  7907. var osRelease = os.release().split('.');
  7908. if (Number(process.versions.node.split('.')[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
  7909. return Number(osRelease[2]) >= 14931 ? 3 : 2;
  7910. }
  7911. return 1;
  7912. }
  7913. if ('CI' in env$1) {
  7914. if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(function (sign) {
  7915. return sign in env$1;
  7916. }) || env$1.CI_NAME === 'codeship') {
  7917. return 1;
  7918. }
  7919. return min;
  7920. }
  7921. if ('TEAMCITY_VERSION' in env$1) {
  7922. return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env$1.TEAMCITY_VERSION) ? 1 : 0;
  7923. }
  7924. if (env$1.COLORTERM === 'truecolor') {
  7925. return 3;
  7926. }
  7927. if ('TERM_PROGRAM' in env$1) {
  7928. var version = parseInt((env$1.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
  7929. switch (env$1.TERM_PROGRAM) {
  7930. case 'iTerm.app':
  7931. return version >= 3 ? 3 : 2;
  7932. case 'Apple_Terminal':
  7933. return 2;
  7934. // No default
  7935. }
  7936. }
  7937. if (/-256(color)?$/i.test(env$1.TERM)) {
  7938. return 2;
  7939. }
  7940. if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env$1.TERM)) {
  7941. return 1;
  7942. }
  7943. if ('COLORTERM' in env$1) {
  7944. return 1;
  7945. }
  7946. if (env$1.TERM === 'dumb') {
  7947. return min;
  7948. }
  7949. return min;
  7950. }
  7951. function getSupportLevel$1(stream) {
  7952. var level = supportsColor$4(stream);
  7953. return translateLevel$1(level);
  7954. }
  7955. var supportsColor_1$3 = {
  7956. supportsColor: getSupportLevel$1,
  7957. stdout: getSupportLevel$1(process.stdout),
  7958. stderr: getSupportLevel$1(process.stderr)
  7959. };
  7960. var templates$4 = createCommonjsModule(function (module) {
  7961. 'use strict';
  7962. var TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
  7963. var STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
  7964. var STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
  7965. var ESCAPE_REGEX = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi;
  7966. var ESCAPES = new Map([['n', '\n'], ['r', '\r'], ['t', '\t'], ['b', '\b'], ['f', '\f'], ['v', '\v'], ['0', '\0'], ['\\', '\\'], ['e', '\u001B'], ['a', '\u0007']]);
  7967. function unescape(c) {
  7968. if (c[0] === 'u' && c.length === 5 || c[0] === 'x' && c.length === 3) {
  7969. return String.fromCharCode(parseInt(c.slice(1), 16));
  7970. }
  7971. return ESCAPES.get(c) || c;
  7972. }
  7973. function parseArguments(name, args) {
  7974. var results = [];
  7975. var chunks = args.trim().split(/\s*,\s*/g);
  7976. var matches;
  7977. var _iteratorNormalCompletion = true;
  7978. var _didIteratorError = false;
  7979. var _iteratorError = undefined;
  7980. try {
  7981. for (var _iterator = chunks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  7982. var chunk = _step.value;
  7983. if (!isNaN(chunk)) {
  7984. results.push(Number(chunk));
  7985. } else if (matches = chunk.match(STRING_REGEX)) {
  7986. results.push(matches[2].replace(ESCAPE_REGEX, function (m, escape, chr) {
  7987. return escape ? unescape(escape) : chr;
  7988. }));
  7989. } else {
  7990. throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
  7991. }
  7992. }
  7993. } catch (err) {
  7994. _didIteratorError = true;
  7995. _iteratorError = err;
  7996. } finally {
  7997. try {
  7998. if (!_iteratorNormalCompletion && _iterator.return != null) {
  7999. _iterator.return();
  8000. }
  8001. } finally {
  8002. if (_didIteratorError) {
  8003. throw _iteratorError;
  8004. }
  8005. }
  8006. }
  8007. return results;
  8008. }
  8009. function parseStyle(style) {
  8010. STYLE_REGEX.lastIndex = 0;
  8011. var results = [];
  8012. var matches;
  8013. while ((matches = STYLE_REGEX.exec(style)) !== null) {
  8014. var name = matches[1];
  8015. if (matches[2]) {
  8016. var args = parseArguments(name, matches[2]);
  8017. results.push([name].concat(args));
  8018. } else {
  8019. results.push([name]);
  8020. }
  8021. }
  8022. return results;
  8023. }
  8024. function buildStyle(chalk, styles) {
  8025. var enabled = {};
  8026. var _iteratorNormalCompletion2 = true;
  8027. var _didIteratorError2 = false;
  8028. var _iteratorError2 = undefined;
  8029. try {
  8030. for (var _iterator2 = styles[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  8031. var layer = _step2.value;
  8032. var _iteratorNormalCompletion3 = true;
  8033. var _didIteratorError3 = false;
  8034. var _iteratorError3 = undefined;
  8035. try {
  8036. for (var _iterator3 = layer.styles[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  8037. var style = _step3.value;
  8038. enabled[style[0]] = layer.inverse ? null : style.slice(1);
  8039. }
  8040. } catch (err) {
  8041. _didIteratorError3 = true;
  8042. _iteratorError3 = err;
  8043. } finally {
  8044. try {
  8045. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  8046. _iterator3.return();
  8047. }
  8048. } finally {
  8049. if (_didIteratorError3) {
  8050. throw _iteratorError3;
  8051. }
  8052. }
  8053. }
  8054. }
  8055. } catch (err) {
  8056. _didIteratorError2 = true;
  8057. _iteratorError2 = err;
  8058. } finally {
  8059. try {
  8060. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  8061. _iterator2.return();
  8062. }
  8063. } finally {
  8064. if (_didIteratorError2) {
  8065. throw _iteratorError2;
  8066. }
  8067. }
  8068. }
  8069. var current = chalk;
  8070. var _arr = Object.keys(enabled);
  8071. for (var _i = 0; _i < _arr.length; _i++) {
  8072. var styleName = _arr[_i];
  8073. if (Array.isArray(enabled[styleName])) {
  8074. if (!(styleName in current)) {
  8075. throw new Error(`Unknown Chalk style: ${styleName}`);
  8076. }
  8077. if (enabled[styleName].length > 0) {
  8078. current = current[styleName].apply(current, enabled[styleName]);
  8079. } else {
  8080. current = current[styleName];
  8081. }
  8082. }
  8083. }
  8084. return current;
  8085. }
  8086. module.exports = function (chalk, tmp) {
  8087. var styles = [];
  8088. var chunks = [];
  8089. var chunk = []; // eslint-disable-next-line max-params
  8090. tmp.replace(TEMPLATE_REGEX, function (m, escapeChar, inverse, style, close, chr) {
  8091. if (escapeChar) {
  8092. chunk.push(unescape(escapeChar));
  8093. } else if (style) {
  8094. var str = chunk.join('');
  8095. chunk = [];
  8096. chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str));
  8097. styles.push({
  8098. inverse,
  8099. styles: parseStyle(style)
  8100. });
  8101. } else if (close) {
  8102. if (styles.length === 0) {
  8103. throw new Error('Found extraneous } in Chalk template literal');
  8104. }
  8105. chunks.push(buildStyle(chalk, styles)(chunk.join('')));
  8106. chunk = [];
  8107. styles.pop();
  8108. } else {
  8109. chunk.push(chr);
  8110. }
  8111. });
  8112. chunks.push(chunk.join(''));
  8113. if (styles.length > 0) {
  8114. var errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
  8115. throw new Error(errMsg);
  8116. }
  8117. return chunks.join('');
  8118. };
  8119. });
  8120. var chalk$5 = createCommonjsModule(function (module) {
  8121. 'use strict';
  8122. var stdoutColor = supportsColor_1$3.stdout;
  8123. var isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm'); // `supportsColor.level` → `ansiStyles.color[name]` mapping
  8124. var levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m']; // `color-convert` models to exclude from the Chalk API due to conflicts and such
  8125. var skipModels = new Set(['gray']);
  8126. var styles = Object.create(null);
  8127. function applyOptions(obj, options) {
  8128. options = options || {}; // Detect level if not set manually
  8129. var scLevel = stdoutColor ? stdoutColor.level : 0;
  8130. obj.level = options.level === undefined ? scLevel : options.level;
  8131. obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
  8132. }
  8133. function Chalk(options) {
  8134. // We check for this.template here since calling `chalk.constructor()`
  8135. // by itself will have a `this` of a previously constructed chalk object
  8136. if (!this || !(this instanceof Chalk) || this.template) {
  8137. var _chalk = {};
  8138. applyOptions(_chalk, options);
  8139. _chalk.template = function () {
  8140. var args = [].slice.call(arguments);
  8141. return chalkTag.apply(null, [_chalk.template].concat(args));
  8142. };
  8143. Object.setPrototypeOf(_chalk, Chalk.prototype);
  8144. Object.setPrototypeOf(_chalk.template, _chalk);
  8145. _chalk.template.constructor = Chalk;
  8146. return _chalk.template;
  8147. }
  8148. applyOptions(this, options);
  8149. } // Use bright blue on Windows as the normal blue color is illegible
  8150. if (isSimpleWindowsTerm) {
  8151. ansiStyles.blue.open = '\u001B[94m';
  8152. }
  8153. var _arr = Object.keys(ansiStyles);
  8154. var _loop = function _loop() {
  8155. var key = _arr[_i];
  8156. ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
  8157. styles[key] = {
  8158. get() {
  8159. var codes = ansiStyles[key];
  8160. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);
  8161. }
  8162. };
  8163. };
  8164. for (var _i = 0; _i < _arr.length; _i++) {
  8165. _loop();
  8166. }
  8167. styles.visible = {
  8168. get() {
  8169. return build.call(this, this._styles || [], true, 'visible');
  8170. }
  8171. };
  8172. ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g');
  8173. var _arr2 = Object.keys(ansiStyles.color.ansi);
  8174. var _loop2 = function _loop2() {
  8175. var model = _arr2[_i2];
  8176. if (skipModels.has(model)) {
  8177. return "continue";
  8178. }
  8179. styles[model] = {
  8180. get() {
  8181. var level = this.level;
  8182. return function () {
  8183. var open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments);
  8184. var codes = {
  8185. open,
  8186. close: ansiStyles.color.close,
  8187. closeRe: ansiStyles.color.closeRe
  8188. };
  8189. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
  8190. };
  8191. }
  8192. };
  8193. };
  8194. for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
  8195. var _ret = _loop2();
  8196. if (_ret === "continue") continue;
  8197. }
  8198. ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), 'g');
  8199. var _arr3 = Object.keys(ansiStyles.bgColor.ansi);
  8200. var _loop3 = function _loop3() {
  8201. var model = _arr3[_i3];
  8202. if (skipModels.has(model)) {
  8203. return "continue";
  8204. }
  8205. var bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
  8206. styles[bgModel] = {
  8207. get() {
  8208. var level = this.level;
  8209. return function () {
  8210. var open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments);
  8211. var codes = {
  8212. open,
  8213. close: ansiStyles.bgColor.close,
  8214. closeRe: ansiStyles.bgColor.closeRe
  8215. };
  8216. return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
  8217. };
  8218. }
  8219. };
  8220. };
  8221. for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
  8222. var _ret2 = _loop3();
  8223. if (_ret2 === "continue") continue;
  8224. }
  8225. var proto = Object.defineProperties(function () {}, styles);
  8226. function build(_styles, _empty, key) {
  8227. var builder = function builder() {
  8228. return applyStyle.apply(builder, arguments);
  8229. };
  8230. builder._styles = _styles;
  8231. builder._empty = _empty;
  8232. var self = this;
  8233. Object.defineProperty(builder, 'level', {
  8234. enumerable: true,
  8235. get() {
  8236. return self.level;
  8237. },
  8238. set(level) {
  8239. self.level = level;
  8240. }
  8241. });
  8242. Object.defineProperty(builder, 'enabled', {
  8243. enumerable: true,
  8244. get() {
  8245. return self.enabled;
  8246. },
  8247. set(enabled) {
  8248. self.enabled = enabled;
  8249. }
  8250. }); // See below for fix regarding invisible grey/dim combination on Windows
  8251. builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey'; // `__proto__` is used because we must return a function, but there is
  8252. // no way to create a function with a different prototype
  8253. builder.__proto__ = proto; // eslint-disable-line no-proto
  8254. return builder;
  8255. }
  8256. function applyStyle() {
  8257. // Support varags, but simply cast to string in case there's only one arg
  8258. var args = arguments;
  8259. var argsLen = args.length;
  8260. var str = String(arguments[0]);
  8261. if (argsLen === 0) {
  8262. return '';
  8263. }
  8264. if (argsLen > 1) {
  8265. // Don't slice `arguments`, it prevents V8 optimizations
  8266. for (var a = 1; a < argsLen; a++) {
  8267. str += ' ' + args[a];
  8268. }
  8269. }
  8270. if (!this.enabled || this.level <= 0 || !str) {
  8271. return this._empty ? '' : str;
  8272. } // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
  8273. // see https://github.com/chalk/chalk/issues/58
  8274. // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
  8275. var originalDim = ansiStyles.dim.open;
  8276. if (isSimpleWindowsTerm && this.hasGrey) {
  8277. ansiStyles.dim.open = '';
  8278. }
  8279. var _iteratorNormalCompletion = true;
  8280. var _didIteratorError = false;
  8281. var _iteratorError = undefined;
  8282. try {
  8283. for (var _iterator = this._styles.slice().reverse()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  8284. var code = _step.value;
  8285. // Replace any instances already present with a re-opening code
  8286. // otherwise only the part of the string until said closing code
  8287. // will be colored, and the rest will simply be 'plain'.
  8288. str = code.open + str.replace(code.closeRe, code.open) + code.close; // Close the styling before a linebreak and reopen
  8289. // after next line to fix a bleed issue on macOS
  8290. // https://github.com/chalk/chalk/pull/92
  8291. str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`);
  8292. } // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue
  8293. } catch (err) {
  8294. _didIteratorError = true;
  8295. _iteratorError = err;
  8296. } finally {
  8297. try {
  8298. if (!_iteratorNormalCompletion && _iterator.return != null) {
  8299. _iterator.return();
  8300. }
  8301. } finally {
  8302. if (_didIteratorError) {
  8303. throw _iteratorError;
  8304. }
  8305. }
  8306. }
  8307. ansiStyles.dim.open = originalDim;
  8308. return str;
  8309. }
  8310. function chalkTag(chalk, strings) {
  8311. if (!Array.isArray(strings)) {
  8312. // If chalk() was called by itself or with a string,
  8313. // return the string itself as a string.
  8314. return [].slice.call(arguments, 1).join(' ');
  8315. }
  8316. var args = [].slice.call(arguments, 2);
  8317. var parts = [strings.raw[0]];
  8318. for (var i = 1; i < strings.length; i++) {
  8319. parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&'));
  8320. parts.push(String(strings.raw[i]));
  8321. }
  8322. return templates$4(chalk, parts.join(''));
  8323. }
  8324. Object.defineProperties(Chalk.prototype, styles);
  8325. module.exports = Chalk(); // eslint-disable-line new-cap
  8326. module.exports.supportsColor = stdoutColor;
  8327. module.exports.default = module.exports; // For TypeScript
  8328. });
  8329. var lib$3 = createCommonjsModule(function (module, exports) {
  8330. "use strict";
  8331. Object.defineProperty(exports, "__esModule", {
  8332. value: true
  8333. });
  8334. exports.shouldHighlight = shouldHighlight;
  8335. exports.getChalk = getChalk;
  8336. exports.default = highlight;
  8337. function _jsTokens() {
  8338. var data = _interopRequireWildcard(jsTokens);
  8339. _jsTokens = function _jsTokens() {
  8340. return data;
  8341. };
  8342. return data;
  8343. }
  8344. function _esutils() {
  8345. var data = _interopRequireDefault(utils$2);
  8346. _esutils = function _esutils() {
  8347. return data;
  8348. };
  8349. return data;
  8350. }
  8351. function _chalk() {
  8352. var data = _interopRequireDefault(chalk$5);
  8353. _chalk = function _chalk() {
  8354. return data;
  8355. };
  8356. return data;
  8357. }
  8358. function _interopRequireDefault(obj) {
  8359. return obj && obj.__esModule ? obj : {
  8360. default: obj
  8361. };
  8362. }
  8363. function _interopRequireWildcard(obj) {
  8364. if (obj && obj.__esModule) {
  8365. return obj;
  8366. } else {
  8367. var newObj = {};
  8368. if (obj != null) {
  8369. for (var key in obj) {
  8370. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  8371. var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
  8372. if (desc.get || desc.set) {
  8373. Object.defineProperty(newObj, key, desc);
  8374. } else {
  8375. newObj[key] = obj[key];
  8376. }
  8377. }
  8378. }
  8379. }
  8380. newObj.default = obj;
  8381. return newObj;
  8382. }
  8383. }
  8384. function getDefs(chalk) {
  8385. return {
  8386. keyword: chalk.cyan,
  8387. capitalized: chalk.yellow,
  8388. jsx_tag: chalk.yellow,
  8389. punctuator: chalk.yellow,
  8390. number: chalk.magenta,
  8391. string: chalk.green,
  8392. regex: chalk.magenta,
  8393. comment: chalk.grey,
  8394. invalid: chalk.white.bgRed.bold
  8395. };
  8396. }
  8397. var NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
  8398. var JSX_TAG = /^[a-z][\w-]*$/i;
  8399. var BRACKET = /^[()[\]{}]$/;
  8400. function getTokenType(match) {
  8401. var _match$slice = match.slice(-2),
  8402. offset = _match$slice[0],
  8403. text = _match$slice[1];
  8404. var token = (0, _jsTokens().matchToToken)(match);
  8405. if (token.type === "name") {
  8406. if (_esutils().default.keyword.isReservedWordES6(token.value)) {
  8407. return "keyword";
  8408. }
  8409. if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.substr(offset - 2, 2) == "</")) {
  8410. return "jsx_tag";
  8411. }
  8412. if (token.value[0] !== token.value[0].toLowerCase()) {
  8413. return "capitalized";
  8414. }
  8415. }
  8416. if (token.type === "punctuator" && BRACKET.test(token.value)) {
  8417. return "bracket";
  8418. }
  8419. if (token.type === "invalid" && (token.value === "@" || token.value === "#")) {
  8420. return "punctuator";
  8421. }
  8422. return token.type;
  8423. }
  8424. function highlightTokens(defs, text) {
  8425. return text.replace(_jsTokens().default, function () {
  8426. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  8427. args[_key] = arguments[_key];
  8428. }
  8429. var type = getTokenType(args);
  8430. var colorize = defs[type];
  8431. if (colorize) {
  8432. return args[0].split(NEWLINE).map(function (str) {
  8433. return colorize(str);
  8434. }).join("\n");
  8435. } else {
  8436. return args[0];
  8437. }
  8438. });
  8439. }
  8440. function shouldHighlight(options) {
  8441. return _chalk().default.supportsColor || options.forceColor;
  8442. }
  8443. function getChalk(options) {
  8444. var chalk = _chalk().default;
  8445. if (options.forceColor) {
  8446. chalk = new (_chalk().default.constructor)({
  8447. enabled: true,
  8448. level: 1
  8449. });
  8450. }
  8451. return chalk;
  8452. }
  8453. function highlight(code, options) {
  8454. if (options === void 0) {
  8455. options = {};
  8456. }
  8457. if (shouldHighlight(options)) {
  8458. var chalk = getChalk(options);
  8459. var defs = getDefs(chalk);
  8460. return highlightTokens(defs, code);
  8461. } else {
  8462. return code;
  8463. }
  8464. }
  8465. });
  8466. unwrapExports(lib$3);
  8467. var lib$2 = createCommonjsModule(function (module, exports) {
  8468. "use strict";
  8469. Object.defineProperty(exports, "__esModule", {
  8470. value: true
  8471. });
  8472. exports.codeFrameColumns = codeFrameColumns;
  8473. exports.default = _default;
  8474. function _highlight() {
  8475. var data = _interopRequireWildcard(lib$3);
  8476. _highlight = function _highlight() {
  8477. return data;
  8478. };
  8479. return data;
  8480. }
  8481. function _interopRequireWildcard(obj) {
  8482. if (obj && obj.__esModule) {
  8483. return obj;
  8484. } else {
  8485. var newObj = {};
  8486. if (obj != null) {
  8487. for (var key in obj) {
  8488. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  8489. var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
  8490. if (desc.get || desc.set) {
  8491. Object.defineProperty(newObj, key, desc);
  8492. } else {
  8493. newObj[key] = obj[key];
  8494. }
  8495. }
  8496. }
  8497. }
  8498. newObj.default = obj;
  8499. return newObj;
  8500. }
  8501. }
  8502. var deprecationWarningShown = false;
  8503. function getDefs(chalk) {
  8504. return {
  8505. gutter: chalk.grey,
  8506. marker: chalk.red.bold,
  8507. message: chalk.red.bold
  8508. };
  8509. }
  8510. var NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
  8511. function getMarkerLines(loc, source, opts) {
  8512. var startLoc = Object.assign({}, {
  8513. column: 0,
  8514. line: -1
  8515. }, loc.start);
  8516. var endLoc = Object.assign({}, startLoc, loc.end);
  8517. var _ref = opts || {},
  8518. _ref$linesAbove = _ref.linesAbove,
  8519. linesAbove = _ref$linesAbove === void 0 ? 2 : _ref$linesAbove,
  8520. _ref$linesBelow = _ref.linesBelow,
  8521. linesBelow = _ref$linesBelow === void 0 ? 3 : _ref$linesBelow;
  8522. var startLine = startLoc.line;
  8523. var startColumn = startLoc.column;
  8524. var endLine = endLoc.line;
  8525. var endColumn = endLoc.column;
  8526. var start = Math.max(startLine - (linesAbove + 1), 0);
  8527. var end = Math.min(source.length, endLine + linesBelow);
  8528. if (startLine === -1) {
  8529. start = 0;
  8530. }
  8531. if (endLine === -1) {
  8532. end = source.length;
  8533. }
  8534. var lineDiff = endLine - startLine;
  8535. var markerLines = {};
  8536. if (lineDiff) {
  8537. for (var i = 0; i <= lineDiff; i++) {
  8538. var lineNumber = i + startLine;
  8539. if (!startColumn) {
  8540. markerLines[lineNumber] = true;
  8541. } else if (i === 0) {
  8542. var sourceLength = source[lineNumber - 1].length;
  8543. markerLines[lineNumber] = [startColumn, sourceLength - startColumn];
  8544. } else if (i === lineDiff) {
  8545. markerLines[lineNumber] = [0, endColumn];
  8546. } else {
  8547. var _sourceLength = source[lineNumber - i].length;
  8548. markerLines[lineNumber] = [0, _sourceLength];
  8549. }
  8550. }
  8551. } else {
  8552. if (startColumn === endColumn) {
  8553. if (startColumn) {
  8554. markerLines[startLine] = [startColumn, 0];
  8555. } else {
  8556. markerLines[startLine] = true;
  8557. }
  8558. } else {
  8559. markerLines[startLine] = [startColumn, endColumn - startColumn];
  8560. }
  8561. }
  8562. return {
  8563. start: start,
  8564. end: end,
  8565. markerLines: markerLines
  8566. };
  8567. }
  8568. function codeFrameColumns(rawLines, loc, opts) {
  8569. if (opts === void 0) {
  8570. opts = {};
  8571. }
  8572. var highlighted = (opts.highlightCode || opts.forceColor) && (0, _highlight().shouldHighlight)(opts);
  8573. var chalk = (0, _highlight().getChalk)(opts);
  8574. var defs = getDefs(chalk);
  8575. var maybeHighlight = function maybeHighlight(chalkFn, string) {
  8576. return highlighted ? chalkFn(string) : string;
  8577. };
  8578. if (highlighted) rawLines = (0, _highlight().default)(rawLines, opts);
  8579. var lines = rawLines.split(NEWLINE);
  8580. var _getMarkerLines = getMarkerLines(loc, lines, opts),
  8581. start = _getMarkerLines.start,
  8582. end = _getMarkerLines.end,
  8583. markerLines = _getMarkerLines.markerLines;
  8584. var hasColumns = loc.start && typeof loc.start.column === "number";
  8585. var numberMaxWidth = String(end).length;
  8586. var frame = lines.slice(start, end).map(function (line, index) {
  8587. var number = start + 1 + index;
  8588. var paddedNumber = (" " + number).slice(-numberMaxWidth);
  8589. var gutter = " " + paddedNumber + " | ";
  8590. var hasMarker = markerLines[number];
  8591. var lastMarkerLine = !markerLines[number + 1];
  8592. if (hasMarker) {
  8593. var markerLine = "";
  8594. if (Array.isArray(hasMarker)) {
  8595. var markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " ");
  8596. var numberOfMarkers = hasMarker[1] || 1;
  8597. markerLine = ["\n ", maybeHighlight(defs.gutter, gutter.replace(/\d/g, " ")), markerSpacing, maybeHighlight(defs.marker, "^").repeat(numberOfMarkers)].join("");
  8598. if (lastMarkerLine && opts.message) {
  8599. markerLine += " " + maybeHighlight(defs.message, opts.message);
  8600. }
  8601. }
  8602. return [maybeHighlight(defs.marker, ">"), maybeHighlight(defs.gutter, gutter), line, markerLine].join("");
  8603. } else {
  8604. return " " + maybeHighlight(defs.gutter, gutter) + line;
  8605. }
  8606. }).join("\n");
  8607. if (opts.message && !hasColumns) {
  8608. frame = "" + " ".repeat(numberMaxWidth + 1) + opts.message + "\n" + frame;
  8609. }
  8610. if (highlighted) {
  8611. return chalk.reset(frame);
  8612. } else {
  8613. return frame;
  8614. }
  8615. }
  8616. function _default(rawLines, lineNumber, colNumber, opts) {
  8617. if (opts === void 0) {
  8618. opts = {};
  8619. }
  8620. if (!deprecationWarningShown) {
  8621. deprecationWarningShown = true;
  8622. var message = "Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`.";
  8623. if (process.emitWarning) {
  8624. process.emitWarning(message, "DeprecationWarning");
  8625. } else {
  8626. var deprecationError = new Error(message);
  8627. deprecationError.name = "DeprecationWarning";
  8628. console.warn(new Error(message));
  8629. }
  8630. }
  8631. colNumber = Math.max(colNumber, 0);
  8632. var location = {
  8633. start: {
  8634. column: colNumber,
  8635. line: lineNumber
  8636. }
  8637. };
  8638. return codeFrameColumns(rawLines, location, opts);
  8639. }
  8640. });
  8641. unwrapExports(lib$2);
  8642. var ConfigError$1 = errors.ConfigError;
  8643. var locStart = loc.locStart;
  8644. var locEnd = loc.locEnd; // Use defineProperties()/getOwnPropertyDescriptor() to prevent
  8645. // triggering the parsers getters.
  8646. var ownNames = Object.getOwnPropertyNames;
  8647. var ownDescriptor = Object.getOwnPropertyDescriptor;
  8648. function getParsers(options) {
  8649. var parsers = {};
  8650. var _iteratorNormalCompletion = true;
  8651. var _didIteratorError = false;
  8652. var _iteratorError = undefined;
  8653. try {
  8654. for (var _iterator = options.plugins[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  8655. var plugin = _step.value;
  8656. if (!plugin.parsers) {
  8657. continue;
  8658. }
  8659. var _iteratorNormalCompletion2 = true;
  8660. var _didIteratorError2 = false;
  8661. var _iteratorError2 = undefined;
  8662. try {
  8663. for (var _iterator2 = ownNames(plugin.parsers)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  8664. var name = _step2.value;
  8665. Object.defineProperty(parsers, name, ownDescriptor(plugin.parsers, name));
  8666. }
  8667. } catch (err) {
  8668. _didIteratorError2 = true;
  8669. _iteratorError2 = err;
  8670. } finally {
  8671. try {
  8672. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  8673. _iterator2.return();
  8674. }
  8675. } finally {
  8676. if (_didIteratorError2) {
  8677. throw _iteratorError2;
  8678. }
  8679. }
  8680. }
  8681. }
  8682. } catch (err) {
  8683. _didIteratorError = true;
  8684. _iteratorError = err;
  8685. } finally {
  8686. try {
  8687. if (!_iteratorNormalCompletion && _iterator.return != null) {
  8688. _iterator.return();
  8689. }
  8690. } finally {
  8691. if (_didIteratorError) {
  8692. throw _iteratorError;
  8693. }
  8694. }
  8695. }
  8696. return parsers;
  8697. }
  8698. function resolveParser$1(opts, parsers) {
  8699. parsers = parsers || getParsers(opts);
  8700. if (typeof opts.parser === "function") {
  8701. // Custom parser API always works with JavaScript.
  8702. return {
  8703. parse: opts.parser,
  8704. astFormat: "estree",
  8705. locStart,
  8706. locEnd
  8707. };
  8708. }
  8709. if (typeof opts.parser === "string") {
  8710. if (parsers.hasOwnProperty(opts.parser)) {
  8711. return parsers[opts.parser];
  8712. }
  8713. /* istanbul ignore next */
  8714. {
  8715. try {
  8716. return {
  8717. parse: require(path.resolve(process.cwd(), opts.parser)),
  8718. astFormat: "estree",
  8719. locStart,
  8720. locEnd
  8721. };
  8722. } catch (err) {
  8723. /* istanbul ignore next */
  8724. throw new ConfigError$1(`Couldn't resolve parser "${opts.parser}"`);
  8725. }
  8726. }
  8727. }
  8728. }
  8729. function parse$2(text, opts) {
  8730. var parsers = getParsers(opts); // Create a new object {parserName: parseFn}. Uses defineProperty() to only call
  8731. // the parsers getters when actually calling the parser `parse` function.
  8732. var parsersForCustomParserApi = Object.keys(parsers).reduce(function (object, parserName) {
  8733. return Object.defineProperty(object, parserName, {
  8734. enumerable: true,
  8735. get() {
  8736. return parsers[parserName].parse;
  8737. }
  8738. });
  8739. }, {});
  8740. var parser = resolveParser$1(opts, parsers);
  8741. try {
  8742. if (parser.preprocess) {
  8743. text = parser.preprocess(text, opts);
  8744. }
  8745. return {
  8746. text,
  8747. ast: parser.parse(text, parsersForCustomParserApi, opts)
  8748. };
  8749. } catch (error) {
  8750. var loc$$1 = error.loc;
  8751. if (loc$$1) {
  8752. var codeFrame = lib$2;
  8753. error.codeFrame = codeFrame.codeFrameColumns(text, loc$$1, {
  8754. highlightCode: true
  8755. });
  8756. error.message += "\n" + error.codeFrame;
  8757. throw error;
  8758. }
  8759. /* istanbul ignore next */
  8760. throw error.stack;
  8761. }
  8762. }
  8763. var parser = {
  8764. parse: parse$2,
  8765. resolveParser: resolveParser$1
  8766. };
  8767. var UndefinedParserError = errors.UndefinedParserError;
  8768. var getSupportInfo$1 = support.getSupportInfo;
  8769. var resolveParser = parser.resolveParser;
  8770. var hiddenDefaults = {
  8771. astFormat: "estree",
  8772. printer: {},
  8773. originalText: undefined,
  8774. locStart: null,
  8775. locEnd: null
  8776. }; // Copy options and fill in default values.
  8777. function normalize(options, opts) {
  8778. opts = opts || {};
  8779. var rawOptions = Object.assign({}, options);
  8780. var supportOptions = getSupportInfo$1(null, {
  8781. plugins: options.plugins,
  8782. showUnreleased: true,
  8783. showDeprecated: true
  8784. }).options;
  8785. var defaults = supportOptions.reduce(function (reduced, optionInfo) {
  8786. return optionInfo.default !== undefined ? Object.assign(reduced, {
  8787. [optionInfo.name]: optionInfo.default
  8788. }) : reduced;
  8789. }, Object.assign({}, hiddenDefaults));
  8790. if (!rawOptions.parser) {
  8791. if (!rawOptions.filepath) {
  8792. var logger = opts.logger || console;
  8793. logger.warn("No parser and no filepath given, using 'babel' the parser now " + "but this will throw an error in the future. " + "Please specify a parser or a filepath so one can be inferred.");
  8794. rawOptions.parser = "babel";
  8795. } else {
  8796. rawOptions.parser = inferParser(rawOptions.filepath, rawOptions.plugins);
  8797. if (!rawOptions.parser) {
  8798. throw new UndefinedParserError(`No parser could be inferred for file: ${rawOptions.filepath}`);
  8799. }
  8800. }
  8801. }
  8802. var parser$$1 = resolveParser(optionsNormalizer.normalizeApiOptions(rawOptions, [supportOptions.find(function (x) {
  8803. return x.name === "parser";
  8804. })], {
  8805. passThrough: true,
  8806. logger: false
  8807. }));
  8808. rawOptions.astFormat = parser$$1.astFormat;
  8809. rawOptions.locEnd = parser$$1.locEnd;
  8810. rawOptions.locStart = parser$$1.locStart;
  8811. var plugin = getPlugin(rawOptions);
  8812. rawOptions.printer = plugin.printers[rawOptions.astFormat];
  8813. var pluginDefaults = supportOptions.filter(function (optionInfo) {
  8814. return optionInfo.pluginDefaults && optionInfo.pluginDefaults[plugin.name];
  8815. }).reduce(function (reduced, optionInfo) {
  8816. return Object.assign(reduced, {
  8817. [optionInfo.name]: optionInfo.pluginDefaults[plugin.name]
  8818. });
  8819. }, {});
  8820. var mixedDefaults = Object.assign({}, defaults, pluginDefaults);
  8821. Object.keys(mixedDefaults).forEach(function (k) {
  8822. if (rawOptions[k] == null) {
  8823. rawOptions[k] = mixedDefaults[k];
  8824. }
  8825. });
  8826. if (rawOptions.parser === "json") {
  8827. rawOptions.trailingComma = "none";
  8828. }
  8829. return optionsNormalizer.normalizeApiOptions(rawOptions, supportOptions, Object.assign({
  8830. passThrough: Object.keys(hiddenDefaults)
  8831. }, opts));
  8832. }
  8833. function getPlugin(options) {
  8834. var astFormat = options.astFormat;
  8835. if (!astFormat) {
  8836. throw new Error("getPlugin() requires astFormat to be set");
  8837. }
  8838. var printerPlugin = options.plugins.find(function (plugin) {
  8839. return plugin.printers && plugin.printers[astFormat];
  8840. });
  8841. if (!printerPlugin) {
  8842. throw new Error(`Couldn't find plugin for AST format "${astFormat}"`);
  8843. }
  8844. return printerPlugin;
  8845. }
  8846. function getInterpreter(filepath) {
  8847. if (typeof filepath !== "string") {
  8848. return "";
  8849. }
  8850. var fd;
  8851. try {
  8852. fd = fs.openSync(filepath, "r");
  8853. } catch (err) {
  8854. return "";
  8855. }
  8856. try {
  8857. var liner = new readlines(fd);
  8858. var firstLine = liner.next().toString("utf8"); // #!/bin/env node, #!/usr/bin/env node
  8859. var m1 = firstLine.match(/^#!\/(?:usr\/)?bin\/env\s+(\S+)/);
  8860. if (m1) {
  8861. return m1[1];
  8862. } // #!/bin/node, #!/usr/bin/node, #!/usr/local/bin/node
  8863. var m2 = firstLine.match(/^#!\/(?:usr\/(?:local\/)?)?bin\/(\S+)/);
  8864. if (m2) {
  8865. return m2[1];
  8866. }
  8867. return "";
  8868. } catch (err) {
  8869. // There are some weird cases where paths are missing, causing Jest
  8870. // failures. It's unclear what these correspond to in the real world.
  8871. return "";
  8872. } finally {
  8873. try {
  8874. // There are some weird cases where paths are missing, causing Jest
  8875. // failures. It's unclear what these correspond to in the real world.
  8876. fs.closeSync(fd);
  8877. } catch (err) {// nop
  8878. }
  8879. }
  8880. }
  8881. function inferParser(filepath, plugins) {
  8882. var filepathParts = normalizePath(filepath).split("/");
  8883. var filename = filepathParts[filepathParts.length - 1].toLowerCase(); // If the file has no extension, we can try to infer the language from the
  8884. // interpreter in the shebang line, if any; but since this requires FS access,
  8885. // do it last.
  8886. var language = getSupportInfo$1(null, {
  8887. plugins
  8888. }).languages.find(function (language) {
  8889. return language.since !== null && (language.extensions && language.extensions.some(function (extension) {
  8890. return filename.endsWith(extension);
  8891. }) || language.filenames && language.filenames.find(function (name) {
  8892. return name.toLowerCase() === filename;
  8893. }) || filename.indexOf(".") === -1 && language.interpreters && language.interpreters.indexOf(getInterpreter(filepath)) !== -1);
  8894. });
  8895. return language && language.parsers[0];
  8896. }
  8897. var options = {
  8898. normalize,
  8899. hiddenDefaults,
  8900. inferParser
  8901. };
  8902. function massageAST(ast, options, parent) {
  8903. if (Array.isArray(ast)) {
  8904. return ast.map(function (e) {
  8905. return massageAST(e, options, parent);
  8906. }).filter(function (e) {
  8907. return e;
  8908. });
  8909. }
  8910. if (!ast || typeof ast !== "object") {
  8911. return ast;
  8912. }
  8913. var newObj = {};
  8914. var _arr = Object.keys(ast);
  8915. for (var _i = 0; _i < _arr.length; _i++) {
  8916. var key = _arr[_i];
  8917. if (typeof ast[key] !== "function") {
  8918. newObj[key] = massageAST(ast[key], options, ast);
  8919. }
  8920. }
  8921. if (options.printer.massageAstNode) {
  8922. var result = options.printer.massageAstNode(ast, newObj, parent);
  8923. if (result === null) {
  8924. return undefined;
  8925. }
  8926. if (result) {
  8927. return result;
  8928. }
  8929. }
  8930. return newObj;
  8931. }
  8932. var massageAst = massageAST;
  8933. function concat$1(parts) {
  8934. return {
  8935. type: "concat",
  8936. parts
  8937. };
  8938. }
  8939. function indent$1(contents) {
  8940. return {
  8941. type: "indent",
  8942. contents
  8943. };
  8944. }
  8945. function align(n, contents) {
  8946. return {
  8947. type: "align",
  8948. contents,
  8949. n
  8950. };
  8951. }
  8952. function group(contents, opts) {
  8953. opts = opts || {};
  8954. return {
  8955. type: "group",
  8956. id: opts.id,
  8957. contents: contents,
  8958. break: !!opts.shouldBreak,
  8959. expandedStates: opts.expandedStates
  8960. };
  8961. }
  8962. function dedentToRoot(contents) {
  8963. return align(-Infinity, contents);
  8964. }
  8965. function markAsRoot(contents) {
  8966. return align({
  8967. type: "root"
  8968. }, contents);
  8969. }
  8970. function dedent$1(contents) {
  8971. return align(-1, contents);
  8972. }
  8973. function conditionalGroup(states, opts) {
  8974. return group(states[0], Object.assign(opts || {}, {
  8975. expandedStates: states
  8976. }));
  8977. }
  8978. function fill(parts) {
  8979. return {
  8980. type: "fill",
  8981. parts
  8982. };
  8983. }
  8984. function ifBreak(breakContents, flatContents, opts) {
  8985. opts = opts || {};
  8986. return {
  8987. type: "if-break",
  8988. breakContents,
  8989. flatContents,
  8990. groupId: opts.groupId
  8991. };
  8992. }
  8993. function lineSuffix$1(contents) {
  8994. return {
  8995. type: "line-suffix",
  8996. contents
  8997. };
  8998. }
  8999. var lineSuffixBoundary = {
  9000. type: "line-suffix-boundary"
  9001. };
  9002. var breakParent$1 = {
  9003. type: "break-parent"
  9004. };
  9005. var trim = {
  9006. type: "trim"
  9007. };
  9008. var line$2 = {
  9009. type: "line"
  9010. };
  9011. var softline = {
  9012. type: "line",
  9013. soft: true
  9014. };
  9015. var hardline$1 = concat$1([{
  9016. type: "line",
  9017. hard: true
  9018. }, breakParent$1]);
  9019. var literalline = concat$1([{
  9020. type: "line",
  9021. hard: true,
  9022. literal: true
  9023. }, breakParent$1]);
  9024. var cursor$1 = {
  9025. type: "cursor",
  9026. placeholder: Symbol("cursor")
  9027. };
  9028. function join$1(sep, arr) {
  9029. var res = [];
  9030. for (var i = 0; i < arr.length; i++) {
  9031. if (i !== 0) {
  9032. res.push(sep);
  9033. }
  9034. res.push(arr[i]);
  9035. }
  9036. return concat$1(res);
  9037. }
  9038. function addAlignmentToDoc(doc, size, tabWidth) {
  9039. var aligned = doc;
  9040. if (size > 0) {
  9041. // Use indent to add tabs for all the levels of tabs we need
  9042. for (var i = 0; i < Math.floor(size / tabWidth); ++i) {
  9043. aligned = indent$1(aligned);
  9044. } // Use align for all the spaces that are needed
  9045. aligned = align(size % tabWidth, aligned); // size is absolute from 0 and not relative to the current
  9046. // indentation, so we use -Infinity to reset the indentation to 0
  9047. aligned = align(-Infinity, aligned);
  9048. }
  9049. return aligned;
  9050. }
  9051. var docBuilders = {
  9052. concat: concat$1,
  9053. join: join$1,
  9054. line: line$2,
  9055. softline,
  9056. hardline: hardline$1,
  9057. literalline,
  9058. group,
  9059. conditionalGroup,
  9060. fill,
  9061. lineSuffix: lineSuffix$1,
  9062. lineSuffixBoundary,
  9063. cursor: cursor$1,
  9064. breakParent: breakParent$1,
  9065. ifBreak,
  9066. trim,
  9067. indent: indent$1,
  9068. align,
  9069. addAlignmentToDoc,
  9070. markAsRoot,
  9071. dedentToRoot,
  9072. dedent: dedent$1
  9073. };
  9074. var ansiRegex = createCommonjsModule(function (module) {
  9075. 'use strict';
  9076. module.exports = function (options) {
  9077. options = Object.assign({
  9078. onlyFirst: false
  9079. }, options);
  9080. var pattern = ['[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)', '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'].join('|');
  9081. return new RegExp(pattern, options.onlyFirst ? undefined : 'g');
  9082. };
  9083. });
  9084. var stripAnsi = function stripAnsi(input) {
  9085. return typeof input === 'string' ? input.replace(ansiRegex(), '') : input;
  9086. };
  9087. var isFullwidthCodePoint = createCommonjsModule(function (module) {
  9088. 'use strict';
  9089. /* eslint-disable yoda */
  9090. module.exports = function (x) {
  9091. if (Number.isNaN(x)) {
  9092. return false;
  9093. } // code points are derived from:
  9094. // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt
  9095. if (x >= 0x1100 && (x <= 0x115f || // Hangul Jamo
  9096. x === 0x2329 || // LEFT-POINTING ANGLE BRACKET
  9097. x === 0x232a || // RIGHT-POINTING ANGLE BRACKET
  9098. // CJK Radicals Supplement .. Enclosed CJK Letters and Months
  9099. 0x2e80 <= x && x <= 0x3247 && x !== 0x303f || // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A
  9100. 0x3250 <= x && x <= 0x4dbf || // CJK Unified Ideographs .. Yi Radicals
  9101. 0x4e00 <= x && x <= 0xa4c6 || // Hangul Jamo Extended-A
  9102. 0xa960 <= x && x <= 0xa97c || // Hangul Syllables
  9103. 0xac00 <= x && x <= 0xd7a3 || // CJK Compatibility Ideographs
  9104. 0xf900 <= x && x <= 0xfaff || // Vertical Forms
  9105. 0xfe10 <= x && x <= 0xfe19 || // CJK Compatibility Forms .. Small Form Variants
  9106. 0xfe30 <= x && x <= 0xfe6b || // Halfwidth and Fullwidth Forms
  9107. 0xff01 <= x && x <= 0xff60 || 0xffe0 <= x && x <= 0xffe6 || // Kana Supplement
  9108. 0x1b000 <= x && x <= 0x1b001 || // Enclosed Ideographic Supplement
  9109. 0x1f200 <= x && x <= 0x1f251 || // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane
  9110. 0x20000 <= x && x <= 0x3fffd)) {
  9111. return true;
  9112. }
  9113. return false;
  9114. };
  9115. });
  9116. var emojiRegex = function emojiRegex() {
  9117. // https://mths.be/emoji
  9118. return /\uD83C\uDFF4(?:\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74)\uDB40\uDC7F|\u200D\u2620\uFE0F)|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC68(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDB0-\uDDB3])|(?:\uD83C[\uDFFB-\uDFFF])\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDB0-\uDDB3]))|\uD83D\uDC69\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDB0-\uDDB3])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2695\u2696\u2708]|\uD83D\uDC68(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83D\uDC69\u200D[\u2695\u2696\u2708])\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC68(?:\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDB0-\uDDB3])|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDD1-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDEEB\uDEEC\uDEF4-\uDEF9]|\uD83E[\uDD10-\uDD3A\uDD3C-\uDD3E\uDD40-\uDD45\uDD47-\uDD70\uDD73-\uDD76\uDD7A\uDD7C-\uDDA2\uDDB0-\uDDB9\uDDC0-\uDDC2\uDDD0-\uDDFF])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEF9]|\uD83E[\uDD10-\uDD3A\uDD3C-\uDD3E\uDD40-\uDD45\uDD47-\uDD70\uDD73-\uDD76\uDD7A\uDD7C-\uDDA2\uDDB0-\uDDB9\uDDC0-\uDDC2\uDDD0-\uDDFF])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC69\uDC6E\uDC70-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD18-\uDD1C\uDD1E\uDD1F\uDD26\uDD30-\uDD39\uDD3D\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDD1-\uDDDD])/g;
  9119. };
  9120. var stringWidth = createCommonjsModule(function (module) {
  9121. 'use strict';
  9122. var emojiRegex$$1 = emojiRegex();
  9123. module.exports = function (input) {
  9124. input = input.replace(emojiRegex$$1, ' ');
  9125. if (typeof input !== 'string' || input.length === 0) {
  9126. return 0;
  9127. }
  9128. input = stripAnsi(input);
  9129. var width = 0;
  9130. for (var i = 0; i < input.length; i++) {
  9131. var code = input.codePointAt(i); // Ignore control characters
  9132. if (code <= 0x1F || code >= 0x7F && code <= 0x9F) {
  9133. continue;
  9134. } // Ignore combining characters
  9135. if (code >= 0x300 && code <= 0x36F) {
  9136. continue;
  9137. } // Surrogates
  9138. if (code > 0xFFFF) {
  9139. i++;
  9140. }
  9141. width += isFullwidthCodePoint(code) ? 2 : 1;
  9142. }
  9143. return width;
  9144. };
  9145. });
  9146. var notAsciiRegex = /[^\x20-\x7F]/;
  9147. function isExportDeclaration(node) {
  9148. if (node) {
  9149. switch (node.type) {
  9150. case "ExportDefaultDeclaration":
  9151. case "ExportDefaultSpecifier":
  9152. case "DeclareExportDeclaration":
  9153. case "ExportNamedDeclaration":
  9154. case "ExportAllDeclaration":
  9155. return true;
  9156. }
  9157. }
  9158. return false;
  9159. }
  9160. function getParentExportDeclaration(path$$1) {
  9161. var parentNode = path$$1.getParentNode();
  9162. if (path$$1.getName() === "declaration" && isExportDeclaration(parentNode)) {
  9163. return parentNode;
  9164. }
  9165. return null;
  9166. }
  9167. function getPenultimate(arr) {
  9168. if (arr.length > 1) {
  9169. return arr[arr.length - 2];
  9170. }
  9171. return null;
  9172. }
  9173. function getLast$3(arr) {
  9174. if (arr.length > 0) {
  9175. return arr[arr.length - 1];
  9176. }
  9177. return null;
  9178. }
  9179. function skip(chars) {
  9180. return function (text, index, opts) {
  9181. var backwards = opts && opts.backwards; // Allow `skip` functions to be threaded together without having
  9182. // to check for failures (did someone say monads?).
  9183. if (index === false) {
  9184. return false;
  9185. }
  9186. var length = text.length;
  9187. var cursor = index;
  9188. while (cursor >= 0 && cursor < length) {
  9189. var c = text.charAt(cursor);
  9190. if (chars instanceof RegExp) {
  9191. if (!chars.test(c)) {
  9192. return cursor;
  9193. }
  9194. } else if (chars.indexOf(c) === -1) {
  9195. return cursor;
  9196. }
  9197. backwards ? cursor-- : cursor++;
  9198. }
  9199. if (cursor === -1 || cursor === length) {
  9200. // If we reached the beginning or end of the file, return the
  9201. // out-of-bounds cursor. It's up to the caller to handle this
  9202. // correctly. We don't want to indicate `false` though if it
  9203. // actually skipped valid characters.
  9204. return cursor;
  9205. }
  9206. return false;
  9207. };
  9208. }
  9209. var skipWhitespace = skip(/\s/);
  9210. var skipSpaces = skip(" \t");
  9211. var skipToLineEnd = skip(",; \t");
  9212. var skipEverythingButNewLine = skip(/[^\r\n]/);
  9213. function skipInlineComment(text, index) {
  9214. if (index === false) {
  9215. return false;
  9216. }
  9217. if (text.charAt(index) === "/" && text.charAt(index + 1) === "*") {
  9218. for (var i = index + 2; i < text.length; ++i) {
  9219. if (text.charAt(i) === "*" && text.charAt(i + 1) === "/") {
  9220. return i + 2;
  9221. }
  9222. }
  9223. }
  9224. return index;
  9225. }
  9226. function skipTrailingComment(text, index) {
  9227. if (index === false) {
  9228. return false;
  9229. }
  9230. if (text.charAt(index) === "/" && text.charAt(index + 1) === "/") {
  9231. return skipEverythingButNewLine(text, index);
  9232. }
  9233. return index;
  9234. } // This one doesn't use the above helper function because it wants to
  9235. // test \r\n in order and `skip` doesn't support ordering and we only
  9236. // want to skip one newline. It's simple to implement.
  9237. function skipNewline$1(text, index, opts) {
  9238. var backwards = opts && opts.backwards;
  9239. if (index === false) {
  9240. return false;
  9241. }
  9242. var atIndex = text.charAt(index);
  9243. if (backwards) {
  9244. if (text.charAt(index - 1) === "\r" && atIndex === "\n") {
  9245. return index - 2;
  9246. }
  9247. if (atIndex === "\n" || atIndex === "\r" || atIndex === "\u2028" || atIndex === "\u2029") {
  9248. return index - 1;
  9249. }
  9250. } else {
  9251. if (atIndex === "\r" && text.charAt(index + 1) === "\n") {
  9252. return index + 2;
  9253. }
  9254. if (atIndex === "\n" || atIndex === "\r" || atIndex === "\u2028" || atIndex === "\u2029") {
  9255. return index + 1;
  9256. }
  9257. }
  9258. return index;
  9259. }
  9260. function hasNewline$1(text, index, opts) {
  9261. opts = opts || {};
  9262. var idx = skipSpaces(text, opts.backwards ? index - 1 : index, opts);
  9263. var idx2 = skipNewline$1(text, idx, opts);
  9264. return idx !== idx2;
  9265. }
  9266. function hasNewlineInRange(text, start, end) {
  9267. for (var i = start; i < end; ++i) {
  9268. if (text.charAt(i) === "\n") {
  9269. return true;
  9270. }
  9271. }
  9272. return false;
  9273. } // Note: this function doesn't ignore leading comments unlike isNextLineEmpty
  9274. function isPreviousLineEmpty$1(text, node, locStart) {
  9275. var idx = locStart(node) - 1;
  9276. idx = skipSpaces(text, idx, {
  9277. backwards: true
  9278. });
  9279. idx = skipNewline$1(text, idx, {
  9280. backwards: true
  9281. });
  9282. idx = skipSpaces(text, idx, {
  9283. backwards: true
  9284. });
  9285. var idx2 = skipNewline$1(text, idx, {
  9286. backwards: true
  9287. });
  9288. return idx !== idx2;
  9289. }
  9290. function isNextLineEmptyAfterIndex(text, index) {
  9291. var oldIdx = null;
  9292. var idx = index;
  9293. while (idx !== oldIdx) {
  9294. // We need to skip all the potential trailing inline comments
  9295. oldIdx = idx;
  9296. idx = skipToLineEnd(text, idx);
  9297. idx = skipInlineComment(text, idx);
  9298. idx = skipSpaces(text, idx);
  9299. }
  9300. idx = skipTrailingComment(text, idx);
  9301. idx = skipNewline$1(text, idx);
  9302. return hasNewline$1(text, idx);
  9303. }
  9304. function isNextLineEmpty(text, node, locEnd) {
  9305. return isNextLineEmptyAfterIndex(text, locEnd(node));
  9306. }
  9307. function getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, idx) {
  9308. var oldIdx = null;
  9309. while (idx !== oldIdx) {
  9310. oldIdx = idx;
  9311. idx = skipSpaces(text, idx);
  9312. idx = skipInlineComment(text, idx);
  9313. idx = skipTrailingComment(text, idx);
  9314. idx = skipNewline$1(text, idx);
  9315. }
  9316. return idx;
  9317. }
  9318. function getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd) {
  9319. return getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, locEnd(node));
  9320. }
  9321. function getNextNonSpaceNonCommentCharacter(text, node, locEnd) {
  9322. return text.charAt(getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd));
  9323. }
  9324. function hasSpaces(text, index, opts) {
  9325. opts = opts || {};
  9326. var idx = skipSpaces(text, opts.backwards ? index - 1 : index, opts);
  9327. return idx !== index;
  9328. }
  9329. function setLocStart(node, index) {
  9330. if (node.range) {
  9331. node.range[0] = index;
  9332. } else {
  9333. node.start = index;
  9334. }
  9335. }
  9336. function setLocEnd(node, index) {
  9337. if (node.range) {
  9338. node.range[1] = index;
  9339. } else {
  9340. node.end = index;
  9341. }
  9342. }
  9343. var PRECEDENCE = {};
  9344. [["|>"], ["||", "??"], ["&&"], ["|"], ["^"], ["&"], ["==", "===", "!=", "!=="], ["<", ">", "<=", ">=", "in", "instanceof"], [">>", "<<", ">>>"], ["+", "-"], ["*", "/", "%"], ["**"]].forEach(function (tier, i) {
  9345. tier.forEach(function (op) {
  9346. PRECEDENCE[op] = i;
  9347. });
  9348. });
  9349. function getPrecedence(op) {
  9350. return PRECEDENCE[op];
  9351. }
  9352. var equalityOperators = {
  9353. "==": true,
  9354. "!=": true,
  9355. "===": true,
  9356. "!==": true
  9357. };
  9358. var multiplicativeOperators = {
  9359. "*": true,
  9360. "/": true,
  9361. "%": true
  9362. };
  9363. var bitshiftOperators = {
  9364. ">>": true,
  9365. ">>>": true,
  9366. "<<": true
  9367. };
  9368. function shouldFlatten(parentOp, nodeOp) {
  9369. if (getPrecedence(nodeOp) !== getPrecedence(parentOp)) {
  9370. return false;
  9371. } // ** is right-associative
  9372. // x ** y ** z --> x ** (y ** z)
  9373. if (parentOp === "**") {
  9374. return false;
  9375. } // x == y == z --> (x == y) == z
  9376. if (equalityOperators[parentOp] && equalityOperators[nodeOp]) {
  9377. return false;
  9378. } // x * y % z --> (x * y) % z
  9379. if (nodeOp === "%" && multiplicativeOperators[parentOp] || parentOp === "%" && multiplicativeOperators[nodeOp]) {
  9380. return false;
  9381. } // x * y / z --> (x * y) / z
  9382. // x / y * z --> (x / y) * z
  9383. if (nodeOp !== parentOp && multiplicativeOperators[nodeOp] && multiplicativeOperators[parentOp]) {
  9384. return false;
  9385. } // x << y << z --> (x << y) << z
  9386. if (bitshiftOperators[parentOp] && bitshiftOperators[nodeOp]) {
  9387. return false;
  9388. }
  9389. return true;
  9390. }
  9391. function isBitwiseOperator(operator) {
  9392. return !!bitshiftOperators[operator] || operator === "|" || operator === "^" || operator === "&";
  9393. } // Tests if an expression starts with `{`, or (if forbidFunctionClassAndDoExpr
  9394. // holds) `function`, `class`, or `do {}`. Will be overzealous if there's
  9395. // already necessary grouping parentheses.
  9396. function startsWithNoLookaheadToken(node, forbidFunctionClassAndDoExpr) {
  9397. node = getLeftMost(node);
  9398. switch (node.type) {
  9399. case "FunctionExpression":
  9400. case "ClassExpression":
  9401. case "DoExpression":
  9402. return forbidFunctionClassAndDoExpr;
  9403. case "ObjectExpression":
  9404. return true;
  9405. case "MemberExpression":
  9406. return startsWithNoLookaheadToken(node.object, forbidFunctionClassAndDoExpr);
  9407. case "TaggedTemplateExpression":
  9408. if (node.tag.type === "FunctionExpression") {
  9409. // IIFEs are always already parenthesized
  9410. return false;
  9411. }
  9412. return startsWithNoLookaheadToken(node.tag, forbidFunctionClassAndDoExpr);
  9413. case "CallExpression":
  9414. if (node.callee.type === "FunctionExpression") {
  9415. // IIFEs are always already parenthesized
  9416. return false;
  9417. }
  9418. return startsWithNoLookaheadToken(node.callee, forbidFunctionClassAndDoExpr);
  9419. case "ConditionalExpression":
  9420. return startsWithNoLookaheadToken(node.test, forbidFunctionClassAndDoExpr);
  9421. case "UpdateExpression":
  9422. return !node.prefix && startsWithNoLookaheadToken(node.argument, forbidFunctionClassAndDoExpr);
  9423. case "BindExpression":
  9424. return node.object && startsWithNoLookaheadToken(node.object, forbidFunctionClassAndDoExpr);
  9425. case "SequenceExpression":
  9426. return startsWithNoLookaheadToken(node.expressions[0], forbidFunctionClassAndDoExpr);
  9427. case "TSAsExpression":
  9428. return startsWithNoLookaheadToken(node.expression, forbidFunctionClassAndDoExpr);
  9429. default:
  9430. return false;
  9431. }
  9432. }
  9433. function getLeftMost(node) {
  9434. if (node.left) {
  9435. return getLeftMost(node.left);
  9436. }
  9437. return node;
  9438. }
  9439. function getAlignmentSize(value, tabWidth, startIndex) {
  9440. startIndex = startIndex || 0;
  9441. var size = 0;
  9442. for (var i = startIndex; i < value.length; ++i) {
  9443. if (value[i] === "\t") {
  9444. // Tabs behave in a way that they are aligned to the nearest
  9445. // multiple of tabWidth:
  9446. // 0 -> 4, 1 -> 4, 2 -> 4, 3 -> 4
  9447. // 4 -> 8, 5 -> 8, 6 -> 8, 7 -> 8 ...
  9448. size = size + tabWidth - size % tabWidth;
  9449. } else {
  9450. size++;
  9451. }
  9452. }
  9453. return size;
  9454. }
  9455. function getIndentSize(value, tabWidth) {
  9456. var lastNewlineIndex = value.lastIndexOf("\n");
  9457. if (lastNewlineIndex === -1) {
  9458. return 0;
  9459. }
  9460. return getAlignmentSize( // All the leading whitespaces
  9461. value.slice(lastNewlineIndex + 1).match(/^[ \t]*/)[0], tabWidth);
  9462. }
  9463. function getPreferredQuote(raw, preferredQuote) {
  9464. // `rawContent` is the string exactly like it appeared in the input source
  9465. // code, without its enclosing quotes.
  9466. var rawContent = raw.slice(1, -1);
  9467. var double = {
  9468. quote: '"',
  9469. regex: /"/g
  9470. };
  9471. var single = {
  9472. quote: "'",
  9473. regex: /'/g
  9474. };
  9475. var preferred = preferredQuote === "'" ? single : double;
  9476. var alternate = preferred === single ? double : single;
  9477. var result = preferred.quote; // If `rawContent` contains at least one of the quote preferred for enclosing
  9478. // the string, we might want to enclose with the alternate quote instead, to
  9479. // minimize the number of escaped quotes.
  9480. if (rawContent.includes(preferred.quote) || rawContent.includes(alternate.quote)) {
  9481. var numPreferredQuotes = (rawContent.match(preferred.regex) || []).length;
  9482. var numAlternateQuotes = (rawContent.match(alternate.regex) || []).length;
  9483. result = numPreferredQuotes > numAlternateQuotes ? alternate.quote : preferred.quote;
  9484. }
  9485. return result;
  9486. }
  9487. function printString(raw, options, isDirectiveLiteral) {
  9488. // `rawContent` is the string exactly like it appeared in the input source
  9489. // code, without its enclosing quotes.
  9490. var rawContent = raw.slice(1, -1); // Check for the alternate quote, to determine if we're allowed to swap
  9491. // the quotes on a DirectiveLiteral.
  9492. var canChangeDirectiveQuotes = !rawContent.includes('"') && !rawContent.includes("'");
  9493. var enclosingQuote = options.parser === "json" ? '"' : options.__isInHtmlAttribute ? "'" : getPreferredQuote(raw, options.singleQuote ? "'" : '"'); // Directives are exact code unit sequences, which means that you can't
  9494. // change the escape sequences they use.
  9495. // See https://github.com/prettier/prettier/issues/1555
  9496. // and https://tc39.github.io/ecma262/#directive-prologue
  9497. if (isDirectiveLiteral) {
  9498. if (canChangeDirectiveQuotes) {
  9499. return enclosingQuote + rawContent + enclosingQuote;
  9500. }
  9501. return raw;
  9502. } // It might sound unnecessary to use `makeString` even if the string already
  9503. // is enclosed with `enclosingQuote`, but it isn't. The string could contain
  9504. // unnecessary escapes (such as in `"\'"`). Always using `makeString` makes
  9505. // sure that we consistently output the minimum amount of escaped quotes.
  9506. return makeString(rawContent, enclosingQuote, !(options.parser === "css" || options.parser === "less" || options.parser === "scss" || options.parentParser === "html" || options.parentParser === "vue" || options.parentParser === "angular"));
  9507. }
  9508. function makeString(rawContent, enclosingQuote, unescapeUnnecessaryEscapes) {
  9509. var otherQuote = enclosingQuote === '"' ? "'" : '"'; // Matches _any_ escape and unescaped quotes (both single and double).
  9510. var regex = /\\([\s\S])|(['"])/g; // Escape and unescape single and double quotes as needed to be able to
  9511. // enclose `rawContent` with `enclosingQuote`.
  9512. var newContent = rawContent.replace(regex, function (match, escaped, quote) {
  9513. // If we matched an escape, and the escaped character is a quote of the
  9514. // other type than we intend to enclose the string with, there's no need for
  9515. // it to be escaped, so return it _without_ the backslash.
  9516. if (escaped === otherQuote) {
  9517. return escaped;
  9518. } // If we matched an unescaped quote and it is of the _same_ type as we
  9519. // intend to enclose the string with, it must be escaped, so return it with
  9520. // a backslash.
  9521. if (quote === enclosingQuote) {
  9522. return "\\" + quote;
  9523. }
  9524. if (quote) {
  9525. return quote;
  9526. } // Unescape any unnecessarily escaped character.
  9527. // Adapted from https://github.com/eslint/eslint/blob/de0b4ad7bd820ade41b1f606008bea68683dc11a/lib/rules/no-useless-escape.js#L27
  9528. return unescapeUnnecessaryEscapes && /^[^\\nrvtbfux\r\n\u2028\u2029"'0-7]$/.test(escaped) ? escaped : "\\" + escaped;
  9529. });
  9530. return enclosingQuote + newContent + enclosingQuote;
  9531. }
  9532. function printNumber(rawNumber) {
  9533. return rawNumber.toLowerCase() // Remove unnecessary plus and zeroes from scientific notation.
  9534. .replace(/^([+-]?[\d.]+e)(?:\+|(-))?0*(\d)/, "$1$2$3") // Remove unnecessary scientific notation (1e0).
  9535. .replace(/^([+-]?[\d.]+)e[+-]?0+$/, "$1") // Make sure numbers always start with a digit.
  9536. .replace(/^([+-])?\./, "$10.") // Remove extraneous trailing decimal zeroes.
  9537. .replace(/(\.\d+?)0+(?=e|$)/, "$1") // Remove trailing dot.
  9538. .replace(/\.(?=e|$)/, "");
  9539. }
  9540. function getMaxContinuousCount(str, target) {
  9541. var results = str.match(new RegExp(`(${escapeStringRegexp(target)})+`, "g"));
  9542. if (results === null) {
  9543. return 0;
  9544. }
  9545. return results.reduce(function (maxCount, result) {
  9546. return Math.max(maxCount, result.length / target.length);
  9547. }, 0);
  9548. }
  9549. function getStringWidth$1(text) {
  9550. if (!text) {
  9551. return 0;
  9552. } // shortcut to avoid needless string `RegExp`s, replacements, and allocations within `string-width`
  9553. if (!notAsciiRegex.test(text)) {
  9554. return text.length;
  9555. }
  9556. return stringWidth(text);
  9557. }
  9558. function hasIgnoreComment(path$$1) {
  9559. var node = path$$1.getValue();
  9560. return hasNodeIgnoreComment(node);
  9561. }
  9562. function hasNodeIgnoreComment(node) {
  9563. return node && node.comments && node.comments.length > 0 && node.comments.some(function (comment) {
  9564. return comment.value.trim() === "prettier-ignore";
  9565. });
  9566. }
  9567. function matchAncestorTypes(path$$1, types, index) {
  9568. index = index || 0;
  9569. types = types.slice();
  9570. while (types.length) {
  9571. var parent = path$$1.getParentNode(index);
  9572. var type = types.shift();
  9573. if (!parent || parent.type !== type) {
  9574. return false;
  9575. }
  9576. index++;
  9577. }
  9578. return true;
  9579. }
  9580. function addCommentHelper(node, comment) {
  9581. var comments = node.comments || (node.comments = []);
  9582. comments.push(comment);
  9583. comment.printed = false; // For some reason, TypeScript parses `// x` inside of JSXText as a comment
  9584. // We already "print" it via the raw text, we don't need to re-print it as a
  9585. // comment
  9586. if (node.type === "JSXText") {
  9587. comment.printed = true;
  9588. }
  9589. }
  9590. function addLeadingComment$1(node, comment) {
  9591. comment.leading = true;
  9592. comment.trailing = false;
  9593. addCommentHelper(node, comment);
  9594. }
  9595. function addDanglingComment$1(node, comment) {
  9596. comment.leading = false;
  9597. comment.trailing = false;
  9598. addCommentHelper(node, comment);
  9599. }
  9600. function addTrailingComment$1(node, comment) {
  9601. comment.leading = false;
  9602. comment.trailing = true;
  9603. addCommentHelper(node, comment);
  9604. }
  9605. function isWithinParentArrayProperty(path$$1, propertyName) {
  9606. var node = path$$1.getValue();
  9607. var parent = path$$1.getParentNode();
  9608. if (parent == null) {
  9609. return false;
  9610. }
  9611. if (!Array.isArray(parent[propertyName])) {
  9612. return false;
  9613. }
  9614. var key = path$$1.getName();
  9615. return parent[propertyName][key] === node;
  9616. }
  9617. function replaceEndOfLineWith(text, replacement) {
  9618. var parts = [];
  9619. var _iteratorNormalCompletion = true;
  9620. var _didIteratorError = false;
  9621. var _iteratorError = undefined;
  9622. try {
  9623. for (var _iterator = text.split("\n")[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  9624. var part = _step.value;
  9625. if (parts.length !== 0) {
  9626. parts.push(replacement);
  9627. }
  9628. parts.push(part);
  9629. }
  9630. } catch (err) {
  9631. _didIteratorError = true;
  9632. _iteratorError = err;
  9633. } finally {
  9634. try {
  9635. if (!_iteratorNormalCompletion && _iterator.return != null) {
  9636. _iterator.return();
  9637. }
  9638. } finally {
  9639. if (_didIteratorError) {
  9640. throw _iteratorError;
  9641. }
  9642. }
  9643. }
  9644. return parts;
  9645. }
  9646. var util$1 = {
  9647. replaceEndOfLineWith,
  9648. getStringWidth: getStringWidth$1,
  9649. getMaxContinuousCount,
  9650. getPrecedence,
  9651. shouldFlatten,
  9652. isBitwiseOperator,
  9653. isExportDeclaration,
  9654. getParentExportDeclaration,
  9655. getPenultimate,
  9656. getLast: getLast$3,
  9657. getNextNonSpaceNonCommentCharacterIndexWithStartIndex,
  9658. getNextNonSpaceNonCommentCharacterIndex,
  9659. getNextNonSpaceNonCommentCharacter,
  9660. skip,
  9661. skipWhitespace,
  9662. skipSpaces,
  9663. skipToLineEnd,
  9664. skipEverythingButNewLine,
  9665. skipInlineComment,
  9666. skipTrailingComment,
  9667. skipNewline: skipNewline$1,
  9668. isNextLineEmptyAfterIndex,
  9669. isNextLineEmpty,
  9670. isPreviousLineEmpty: isPreviousLineEmpty$1,
  9671. hasNewline: hasNewline$1,
  9672. hasNewlineInRange,
  9673. hasSpaces,
  9674. setLocStart,
  9675. setLocEnd,
  9676. startsWithNoLookaheadToken,
  9677. getAlignmentSize,
  9678. getIndentSize,
  9679. getPreferredQuote,
  9680. printString,
  9681. printNumber,
  9682. hasIgnoreComment,
  9683. hasNodeIgnoreComment,
  9684. makeString,
  9685. matchAncestorTypes,
  9686. addLeadingComment: addLeadingComment$1,
  9687. addDanglingComment: addDanglingComment$1,
  9688. addTrailingComment: addTrailingComment$1,
  9689. isWithinParentArrayProperty
  9690. };
  9691. function guessEndOfLine$1(text) {
  9692. var index = text.indexOf("\r");
  9693. if (index >= 0) {
  9694. return text.charAt(index + 1) === "\n" ? "crlf" : "cr";
  9695. }
  9696. return "lf";
  9697. }
  9698. function convertEndOfLineToChars$2(value) {
  9699. switch (value) {
  9700. case "cr":
  9701. return "\r";
  9702. case "crlf":
  9703. return "\r\n";
  9704. default:
  9705. return "\n";
  9706. }
  9707. }
  9708. var endOfLine = {
  9709. guessEndOfLine: guessEndOfLine$1,
  9710. convertEndOfLineToChars: convertEndOfLineToChars$2
  9711. };
  9712. var getStringWidth = util$1.getStringWidth;
  9713. var convertEndOfLineToChars$1 = endOfLine.convertEndOfLineToChars;
  9714. var concat$2 = docBuilders.concat;
  9715. var fill$1 = docBuilders.fill;
  9716. var cursor$2 = docBuilders.cursor;
  9717. /** @type {{[groupId: PropertyKey]: MODE}} */
  9718. var groupModeMap;
  9719. var MODE_BREAK = 1;
  9720. var MODE_FLAT = 2;
  9721. function rootIndent() {
  9722. return {
  9723. value: "",
  9724. length: 0,
  9725. queue: []
  9726. };
  9727. }
  9728. function makeIndent(ind, options) {
  9729. return generateInd(ind, {
  9730. type: "indent"
  9731. }, options);
  9732. }
  9733. function makeAlign(ind, n, options) {
  9734. return n === -Infinity ? ind.root || rootIndent() : n < 0 ? generateInd(ind, {
  9735. type: "dedent"
  9736. }, options) : !n ? ind : n.type === "root" ? Object.assign({}, ind, {
  9737. root: ind
  9738. }) : typeof n === "string" ? generateInd(ind, {
  9739. type: "stringAlign",
  9740. n
  9741. }, options) : generateInd(ind, {
  9742. type: "numberAlign",
  9743. n
  9744. }, options);
  9745. }
  9746. function generateInd(ind, newPart, options) {
  9747. var queue = newPart.type === "dedent" ? ind.queue.slice(0, -1) : ind.queue.concat(newPart);
  9748. var value = "";
  9749. var length = 0;
  9750. var lastTabs = 0;
  9751. var lastSpaces = 0;
  9752. var _iteratorNormalCompletion = true;
  9753. var _didIteratorError = false;
  9754. var _iteratorError = undefined;
  9755. try {
  9756. for (var _iterator = queue[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  9757. var part = _step.value;
  9758. switch (part.type) {
  9759. case "indent":
  9760. flush();
  9761. if (options.useTabs) {
  9762. addTabs(1);
  9763. } else {
  9764. addSpaces(options.tabWidth);
  9765. }
  9766. break;
  9767. case "stringAlign":
  9768. flush();
  9769. value += part.n;
  9770. length += part.n.length;
  9771. break;
  9772. case "numberAlign":
  9773. lastTabs += 1;
  9774. lastSpaces += part.n;
  9775. break;
  9776. /* istanbul ignore next */
  9777. default:
  9778. throw new Error(`Unexpected type '${part.type}'`);
  9779. }
  9780. }
  9781. } catch (err) {
  9782. _didIteratorError = true;
  9783. _iteratorError = err;
  9784. } finally {
  9785. try {
  9786. if (!_iteratorNormalCompletion && _iterator.return != null) {
  9787. _iterator.return();
  9788. }
  9789. } finally {
  9790. if (_didIteratorError) {
  9791. throw _iteratorError;
  9792. }
  9793. }
  9794. }
  9795. flushSpaces();
  9796. return Object.assign({}, ind, {
  9797. value,
  9798. length,
  9799. queue
  9800. });
  9801. function addTabs(count) {
  9802. value += "\t".repeat(count);
  9803. length += options.tabWidth * count;
  9804. }
  9805. function addSpaces(count) {
  9806. value += " ".repeat(count);
  9807. length += count;
  9808. }
  9809. function flush() {
  9810. if (options.useTabs) {
  9811. flushTabs();
  9812. } else {
  9813. flushSpaces();
  9814. }
  9815. }
  9816. function flushTabs() {
  9817. if (lastTabs > 0) {
  9818. addTabs(lastTabs);
  9819. }
  9820. resetLast();
  9821. }
  9822. function flushSpaces() {
  9823. if (lastSpaces > 0) {
  9824. addSpaces(lastSpaces);
  9825. }
  9826. resetLast();
  9827. }
  9828. function resetLast() {
  9829. lastTabs = 0;
  9830. lastSpaces = 0;
  9831. }
  9832. }
  9833. function trim$1(out) {
  9834. if (out.length === 0) {
  9835. return 0;
  9836. }
  9837. var trimCount = 0; // Trim whitespace at the end of line
  9838. while (out.length > 0 && typeof out[out.length - 1] === "string" && out[out.length - 1].match(/^[ \t]*$/)) {
  9839. trimCount += out.pop().length;
  9840. }
  9841. if (out.length && typeof out[out.length - 1] === "string") {
  9842. var trimmed = out[out.length - 1].replace(/[ \t]*$/, "");
  9843. trimCount += out[out.length - 1].length - trimmed.length;
  9844. out[out.length - 1] = trimmed;
  9845. }
  9846. return trimCount;
  9847. }
  9848. function fits(next, restCommands, width, options, mustBeFlat) {
  9849. var restIdx = restCommands.length;
  9850. var cmds = [next]; // `out` is only used for width counting because `trim` requires to look
  9851. // backwards for space characters.
  9852. var out = [];
  9853. while (width >= 0) {
  9854. if (cmds.length === 0) {
  9855. if (restIdx === 0) {
  9856. return true;
  9857. }
  9858. cmds.push(restCommands[restIdx - 1]);
  9859. restIdx--;
  9860. continue;
  9861. }
  9862. var x = cmds.pop();
  9863. var ind = x[0];
  9864. var mode = x[1];
  9865. var doc = x[2];
  9866. if (typeof doc === "string") {
  9867. out.push(doc);
  9868. width -= getStringWidth(doc);
  9869. } else {
  9870. switch (doc.type) {
  9871. case "concat":
  9872. for (var i = doc.parts.length - 1; i >= 0; i--) {
  9873. cmds.push([ind, mode, doc.parts[i]]);
  9874. }
  9875. break;
  9876. case "indent":
  9877. cmds.push([makeIndent(ind, options), mode, doc.contents]);
  9878. break;
  9879. case "align":
  9880. cmds.push([makeAlign(ind, doc.n, options), mode, doc.contents]);
  9881. break;
  9882. case "trim":
  9883. width += trim$1(out);
  9884. break;
  9885. case "group":
  9886. if (mustBeFlat && doc.break) {
  9887. return false;
  9888. }
  9889. cmds.push([ind, doc.break ? MODE_BREAK : mode, doc.contents]);
  9890. if (doc.id) {
  9891. groupModeMap[doc.id] = cmds[cmds.length - 1][1];
  9892. }
  9893. break;
  9894. case "fill":
  9895. for (var _i = doc.parts.length - 1; _i >= 0; _i--) {
  9896. cmds.push([ind, mode, doc.parts[_i]]);
  9897. }
  9898. break;
  9899. case "if-break":
  9900. {
  9901. var groupMode = doc.groupId ? groupModeMap[doc.groupId] : mode;
  9902. if (groupMode === MODE_BREAK) {
  9903. if (doc.breakContents) {
  9904. cmds.push([ind, mode, doc.breakContents]);
  9905. }
  9906. }
  9907. if (groupMode === MODE_FLAT) {
  9908. if (doc.flatContents) {
  9909. cmds.push([ind, mode, doc.flatContents]);
  9910. }
  9911. }
  9912. break;
  9913. }
  9914. case "line":
  9915. switch (mode) {
  9916. // fallthrough
  9917. case MODE_FLAT:
  9918. if (!doc.hard) {
  9919. if (!doc.soft) {
  9920. out.push(" ");
  9921. width -= 1;
  9922. }
  9923. break;
  9924. }
  9925. return true;
  9926. case MODE_BREAK:
  9927. return true;
  9928. }
  9929. break;
  9930. }
  9931. }
  9932. }
  9933. return false;
  9934. }
  9935. function printDocToString$1(doc, options) {
  9936. groupModeMap = {};
  9937. var width = options.printWidth;
  9938. var newLine = convertEndOfLineToChars$1(options.endOfLine);
  9939. var pos = 0; // cmds is basically a stack. We've turned a recursive call into a
  9940. // while loop which is much faster. The while loop below adds new
  9941. // cmds to the array instead of recursively calling `print`.
  9942. var cmds = [[rootIndent(), MODE_BREAK, doc]];
  9943. var out = [];
  9944. var shouldRemeasure = false;
  9945. var lineSuffix = [];
  9946. while (cmds.length !== 0) {
  9947. var x = cmds.pop();
  9948. var ind = x[0];
  9949. var mode = x[1];
  9950. var _doc = x[2];
  9951. if (typeof _doc === "string") {
  9952. out.push(_doc);
  9953. pos += getStringWidth(_doc);
  9954. } else {
  9955. switch (_doc.type) {
  9956. case "cursor":
  9957. out.push(cursor$2.placeholder);
  9958. break;
  9959. case "concat":
  9960. for (var i = _doc.parts.length - 1; i >= 0; i--) {
  9961. cmds.push([ind, mode, _doc.parts[i]]);
  9962. }
  9963. break;
  9964. case "indent":
  9965. cmds.push([makeIndent(ind, options), mode, _doc.contents]);
  9966. break;
  9967. case "align":
  9968. cmds.push([makeAlign(ind, _doc.n, options), mode, _doc.contents]);
  9969. break;
  9970. case "trim":
  9971. pos -= trim$1(out);
  9972. break;
  9973. case "group":
  9974. switch (mode) {
  9975. case MODE_FLAT:
  9976. if (!shouldRemeasure) {
  9977. cmds.push([ind, _doc.break ? MODE_BREAK : MODE_FLAT, _doc.contents]);
  9978. break;
  9979. }
  9980. // fallthrough
  9981. case MODE_BREAK:
  9982. {
  9983. shouldRemeasure = false;
  9984. var next = [ind, MODE_FLAT, _doc.contents];
  9985. var rem = width - pos;
  9986. if (!_doc.break && fits(next, cmds, rem, options)) {
  9987. cmds.push(next);
  9988. } else {
  9989. // Expanded states are a rare case where a document
  9990. // can manually provide multiple representations of
  9991. // itself. It provides an array of documents
  9992. // going from the least expanded (most flattened)
  9993. // representation first to the most expanded. If a
  9994. // group has these, we need to manually go through
  9995. // these states and find the first one that fits.
  9996. if (_doc.expandedStates) {
  9997. var mostExpanded = _doc.expandedStates[_doc.expandedStates.length - 1];
  9998. if (_doc.break) {
  9999. cmds.push([ind, MODE_BREAK, mostExpanded]);
  10000. break;
  10001. } else {
  10002. for (var _i2 = 1; _i2 < _doc.expandedStates.length + 1; _i2++) {
  10003. if (_i2 >= _doc.expandedStates.length) {
  10004. cmds.push([ind, MODE_BREAK, mostExpanded]);
  10005. break;
  10006. } else {
  10007. var state = _doc.expandedStates[_i2];
  10008. var cmd = [ind, MODE_FLAT, state];
  10009. if (fits(cmd, cmds, rem, options)) {
  10010. cmds.push(cmd);
  10011. break;
  10012. }
  10013. }
  10014. }
  10015. }
  10016. } else {
  10017. cmds.push([ind, MODE_BREAK, _doc.contents]);
  10018. }
  10019. }
  10020. break;
  10021. }
  10022. }
  10023. if (_doc.id) {
  10024. groupModeMap[_doc.id] = cmds[cmds.length - 1][1];
  10025. }
  10026. break;
  10027. // Fills each line with as much code as possible before moving to a new
  10028. // line with the same indentation.
  10029. //
  10030. // Expects doc.parts to be an array of alternating content and
  10031. // whitespace. The whitespace contains the linebreaks.
  10032. //
  10033. // For example:
  10034. // ["I", line, "love", line, "monkeys"]
  10035. // or
  10036. // [{ type: group, ... }, softline, { type: group, ... }]
  10037. //
  10038. // It uses this parts structure to handle three main layout cases:
  10039. // * The first two content items fit on the same line without
  10040. // breaking
  10041. // -> output the first content item and the whitespace "flat".
  10042. // * Only the first content item fits on the line without breaking
  10043. // -> output the first content item "flat" and the whitespace with
  10044. // "break".
  10045. // * Neither content item fits on the line without breaking
  10046. // -> output the first content item and the whitespace with "break".
  10047. case "fill":
  10048. {
  10049. var _rem = width - pos;
  10050. var parts = _doc.parts;
  10051. if (parts.length === 0) {
  10052. break;
  10053. }
  10054. var content = parts[0];
  10055. var contentFlatCmd = [ind, MODE_FLAT, content];
  10056. var contentBreakCmd = [ind, MODE_BREAK, content];
  10057. var contentFits = fits(contentFlatCmd, [], _rem, options, true);
  10058. if (parts.length === 1) {
  10059. if (contentFits) {
  10060. cmds.push(contentFlatCmd);
  10061. } else {
  10062. cmds.push(contentBreakCmd);
  10063. }
  10064. break;
  10065. }
  10066. var whitespace = parts[1];
  10067. var whitespaceFlatCmd = [ind, MODE_FLAT, whitespace];
  10068. var whitespaceBreakCmd = [ind, MODE_BREAK, whitespace];
  10069. if (parts.length === 2) {
  10070. if (contentFits) {
  10071. cmds.push(whitespaceFlatCmd);
  10072. cmds.push(contentFlatCmd);
  10073. } else {
  10074. cmds.push(whitespaceBreakCmd);
  10075. cmds.push(contentBreakCmd);
  10076. }
  10077. break;
  10078. } // At this point we've handled the first pair (context, separator)
  10079. // and will create a new fill doc for the rest of the content.
  10080. // Ideally we wouldn't mutate the array here but coping all the
  10081. // elements to a new array would make this algorithm quadratic,
  10082. // which is unusable for large arrays (e.g. large texts in JSX).
  10083. parts.splice(0, 2);
  10084. var remainingCmd = [ind, mode, fill$1(parts)];
  10085. var secondContent = parts[0];
  10086. var firstAndSecondContentFlatCmd = [ind, MODE_FLAT, concat$2([content, whitespace, secondContent])];
  10087. var firstAndSecondContentFits = fits(firstAndSecondContentFlatCmd, [], _rem, options, true);
  10088. if (firstAndSecondContentFits) {
  10089. cmds.push(remainingCmd);
  10090. cmds.push(whitespaceFlatCmd);
  10091. cmds.push(contentFlatCmd);
  10092. } else if (contentFits) {
  10093. cmds.push(remainingCmd);
  10094. cmds.push(whitespaceBreakCmd);
  10095. cmds.push(contentFlatCmd);
  10096. } else {
  10097. cmds.push(remainingCmd);
  10098. cmds.push(whitespaceBreakCmd);
  10099. cmds.push(contentBreakCmd);
  10100. }
  10101. break;
  10102. }
  10103. case "if-break":
  10104. {
  10105. var groupMode = _doc.groupId ? groupModeMap[_doc.groupId] : mode;
  10106. if (groupMode === MODE_BREAK) {
  10107. if (_doc.breakContents) {
  10108. cmds.push([ind, mode, _doc.breakContents]);
  10109. }
  10110. }
  10111. if (groupMode === MODE_FLAT) {
  10112. if (_doc.flatContents) {
  10113. cmds.push([ind, mode, _doc.flatContents]);
  10114. }
  10115. }
  10116. break;
  10117. }
  10118. case "line-suffix":
  10119. lineSuffix.push([ind, mode, _doc.contents]);
  10120. break;
  10121. case "line-suffix-boundary":
  10122. if (lineSuffix.length > 0) {
  10123. cmds.push([ind, mode, {
  10124. type: "line",
  10125. hard: true
  10126. }]);
  10127. }
  10128. break;
  10129. case "line":
  10130. switch (mode) {
  10131. case MODE_FLAT:
  10132. if (!_doc.hard) {
  10133. if (!_doc.soft) {
  10134. out.push(" ");
  10135. pos += 1;
  10136. }
  10137. break;
  10138. } else {
  10139. // This line was forced into the output even if we
  10140. // were in flattened mode, so we need to tell the next
  10141. // group that no matter what, it needs to remeasure
  10142. // because the previous measurement didn't accurately
  10143. // capture the entire expression (this is necessary
  10144. // for nested groups)
  10145. shouldRemeasure = true;
  10146. }
  10147. // fallthrough
  10148. case MODE_BREAK:
  10149. if (lineSuffix.length) {
  10150. cmds.push([ind, mode, _doc]);
  10151. [].push.apply(cmds, lineSuffix.reverse());
  10152. lineSuffix = [];
  10153. break;
  10154. }
  10155. if (_doc.literal) {
  10156. if (ind.root) {
  10157. out.push(newLine, ind.root.value);
  10158. pos = ind.root.length;
  10159. } else {
  10160. out.push(newLine);
  10161. pos = 0;
  10162. }
  10163. } else {
  10164. pos -= trim$1(out);
  10165. out.push(newLine + ind.value);
  10166. pos = ind.length;
  10167. }
  10168. break;
  10169. }
  10170. break;
  10171. default:
  10172. }
  10173. }
  10174. }
  10175. var cursorPlaceholderIndex = out.indexOf(cursor$2.placeholder);
  10176. if (cursorPlaceholderIndex !== -1) {
  10177. var otherCursorPlaceholderIndex = out.indexOf(cursor$2.placeholder, cursorPlaceholderIndex + 1);
  10178. var beforeCursor = out.slice(0, cursorPlaceholderIndex).join("");
  10179. var aroundCursor = out.slice(cursorPlaceholderIndex + 1, otherCursorPlaceholderIndex).join("");
  10180. var afterCursor = out.slice(otherCursorPlaceholderIndex + 1).join("");
  10181. return {
  10182. formatted: beforeCursor + aroundCursor + afterCursor,
  10183. cursorNodeStart: beforeCursor.length,
  10184. cursorNodeText: aroundCursor
  10185. };
  10186. }
  10187. return {
  10188. formatted: out.join("")
  10189. };
  10190. }
  10191. var docPrinter = {
  10192. printDocToString: printDocToString$1
  10193. };
  10194. var traverseDocOnExitStackMarker = {};
  10195. function traverseDoc(doc, onEnter, onExit, shouldTraverseConditionalGroups) {
  10196. var docsStack = [doc];
  10197. while (docsStack.length !== 0) {
  10198. var _doc = docsStack.pop();
  10199. if (_doc === traverseDocOnExitStackMarker) {
  10200. onExit(docsStack.pop());
  10201. continue;
  10202. }
  10203. var shouldRecurse = true;
  10204. if (onEnter) {
  10205. if (onEnter(_doc) === false) {
  10206. shouldRecurse = false;
  10207. }
  10208. }
  10209. if (onExit) {
  10210. docsStack.push(_doc);
  10211. docsStack.push(traverseDocOnExitStackMarker);
  10212. }
  10213. if (shouldRecurse) {
  10214. // When there are multiple parts to process,
  10215. // the parts need to be pushed onto the stack in reverse order,
  10216. // so that they are processed in the original order
  10217. // when the stack is popped.
  10218. if (_doc.type === "concat" || _doc.type === "fill") {
  10219. for (var ic = _doc.parts.length, i = ic - 1; i >= 0; --i) {
  10220. docsStack.push(_doc.parts[i]);
  10221. }
  10222. } else if (_doc.type === "if-break") {
  10223. if (_doc.flatContents) {
  10224. docsStack.push(_doc.flatContents);
  10225. }
  10226. if (_doc.breakContents) {
  10227. docsStack.push(_doc.breakContents);
  10228. }
  10229. } else if (_doc.type === "group" && _doc.expandedStates) {
  10230. if (shouldTraverseConditionalGroups) {
  10231. for (var _ic = _doc.expandedStates.length, _i = _ic - 1; _i >= 0; --_i) {
  10232. docsStack.push(_doc.expandedStates[_i]);
  10233. }
  10234. } else {
  10235. docsStack.push(_doc.contents);
  10236. }
  10237. } else if (_doc.contents) {
  10238. docsStack.push(_doc.contents);
  10239. }
  10240. }
  10241. }
  10242. }
  10243. function mapDoc$1(doc, cb) {
  10244. if (doc.type === "concat" || doc.type === "fill") {
  10245. var parts = doc.parts.map(function (part) {
  10246. return mapDoc$1(part, cb);
  10247. });
  10248. return cb(Object.assign({}, doc, {
  10249. parts
  10250. }));
  10251. } else if (doc.type === "if-break") {
  10252. var breakContents = doc.breakContents && mapDoc$1(doc.breakContents, cb);
  10253. var flatContents = doc.flatContents && mapDoc$1(doc.flatContents, cb);
  10254. return cb(Object.assign({}, doc, {
  10255. breakContents,
  10256. flatContents
  10257. }));
  10258. } else if (doc.contents) {
  10259. var contents = mapDoc$1(doc.contents, cb);
  10260. return cb(Object.assign({}, doc, {
  10261. contents
  10262. }));
  10263. }
  10264. return cb(doc);
  10265. }
  10266. function findInDoc(doc, fn, defaultValue) {
  10267. var result = defaultValue;
  10268. var hasStopped = false;
  10269. function findInDocOnEnterFn(doc) {
  10270. var maybeResult = fn(doc);
  10271. if (maybeResult !== undefined) {
  10272. hasStopped = true;
  10273. result = maybeResult;
  10274. }
  10275. if (hasStopped) {
  10276. return false;
  10277. }
  10278. }
  10279. traverseDoc(doc, findInDocOnEnterFn);
  10280. return result;
  10281. }
  10282. function isEmpty(n) {
  10283. return typeof n === "string" && n.length === 0;
  10284. }
  10285. function isLineNextFn(doc) {
  10286. if (typeof doc === "string") {
  10287. return false;
  10288. }
  10289. if (doc.type === "line") {
  10290. return true;
  10291. }
  10292. }
  10293. function isLineNext(doc) {
  10294. return findInDoc(doc, isLineNextFn, false);
  10295. }
  10296. function willBreakFn(doc) {
  10297. if (doc.type === "group" && doc.break) {
  10298. return true;
  10299. }
  10300. if (doc.type === "line" && doc.hard) {
  10301. return true;
  10302. }
  10303. if (doc.type === "break-parent") {
  10304. return true;
  10305. }
  10306. }
  10307. function willBreak(doc) {
  10308. return findInDoc(doc, willBreakFn, false);
  10309. }
  10310. function breakParentGroup(groupStack) {
  10311. if (groupStack.length > 0) {
  10312. var parentGroup = groupStack[groupStack.length - 1]; // Breaks are not propagated through conditional groups because
  10313. // the user is expected to manually handle what breaks.
  10314. if (!parentGroup.expandedStates) {
  10315. parentGroup.break = true;
  10316. }
  10317. }
  10318. return null;
  10319. }
  10320. function propagateBreaks(doc) {
  10321. var alreadyVisitedSet = new Set();
  10322. var groupStack = [];
  10323. function propagateBreaksOnEnterFn(doc) {
  10324. if (doc.type === "break-parent") {
  10325. breakParentGroup(groupStack);
  10326. }
  10327. if (doc.type === "group") {
  10328. groupStack.push(doc);
  10329. if (alreadyVisitedSet.has(doc)) {
  10330. return false;
  10331. }
  10332. alreadyVisitedSet.add(doc);
  10333. }
  10334. }
  10335. function propagateBreaksOnExitFn(doc) {
  10336. if (doc.type === "group") {
  10337. var group = groupStack.pop();
  10338. if (group.break) {
  10339. breakParentGroup(groupStack);
  10340. }
  10341. }
  10342. }
  10343. traverseDoc(doc, propagateBreaksOnEnterFn, propagateBreaksOnExitFn,
  10344. /* shouldTraverseConditionalGroups */
  10345. true);
  10346. }
  10347. function removeLinesFn(doc) {
  10348. // Force this doc into flat mode by statically converting all
  10349. // lines into spaces (or soft lines into nothing). Hard lines
  10350. // should still output because there's too great of a chance
  10351. // of breaking existing assumptions otherwise.
  10352. if (doc.type === "line" && !doc.hard) {
  10353. return doc.soft ? "" : " ";
  10354. } else if (doc.type === "if-break") {
  10355. return doc.flatContents || "";
  10356. }
  10357. return doc;
  10358. }
  10359. function removeLines(doc) {
  10360. return mapDoc$1(doc, removeLinesFn);
  10361. }
  10362. function stripTrailingHardline(doc) {
  10363. // HACK remove ending hardline, original PR: #1984
  10364. if (doc.type === "concat" && doc.parts.length !== 0) {
  10365. var lastPart = doc.parts[doc.parts.length - 1];
  10366. if (lastPart.type === "concat") {
  10367. if (lastPart.parts.length === 2 && lastPart.parts[0].hard && lastPart.parts[1].type === "break-parent") {
  10368. return {
  10369. type: "concat",
  10370. parts: doc.parts.slice(0, -1)
  10371. };
  10372. }
  10373. return {
  10374. type: "concat",
  10375. parts: doc.parts.slice(0, -1).concat(stripTrailingHardline(lastPart))
  10376. };
  10377. }
  10378. }
  10379. return doc;
  10380. }
  10381. var docUtils = {
  10382. isEmpty,
  10383. willBreak,
  10384. isLineNext,
  10385. traverseDoc,
  10386. mapDoc: mapDoc$1,
  10387. propagateBreaks,
  10388. removeLines,
  10389. stripTrailingHardline
  10390. };
  10391. function flattenDoc(doc) {
  10392. if (doc.type === "concat") {
  10393. var res = [];
  10394. for (var i = 0; i < doc.parts.length; ++i) {
  10395. var doc2 = doc.parts[i];
  10396. if (typeof doc2 !== "string" && doc2.type === "concat") {
  10397. [].push.apply(res, flattenDoc(doc2).parts);
  10398. } else {
  10399. var flattened = flattenDoc(doc2);
  10400. if (flattened !== "") {
  10401. res.push(flattened);
  10402. }
  10403. }
  10404. }
  10405. return Object.assign({}, doc, {
  10406. parts: res
  10407. });
  10408. } else if (doc.type === "if-break") {
  10409. return Object.assign({}, doc, {
  10410. breakContents: doc.breakContents != null ? flattenDoc(doc.breakContents) : null,
  10411. flatContents: doc.flatContents != null ? flattenDoc(doc.flatContents) : null
  10412. });
  10413. } else if (doc.type === "group") {
  10414. return Object.assign({}, doc, {
  10415. contents: flattenDoc(doc.contents),
  10416. expandedStates: doc.expandedStates ? doc.expandedStates.map(flattenDoc) : doc.expandedStates
  10417. });
  10418. } else if (doc.contents) {
  10419. return Object.assign({}, doc, {
  10420. contents: flattenDoc(doc.contents)
  10421. });
  10422. }
  10423. return doc;
  10424. }
  10425. function printDoc(doc) {
  10426. if (typeof doc === "string") {
  10427. return JSON.stringify(doc);
  10428. }
  10429. if (doc.type === "line") {
  10430. if (doc.literal) {
  10431. return "literalline";
  10432. }
  10433. if (doc.hard) {
  10434. return "hardline";
  10435. }
  10436. if (doc.soft) {
  10437. return "softline";
  10438. }
  10439. return "line";
  10440. }
  10441. if (doc.type === "break-parent") {
  10442. return "breakParent";
  10443. }
  10444. if (doc.type === "trim") {
  10445. return "trim";
  10446. }
  10447. if (doc.type === "concat") {
  10448. return "[" + doc.parts.map(printDoc).join(", ") + "]";
  10449. }
  10450. if (doc.type === "indent") {
  10451. return "indent(" + printDoc(doc.contents) + ")";
  10452. }
  10453. if (doc.type === "align") {
  10454. return doc.n === -Infinity ? "dedentToRoot(" + printDoc(doc.contents) + ")" : doc.n < 0 ? "dedent(" + printDoc(doc.contents) + ")" : doc.n.type === "root" ? "markAsRoot(" + printDoc(doc.contents) + ")" : "align(" + JSON.stringify(doc.n) + ", " + printDoc(doc.contents) + ")";
  10455. }
  10456. if (doc.type === "if-break") {
  10457. return "ifBreak(" + printDoc(doc.breakContents) + (doc.flatContents ? ", " + printDoc(doc.flatContents) : "") + ")";
  10458. }
  10459. if (doc.type === "group") {
  10460. if (doc.expandedStates) {
  10461. return "conditionalGroup(" + "[" + doc.expandedStates.map(printDoc).join(",") + "])";
  10462. }
  10463. return (doc.break ? "wrappedGroup" : "group") + "(" + printDoc(doc.contents) + ")";
  10464. }
  10465. if (doc.type === "fill") {
  10466. return "fill" + "(" + doc.parts.map(printDoc).join(", ") + ")";
  10467. }
  10468. if (doc.type === "line-suffix") {
  10469. return "lineSuffix(" + printDoc(doc.contents) + ")";
  10470. }
  10471. if (doc.type === "line-suffix-boundary") {
  10472. return "lineSuffixBoundary";
  10473. }
  10474. throw new Error("Unknown doc type " + doc.type);
  10475. }
  10476. var docDebug = {
  10477. printDocToDebug: function printDocToDebug(doc) {
  10478. return printDoc(flattenDoc(doc));
  10479. }
  10480. };
  10481. var doc = {
  10482. builders: docBuilders,
  10483. printer: docPrinter,
  10484. utils: docUtils,
  10485. debug: docDebug
  10486. };
  10487. var mapDoc$2 = doc.utils.mapDoc;
  10488. function isNextLineEmpty$1(text, node, options) {
  10489. return util$1.isNextLineEmpty(text, node, options.locEnd);
  10490. }
  10491. function isPreviousLineEmpty$2(text, node, options) {
  10492. return util$1.isPreviousLineEmpty(text, node, options.locStart);
  10493. }
  10494. function getNextNonSpaceNonCommentCharacterIndex$1(text, node, options) {
  10495. return util$1.getNextNonSpaceNonCommentCharacterIndex(text, node, options.locEnd);
  10496. }
  10497. var utilShared = {
  10498. getMaxContinuousCount: util$1.getMaxContinuousCount,
  10499. getStringWidth: util$1.getStringWidth,
  10500. getAlignmentSize: util$1.getAlignmentSize,
  10501. getIndentSize: util$1.getIndentSize,
  10502. skip: util$1.skip,
  10503. skipWhitespace: util$1.skipWhitespace,
  10504. skipSpaces: util$1.skipSpaces,
  10505. skipNewline: util$1.skipNewline,
  10506. skipToLineEnd: util$1.skipToLineEnd,
  10507. skipEverythingButNewLine: util$1.skipEverythingButNewLine,
  10508. skipInlineComment: util$1.skipInlineComment,
  10509. skipTrailingComment: util$1.skipTrailingComment,
  10510. hasNewline: util$1.hasNewline,
  10511. hasNewlineInRange: util$1.hasNewlineInRange,
  10512. hasSpaces: util$1.hasSpaces,
  10513. isNextLineEmpty: isNextLineEmpty$1,
  10514. isNextLineEmptyAfterIndex: util$1.isNextLineEmptyAfterIndex,
  10515. isPreviousLineEmpty: isPreviousLineEmpty$2,
  10516. getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex$1,
  10517. mapDoc: mapDoc$2,
  10518. // TODO: remove in 2.0, we already exposed it in docUtils
  10519. makeString: util$1.makeString,
  10520. addLeadingComment: util$1.addLeadingComment,
  10521. addDanglingComment: util$1.addDanglingComment,
  10522. addTrailingComment: util$1.addTrailingComment
  10523. };
  10524. var _require$$0$builders = doc.builders;
  10525. var concat = _require$$0$builders.concat;
  10526. var hardline = _require$$0$builders.hardline;
  10527. var breakParent = _require$$0$builders.breakParent;
  10528. var indent = _require$$0$builders.indent;
  10529. var lineSuffix = _require$$0$builders.lineSuffix;
  10530. var join = _require$$0$builders.join;
  10531. var cursor = _require$$0$builders.cursor;
  10532. var hasNewline = util$1.hasNewline;
  10533. var skipNewline = util$1.skipNewline;
  10534. var isPreviousLineEmpty = util$1.isPreviousLineEmpty;
  10535. var addLeadingComment = utilShared.addLeadingComment;
  10536. var addDanglingComment = utilShared.addDanglingComment;
  10537. var addTrailingComment = utilShared.addTrailingComment;
  10538. var childNodesCacheKey = Symbol("child-nodes");
  10539. function getSortedChildNodes(node, options, resultArray) {
  10540. if (!node) {
  10541. return;
  10542. }
  10543. var printer = options.printer,
  10544. locStart = options.locStart,
  10545. locEnd = options.locEnd;
  10546. if (resultArray) {
  10547. if (node && printer.canAttachComment && printer.canAttachComment(node)) {
  10548. // This reverse insertion sort almost always takes constant
  10549. // time because we almost always (maybe always?) append the
  10550. // nodes in order anyway.
  10551. var i;
  10552. for (i = resultArray.length - 1; i >= 0; --i) {
  10553. if (locStart(resultArray[i]) <= locStart(node) && locEnd(resultArray[i]) <= locEnd(node)) {
  10554. break;
  10555. }
  10556. }
  10557. resultArray.splice(i + 1, 0, node);
  10558. return;
  10559. }
  10560. } else if (node[childNodesCacheKey]) {
  10561. return node[childNodesCacheKey];
  10562. }
  10563. var childNodes;
  10564. if (printer.getCommentChildNodes) {
  10565. childNodes = printer.getCommentChildNodes(node);
  10566. } else if (node && typeof node === "object") {
  10567. childNodes = Object.keys(node).filter(function (n) {
  10568. return n !== "enclosingNode" && n !== "precedingNode" && n !== "followingNode";
  10569. }).map(function (n) {
  10570. return node[n];
  10571. });
  10572. }
  10573. if (!childNodes) {
  10574. return;
  10575. }
  10576. if (!resultArray) {
  10577. Object.defineProperty(node, childNodesCacheKey, {
  10578. value: resultArray = [],
  10579. enumerable: false
  10580. });
  10581. }
  10582. childNodes.forEach(function (childNode) {
  10583. getSortedChildNodes(childNode, options, resultArray);
  10584. });
  10585. return resultArray;
  10586. } // As efficiently as possible, decorate the comment object with
  10587. // .precedingNode, .enclosingNode, and/or .followingNode properties, at
  10588. // least one of which is guaranteed to be defined.
  10589. function decorateComment(node, comment, options) {
  10590. var locStart = options.locStart,
  10591. locEnd = options.locEnd;
  10592. var childNodes = getSortedChildNodes(node, options);
  10593. var precedingNode;
  10594. var followingNode; // Time to dust off the old binary search robes and wizard hat.
  10595. var left = 0;
  10596. var right = childNodes.length;
  10597. while (left < right) {
  10598. var middle = left + right >> 1;
  10599. var child = childNodes[middle];
  10600. if (locStart(child) - locStart(comment) <= 0 && locEnd(comment) - locEnd(child) <= 0) {
  10601. // The comment is completely contained by this child node.
  10602. comment.enclosingNode = child;
  10603. decorateComment(child, comment, options);
  10604. return; // Abandon the binary search at this level.
  10605. }
  10606. if (locEnd(child) - locStart(comment) <= 0) {
  10607. // This child node falls completely before the comment.
  10608. // Because we will never consider this node or any nodes
  10609. // before it again, this node must be the closest preceding
  10610. // node we have encountered so far.
  10611. precedingNode = child;
  10612. left = middle + 1;
  10613. continue;
  10614. }
  10615. if (locEnd(comment) - locStart(child) <= 0) {
  10616. // This child node falls completely after the comment.
  10617. // Because we will never consider this node or any nodes after
  10618. // it again, this node must be the closest following node we
  10619. // have encountered so far.
  10620. followingNode = child;
  10621. right = middle;
  10622. continue;
  10623. }
  10624. /* istanbul ignore next */
  10625. throw new Error("Comment location overlaps with node location");
  10626. } // We don't want comments inside of different expressions inside of the same
  10627. // template literal to move to another expression.
  10628. if (comment.enclosingNode && comment.enclosingNode.type === "TemplateLiteral") {
  10629. var quasis = comment.enclosingNode.quasis;
  10630. var commentIndex = findExpressionIndexForComment(quasis, comment, options);
  10631. if (precedingNode && findExpressionIndexForComment(quasis, precedingNode, options) !== commentIndex) {
  10632. precedingNode = null;
  10633. }
  10634. if (followingNode && findExpressionIndexForComment(quasis, followingNode, options) !== commentIndex) {
  10635. followingNode = null;
  10636. }
  10637. }
  10638. if (precedingNode) {
  10639. comment.precedingNode = precedingNode;
  10640. }
  10641. if (followingNode) {
  10642. comment.followingNode = followingNode;
  10643. }
  10644. }
  10645. function attach(comments, ast, text, options) {
  10646. if (!Array.isArray(comments)) {
  10647. return;
  10648. }
  10649. var tiesToBreak = [];
  10650. var locStart = options.locStart,
  10651. locEnd = options.locEnd;
  10652. comments.forEach(function (comment, i) {
  10653. if (options.parser === "json" || options.parser === "json5" || options.parser === "__js_expression" || options.parser === "__vue_expression") {
  10654. if (locStart(comment) - locStart(ast) <= 0) {
  10655. addLeadingComment(ast, comment);
  10656. return;
  10657. }
  10658. if (locEnd(comment) - locEnd(ast) >= 0) {
  10659. addTrailingComment(ast, comment);
  10660. return;
  10661. }
  10662. }
  10663. decorateComment(ast, comment, options);
  10664. var precedingNode = comment.precedingNode,
  10665. enclosingNode = comment.enclosingNode,
  10666. followingNode = comment.followingNode;
  10667. var pluginHandleOwnLineComment = options.printer.handleComments && options.printer.handleComments.ownLine ? options.printer.handleComments.ownLine : function () {
  10668. return false;
  10669. };
  10670. var pluginHandleEndOfLineComment = options.printer.handleComments && options.printer.handleComments.endOfLine ? options.printer.handleComments.endOfLine : function () {
  10671. return false;
  10672. };
  10673. var pluginHandleRemainingComment = options.printer.handleComments && options.printer.handleComments.remaining ? options.printer.handleComments.remaining : function () {
  10674. return false;
  10675. };
  10676. var isLastComment = comments.length - 1 === i;
  10677. if (hasNewline(text, locStart(comment), {
  10678. backwards: true
  10679. })) {
  10680. // If a comment exists on its own line, prefer a leading comment.
  10681. // We also need to check if it's the first line of the file.
  10682. if (pluginHandleOwnLineComment(comment, text, options, ast, isLastComment)) {// We're good
  10683. } else if (followingNode) {
  10684. // Always a leading comment.
  10685. addLeadingComment(followingNode, comment);
  10686. } else if (precedingNode) {
  10687. addTrailingComment(precedingNode, comment);
  10688. } else if (enclosingNode) {
  10689. addDanglingComment(enclosingNode, comment);
  10690. } else {
  10691. // There are no nodes, let's attach it to the root of the ast
  10692. /* istanbul ignore next */
  10693. addDanglingComment(ast, comment);
  10694. }
  10695. } else if (hasNewline(text, locEnd(comment))) {
  10696. if (pluginHandleEndOfLineComment(comment, text, options, ast, isLastComment)) {// We're good
  10697. } else if (precedingNode) {
  10698. // There is content before this comment on the same line, but
  10699. // none after it, so prefer a trailing comment of the previous node.
  10700. addTrailingComment(precedingNode, comment);
  10701. } else if (followingNode) {
  10702. addLeadingComment(followingNode, comment);
  10703. } else if (enclosingNode) {
  10704. addDanglingComment(enclosingNode, comment);
  10705. } else {
  10706. // There are no nodes, let's attach it to the root of the ast
  10707. /* istanbul ignore next */
  10708. addDanglingComment(ast, comment);
  10709. }
  10710. } else {
  10711. if (pluginHandleRemainingComment(comment, text, options, ast, isLastComment)) {// We're good
  10712. } else if (precedingNode && followingNode) {
  10713. // Otherwise, text exists both before and after the comment on
  10714. // the same line. If there is both a preceding and following
  10715. // node, use a tie-breaking algorithm to determine if it should
  10716. // be attached to the next or previous node. In the last case,
  10717. // simply attach the right node;
  10718. var tieCount = tiesToBreak.length;
  10719. if (tieCount > 0) {
  10720. var lastTie = tiesToBreak[tieCount - 1];
  10721. if (lastTie.followingNode !== comment.followingNode) {
  10722. breakTies(tiesToBreak, text, options);
  10723. }
  10724. }
  10725. tiesToBreak.push(comment);
  10726. } else if (precedingNode) {
  10727. addTrailingComment(precedingNode, comment);
  10728. } else if (followingNode) {
  10729. addLeadingComment(followingNode, comment);
  10730. } else if (enclosingNode) {
  10731. addDanglingComment(enclosingNode, comment);
  10732. } else {
  10733. // There are no nodes, let's attach it to the root of the ast
  10734. /* istanbul ignore next */
  10735. addDanglingComment(ast, comment);
  10736. }
  10737. }
  10738. });
  10739. breakTies(tiesToBreak, text, options);
  10740. comments.forEach(function (comment) {
  10741. // These node references were useful for breaking ties, but we
  10742. // don't need them anymore, and they create cycles in the AST that
  10743. // may lead to infinite recursion if we don't delete them here.
  10744. delete comment.precedingNode;
  10745. delete comment.enclosingNode;
  10746. delete comment.followingNode;
  10747. });
  10748. }
  10749. function breakTies(tiesToBreak, text, options) {
  10750. var tieCount = tiesToBreak.length;
  10751. if (tieCount === 0) {
  10752. return;
  10753. }
  10754. var _tiesToBreak$ = tiesToBreak[0],
  10755. precedingNode = _tiesToBreak$.precedingNode,
  10756. followingNode = _tiesToBreak$.followingNode;
  10757. var gapEndPos = options.locStart(followingNode); // Iterate backwards through tiesToBreak, examining the gaps
  10758. // between the tied comments. In order to qualify as leading, a
  10759. // comment must be separated from followingNode by an unbroken series of
  10760. // gaps (or other comments). Gaps should only contain whitespace or open
  10761. // parentheses.
  10762. var indexOfFirstLeadingComment;
  10763. for (indexOfFirstLeadingComment = tieCount; indexOfFirstLeadingComment > 0; --indexOfFirstLeadingComment) {
  10764. var comment = tiesToBreak[indexOfFirstLeadingComment - 1];
  10765. assert.strictEqual(comment.precedingNode, precedingNode);
  10766. assert.strictEqual(comment.followingNode, followingNode);
  10767. var gap = text.slice(options.locEnd(comment), gapEndPos).trim();
  10768. if (gap === "" || /^\(+$/.test(gap)) {
  10769. gapEndPos = options.locStart(comment);
  10770. } else {
  10771. // The gap string contained something other than whitespace or open
  10772. // parentheses.
  10773. break;
  10774. }
  10775. }
  10776. tiesToBreak.forEach(function (comment, i) {
  10777. if (i < indexOfFirstLeadingComment) {
  10778. addTrailingComment(precedingNode, comment);
  10779. } else {
  10780. addLeadingComment(followingNode, comment);
  10781. }
  10782. });
  10783. tiesToBreak.length = 0;
  10784. }
  10785. function printComment(commentPath, options) {
  10786. var comment = commentPath.getValue();
  10787. comment.printed = true;
  10788. return options.printer.printComment(commentPath, options);
  10789. }
  10790. function findExpressionIndexForComment(quasis, comment, options) {
  10791. var startPos = options.locStart(comment) - 1;
  10792. for (var i = 1; i < quasis.length; ++i) {
  10793. if (startPos < getQuasiRange(quasis[i]).start) {
  10794. return i - 1;
  10795. }
  10796. } // We haven't found it, it probably means that some of the locations are off.
  10797. // Let's just return the first one.
  10798. /* istanbul ignore next */
  10799. return 0;
  10800. }
  10801. function getQuasiRange(expr) {
  10802. if (expr.start !== undefined) {
  10803. // Babel
  10804. return {
  10805. start: expr.start,
  10806. end: expr.end
  10807. };
  10808. } // Flow
  10809. return {
  10810. start: expr.range[0],
  10811. end: expr.range[1]
  10812. };
  10813. }
  10814. function printLeadingComment(commentPath, print, options) {
  10815. var comment = commentPath.getValue();
  10816. var contents = printComment(commentPath, options);
  10817. if (!contents) {
  10818. return "";
  10819. }
  10820. var isBlock = options.printer.isBlockComment && options.printer.isBlockComment(comment); // Leading block comments should see if they need to stay on the
  10821. // same line or not.
  10822. if (isBlock) {
  10823. return concat([contents, hasNewline(options.originalText, options.locEnd(comment)) ? hardline : " "]);
  10824. }
  10825. return concat([contents, hardline]);
  10826. }
  10827. function printTrailingComment(commentPath, print, options) {
  10828. var comment = commentPath.getValue();
  10829. var contents = printComment(commentPath, options);
  10830. if (!contents) {
  10831. return "";
  10832. }
  10833. var isBlock = options.printer.isBlockComment && options.printer.isBlockComment(comment); // We don't want the line to break
  10834. // when the parentParentNode is a ClassDeclaration/-Expression
  10835. // And the parentNode is in the superClass property
  10836. var parentNode = commentPath.getNode(1);
  10837. var parentParentNode = commentPath.getNode(2);
  10838. var isParentSuperClass = parentParentNode && (parentParentNode.type === "ClassDeclaration" || parentParentNode.type === "ClassExpression") && parentParentNode.superClass === parentNode;
  10839. if (hasNewline(options.originalText, options.locStart(comment), {
  10840. backwards: true
  10841. })) {
  10842. // This allows comments at the end of nested structures:
  10843. // {
  10844. // x: 1,
  10845. // y: 2
  10846. // // A comment
  10847. // }
  10848. // Those kinds of comments are almost always leading comments, but
  10849. // here it doesn't go "outside" the block and turns it into a
  10850. // trailing comment for `2`. We can simulate the above by checking
  10851. // if this a comment on its own line; normal trailing comments are
  10852. // always at the end of another expression.
  10853. var isLineBeforeEmpty = isPreviousLineEmpty(options.originalText, comment, options.locStart);
  10854. return lineSuffix(concat([hardline, isLineBeforeEmpty ? hardline : "", contents]));
  10855. } else if (isBlock || isParentSuperClass) {
  10856. // Trailing block comments never need a newline
  10857. return concat([" ", contents]);
  10858. }
  10859. return concat([lineSuffix(" " + contents), !isBlock ? breakParent : ""]);
  10860. }
  10861. function printDanglingComments(path$$1, options, sameIndent, filter) {
  10862. var parts = [];
  10863. var node = path$$1.getValue();
  10864. if (!node || !node.comments) {
  10865. return "";
  10866. }
  10867. path$$1.each(function (commentPath) {
  10868. var comment = commentPath.getValue();
  10869. if (comment && !comment.leading && !comment.trailing && (!filter || filter(comment))) {
  10870. parts.push(printComment(commentPath, options));
  10871. }
  10872. }, "comments");
  10873. if (parts.length === 0) {
  10874. return "";
  10875. }
  10876. if (sameIndent) {
  10877. return join(hardline, parts);
  10878. }
  10879. return indent(concat([hardline, join(hardline, parts)]));
  10880. }
  10881. function prependCursorPlaceholder(path$$1, options, printed) {
  10882. if (path$$1.getNode() === options.cursorNode && path$$1.getValue()) {
  10883. return concat([cursor, printed, cursor]);
  10884. }
  10885. return printed;
  10886. }
  10887. function printComments(path$$1, print, options, needsSemi) {
  10888. var value = path$$1.getValue();
  10889. var printed = print(path$$1);
  10890. var comments = value && value.comments;
  10891. if (!comments || comments.length === 0) {
  10892. return prependCursorPlaceholder(path$$1, options, printed);
  10893. }
  10894. var leadingParts = [];
  10895. var trailingParts = [needsSemi ? ";" : "", printed];
  10896. path$$1.each(function (commentPath) {
  10897. var comment = commentPath.getValue();
  10898. var leading = comment.leading,
  10899. trailing = comment.trailing;
  10900. if (leading) {
  10901. var contents = printLeadingComment(commentPath, print, options);
  10902. if (!contents) {
  10903. return;
  10904. }
  10905. leadingParts.push(contents);
  10906. var text = options.originalText;
  10907. if (hasNewline(text, skipNewline(text, options.locEnd(comment)))) {
  10908. leadingParts.push(hardline);
  10909. }
  10910. } else if (trailing) {
  10911. trailingParts.push(printTrailingComment(commentPath, print, options));
  10912. }
  10913. }, "comments");
  10914. return prependCursorPlaceholder(path$$1, options, concat(leadingParts.concat(trailingParts)));
  10915. }
  10916. var comments = {
  10917. attach,
  10918. printComments,
  10919. printDanglingComments,
  10920. getSortedChildNodes
  10921. };
  10922. function FastPath(value) {
  10923. assert.ok(this instanceof FastPath);
  10924. this.stack = [value];
  10925. } // The name of the current property is always the penultimate element of
  10926. // this.stack, and always a String.
  10927. FastPath.prototype.getName = function getName() {
  10928. var s = this.stack;
  10929. var len = s.length;
  10930. if (len > 1) {
  10931. return s[len - 2];
  10932. } // Since the name is always a string, null is a safe sentinel value to
  10933. // return if we do not know the name of the (root) value.
  10934. /* istanbul ignore next */
  10935. return null;
  10936. }; // The value of the current property is always the final element of
  10937. // this.stack.
  10938. FastPath.prototype.getValue = function getValue() {
  10939. var s = this.stack;
  10940. return s[s.length - 1];
  10941. };
  10942. function getNodeHelper(path$$1, count) {
  10943. var stackIndex = getNodeStackIndexHelper(path$$1.stack, count);
  10944. return stackIndex === -1 ? null : path$$1.stack[stackIndex];
  10945. }
  10946. function getNodeStackIndexHelper(stack, count) {
  10947. for (var i = stack.length - 1; i >= 0; i -= 2) {
  10948. var value = stack[i];
  10949. if (value && !Array.isArray(value) && --count < 0) {
  10950. return i;
  10951. }
  10952. }
  10953. return -1;
  10954. }
  10955. FastPath.prototype.getNode = function getNode(count) {
  10956. return getNodeHelper(this, ~~count);
  10957. };
  10958. FastPath.prototype.getParentNode = function getParentNode(count) {
  10959. return getNodeHelper(this, ~~count + 1);
  10960. }; // Temporarily push properties named by string arguments given after the
  10961. // callback function onto this.stack, then call the callback with a
  10962. // reference to this (modified) FastPath object. Note that the stack will
  10963. // be restored to its original state after the callback is finished, so it
  10964. // is probably a mistake to retain a reference to the path.
  10965. FastPath.prototype.call = function call(callback
  10966. /*, name1, name2, ... */
  10967. ) {
  10968. var s = this.stack;
  10969. var origLen = s.length;
  10970. var value = s[origLen - 1];
  10971. var argc = arguments.length;
  10972. for (var i = 1; i < argc; ++i) {
  10973. var name = arguments[i];
  10974. value = value[name];
  10975. s.push(name, value);
  10976. }
  10977. var result = callback(this);
  10978. s.length = origLen;
  10979. return result;
  10980. };
  10981. FastPath.prototype.callParent = function callParent(callback, count) {
  10982. var stackIndex = getNodeStackIndexHelper(this.stack, ~~count + 1);
  10983. var parentValues = this.stack.splice(stackIndex + 1);
  10984. var result = callback(this);
  10985. Array.prototype.push.apply(this.stack, parentValues);
  10986. return result;
  10987. }; // Similar to FastPath.prototype.call, except that the value obtained by
  10988. // accessing this.getValue()[name1][name2]... should be array-like. The
  10989. // callback will be called with a reference to this path object for each
  10990. // element of the array.
  10991. FastPath.prototype.each = function each(callback
  10992. /*, name1, name2, ... */
  10993. ) {
  10994. var s = this.stack;
  10995. var origLen = s.length;
  10996. var value = s[origLen - 1];
  10997. var argc = arguments.length;
  10998. for (var i = 1; i < argc; ++i) {
  10999. var name = arguments[i];
  11000. value = value[name];
  11001. s.push(name, value);
  11002. }
  11003. for (var _i = 0; _i < value.length; ++_i) {
  11004. if (_i in value) {
  11005. s.push(_i, value[_i]); // If the callback needs to know the value of i, call
  11006. // path.getName(), assuming path is the parameter name.
  11007. callback(this);
  11008. s.length -= 2;
  11009. }
  11010. }
  11011. s.length = origLen;
  11012. }; // Similar to FastPath.prototype.each, except that the results of the
  11013. // callback function invocations are stored in an array and returned at
  11014. // the end of the iteration.
  11015. FastPath.prototype.map = function map(callback
  11016. /*, name1, name2, ... */
  11017. ) {
  11018. var s = this.stack;
  11019. var origLen = s.length;
  11020. var value = s[origLen - 1];
  11021. var argc = arguments.length;
  11022. for (var i = 1; i < argc; ++i) {
  11023. var name = arguments[i];
  11024. value = value[name];
  11025. s.push(name, value);
  11026. }
  11027. var result = new Array(value.length);
  11028. for (var _i2 = 0; _i2 < value.length; ++_i2) {
  11029. if (_i2 in value) {
  11030. s.push(_i2, value[_i2]);
  11031. result[_i2] = callback(this, _i2);
  11032. s.length -= 2;
  11033. }
  11034. }
  11035. s.length = origLen;
  11036. return result;
  11037. };
  11038. var fastPath = FastPath;
  11039. var normalize$3 = options.normalize;
  11040. function printSubtree(path$$1, print, options$$1, printAstToDoc) {
  11041. if (options$$1.printer.embed) {
  11042. return options$$1.printer.embed(path$$1, print, function (text, partialNextOptions) {
  11043. return textToDoc(text, partialNextOptions, options$$1, printAstToDoc);
  11044. }, options$$1);
  11045. }
  11046. }
  11047. function textToDoc(text, partialNextOptions, parentOptions, printAstToDoc) {
  11048. var nextOptions = normalize$3(Object.assign({}, parentOptions, partialNextOptions, {
  11049. parentParser: parentOptions.parser,
  11050. originalText: text
  11051. }), {
  11052. passThrough: true
  11053. });
  11054. var result = parser.parse(text, nextOptions);
  11055. var ast = result.ast;
  11056. text = result.text;
  11057. var astComments = ast.comments;
  11058. delete ast.comments;
  11059. comments.attach(astComments, ast, text, nextOptions);
  11060. return printAstToDoc(ast, nextOptions);
  11061. }
  11062. var multiparser = {
  11063. printSubtree
  11064. };
  11065. var doc$2 = doc;
  11066. var docBuilders$2 = doc$2.builders;
  11067. var concat$3 = docBuilders$2.concat;
  11068. var hardline$2 = docBuilders$2.hardline;
  11069. var addAlignmentToDoc$1 = docBuilders$2.addAlignmentToDoc;
  11070. var docUtils$2 = doc$2.utils;
  11071. /**
  11072. * Takes an abstract syntax tree (AST) and recursively converts it to a
  11073. * document (series of printing primitives).
  11074. *
  11075. * This is done by descending down the AST recursively. The recursion
  11076. * involves two functions that call each other:
  11077. *
  11078. * 1. printGenerically(), which is defined as an inner function here.
  11079. * It basically takes care of node caching.
  11080. * 2. callPluginPrintFunction(), which checks for some options, and
  11081. * ultimately calls the print() function provided by the plugin.
  11082. *
  11083. * The plugin function will call printGenerically() again for child nodes
  11084. * of the current node, which will do its housekeeping, then call the
  11085. * plugin function again, and so on.
  11086. *
  11087. * All the while, these functions pass a "path" variable around, which
  11088. * is a stack-like data structure (FastPath) that maintains the current
  11089. * state of the recursion. It is called "path", because it represents
  11090. * the path to the current node through the Abstract Syntax Tree.
  11091. */
  11092. function printAstToDoc(ast, options) {
  11093. var alignmentSize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  11094. var printer = options.printer;
  11095. if (printer.preprocess) {
  11096. ast = printer.preprocess(ast, options);
  11097. }
  11098. var cache = new Map();
  11099. function printGenerically(path$$1, args) {
  11100. var node = path$$1.getValue();
  11101. var shouldCache = node && typeof node === "object" && args === undefined;
  11102. if (shouldCache && cache.has(node)) {
  11103. return cache.get(node);
  11104. } // We let JSXElement print its comments itself because it adds () around
  11105. // UnionTypeAnnotation has to align the child without the comments
  11106. var res;
  11107. if (printer.willPrintOwnComments && printer.willPrintOwnComments(path$$1)) {
  11108. res = callPluginPrintFunction(path$$1, options, printGenerically, args);
  11109. } else {
  11110. // printComments will call the plugin print function and check for
  11111. // comments to print
  11112. res = comments.printComments(path$$1, function (p) {
  11113. return callPluginPrintFunction(p, options, printGenerically, args);
  11114. }, options, args && args.needsSemi);
  11115. }
  11116. if (shouldCache) {
  11117. cache.set(node, res);
  11118. }
  11119. return res;
  11120. }
  11121. var doc$$2 = printGenerically(new fastPath(ast));
  11122. if (alignmentSize > 0) {
  11123. // Add a hardline to make the indents take effect
  11124. // It should be removed in index.js format()
  11125. doc$$2 = addAlignmentToDoc$1(concat$3([hardline$2, doc$$2]), alignmentSize, options.tabWidth);
  11126. }
  11127. docUtils$2.propagateBreaks(doc$$2);
  11128. return doc$$2;
  11129. }
  11130. function callPluginPrintFunction(path$$1, options, printPath, args) {
  11131. assert.ok(path$$1 instanceof fastPath);
  11132. var node = path$$1.getValue();
  11133. var printer = options.printer; // Escape hatch
  11134. if (printer.hasPrettierIgnore && printer.hasPrettierIgnore(path$$1)) {
  11135. return options.originalText.slice(options.locStart(node), options.locEnd(node));
  11136. }
  11137. if (node) {
  11138. try {
  11139. // Potentially switch to a different parser
  11140. var sub = multiparser.printSubtree(path$$1, printPath, options, printAstToDoc);
  11141. if (sub) {
  11142. return sub;
  11143. }
  11144. } catch (error) {
  11145. /* istanbul ignore if */
  11146. if (process.env.PRETTIER_DEBUG) {
  11147. throw error;
  11148. } // Continue with current parser
  11149. }
  11150. }
  11151. return printer.print(path$$1, options, printPath, args);
  11152. }
  11153. var astToDoc = printAstToDoc;
  11154. function findSiblingAncestors(startNodeAndParents, endNodeAndParents, opts) {
  11155. var resultStartNode = startNodeAndParents.node;
  11156. var resultEndNode = endNodeAndParents.node;
  11157. if (resultStartNode === resultEndNode) {
  11158. return {
  11159. startNode: resultStartNode,
  11160. endNode: resultEndNode
  11161. };
  11162. }
  11163. var _iteratorNormalCompletion = true;
  11164. var _didIteratorError = false;
  11165. var _iteratorError = undefined;
  11166. try {
  11167. for (var _iterator = endNodeAndParents.parentNodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  11168. var endParent = _step.value;
  11169. if (endParent.type !== "Program" && endParent.type !== "File" && opts.locStart(endParent) >= opts.locStart(startNodeAndParents.node)) {
  11170. resultEndNode = endParent;
  11171. } else {
  11172. break;
  11173. }
  11174. }
  11175. } catch (err) {
  11176. _didIteratorError = true;
  11177. _iteratorError = err;
  11178. } finally {
  11179. try {
  11180. if (!_iteratorNormalCompletion && _iterator.return != null) {
  11181. _iterator.return();
  11182. }
  11183. } finally {
  11184. if (_didIteratorError) {
  11185. throw _iteratorError;
  11186. }
  11187. }
  11188. }
  11189. var _iteratorNormalCompletion2 = true;
  11190. var _didIteratorError2 = false;
  11191. var _iteratorError2 = undefined;
  11192. try {
  11193. for (var _iterator2 = startNodeAndParents.parentNodes[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  11194. var startParent = _step2.value;
  11195. if (startParent.type !== "Program" && startParent.type !== "File" && opts.locEnd(startParent) <= opts.locEnd(endNodeAndParents.node)) {
  11196. resultStartNode = startParent;
  11197. } else {
  11198. break;
  11199. }
  11200. }
  11201. } catch (err) {
  11202. _didIteratorError2 = true;
  11203. _iteratorError2 = err;
  11204. } finally {
  11205. try {
  11206. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  11207. _iterator2.return();
  11208. }
  11209. } finally {
  11210. if (_didIteratorError2) {
  11211. throw _iteratorError2;
  11212. }
  11213. }
  11214. }
  11215. return {
  11216. startNode: resultStartNode,
  11217. endNode: resultEndNode
  11218. };
  11219. }
  11220. function findNodeAtOffset(node, offset, options, predicate, parentNodes) {
  11221. predicate = predicate || function () {
  11222. return true;
  11223. };
  11224. parentNodes = parentNodes || [];
  11225. var start = options.locStart(node, options.locStart);
  11226. var end = options.locEnd(node, options.locEnd);
  11227. if (start <= offset && offset <= end) {
  11228. var _iteratorNormalCompletion3 = true;
  11229. var _didIteratorError3 = false;
  11230. var _iteratorError3 = undefined;
  11231. try {
  11232. for (var _iterator3 = comments.getSortedChildNodes(node, options)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  11233. var childNode = _step3.value;
  11234. var childResult = findNodeAtOffset(childNode, offset, options, predicate, [node].concat(parentNodes));
  11235. if (childResult) {
  11236. return childResult;
  11237. }
  11238. }
  11239. } catch (err) {
  11240. _didIteratorError3 = true;
  11241. _iteratorError3 = err;
  11242. } finally {
  11243. try {
  11244. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  11245. _iterator3.return();
  11246. }
  11247. } finally {
  11248. if (_didIteratorError3) {
  11249. throw _iteratorError3;
  11250. }
  11251. }
  11252. }
  11253. if (predicate(node)) {
  11254. return {
  11255. node: node,
  11256. parentNodes: parentNodes
  11257. };
  11258. }
  11259. }
  11260. } // See https://www.ecma-international.org/ecma-262/5.1/#sec-A.5
  11261. function isSourceElement(opts, node) {
  11262. if (node == null) {
  11263. return false;
  11264. } // JS and JS like to avoid repetitions
  11265. var jsSourceElements = ["FunctionDeclaration", "BlockStatement", "BreakStatement", "ContinueStatement", "DebuggerStatement", "DoWhileStatement", "EmptyStatement", "ExpressionStatement", "ForInStatement", "ForStatement", "IfStatement", "LabeledStatement", "ReturnStatement", "SwitchStatement", "ThrowStatement", "TryStatement", "VariableDeclaration", "WhileStatement", "WithStatement", "ClassDeclaration", // ES 2015
  11266. "ImportDeclaration", // Module
  11267. "ExportDefaultDeclaration", // Module
  11268. "ExportNamedDeclaration", // Module
  11269. "ExportAllDeclaration", // Module
  11270. "TypeAlias", // Flow
  11271. "InterfaceDeclaration", // Flow, TypeScript
  11272. "TypeAliasDeclaration", // TypeScript
  11273. "ExportAssignment", // TypeScript
  11274. "ExportDeclaration" // TypeScript
  11275. ];
  11276. var jsonSourceElements = ["ObjectExpression", "ArrayExpression", "StringLiteral", "NumericLiteral", "BooleanLiteral", "NullLiteral"];
  11277. var graphqlSourceElements = ["OperationDefinition", "FragmentDefinition", "VariableDefinition", "TypeExtensionDefinition", "ObjectTypeDefinition", "FieldDefinition", "DirectiveDefinition", "EnumTypeDefinition", "EnumValueDefinition", "InputValueDefinition", "InputObjectTypeDefinition", "SchemaDefinition", "OperationTypeDefinition", "InterfaceTypeDefinition", "UnionTypeDefinition", "ScalarTypeDefinition"];
  11278. switch (opts.parser) {
  11279. case "flow":
  11280. case "babel":
  11281. case "typescript":
  11282. return jsSourceElements.indexOf(node.type) > -1;
  11283. case "json":
  11284. return jsonSourceElements.indexOf(node.type) > -1;
  11285. case "graphql":
  11286. return graphqlSourceElements.indexOf(node.kind) > -1;
  11287. case "vue":
  11288. return node.tag !== "root";
  11289. }
  11290. return false;
  11291. }
  11292. function calculateRange(text, opts, ast) {
  11293. // Contract the range so that it has non-whitespace characters at its endpoints.
  11294. // This ensures we can format a range that doesn't end on a node.
  11295. var rangeStringOrig = text.slice(opts.rangeStart, opts.rangeEnd);
  11296. var startNonWhitespace = Math.max(opts.rangeStart + rangeStringOrig.search(/\S/), opts.rangeStart);
  11297. var endNonWhitespace;
  11298. for (endNonWhitespace = opts.rangeEnd; endNonWhitespace > opts.rangeStart; --endNonWhitespace) {
  11299. if (text[endNonWhitespace - 1].match(/\S/)) {
  11300. break;
  11301. }
  11302. }
  11303. var startNodeAndParents = findNodeAtOffset(ast, startNonWhitespace, opts, function (node) {
  11304. return isSourceElement(opts, node);
  11305. });
  11306. var endNodeAndParents = findNodeAtOffset(ast, endNonWhitespace, opts, function (node) {
  11307. return isSourceElement(opts, node);
  11308. });
  11309. if (!startNodeAndParents || !endNodeAndParents) {
  11310. return {
  11311. rangeStart: 0,
  11312. rangeEnd: 0
  11313. };
  11314. }
  11315. var siblingAncestors = findSiblingAncestors(startNodeAndParents, endNodeAndParents, opts);
  11316. var startNode = siblingAncestors.startNode,
  11317. endNode = siblingAncestors.endNode;
  11318. var rangeStart = Math.min(opts.locStart(startNode, opts.locStart), opts.locStart(endNode, opts.locStart));
  11319. var rangeEnd = Math.max(opts.locEnd(startNode, opts.locEnd), opts.locEnd(endNode, opts.locEnd));
  11320. return {
  11321. rangeStart: rangeStart,
  11322. rangeEnd: rangeEnd
  11323. };
  11324. }
  11325. var rangeUtil = {
  11326. calculateRange,
  11327. findNodeAtOffset
  11328. };
  11329. var normalizeOptions = options.normalize;
  11330. var guessEndOfLine = endOfLine.guessEndOfLine;
  11331. var convertEndOfLineToChars = endOfLine.convertEndOfLineToChars;
  11332. var mapDoc = doc.utils.mapDoc;
  11333. var printDocToString = doc.printer.printDocToString;
  11334. var printDocToDebug = doc.debug.printDocToDebug;
  11335. var UTF8BOM = 0xfeff;
  11336. var CURSOR = Symbol("cursor");
  11337. var PLACEHOLDERS = {
  11338. cursorOffset: "<<<PRETTIER_CURSOR>>>",
  11339. rangeStart: "<<<PRETTIER_RANGE_START>>>",
  11340. rangeEnd: "<<<PRETTIER_RANGE_END>>>"
  11341. };
  11342. function ensureAllCommentsPrinted(astComments) {
  11343. if (!astComments) {
  11344. return;
  11345. }
  11346. for (var i = 0; i < astComments.length; ++i) {
  11347. if (astComments[i].value.trim() === "prettier-ignore") {
  11348. // If there's a prettier-ignore, we're not printing that sub-tree so we
  11349. // don't know if the comments was printed or not.
  11350. return;
  11351. }
  11352. }
  11353. astComments.forEach(function (comment) {
  11354. if (!comment.printed) {
  11355. throw new Error('Comment "' + comment.value.trim() + '" was not printed. Please report this error!');
  11356. }
  11357. delete comment.printed;
  11358. });
  11359. }
  11360. function attachComments(text, ast, opts) {
  11361. var astComments = ast.comments;
  11362. if (astComments) {
  11363. delete ast.comments;
  11364. comments.attach(astComments, ast, text, opts);
  11365. }
  11366. ast.tokens = [];
  11367. opts.originalText = opts.parser === "yaml" ? text : text.trimRight();
  11368. return astComments;
  11369. }
  11370. function coreFormat(text, opts, addAlignmentSize) {
  11371. if (!text || !text.trim().length) {
  11372. return {
  11373. formatted: "",
  11374. cursorOffset: 0
  11375. };
  11376. }
  11377. addAlignmentSize = addAlignmentSize || 0;
  11378. var parsed = parser.parse(text, opts);
  11379. var ast = parsed.ast;
  11380. text = parsed.text;
  11381. if (opts.cursorOffset >= 0) {
  11382. var nodeResult = rangeUtil.findNodeAtOffset(ast, opts.cursorOffset, opts);
  11383. if (nodeResult && nodeResult.node) {
  11384. opts.cursorNode = nodeResult.node;
  11385. }
  11386. }
  11387. var astComments = attachComments(text, ast, opts);
  11388. var doc$$1 = astToDoc(ast, opts, addAlignmentSize);
  11389. var eol = convertEndOfLineToChars(opts.endOfLine);
  11390. var result = printDocToString(opts.endOfLine === "lf" ? doc$$1 : mapDoc(doc$$1, function (currentDoc) {
  11391. return typeof currentDoc === "string" && currentDoc.indexOf("\n") !== -1 ? currentDoc.replace(/\n/g, eol) : currentDoc;
  11392. }), opts);
  11393. ensureAllCommentsPrinted(astComments); // Remove extra leading indentation as well as the added indentation after last newline
  11394. if (addAlignmentSize > 0) {
  11395. var trimmed = result.formatted.trim();
  11396. if (result.cursorNodeStart !== undefined) {
  11397. result.cursorNodeStart -= result.formatted.indexOf(trimmed);
  11398. }
  11399. result.formatted = trimmed + convertEndOfLineToChars(opts.endOfLine);
  11400. }
  11401. if (opts.cursorOffset >= 0) {
  11402. var oldCursorNodeStart;
  11403. var oldCursorNodeText;
  11404. var cursorOffsetRelativeToOldCursorNode;
  11405. var newCursorNodeStart;
  11406. var newCursorNodeText;
  11407. if (opts.cursorNode && result.cursorNodeText) {
  11408. oldCursorNodeStart = opts.locStart(opts.cursorNode);
  11409. oldCursorNodeText = text.slice(oldCursorNodeStart, opts.locEnd(opts.cursorNode));
  11410. cursorOffsetRelativeToOldCursorNode = opts.cursorOffset - oldCursorNodeStart;
  11411. newCursorNodeStart = result.cursorNodeStart;
  11412. newCursorNodeText = result.cursorNodeText;
  11413. } else {
  11414. oldCursorNodeStart = 0;
  11415. oldCursorNodeText = text;
  11416. cursorOffsetRelativeToOldCursorNode = opts.cursorOffset;
  11417. newCursorNodeStart = 0;
  11418. newCursorNodeText = result.formatted;
  11419. }
  11420. if (oldCursorNodeText === newCursorNodeText) {
  11421. return {
  11422. formatted: result.formatted,
  11423. cursorOffset: newCursorNodeStart + cursorOffsetRelativeToOldCursorNode
  11424. };
  11425. } // diff old and new cursor node texts, with a special cursor
  11426. // symbol inserted to find out where it moves to
  11427. var oldCursorNodeCharArray = oldCursorNodeText.split("");
  11428. oldCursorNodeCharArray.splice(cursorOffsetRelativeToOldCursorNode, 0, CURSOR);
  11429. var newCursorNodeCharArray = newCursorNodeText.split("");
  11430. var cursorNodeDiff = lib.diffArrays(oldCursorNodeCharArray, newCursorNodeCharArray);
  11431. var cursorOffset = newCursorNodeStart;
  11432. var _iteratorNormalCompletion = true;
  11433. var _didIteratorError = false;
  11434. var _iteratorError = undefined;
  11435. try {
  11436. for (var _iterator = cursorNodeDiff[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  11437. var entry = _step.value;
  11438. if (entry.removed) {
  11439. if (entry.value.indexOf(CURSOR) > -1) {
  11440. break;
  11441. }
  11442. } else {
  11443. cursorOffset += entry.count;
  11444. }
  11445. }
  11446. } catch (err) {
  11447. _didIteratorError = true;
  11448. _iteratorError = err;
  11449. } finally {
  11450. try {
  11451. if (!_iteratorNormalCompletion && _iterator.return != null) {
  11452. _iterator.return();
  11453. }
  11454. } finally {
  11455. if (_didIteratorError) {
  11456. throw _iteratorError;
  11457. }
  11458. }
  11459. }
  11460. return {
  11461. formatted: result.formatted,
  11462. cursorOffset
  11463. };
  11464. }
  11465. return {
  11466. formatted: result.formatted
  11467. };
  11468. }
  11469. function formatRange(text, opts) {
  11470. var parsed = parser.parse(text, opts);
  11471. var ast = parsed.ast;
  11472. text = parsed.text;
  11473. var range = rangeUtil.calculateRange(text, opts, ast);
  11474. var rangeStart = range.rangeStart;
  11475. var rangeEnd = range.rangeEnd;
  11476. var rangeString = text.slice(rangeStart, rangeEnd); // Try to extend the range backwards to the beginning of the line.
  11477. // This is so we can detect indentation correctly and restore it.
  11478. // Use `Math.min` since `lastIndexOf` returns 0 when `rangeStart` is 0
  11479. var rangeStart2 = Math.min(rangeStart, text.lastIndexOf("\n", rangeStart) + 1);
  11480. var indentString = text.slice(rangeStart2, rangeStart);
  11481. var alignmentSize = util$1.getAlignmentSize(indentString, opts.tabWidth);
  11482. var rangeResult = coreFormat(rangeString, Object.assign({}, opts, {
  11483. rangeStart: 0,
  11484. rangeEnd: Infinity,
  11485. printWidth: opts.printWidth - alignmentSize,
  11486. // track the cursor offset only if it's within our range
  11487. cursorOffset: opts.cursorOffset >= rangeStart && opts.cursorOffset < rangeEnd ? opts.cursorOffset - rangeStart : -1
  11488. }), alignmentSize); // Since the range contracts to avoid trailing whitespace,
  11489. // we need to remove the newline that was inserted by the `format` call.
  11490. var rangeTrimmed = rangeResult.formatted.trimRight();
  11491. var rangeLeft = text.slice(0, rangeStart);
  11492. var rangeRight = text.slice(rangeEnd);
  11493. var cursorOffset = opts.cursorOffset;
  11494. if (opts.cursorOffset >= rangeEnd) {
  11495. // handle the case where the cursor was past the end of the range
  11496. cursorOffset = opts.cursorOffset - rangeEnd + (rangeStart + rangeTrimmed.length);
  11497. } else if (rangeResult.cursorOffset !== undefined) {
  11498. // handle the case where the cursor was in the range
  11499. cursorOffset = rangeResult.cursorOffset + rangeStart;
  11500. } // keep the cursor as it was if it was before the start of the range
  11501. var formatted;
  11502. if (opts.endOfLine === "lf") {
  11503. formatted = rangeLeft + rangeTrimmed + rangeRight;
  11504. } else {
  11505. var eol = convertEndOfLineToChars(opts.endOfLine);
  11506. if (cursorOffset >= 0) {
  11507. var parts = [rangeLeft, rangeTrimmed, rangeRight];
  11508. var partIndex = 0;
  11509. var partOffset = cursorOffset;
  11510. while (partIndex < parts.length) {
  11511. var part = parts[partIndex];
  11512. if (partOffset < part.length) {
  11513. parts[partIndex] = parts[partIndex].slice(0, partOffset) + PLACEHOLDERS.cursorOffset + parts[partIndex].slice(partOffset);
  11514. break;
  11515. }
  11516. partIndex++;
  11517. partOffset -= part.length;
  11518. }
  11519. var newRangeLeft = parts[0],
  11520. newRangeTrimmed = parts[1],
  11521. newRangeRight = parts[2];
  11522. formatted = (newRangeLeft.replace(/\n/g, eol) + newRangeTrimmed + newRangeRight.replace(/\n/g, eol)).replace(PLACEHOLDERS.cursorOffset, function (_, index) {
  11523. cursorOffset = index;
  11524. return "";
  11525. });
  11526. } else {
  11527. formatted = rangeLeft.replace(/\n/g, eol) + rangeTrimmed + rangeRight.replace(/\n/g, eol);
  11528. }
  11529. }
  11530. return {
  11531. formatted,
  11532. cursorOffset
  11533. };
  11534. }
  11535. function format(text, opts) {
  11536. var selectedParser = parser.resolveParser(opts);
  11537. var hasPragma = !selectedParser.hasPragma || selectedParser.hasPragma(text);
  11538. if (opts.requirePragma && !hasPragma) {
  11539. return {
  11540. formatted: text
  11541. };
  11542. }
  11543. if (opts.endOfLine === "auto") {
  11544. opts.endOfLine = guessEndOfLine(text);
  11545. }
  11546. var hasCursor = opts.cursorOffset >= 0;
  11547. var hasRangeStart = opts.rangeStart > 0;
  11548. var hasRangeEnd = opts.rangeEnd < text.length; // get rid of CR/CRLF parsing
  11549. if (text.indexOf("\r") !== -1) {
  11550. var offsetKeys = [hasCursor && "cursorOffset", hasRangeStart && "rangeStart", hasRangeEnd && "rangeEnd"].filter(Boolean).sort(function (aKey, bKey) {
  11551. return opts[aKey] - opts[bKey];
  11552. });
  11553. for (var i = offsetKeys.length - 1; i >= 0; i--) {
  11554. var key = offsetKeys[i];
  11555. text = text.slice(0, opts[key]) + PLACEHOLDERS[key] + text.slice(opts[key]);
  11556. }
  11557. text = text.replace(/\r\n?/g, "\n");
  11558. var _loop = function _loop(_i) {
  11559. var key = offsetKeys[_i];
  11560. text = text.replace(PLACEHOLDERS[key], function (_, index) {
  11561. opts[key] = index;
  11562. return "";
  11563. });
  11564. };
  11565. for (var _i = 0; _i < offsetKeys.length; _i++) {
  11566. _loop(_i);
  11567. }
  11568. }
  11569. var hasUnicodeBOM = text.charCodeAt(0) === UTF8BOM;
  11570. if (hasUnicodeBOM) {
  11571. text = text.substring(1);
  11572. if (hasCursor) {
  11573. opts.cursorOffset++;
  11574. }
  11575. if (hasRangeStart) {
  11576. opts.rangeStart++;
  11577. }
  11578. if (hasRangeEnd) {
  11579. opts.rangeEnd++;
  11580. }
  11581. }
  11582. if (!hasCursor) {
  11583. opts.cursorOffset = -1;
  11584. }
  11585. if (opts.rangeStart < 0) {
  11586. opts.rangeStart = 0;
  11587. }
  11588. if (opts.rangeEnd > text.length) {
  11589. opts.rangeEnd = text.length;
  11590. }
  11591. var result = hasRangeStart || hasRangeEnd ? formatRange(text, opts) : coreFormat(opts.insertPragma && opts.printer.insertPragma && !hasPragma ? opts.printer.insertPragma(text) : text, opts);
  11592. if (hasUnicodeBOM) {
  11593. result.formatted = String.fromCharCode(UTF8BOM) + result.formatted;
  11594. if (hasCursor) {
  11595. result.cursorOffset++;
  11596. }
  11597. }
  11598. return result;
  11599. }
  11600. var core = {
  11601. formatWithCursor(text, opts) {
  11602. opts = normalizeOptions(opts);
  11603. return format(text, opts);
  11604. },
  11605. parse(text, opts, massage) {
  11606. opts = normalizeOptions(opts);
  11607. if (text.indexOf("\r") !== -1) {
  11608. text = text.replace(/\r\n?/g, "\n");
  11609. }
  11610. var parsed = parser.parse(text, opts);
  11611. if (massage) {
  11612. parsed.ast = massageAst(parsed.ast, opts);
  11613. }
  11614. return parsed;
  11615. },
  11616. formatAST(ast, opts) {
  11617. opts = normalizeOptions(opts);
  11618. var doc$$1 = astToDoc(ast, opts);
  11619. return printDocToString(doc$$1, opts);
  11620. },
  11621. // Doesn't handle shebang for now
  11622. formatDoc(doc$$1, opts) {
  11623. var debug = printDocToDebug(doc$$1);
  11624. opts = normalizeOptions(Object.assign({}, opts, {
  11625. parser: "babel"
  11626. }));
  11627. return format(debug, opts).formatted;
  11628. },
  11629. printToDoc(text, opts) {
  11630. opts = normalizeOptions(opts);
  11631. var parsed = parser.parse(text, opts);
  11632. var ast = parsed.ast;
  11633. text = parsed.text;
  11634. attachComments(text, ast, opts);
  11635. return astToDoc(ast, opts);
  11636. },
  11637. printDocToString(doc$$1, opts) {
  11638. return printDocToString(doc$$1, normalizeOptions(opts));
  11639. }
  11640. };
  11641. var _createClass$1 = function () {
  11642. function defineProperties(target, props) {
  11643. for (var i = 0; i < props.length; i++) {
  11644. var descriptor = props[i];
  11645. descriptor.enumerable = descriptor.enumerable || false;
  11646. descriptor.configurable = true;
  11647. if ("value" in descriptor) descriptor.writable = true;
  11648. Object.defineProperty(target, descriptor.key, descriptor);
  11649. }
  11650. }
  11651. return function (Constructor, protoProps, staticProps) {
  11652. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  11653. if (staticProps) defineProperties(Constructor, staticProps);
  11654. return Constructor;
  11655. };
  11656. }();
  11657. function _classCallCheck$1(instance, Constructor) {
  11658. if (!(instance instanceof Constructor)) {
  11659. throw new TypeError("Cannot call a class as a function");
  11660. }
  11661. }
  11662. var ignore = function ignore() {
  11663. return new IgnoreBase();
  11664. }; // A simple implementation of make-array
  11665. function make_array(subject) {
  11666. return Array.isArray(subject) ? subject : [subject];
  11667. }
  11668. var REGEX_BLANK_LINE = /^\s+$/;
  11669. var REGEX_LEADING_EXCAPED_EXCLAMATION = /^\\\!/;
  11670. var REGEX_LEADING_EXCAPED_HASH = /^\\#/;
  11671. var SLASH = '/';
  11672. var KEY_IGNORE = typeof Symbol !== 'undefined' ? Symbol.for('node-ignore')
  11673. /* istanbul ignore next */
  11674. : 'node-ignore';
  11675. var IgnoreBase = function () {
  11676. function IgnoreBase() {
  11677. _classCallCheck$1(this, IgnoreBase);
  11678. this._rules = [];
  11679. this[KEY_IGNORE] = true;
  11680. this._initCache();
  11681. }
  11682. _createClass$1(IgnoreBase, [{
  11683. key: '_initCache',
  11684. value: function _initCache() {
  11685. this._cache = {};
  11686. } // @param {Array.<string>|string|Ignore} pattern
  11687. }, {
  11688. key: 'add',
  11689. value: function add(pattern) {
  11690. this._added = false;
  11691. if (typeof pattern === 'string') {
  11692. pattern = pattern.split(/\r?\n/g);
  11693. }
  11694. make_array(pattern).forEach(this._addPattern, this); // Some rules have just added to the ignore,
  11695. // making the behavior changed.
  11696. if (this._added) {
  11697. this._initCache();
  11698. }
  11699. return this;
  11700. } // legacy
  11701. }, {
  11702. key: 'addPattern',
  11703. value: function addPattern(pattern) {
  11704. return this.add(pattern);
  11705. }
  11706. }, {
  11707. key: '_addPattern',
  11708. value: function _addPattern(pattern) {
  11709. // #32
  11710. if (pattern && pattern[KEY_IGNORE]) {
  11711. this._rules = this._rules.concat(pattern._rules);
  11712. this._added = true;
  11713. return;
  11714. }
  11715. if (this._checkPattern(pattern)) {
  11716. var rule = this._createRule(pattern);
  11717. this._added = true;
  11718. this._rules.push(rule);
  11719. }
  11720. }
  11721. }, {
  11722. key: '_checkPattern',
  11723. value: function _checkPattern(pattern) {
  11724. // > A blank line matches no files, so it can serve as a separator for readability.
  11725. return pattern && typeof pattern === 'string' && !REGEX_BLANK_LINE.test(pattern) // > A line starting with # serves as a comment.
  11726. && pattern.indexOf('#') !== 0;
  11727. }
  11728. }, {
  11729. key: 'filter',
  11730. value: function filter(paths) {
  11731. var _this = this;
  11732. return make_array(paths).filter(function (path$$1) {
  11733. return _this._filter(path$$1);
  11734. });
  11735. }
  11736. }, {
  11737. key: 'createFilter',
  11738. value: function createFilter() {
  11739. var _this2 = this;
  11740. return function (path$$1) {
  11741. return _this2._filter(path$$1);
  11742. };
  11743. }
  11744. }, {
  11745. key: 'ignores',
  11746. value: function ignores(path$$1) {
  11747. return !this._filter(path$$1);
  11748. }
  11749. }, {
  11750. key: '_createRule',
  11751. value: function _createRule(pattern) {
  11752. var origin = pattern;
  11753. var negative = false; // > An optional prefix "!" which negates the pattern;
  11754. if (pattern.indexOf('!') === 0) {
  11755. negative = true;
  11756. pattern = pattern.substr(1);
  11757. }
  11758. pattern = pattern // > Put a backslash ("\") in front of the first "!" for patterns that begin with a literal "!", for example, `"\!important!.txt"`.
  11759. .replace(REGEX_LEADING_EXCAPED_EXCLAMATION, '!') // > Put a backslash ("\") in front of the first hash for patterns that begin with a hash.
  11760. .replace(REGEX_LEADING_EXCAPED_HASH, '#');
  11761. var regex = make_regex(pattern, negative);
  11762. return {
  11763. origin: origin,
  11764. pattern: pattern,
  11765. negative: negative,
  11766. regex: regex
  11767. };
  11768. } // @returns `Boolean` true if the `path` is NOT ignored
  11769. }, {
  11770. key: '_filter',
  11771. value: function _filter(path$$1, slices) {
  11772. if (!path$$1) {
  11773. return false;
  11774. }
  11775. if (path$$1 in this._cache) {
  11776. return this._cache[path$$1];
  11777. }
  11778. if (!slices) {
  11779. // path/to/a.js
  11780. // ['path', 'to', 'a.js']
  11781. slices = path$$1.split(SLASH);
  11782. }
  11783. slices.pop();
  11784. return this._cache[path$$1] = slices.length // > It is not possible to re-include a file if a parent directory of that file is excluded.
  11785. // If the path contains a parent directory, check the parent first
  11786. ? this._filter(slices.join(SLASH) + SLASH, slices) && this._test(path$$1) // Or only test the path
  11787. : this._test(path$$1);
  11788. } // @returns {Boolean} true if a file is NOT ignored
  11789. }, {
  11790. key: '_test',
  11791. value: function _test(path$$1) {
  11792. // Explicitly define variable type by setting matched to `0`
  11793. var matched = 0;
  11794. this._rules.forEach(function (rule) {
  11795. // if matched = true, then we only test negative rules
  11796. // if matched = false, then we test non-negative rules
  11797. if (!(matched ^ rule.negative)) {
  11798. matched = rule.negative ^ rule.regex.test(path$$1);
  11799. }
  11800. });
  11801. return !matched;
  11802. }
  11803. }]);
  11804. return IgnoreBase;
  11805. }(); // > If the pattern ends with a slash,
  11806. // > it is removed for the purpose of the following description,
  11807. // > but it would only find a match with a directory.
  11808. // > In other words, foo/ will match a directory foo and paths underneath it,
  11809. // > but will not match a regular file or a symbolic link foo
  11810. // > (this is consistent with the way how pathspec works in general in Git).
  11811. // '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`'
  11812. // -> ignore-rules will not deal with it, because it costs extra `fs.stat` call
  11813. // you could use option `mark: true` with `glob`
  11814. // '`foo/`' should not continue with the '`..`'
  11815. var DEFAULT_REPLACER_PREFIX = [// > Trailing spaces are ignored unless they are quoted with backslash ("\")
  11816. [// (a\ ) -> (a )
  11817. // (a ) -> (a)
  11818. // (a \ ) -> (a )
  11819. /\\?\s+$/, function (match) {
  11820. return match.indexOf('\\') === 0 ? ' ' : '';
  11821. }], // replace (\ ) with ' '
  11822. [/\\\s/g, function () {
  11823. return ' ';
  11824. }], // Escape metacharacters
  11825. // which is written down by users but means special for regular expressions.
  11826. // > There are 12 characters with special meanings:
  11827. // > - the backslash \,
  11828. // > - the caret ^,
  11829. // > - the dollar sign $,
  11830. // > - the period or dot .,
  11831. // > - the vertical bar or pipe symbol |,
  11832. // > - the question mark ?,
  11833. // > - the asterisk or star *,
  11834. // > - the plus sign +,
  11835. // > - the opening parenthesis (,
  11836. // > - the closing parenthesis ),
  11837. // > - and the opening square bracket [,
  11838. // > - the opening curly brace {,
  11839. // > These special characters are often called "metacharacters".
  11840. [/[\\\^$.|?*+()\[{]/g, function (match) {
  11841. return '\\' + match;
  11842. }], // leading slash
  11843. [// > A leading slash matches the beginning of the pathname.
  11844. // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
  11845. // A leading slash matches the beginning of the pathname
  11846. /^\//, function () {
  11847. return '^';
  11848. }], // replace special metacharacter slash after the leading slash
  11849. [/\//g, function () {
  11850. return '\\/';
  11851. }], [// > A leading "**" followed by a slash means match in all directories.
  11852. // > For example, "**/foo" matches file or directory "foo" anywhere,
  11853. // > the same as pattern "foo".
  11854. // > "**/foo/bar" matches file or directory "bar" anywhere that is directly under directory "foo".
  11855. // Notice that the '*'s have been replaced as '\\*'
  11856. /^\^*\\\*\\\*\\\//, // '**/foo' <-> 'foo'
  11857. function () {
  11858. return '^(?:.*\\/)?';
  11859. }]];
  11860. var DEFAULT_REPLACER_SUFFIX = [// starting
  11861. [// there will be no leading '/' (which has been replaced by section "leading slash")
  11862. // If starts with '**', adding a '^' to the regular expression also works
  11863. /^(?=[^\^])/, function () {
  11864. return !/\/(?!$)/.test(this) // > If the pattern does not contain a slash /, Git treats it as a shell glob pattern
  11865. // Actually, if there is only a trailing slash, git also treats it as a shell glob pattern
  11866. ? '(?:^|\\/)' // > Otherwise, Git treats the pattern as a shell glob suitable for consumption by fnmatch(3)
  11867. : '^';
  11868. }], // two globstars
  11869. [// Use lookahead assertions so that we could match more than one `'/**'`
  11870. /\\\/\\\*\\\*(?=\\\/|$)/g, // Zero, one or several directories
  11871. // should not use '*', or it will be replaced by the next replacer
  11872. // Check if it is not the last `'/**'`
  11873. function (match, index, str) {
  11874. return index + 6 < str.length // case: /**/
  11875. // > A slash followed by two consecutive asterisks then a slash matches zero or more directories.
  11876. // > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.
  11877. // '/**/'
  11878. ? '(?:\\/[^\\/]+)*' // case: /**
  11879. // > A trailing `"/**"` matches everything inside.
  11880. // #21: everything inside but it should not include the current folder
  11881. : '\\/.+';
  11882. }], // intermediate wildcards
  11883. [// Never replace escaped '*'
  11884. // ignore rule '\*' will match the path '*'
  11885. // 'abc.*/' -> go
  11886. // 'abc.*' -> skip this rule
  11887. /(^|[^\\]+)\\\*(?=.+)/g, // '*.js' matches '.js'
  11888. // '*.js' doesn't match 'abc'
  11889. function (match, p1) {
  11890. return p1 + '[^\\/]*';
  11891. }], // trailing wildcard
  11892. [/(\^|\\\/)?\\\*$/, function (match, p1) {
  11893. return (p1 // '\^':
  11894. // '/*' does not match ''
  11895. // '/*' does not match everything
  11896. // '\\\/':
  11897. // 'abc/*' does not match 'abc/'
  11898. ? p1 + '[^/]+' // 'a*' matches 'a'
  11899. // 'a*' matches 'aa'
  11900. : '[^/]*') + '(?=$|\\/$)';
  11901. }], [// unescape
  11902. /\\\\\\/g, function () {
  11903. return '\\';
  11904. }]];
  11905. var POSITIVE_REPLACERS = [].concat(DEFAULT_REPLACER_PREFIX, [// 'f'
  11906. // matches
  11907. // - /f(end)
  11908. // - /f/
  11909. // - (start)f(end)
  11910. // - (start)f/
  11911. // doesn't match
  11912. // - oof
  11913. // - foo
  11914. // pseudo:
  11915. // -> (^|/)f(/|$)
  11916. // ending
  11917. [// 'js' will not match 'js.'
  11918. // 'ab' will not match 'abc'
  11919. /(?:[^*\/])$/, // 'js*' will not match 'a.js'
  11920. // 'js/' will not match 'a.js'
  11921. // 'js' will match 'a.js' and 'a.js/'
  11922. function (match) {
  11923. return match + '(?=$|\\/)';
  11924. }]], DEFAULT_REPLACER_SUFFIX);
  11925. var NEGATIVE_REPLACERS = [].concat(DEFAULT_REPLACER_PREFIX, [// #24
  11926. // The MISSING rule of [gitignore docs](https://git-scm.com/docs/gitignore)
  11927. // A negative pattern without a trailing wildcard should not
  11928. // re-include the things inside that directory.
  11929. // eg:
  11930. // ['node_modules/*', '!node_modules']
  11931. // should ignore `node_modules/a.js`
  11932. [/(?:[^*\/])$/, function (match) {
  11933. return match + '(?=$|\\/$)';
  11934. }]], DEFAULT_REPLACER_SUFFIX); // A simple cache, because an ignore rule only has only one certain meaning
  11935. var cache = {}; // @param {pattern}
  11936. function make_regex(pattern, negative) {
  11937. var r = cache[pattern];
  11938. if (r) {
  11939. return r;
  11940. }
  11941. var replacers = negative ? NEGATIVE_REPLACERS : POSITIVE_REPLACERS;
  11942. var source = replacers.reduce(function (prev, current) {
  11943. return prev.replace(current[0], current[1].bind(pattern));
  11944. }, pattern);
  11945. return cache[pattern] = new RegExp(source, 'i');
  11946. } // Windows
  11947. // --------------------------------------------------------------
  11948. /* istanbul ignore if */
  11949. if ( // Detect `process` so that it can run in browsers.
  11950. typeof process !== 'undefined' && (process.env && process.env.IGNORE_TEST_WIN32 || process.platform === 'win32')) {
  11951. var filter = IgnoreBase.prototype._filter;
  11952. var make_posix = function make_posix(str) {
  11953. return /^\\\\\?\\/.test(str) || /[^\x00-\x80]+/.test(str) ? str : str.replace(/\\/g, '/');
  11954. };
  11955. IgnoreBase.prototype._filter = function (path$$1, slices) {
  11956. path$$1 = make_posix(path$$1);
  11957. return filter.call(this, path$$1, slices);
  11958. };
  11959. }
  11960. /**
  11961. * @param {string} filename
  11962. * @returns {Promise<null | string>}
  11963. */
  11964. function getFileContentOrNull(filename) {
  11965. return new Promise(function (resolve, reject) {
  11966. fs.readFile(filename, "utf8", function (error, data) {
  11967. if (error && error.code !== "ENOENT") {
  11968. reject(createError(filename, error));
  11969. } else {
  11970. resolve(error ? null : data);
  11971. }
  11972. });
  11973. });
  11974. }
  11975. /**
  11976. * @param {string} filename
  11977. * @returns {null | string}
  11978. */
  11979. getFileContentOrNull.sync = function (filename) {
  11980. try {
  11981. return fs.readFileSync(filename, "utf8");
  11982. } catch (error) {
  11983. if (error && error.code === "ENOENT") {
  11984. return null;
  11985. }
  11986. throw createError(filename, error);
  11987. }
  11988. };
  11989. function createError(filename, error) {
  11990. return new Error(`Unable to read ${filename}: ${error.message}`);
  11991. }
  11992. var getFileContentOrNull_1 = getFileContentOrNull;
  11993. /**
  11994. * @param {undefined | string} ignorePath
  11995. * @param {undefined | boolean} withNodeModules
  11996. */
  11997. function createIgnorer(ignorePath, withNodeModules) {
  11998. return (!ignorePath ? Promise.resolve(null) : getFileContentOrNull_1(path.resolve(ignorePath))).then(function (ignoreContent) {
  11999. return _createIgnorer(ignoreContent, withNodeModules);
  12000. });
  12001. }
  12002. /**
  12003. * @param {undefined | string} ignorePath
  12004. * @param {undefined | boolean} withNodeModules
  12005. */
  12006. createIgnorer.sync = function (ignorePath, withNodeModules) {
  12007. var ignoreContent = !ignorePath ? null : getFileContentOrNull_1.sync(path.resolve(ignorePath));
  12008. return _createIgnorer(ignoreContent, withNodeModules);
  12009. };
  12010. /**
  12011. * @param {null | string} ignoreContent
  12012. * @param {undefined | boolean} withNodeModules
  12013. */
  12014. function _createIgnorer(ignoreContent, withNodeModules) {
  12015. var ignorer = ignore().add(ignoreContent || "");
  12016. if (!withNodeModules) {
  12017. ignorer.add("node_modules");
  12018. }
  12019. return ignorer;
  12020. }
  12021. var createIgnorer_1 = createIgnorer;
  12022. /**
  12023. * @typedef {{ ignorePath?: string, withNodeModules?: boolean, plugins: object }} FileInfoOptions
  12024. * @typedef {{ ignored: boolean, inferredParser: string | null }} FileInfoResult
  12025. */
  12026. /**
  12027. * @param {string} filePath
  12028. * @param {FileInfoOptions} opts
  12029. * @returns {Promise<FileInfoResult>}
  12030. *
  12031. * Please note that prettier.getFileInfo() expects opts.plugins to be an array of paths,
  12032. * not an object. A transformation from this array to an object is automatically done
  12033. * internally by the method wrapper. See withPlugins() in index.js.
  12034. */
  12035. function getFileInfo(filePath, opts) {
  12036. return createIgnorer_1(opts.ignorePath, opts.withNodeModules).then(function (ignorer) {
  12037. return _getFileInfo(ignorer, normalizeFilePath(filePath, opts.ignorePath), opts.plugins);
  12038. });
  12039. }
  12040. /**
  12041. * @param {string} filePath
  12042. * @param {FileInfoOptions} opts
  12043. * @returns {FileInfoResult}
  12044. */
  12045. getFileInfo.sync = function (filePath, opts) {
  12046. var ignorer = createIgnorer_1.sync(opts.ignorePath, opts.withNodeModules);
  12047. return _getFileInfo(ignorer, normalizeFilePath(filePath, opts.ignorePath), opts.plugins);
  12048. };
  12049. function _getFileInfo(ignorer, filePath, plugins) {
  12050. var ignored = ignorer.ignores(filePath);
  12051. var inferredParser = options.inferParser(filePath, plugins) || null;
  12052. return {
  12053. ignored,
  12054. inferredParser
  12055. };
  12056. }
  12057. function normalizeFilePath(filePath, ignorePath) {
  12058. return ignorePath ? path.relative(path.dirname(ignorePath), filePath) : filePath;
  12059. }
  12060. var getFileInfo_1 = getFileInfo;
  12061. var lodash_uniqby = createCommonjsModule(function (module, exports) {
  12062. /**
  12063. * lodash (Custom Build) <https://lodash.com/>
  12064. * Build: `lodash modularize exports="npm" -o ./`
  12065. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  12066. * Released under MIT license <https://lodash.com/license>
  12067. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  12068. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  12069. */
  12070. /** Used as the size to enable large array optimizations. */
  12071. var LARGE_ARRAY_SIZE = 200;
  12072. /** Used as the `TypeError` message for "Functions" methods. */
  12073. var FUNC_ERROR_TEXT = 'Expected a function';
  12074. /** Used to stand-in for `undefined` hash values. */
  12075. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  12076. /** Used to compose bitmasks for comparison styles. */
  12077. var UNORDERED_COMPARE_FLAG = 1,
  12078. PARTIAL_COMPARE_FLAG = 2;
  12079. /** Used as references for various `Number` constants. */
  12080. var INFINITY = 1 / 0,
  12081. MAX_SAFE_INTEGER = 9007199254740991;
  12082. /** `Object#toString` result references. */
  12083. var argsTag = '[object Arguments]',
  12084. arrayTag = '[object Array]',
  12085. boolTag = '[object Boolean]',
  12086. dateTag = '[object Date]',
  12087. errorTag = '[object Error]',
  12088. funcTag = '[object Function]',
  12089. genTag = '[object GeneratorFunction]',
  12090. mapTag = '[object Map]',
  12091. numberTag = '[object Number]',
  12092. objectTag = '[object Object]',
  12093. promiseTag = '[object Promise]',
  12094. regexpTag = '[object RegExp]',
  12095. setTag = '[object Set]',
  12096. stringTag = '[object String]',
  12097. symbolTag = '[object Symbol]',
  12098. weakMapTag = '[object WeakMap]';
  12099. var arrayBufferTag = '[object ArrayBuffer]',
  12100. dataViewTag = '[object DataView]',
  12101. float32Tag = '[object Float32Array]',
  12102. float64Tag = '[object Float64Array]',
  12103. int8Tag = '[object Int8Array]',
  12104. int16Tag = '[object Int16Array]',
  12105. int32Tag = '[object Int32Array]',
  12106. uint8Tag = '[object Uint8Array]',
  12107. uint8ClampedTag = '[object Uint8ClampedArray]',
  12108. uint16Tag = '[object Uint16Array]',
  12109. uint32Tag = '[object Uint32Array]';
  12110. /** Used to match property names within property paths. */
  12111. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  12112. reIsPlainProp = /^\w*$/,
  12113. reLeadingDot = /^\./,
  12114. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  12115. /**
  12116. * Used to match `RegExp`
  12117. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  12118. */
  12119. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  12120. /** Used to match backslashes in property paths. */
  12121. var reEscapeChar = /\\(\\)?/g;
  12122. /** Used to detect host constructors (Safari). */
  12123. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  12124. /** Used to detect unsigned integer values. */
  12125. var reIsUint = /^(?:0|[1-9]\d*)$/;
  12126. /** Used to identify `toStringTag` values of typed arrays. */
  12127. var typedArrayTags = {};
  12128. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
  12129. typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
  12130. /** Detect free variable `global` from Node.js. */
  12131. var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
  12132. /** Detect free variable `self`. */
  12133. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  12134. /** Used as a reference to the global object. */
  12135. var root = freeGlobal || freeSelf || Function('return this')();
  12136. /** Detect free variable `exports`. */
  12137. var freeExports = 'object' == 'object' && exports && !exports.nodeType && exports;
  12138. /** Detect free variable `module`. */
  12139. var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
  12140. /** Detect the popular CommonJS extension `module.exports`. */
  12141. var moduleExports = freeModule && freeModule.exports === freeExports;
  12142. /** Detect free variable `process` from Node.js. */
  12143. var freeProcess = moduleExports && freeGlobal.process;
  12144. /** Used to access faster Node.js helpers. */
  12145. var nodeUtil = function () {
  12146. try {
  12147. return freeProcess && freeProcess.binding('util');
  12148. } catch (e) {}
  12149. }();
  12150. /* Node.js helper references. */
  12151. var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  12152. /**
  12153. * A specialized version of `_.includes` for arrays without support for
  12154. * specifying an index to search from.
  12155. *
  12156. * @private
  12157. * @param {Array} [array] The array to inspect.
  12158. * @param {*} target The value to search for.
  12159. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  12160. */
  12161. function arrayIncludes(array, value) {
  12162. var length = array ? array.length : 0;
  12163. return !!length && baseIndexOf(array, value, 0) > -1;
  12164. }
  12165. /**
  12166. * This function is like `arrayIncludes` except that it accepts a comparator.
  12167. *
  12168. * @private
  12169. * @param {Array} [array] The array to inspect.
  12170. * @param {*} target The value to search for.
  12171. * @param {Function} comparator The comparator invoked per element.
  12172. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  12173. */
  12174. function arrayIncludesWith(array, value, comparator) {
  12175. var index = -1,
  12176. length = array ? array.length : 0;
  12177. while (++index < length) {
  12178. if (comparator(value, array[index])) {
  12179. return true;
  12180. }
  12181. }
  12182. return false;
  12183. }
  12184. /**
  12185. * A specialized version of `_.some` for arrays without support for iteratee
  12186. * shorthands.
  12187. *
  12188. * @private
  12189. * @param {Array} [array] The array to iterate over.
  12190. * @param {Function} predicate The function invoked per iteration.
  12191. * @returns {boolean} Returns `true` if any element passes the predicate check,
  12192. * else `false`.
  12193. */
  12194. function arraySome(array, predicate) {
  12195. var index = -1,
  12196. length = array ? array.length : 0;
  12197. while (++index < length) {
  12198. if (predicate(array[index], index, array)) {
  12199. return true;
  12200. }
  12201. }
  12202. return false;
  12203. }
  12204. /**
  12205. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  12206. * support for iteratee shorthands.
  12207. *
  12208. * @private
  12209. * @param {Array} array The array to inspect.
  12210. * @param {Function} predicate The function invoked per iteration.
  12211. * @param {number} fromIndex The index to search from.
  12212. * @param {boolean} [fromRight] Specify iterating from right to left.
  12213. * @returns {number} Returns the index of the matched value, else `-1`.
  12214. */
  12215. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  12216. var length = array.length,
  12217. index = fromIndex + (fromRight ? 1 : -1);
  12218. while (fromRight ? index-- : ++index < length) {
  12219. if (predicate(array[index], index, array)) {
  12220. return index;
  12221. }
  12222. }
  12223. return -1;
  12224. }
  12225. /**
  12226. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  12227. *
  12228. * @private
  12229. * @param {Array} array The array to inspect.
  12230. * @param {*} value The value to search for.
  12231. * @param {number} fromIndex The index to search from.
  12232. * @returns {number} Returns the index of the matched value, else `-1`.
  12233. */
  12234. function baseIndexOf(array, value, fromIndex) {
  12235. if (value !== value) {
  12236. return baseFindIndex(array, baseIsNaN, fromIndex);
  12237. }
  12238. var index = fromIndex - 1,
  12239. length = array.length;
  12240. while (++index < length) {
  12241. if (array[index] === value) {
  12242. return index;
  12243. }
  12244. }
  12245. return -1;
  12246. }
  12247. /**
  12248. * The base implementation of `_.isNaN` without support for number objects.
  12249. *
  12250. * @private
  12251. * @param {*} value The value to check.
  12252. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  12253. */
  12254. function baseIsNaN(value) {
  12255. return value !== value;
  12256. }
  12257. /**
  12258. * The base implementation of `_.property` without support for deep paths.
  12259. *
  12260. * @private
  12261. * @param {string} key The key of the property to get.
  12262. * @returns {Function} Returns the new accessor function.
  12263. */
  12264. function baseProperty(key) {
  12265. return function (object) {
  12266. return object == null ? undefined : object[key];
  12267. };
  12268. }
  12269. /**
  12270. * The base implementation of `_.times` without support for iteratee shorthands
  12271. * or max array length checks.
  12272. *
  12273. * @private
  12274. * @param {number} n The number of times to invoke `iteratee`.
  12275. * @param {Function} iteratee The function invoked per iteration.
  12276. * @returns {Array} Returns the array of results.
  12277. */
  12278. function baseTimes(n, iteratee) {
  12279. var index = -1,
  12280. result = Array(n);
  12281. while (++index < n) {
  12282. result[index] = iteratee(index);
  12283. }
  12284. return result;
  12285. }
  12286. /**
  12287. * The base implementation of `_.unary` without support for storing metadata.
  12288. *
  12289. * @private
  12290. * @param {Function} func The function to cap arguments for.
  12291. * @returns {Function} Returns the new capped function.
  12292. */
  12293. function baseUnary(func) {
  12294. return function (value) {
  12295. return func(value);
  12296. };
  12297. }
  12298. /**
  12299. * Checks if a cache value for `key` exists.
  12300. *
  12301. * @private
  12302. * @param {Object} cache The cache to query.
  12303. * @param {string} key The key of the entry to check.
  12304. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  12305. */
  12306. function cacheHas(cache, key) {
  12307. return cache.has(key);
  12308. }
  12309. /**
  12310. * Gets the value at `key` of `object`.
  12311. *
  12312. * @private
  12313. * @param {Object} [object] The object to query.
  12314. * @param {string} key The key of the property to get.
  12315. * @returns {*} Returns the property value.
  12316. */
  12317. function getValue(object, key) {
  12318. return object == null ? undefined : object[key];
  12319. }
  12320. /**
  12321. * Checks if `value` is a host object in IE < 9.
  12322. *
  12323. * @private
  12324. * @param {*} value The value to check.
  12325. * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
  12326. */
  12327. function isHostObject(value) {
  12328. // Many host objects are `Object` objects that can coerce to strings
  12329. // despite having improperly defined `toString` methods.
  12330. var result = false;
  12331. if (value != null && typeof value.toString != 'function') {
  12332. try {
  12333. result = !!(value + '');
  12334. } catch (e) {}
  12335. }
  12336. return result;
  12337. }
  12338. /**
  12339. * Converts `map` to its key-value pairs.
  12340. *
  12341. * @private
  12342. * @param {Object} map The map to convert.
  12343. * @returns {Array} Returns the key-value pairs.
  12344. */
  12345. function mapToArray(map) {
  12346. var index = -1,
  12347. result = Array(map.size);
  12348. map.forEach(function (value, key) {
  12349. result[++index] = [key, value];
  12350. });
  12351. return result;
  12352. }
  12353. /**
  12354. * Creates a unary function that invokes `func` with its argument transformed.
  12355. *
  12356. * @private
  12357. * @param {Function} func The function to wrap.
  12358. * @param {Function} transform The argument transform.
  12359. * @returns {Function} Returns the new function.
  12360. */
  12361. function overArg(func, transform) {
  12362. return function (arg) {
  12363. return func(transform(arg));
  12364. };
  12365. }
  12366. /**
  12367. * Converts `set` to an array of its values.
  12368. *
  12369. * @private
  12370. * @param {Object} set The set to convert.
  12371. * @returns {Array} Returns the values.
  12372. */
  12373. function setToArray(set) {
  12374. var index = -1,
  12375. result = Array(set.size);
  12376. set.forEach(function (value) {
  12377. result[++index] = value;
  12378. });
  12379. return result;
  12380. }
  12381. /** Used for built-in method references. */
  12382. var arrayProto = Array.prototype,
  12383. funcProto = Function.prototype,
  12384. objectProto = Object.prototype;
  12385. /** Used to detect overreaching core-js shims. */
  12386. var coreJsData = root['__core-js_shared__'];
  12387. /** Used to detect methods masquerading as native. */
  12388. var maskSrcKey = function () {
  12389. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  12390. return uid ? 'Symbol(src)_1.' + uid : '';
  12391. }();
  12392. /** Used to resolve the decompiled source of functions. */
  12393. var funcToString = funcProto.toString;
  12394. /** Used to check objects for own properties. */
  12395. var hasOwnProperty = objectProto.hasOwnProperty;
  12396. /**
  12397. * Used to resolve the
  12398. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  12399. * of values.
  12400. */
  12401. var objectToString = objectProto.toString;
  12402. /** Used to detect if a method is native. */
  12403. var reIsNative = RegExp('^' + funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
  12404. /** Built-in value references. */
  12405. var Symbol = root.Symbol,
  12406. Uint8Array = root.Uint8Array,
  12407. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  12408. splice = arrayProto.splice;
  12409. /* Built-in method references for those with the same name as other `lodash` methods. */
  12410. var nativeKeys = overArg(Object.keys, Object);
  12411. /* Built-in method references that are verified to be native. */
  12412. var DataView = getNative(root, 'DataView'),
  12413. Map = getNative(root, 'Map'),
  12414. Promise = getNative(root, 'Promise'),
  12415. Set = getNative(root, 'Set'),
  12416. WeakMap = getNative(root, 'WeakMap'),
  12417. nativeCreate = getNative(Object, 'create');
  12418. /** Used to detect maps, sets, and weakmaps. */
  12419. var dataViewCtorString = toSource(DataView),
  12420. mapCtorString = toSource(Map),
  12421. promiseCtorString = toSource(Promise),
  12422. setCtorString = toSource(Set),
  12423. weakMapCtorString = toSource(WeakMap);
  12424. /** Used to convert symbols to primitives and strings. */
  12425. var symbolProto = Symbol ? Symbol.prototype : undefined,
  12426. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  12427. symbolToString = symbolProto ? symbolProto.toString : undefined;
  12428. /**
  12429. * Creates a hash object.
  12430. *
  12431. * @private
  12432. * @constructor
  12433. * @param {Array} [entries] The key-value pairs to cache.
  12434. */
  12435. function Hash(entries) {
  12436. var index = -1,
  12437. length = entries ? entries.length : 0;
  12438. this.clear();
  12439. while (++index < length) {
  12440. var entry = entries[index];
  12441. this.set(entry[0], entry[1]);
  12442. }
  12443. }
  12444. /**
  12445. * Removes all key-value entries from the hash.
  12446. *
  12447. * @private
  12448. * @name clear
  12449. * @memberOf Hash
  12450. */
  12451. function hashClear() {
  12452. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  12453. }
  12454. /**
  12455. * Removes `key` and its value from the hash.
  12456. *
  12457. * @private
  12458. * @name delete
  12459. * @memberOf Hash
  12460. * @param {Object} hash The hash to modify.
  12461. * @param {string} key The key of the value to remove.
  12462. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  12463. */
  12464. function hashDelete(key) {
  12465. return this.has(key) && delete this.__data__[key];
  12466. }
  12467. /**
  12468. * Gets the hash value for `key`.
  12469. *
  12470. * @private
  12471. * @name get
  12472. * @memberOf Hash
  12473. * @param {string} key The key of the value to get.
  12474. * @returns {*} Returns the entry value.
  12475. */
  12476. function hashGet(key) {
  12477. var data = this.__data__;
  12478. if (nativeCreate) {
  12479. var result = data[key];
  12480. return result === HASH_UNDEFINED ? undefined : result;
  12481. }
  12482. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  12483. }
  12484. /**
  12485. * Checks if a hash value for `key` exists.
  12486. *
  12487. * @private
  12488. * @name has
  12489. * @memberOf Hash
  12490. * @param {string} key The key of the entry to check.
  12491. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  12492. */
  12493. function hashHas(key) {
  12494. var data = this.__data__;
  12495. return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
  12496. }
  12497. /**
  12498. * Sets the hash `key` to `value`.
  12499. *
  12500. * @private
  12501. * @name set
  12502. * @memberOf Hash
  12503. * @param {string} key The key of the value to set.
  12504. * @param {*} value The value to set.
  12505. * @returns {Object} Returns the hash instance.
  12506. */
  12507. function hashSet(key, value) {
  12508. var data = this.__data__;
  12509. data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED : value;
  12510. return this;
  12511. } // Add methods to `Hash`.
  12512. Hash.prototype.clear = hashClear;
  12513. Hash.prototype['delete'] = hashDelete;
  12514. Hash.prototype.get = hashGet;
  12515. Hash.prototype.has = hashHas;
  12516. Hash.prototype.set = hashSet;
  12517. /**
  12518. * Creates an list cache object.
  12519. *
  12520. * @private
  12521. * @constructor
  12522. * @param {Array} [entries] The key-value pairs to cache.
  12523. */
  12524. function ListCache(entries) {
  12525. var index = -1,
  12526. length = entries ? entries.length : 0;
  12527. this.clear();
  12528. while (++index < length) {
  12529. var entry = entries[index];
  12530. this.set(entry[0], entry[1]);
  12531. }
  12532. }
  12533. /**
  12534. * Removes all key-value entries from the list cache.
  12535. *
  12536. * @private
  12537. * @name clear
  12538. * @memberOf ListCache
  12539. */
  12540. function listCacheClear() {
  12541. this.__data__ = [];
  12542. }
  12543. /**
  12544. * Removes `key` and its value from the list cache.
  12545. *
  12546. * @private
  12547. * @name delete
  12548. * @memberOf ListCache
  12549. * @param {string} key The key of the value to remove.
  12550. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  12551. */
  12552. function listCacheDelete(key) {
  12553. var data = this.__data__,
  12554. index = assocIndexOf(data, key);
  12555. if (index < 0) {
  12556. return false;
  12557. }
  12558. var lastIndex = data.length - 1;
  12559. if (index == lastIndex) {
  12560. data.pop();
  12561. } else {
  12562. splice.call(data, index, 1);
  12563. }
  12564. return true;
  12565. }
  12566. /**
  12567. * Gets the list cache value for `key`.
  12568. *
  12569. * @private
  12570. * @name get
  12571. * @memberOf ListCache
  12572. * @param {string} key The key of the value to get.
  12573. * @returns {*} Returns the entry value.
  12574. */
  12575. function listCacheGet(key) {
  12576. var data = this.__data__,
  12577. index = assocIndexOf(data, key);
  12578. return index < 0 ? undefined : data[index][1];
  12579. }
  12580. /**
  12581. * Checks if a list cache value for `key` exists.
  12582. *
  12583. * @private
  12584. * @name has
  12585. * @memberOf ListCache
  12586. * @param {string} key The key of the entry to check.
  12587. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  12588. */
  12589. function listCacheHas(key) {
  12590. return assocIndexOf(this.__data__, key) > -1;
  12591. }
  12592. /**
  12593. * Sets the list cache `key` to `value`.
  12594. *
  12595. * @private
  12596. * @name set
  12597. * @memberOf ListCache
  12598. * @param {string} key The key of the value to set.
  12599. * @param {*} value The value to set.
  12600. * @returns {Object} Returns the list cache instance.
  12601. */
  12602. function listCacheSet(key, value) {
  12603. var data = this.__data__,
  12604. index = assocIndexOf(data, key);
  12605. if (index < 0) {
  12606. data.push([key, value]);
  12607. } else {
  12608. data[index][1] = value;
  12609. }
  12610. return this;
  12611. } // Add methods to `ListCache`.
  12612. ListCache.prototype.clear = listCacheClear;
  12613. ListCache.prototype['delete'] = listCacheDelete;
  12614. ListCache.prototype.get = listCacheGet;
  12615. ListCache.prototype.has = listCacheHas;
  12616. ListCache.prototype.set = listCacheSet;
  12617. /**
  12618. * Creates a map cache object to store key-value pairs.
  12619. *
  12620. * @private
  12621. * @constructor
  12622. * @param {Array} [entries] The key-value pairs to cache.
  12623. */
  12624. function MapCache(entries) {
  12625. var index = -1,
  12626. length = entries ? entries.length : 0;
  12627. this.clear();
  12628. while (++index < length) {
  12629. var entry = entries[index];
  12630. this.set(entry[0], entry[1]);
  12631. }
  12632. }
  12633. /**
  12634. * Removes all key-value entries from the map.
  12635. *
  12636. * @private
  12637. * @name clear
  12638. * @memberOf MapCache
  12639. */
  12640. function mapCacheClear() {
  12641. this.__data__ = {
  12642. 'hash': new Hash(),
  12643. 'map': new (Map || ListCache)(),
  12644. 'string': new Hash()
  12645. };
  12646. }
  12647. /**
  12648. * Removes `key` and its value from the map.
  12649. *
  12650. * @private
  12651. * @name delete
  12652. * @memberOf MapCache
  12653. * @param {string} key The key of the value to remove.
  12654. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  12655. */
  12656. function mapCacheDelete(key) {
  12657. return getMapData(this, key)['delete'](key);
  12658. }
  12659. /**
  12660. * Gets the map value for `key`.
  12661. *
  12662. * @private
  12663. * @name get
  12664. * @memberOf MapCache
  12665. * @param {string} key The key of the value to get.
  12666. * @returns {*} Returns the entry value.
  12667. */
  12668. function mapCacheGet(key) {
  12669. return getMapData(this, key).get(key);
  12670. }
  12671. /**
  12672. * Checks if a map value for `key` exists.
  12673. *
  12674. * @private
  12675. * @name has
  12676. * @memberOf MapCache
  12677. * @param {string} key The key of the entry to check.
  12678. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  12679. */
  12680. function mapCacheHas(key) {
  12681. return getMapData(this, key).has(key);
  12682. }
  12683. /**
  12684. * Sets the map `key` to `value`.
  12685. *
  12686. * @private
  12687. * @name set
  12688. * @memberOf MapCache
  12689. * @param {string} key The key of the value to set.
  12690. * @param {*} value The value to set.
  12691. * @returns {Object} Returns the map cache instance.
  12692. */
  12693. function mapCacheSet(key, value) {
  12694. getMapData(this, key).set(key, value);
  12695. return this;
  12696. } // Add methods to `MapCache`.
  12697. MapCache.prototype.clear = mapCacheClear;
  12698. MapCache.prototype['delete'] = mapCacheDelete;
  12699. MapCache.prototype.get = mapCacheGet;
  12700. MapCache.prototype.has = mapCacheHas;
  12701. MapCache.prototype.set = mapCacheSet;
  12702. /**
  12703. *
  12704. * Creates an array cache object to store unique values.
  12705. *
  12706. * @private
  12707. * @constructor
  12708. * @param {Array} [values] The values to cache.
  12709. */
  12710. function SetCache(values) {
  12711. var index = -1,
  12712. length = values ? values.length : 0;
  12713. this.__data__ = new MapCache();
  12714. while (++index < length) {
  12715. this.add(values[index]);
  12716. }
  12717. }
  12718. /**
  12719. * Adds `value` to the array cache.
  12720. *
  12721. * @private
  12722. * @name add
  12723. * @memberOf SetCache
  12724. * @alias push
  12725. * @param {*} value The value to cache.
  12726. * @returns {Object} Returns the cache instance.
  12727. */
  12728. function setCacheAdd(value) {
  12729. this.__data__.set(value, HASH_UNDEFINED);
  12730. return this;
  12731. }
  12732. /**
  12733. * Checks if `value` is in the array cache.
  12734. *
  12735. * @private
  12736. * @name has
  12737. * @memberOf SetCache
  12738. * @param {*} value The value to search for.
  12739. * @returns {number} Returns `true` if `value` is found, else `false`.
  12740. */
  12741. function setCacheHas(value) {
  12742. return this.__data__.has(value);
  12743. } // Add methods to `SetCache`.
  12744. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  12745. SetCache.prototype.has = setCacheHas;
  12746. /**
  12747. * Creates a stack cache object to store key-value pairs.
  12748. *
  12749. * @private
  12750. * @constructor
  12751. * @param {Array} [entries] The key-value pairs to cache.
  12752. */
  12753. function Stack(entries) {
  12754. this.__data__ = new ListCache(entries);
  12755. }
  12756. /**
  12757. * Removes all key-value entries from the stack.
  12758. *
  12759. * @private
  12760. * @name clear
  12761. * @memberOf Stack
  12762. */
  12763. function stackClear() {
  12764. this.__data__ = new ListCache();
  12765. }
  12766. /**
  12767. * Removes `key` and its value from the stack.
  12768. *
  12769. * @private
  12770. * @name delete
  12771. * @memberOf Stack
  12772. * @param {string} key The key of the value to remove.
  12773. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  12774. */
  12775. function stackDelete(key) {
  12776. return this.__data__['delete'](key);
  12777. }
  12778. /**
  12779. * Gets the stack value for `key`.
  12780. *
  12781. * @private
  12782. * @name get
  12783. * @memberOf Stack
  12784. * @param {string} key The key of the value to get.
  12785. * @returns {*} Returns the entry value.
  12786. */
  12787. function stackGet(key) {
  12788. return this.__data__.get(key);
  12789. }
  12790. /**
  12791. * Checks if a stack value for `key` exists.
  12792. *
  12793. * @private
  12794. * @name has
  12795. * @memberOf Stack
  12796. * @param {string} key The key of the entry to check.
  12797. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  12798. */
  12799. function stackHas(key) {
  12800. return this.__data__.has(key);
  12801. }
  12802. /**
  12803. * Sets the stack `key` to `value`.
  12804. *
  12805. * @private
  12806. * @name set
  12807. * @memberOf Stack
  12808. * @param {string} key The key of the value to set.
  12809. * @param {*} value The value to set.
  12810. * @returns {Object} Returns the stack cache instance.
  12811. */
  12812. function stackSet(key, value) {
  12813. var cache = this.__data__;
  12814. if (cache instanceof ListCache) {
  12815. var pairs = cache.__data__;
  12816. if (!Map || pairs.length < LARGE_ARRAY_SIZE - 1) {
  12817. pairs.push([key, value]);
  12818. return this;
  12819. }
  12820. cache = this.__data__ = new MapCache(pairs);
  12821. }
  12822. cache.set(key, value);
  12823. return this;
  12824. } // Add methods to `Stack`.
  12825. Stack.prototype.clear = stackClear;
  12826. Stack.prototype['delete'] = stackDelete;
  12827. Stack.prototype.get = stackGet;
  12828. Stack.prototype.has = stackHas;
  12829. Stack.prototype.set = stackSet;
  12830. /**
  12831. * Creates an array of the enumerable property names of the array-like `value`.
  12832. *
  12833. * @private
  12834. * @param {*} value The value to query.
  12835. * @param {boolean} inherited Specify returning inherited property names.
  12836. * @returns {Array} Returns the array of property names.
  12837. */
  12838. function arrayLikeKeys(value, inherited) {
  12839. // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
  12840. // Safari 9 makes `arguments.length` enumerable in strict mode.
  12841. var result = isArray(value) || isArguments(value) ? baseTimes(value.length, String) : [];
  12842. var length = result.length,
  12843. skipIndexes = !!length;
  12844. for (var key in value) {
  12845. if ((inherited || hasOwnProperty.call(value, key)) && !(skipIndexes && (key == 'length' || isIndex(key, length)))) {
  12846. result.push(key);
  12847. }
  12848. }
  12849. return result;
  12850. }
  12851. /**
  12852. * Gets the index at which the `key` is found in `array` of key-value pairs.
  12853. *
  12854. * @private
  12855. * @param {Array} array The array to inspect.
  12856. * @param {*} key The key to search for.
  12857. * @returns {number} Returns the index of the matched value, else `-1`.
  12858. */
  12859. function assocIndexOf(array, key) {
  12860. var length = array.length;
  12861. while (length--) {
  12862. if (eq(array[length][0], key)) {
  12863. return length;
  12864. }
  12865. }
  12866. return -1;
  12867. }
  12868. /**
  12869. * The base implementation of `_.get` without support for default values.
  12870. *
  12871. * @private
  12872. * @param {Object} object The object to query.
  12873. * @param {Array|string} path The path of the property to get.
  12874. * @returns {*} Returns the resolved value.
  12875. */
  12876. function baseGet(object, path$$1) {
  12877. path$$1 = isKey(path$$1, object) ? [path$$1] : castPath(path$$1);
  12878. var index = 0,
  12879. length = path$$1.length;
  12880. while (object != null && index < length) {
  12881. object = object[toKey(path$$1[index++])];
  12882. }
  12883. return index && index == length ? object : undefined;
  12884. }
  12885. /**
  12886. * The base implementation of `getTag`.
  12887. *
  12888. * @private
  12889. * @param {*} value The value to query.
  12890. * @returns {string} Returns the `toStringTag`.
  12891. */
  12892. function baseGetTag(value) {
  12893. return objectToString.call(value);
  12894. }
  12895. /**
  12896. * The base implementation of `_.hasIn` without support for deep paths.
  12897. *
  12898. * @private
  12899. * @param {Object} [object] The object to query.
  12900. * @param {Array|string} key The key to check.
  12901. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  12902. */
  12903. function baseHasIn(object, key) {
  12904. return object != null && key in Object(object);
  12905. }
  12906. /**
  12907. * The base implementation of `_.isEqual` which supports partial comparisons
  12908. * and tracks traversed objects.
  12909. *
  12910. * @private
  12911. * @param {*} value The value to compare.
  12912. * @param {*} other The other value to compare.
  12913. * @param {Function} [customizer] The function to customize comparisons.
  12914. * @param {boolean} [bitmask] The bitmask of comparison flags.
  12915. * The bitmask may be composed of the following flags:
  12916. * 1 - Unordered comparison
  12917. * 2 - Partial comparison
  12918. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  12919. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  12920. */
  12921. function baseIsEqual(value, other, customizer, bitmask, stack) {
  12922. if (value === other) {
  12923. return true;
  12924. }
  12925. if (value == null || other == null || !isObject(value) && !isObjectLike(other)) {
  12926. return value !== value && other !== other;
  12927. }
  12928. return baseIsEqualDeep(value, other, baseIsEqual, customizer, bitmask, stack);
  12929. }
  12930. /**
  12931. * A specialized version of `baseIsEqual` for arrays and objects which performs
  12932. * deep comparisons and tracks traversed objects enabling objects with circular
  12933. * references to be compared.
  12934. *
  12935. * @private
  12936. * @param {Object} object The object to compare.
  12937. * @param {Object} other The other object to compare.
  12938. * @param {Function} equalFunc The function to determine equivalents of values.
  12939. * @param {Function} [customizer] The function to customize comparisons.
  12940. * @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual`
  12941. * for more details.
  12942. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  12943. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  12944. */
  12945. function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
  12946. var objIsArr = isArray(object),
  12947. othIsArr = isArray(other),
  12948. objTag = arrayTag,
  12949. othTag = arrayTag;
  12950. if (!objIsArr) {
  12951. objTag = getTag(object);
  12952. objTag = objTag == argsTag ? objectTag : objTag;
  12953. }
  12954. if (!othIsArr) {
  12955. othTag = getTag(other);
  12956. othTag = othTag == argsTag ? objectTag : othTag;
  12957. }
  12958. var objIsObj = objTag == objectTag && !isHostObject(object),
  12959. othIsObj = othTag == objectTag && !isHostObject(other),
  12960. isSameTag = objTag == othTag;
  12961. if (isSameTag && !objIsObj) {
  12962. stack || (stack = new Stack());
  12963. return objIsArr || isTypedArray(object) ? equalArrays(object, other, equalFunc, customizer, bitmask, stack) : equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack);
  12964. }
  12965. if (!(bitmask & PARTIAL_COMPARE_FLAG)) {
  12966. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  12967. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  12968. if (objIsWrapped || othIsWrapped) {
  12969. var objUnwrapped = objIsWrapped ? object.value() : object,
  12970. othUnwrapped = othIsWrapped ? other.value() : other;
  12971. stack || (stack = new Stack());
  12972. return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack);
  12973. }
  12974. }
  12975. if (!isSameTag) {
  12976. return false;
  12977. }
  12978. stack || (stack = new Stack());
  12979. return equalObjects(object, other, equalFunc, customizer, bitmask, stack);
  12980. }
  12981. /**
  12982. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  12983. *
  12984. * @private
  12985. * @param {Object} object The object to inspect.
  12986. * @param {Object} source The object of property values to match.
  12987. * @param {Array} matchData The property names, values, and compare flags to match.
  12988. * @param {Function} [customizer] The function to customize comparisons.
  12989. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  12990. */
  12991. function baseIsMatch(object, source, matchData, customizer) {
  12992. var index = matchData.length,
  12993. length = index,
  12994. noCustomizer = !customizer;
  12995. if (object == null) {
  12996. return !length;
  12997. }
  12998. object = Object(object);
  12999. while (index--) {
  13000. var data = matchData[index];
  13001. if (noCustomizer && data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) {
  13002. return false;
  13003. }
  13004. }
  13005. while (++index < length) {
  13006. data = matchData[index];
  13007. var key = data[0],
  13008. objValue = object[key],
  13009. srcValue = data[1];
  13010. if (noCustomizer && data[2]) {
  13011. if (objValue === undefined && !(key in object)) {
  13012. return false;
  13013. }
  13014. } else {
  13015. var stack = new Stack();
  13016. if (customizer) {
  13017. var result = customizer(objValue, srcValue, key, object, source, stack);
  13018. }
  13019. if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack) : result)) {
  13020. return false;
  13021. }
  13022. }
  13023. }
  13024. return true;
  13025. }
  13026. /**
  13027. * The base implementation of `_.isNative` without bad shim checks.
  13028. *
  13029. * @private
  13030. * @param {*} value The value to check.
  13031. * @returns {boolean} Returns `true` if `value` is a native function,
  13032. * else `false`.
  13033. */
  13034. function baseIsNative(value) {
  13035. if (!isObject(value) || isMasked(value)) {
  13036. return false;
  13037. }
  13038. var pattern = isFunction(value) || isHostObject(value) ? reIsNative : reIsHostCtor;
  13039. return pattern.test(toSource(value));
  13040. }
  13041. /**
  13042. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  13043. *
  13044. * @private
  13045. * @param {*} value The value to check.
  13046. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  13047. */
  13048. function baseIsTypedArray(value) {
  13049. return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
  13050. }
  13051. /**
  13052. * The base implementation of `_.iteratee`.
  13053. *
  13054. * @private
  13055. * @param {*} [value=_.identity] The value to convert to an iteratee.
  13056. * @returns {Function} Returns the iteratee.
  13057. */
  13058. function baseIteratee(value) {
  13059. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  13060. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  13061. if (typeof value == 'function') {
  13062. return value;
  13063. }
  13064. if (value == null) {
  13065. return identity;
  13066. }
  13067. if (typeof value == 'object') {
  13068. return isArray(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches(value);
  13069. }
  13070. return property(value);
  13071. }
  13072. /**
  13073. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  13074. *
  13075. * @private
  13076. * @param {Object} object The object to query.
  13077. * @returns {Array} Returns the array of property names.
  13078. */
  13079. function baseKeys(object) {
  13080. if (!isPrototype(object)) {
  13081. return nativeKeys(object);
  13082. }
  13083. var result = [];
  13084. for (var key in Object(object)) {
  13085. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  13086. result.push(key);
  13087. }
  13088. }
  13089. return result;
  13090. }
  13091. /**
  13092. * The base implementation of `_.matches` which doesn't clone `source`.
  13093. *
  13094. * @private
  13095. * @param {Object} source The object of property values to match.
  13096. * @returns {Function} Returns the new spec function.
  13097. */
  13098. function baseMatches(source) {
  13099. var matchData = getMatchData(source);
  13100. if (matchData.length == 1 && matchData[0][2]) {
  13101. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  13102. }
  13103. return function (object) {
  13104. return object === source || baseIsMatch(object, source, matchData);
  13105. };
  13106. }
  13107. /**
  13108. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  13109. *
  13110. * @private
  13111. * @param {string} path The path of the property to get.
  13112. * @param {*} srcValue The value to match.
  13113. * @returns {Function} Returns the new spec function.
  13114. */
  13115. function baseMatchesProperty(path$$1, srcValue) {
  13116. if (isKey(path$$1) && isStrictComparable(srcValue)) {
  13117. return matchesStrictComparable(toKey(path$$1), srcValue);
  13118. }
  13119. return function (object) {
  13120. var objValue = get(object, path$$1);
  13121. return objValue === undefined && objValue === srcValue ? hasIn(object, path$$1) : baseIsEqual(srcValue, objValue, undefined, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG);
  13122. };
  13123. }
  13124. /**
  13125. * A specialized version of `baseProperty` which supports deep paths.
  13126. *
  13127. * @private
  13128. * @param {Array|string} path The path of the property to get.
  13129. * @returns {Function} Returns the new accessor function.
  13130. */
  13131. function basePropertyDeep(path$$1) {
  13132. return function (object) {
  13133. return baseGet(object, path$$1);
  13134. };
  13135. }
  13136. /**
  13137. * The base implementation of `_.toString` which doesn't convert nullish
  13138. * values to empty strings.
  13139. *
  13140. * @private
  13141. * @param {*} value The value to process.
  13142. * @returns {string} Returns the string.
  13143. */
  13144. function baseToString(value) {
  13145. // Exit early for strings to avoid a performance hit in some environments.
  13146. if (typeof value == 'string') {
  13147. return value;
  13148. }
  13149. if (isSymbol(value)) {
  13150. return symbolToString ? symbolToString.call(value) : '';
  13151. }
  13152. var result = value + '';
  13153. return result == '0' && 1 / value == -INFINITY ? '-0' : result;
  13154. }
  13155. /**
  13156. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  13157. *
  13158. * @private
  13159. * @param {Array} array The array to inspect.
  13160. * @param {Function} [iteratee] The iteratee invoked per element.
  13161. * @param {Function} [comparator] The comparator invoked per element.
  13162. * @returns {Array} Returns the new duplicate free array.
  13163. */
  13164. function baseUniq(array, iteratee, comparator) {
  13165. var index = -1,
  13166. includes = arrayIncludes,
  13167. length = array.length,
  13168. isCommon = true,
  13169. result = [],
  13170. seen = result;
  13171. if (comparator) {
  13172. isCommon = false;
  13173. includes = arrayIncludesWith;
  13174. } else if (length >= LARGE_ARRAY_SIZE) {
  13175. var set = iteratee ? null : createSet(array);
  13176. if (set) {
  13177. return setToArray(set);
  13178. }
  13179. isCommon = false;
  13180. includes = cacheHas;
  13181. seen = new SetCache();
  13182. } else {
  13183. seen = iteratee ? [] : result;
  13184. }
  13185. outer: while (++index < length) {
  13186. var value = array[index],
  13187. computed = iteratee ? iteratee(value) : value;
  13188. value = comparator || value !== 0 ? value : 0;
  13189. if (isCommon && computed === computed) {
  13190. var seenIndex = seen.length;
  13191. while (seenIndex--) {
  13192. if (seen[seenIndex] === computed) {
  13193. continue outer;
  13194. }
  13195. }
  13196. if (iteratee) {
  13197. seen.push(computed);
  13198. }
  13199. result.push(value);
  13200. } else if (!includes(seen, computed, comparator)) {
  13201. if (seen !== result) {
  13202. seen.push(computed);
  13203. }
  13204. result.push(value);
  13205. }
  13206. }
  13207. return result;
  13208. }
  13209. /**
  13210. * Casts `value` to a path array if it's not one.
  13211. *
  13212. * @private
  13213. * @param {*} value The value to inspect.
  13214. * @returns {Array} Returns the cast property path array.
  13215. */
  13216. function castPath(value) {
  13217. return isArray(value) ? value : stringToPath(value);
  13218. }
  13219. /**
  13220. * Creates a set object of `values`.
  13221. *
  13222. * @private
  13223. * @param {Array} values The values to add to the set.
  13224. * @returns {Object} Returns the new set.
  13225. */
  13226. var createSet = !(Set && 1 / setToArray(new Set([, -0]))[1] == INFINITY) ? noop : function (values) {
  13227. return new Set(values);
  13228. };
  13229. /**
  13230. * A specialized version of `baseIsEqualDeep` for arrays with support for
  13231. * partial deep comparisons.
  13232. *
  13233. * @private
  13234. * @param {Array} array The array to compare.
  13235. * @param {Array} other The other array to compare.
  13236. * @param {Function} equalFunc The function to determine equivalents of values.
  13237. * @param {Function} customizer The function to customize comparisons.
  13238. * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
  13239. * for more details.
  13240. * @param {Object} stack Tracks traversed `array` and `other` objects.
  13241. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  13242. */
  13243. function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
  13244. var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
  13245. arrLength = array.length,
  13246. othLength = other.length;
  13247. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  13248. return false;
  13249. } // Assume cyclic values are equal.
  13250. var stacked = stack.get(array);
  13251. if (stacked && stack.get(other)) {
  13252. return stacked == other;
  13253. }
  13254. var index = -1,
  13255. result = true,
  13256. seen = bitmask & UNORDERED_COMPARE_FLAG ? new SetCache() : undefined;
  13257. stack.set(array, other);
  13258. stack.set(other, array); // Ignore non-index properties.
  13259. while (++index < arrLength) {
  13260. var arrValue = array[index],
  13261. othValue = other[index];
  13262. if (customizer) {
  13263. var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack);
  13264. }
  13265. if (compared !== undefined) {
  13266. if (compared) {
  13267. continue;
  13268. }
  13269. result = false;
  13270. break;
  13271. } // Recursively compare arrays (susceptible to call stack limits).
  13272. if (seen) {
  13273. if (!arraySome(other, function (othValue, othIndex) {
  13274. if (!seen.has(othIndex) && (arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {
  13275. return seen.add(othIndex);
  13276. }
  13277. })) {
  13278. result = false;
  13279. break;
  13280. }
  13281. } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {
  13282. result = false;
  13283. break;
  13284. }
  13285. }
  13286. stack['delete'](array);
  13287. stack['delete'](other);
  13288. return result;
  13289. }
  13290. /**
  13291. * A specialized version of `baseIsEqualDeep` for comparing objects of
  13292. * the same `toStringTag`.
  13293. *
  13294. * **Note:** This function only supports comparing values with tags of
  13295. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  13296. *
  13297. * @private
  13298. * @param {Object} object The object to compare.
  13299. * @param {Object} other The other object to compare.
  13300. * @param {string} tag The `toStringTag` of the objects to compare.
  13301. * @param {Function} equalFunc The function to determine equivalents of values.
  13302. * @param {Function} customizer The function to customize comparisons.
  13303. * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
  13304. * for more details.
  13305. * @param {Object} stack Tracks traversed `object` and `other` objects.
  13306. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  13307. */
  13308. function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
  13309. switch (tag) {
  13310. case dataViewTag:
  13311. if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
  13312. return false;
  13313. }
  13314. object = object.buffer;
  13315. other = other.buffer;
  13316. case arrayBufferTag:
  13317. if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  13318. return false;
  13319. }
  13320. return true;
  13321. case boolTag:
  13322. case dateTag:
  13323. case numberTag:
  13324. // Coerce booleans to `1` or `0` and dates to milliseconds.
  13325. // Invalid dates are coerced to `NaN`.
  13326. return eq(+object, +other);
  13327. case errorTag:
  13328. return object.name == other.name && object.message == other.message;
  13329. case regexpTag:
  13330. case stringTag:
  13331. // Coerce regexes to strings and treat strings, primitives and objects,
  13332. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  13333. // for more details.
  13334. return object == other + '';
  13335. case mapTag:
  13336. var convert = mapToArray;
  13337. case setTag:
  13338. var isPartial = bitmask & PARTIAL_COMPARE_FLAG;
  13339. convert || (convert = setToArray);
  13340. if (object.size != other.size && !isPartial) {
  13341. return false;
  13342. } // Assume cyclic values are equal.
  13343. var stacked = stack.get(object);
  13344. if (stacked) {
  13345. return stacked == other;
  13346. }
  13347. bitmask |= UNORDERED_COMPARE_FLAG; // Recursively compare objects (susceptible to call stack limits).
  13348. stack.set(object, other);
  13349. var result = equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask, stack);
  13350. stack['delete'](object);
  13351. return result;
  13352. case symbolTag:
  13353. if (symbolValueOf) {
  13354. return symbolValueOf.call(object) == symbolValueOf.call(other);
  13355. }
  13356. }
  13357. return false;
  13358. }
  13359. /**
  13360. * A specialized version of `baseIsEqualDeep` for objects with support for
  13361. * partial deep comparisons.
  13362. *
  13363. * @private
  13364. * @param {Object} object The object to compare.
  13365. * @param {Object} other The other object to compare.
  13366. * @param {Function} equalFunc The function to determine equivalents of values.
  13367. * @param {Function} customizer The function to customize comparisons.
  13368. * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
  13369. * for more details.
  13370. * @param {Object} stack Tracks traversed `object` and `other` objects.
  13371. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  13372. */
  13373. function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {
  13374. var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
  13375. objProps = keys(object),
  13376. objLength = objProps.length,
  13377. othProps = keys(other),
  13378. othLength = othProps.length;
  13379. if (objLength != othLength && !isPartial) {
  13380. return false;
  13381. }
  13382. var index = objLength;
  13383. while (index--) {
  13384. var key = objProps[index];
  13385. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  13386. return false;
  13387. }
  13388. } // Assume cyclic values are equal.
  13389. var stacked = stack.get(object);
  13390. if (stacked && stack.get(other)) {
  13391. return stacked == other;
  13392. }
  13393. var result = true;
  13394. stack.set(object, other);
  13395. stack.set(other, object);
  13396. var skipCtor = isPartial;
  13397. while (++index < objLength) {
  13398. key = objProps[index];
  13399. var objValue = object[key],
  13400. othValue = other[key];
  13401. if (customizer) {
  13402. var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack);
  13403. } // Recursively compare objects (susceptible to call stack limits).
  13404. if (!(compared === undefined ? objValue === othValue || equalFunc(objValue, othValue, customizer, bitmask, stack) : compared)) {
  13405. result = false;
  13406. break;
  13407. }
  13408. skipCtor || (skipCtor = key == 'constructor');
  13409. }
  13410. if (result && !skipCtor) {
  13411. var objCtor = object.constructor,
  13412. othCtor = other.constructor; // Non `Object` object instances with different constructors are not equal.
  13413. if (objCtor != othCtor && 'constructor' in object && 'constructor' in other && !(typeof objCtor == 'function' && objCtor instanceof objCtor && typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  13414. result = false;
  13415. }
  13416. }
  13417. stack['delete'](object);
  13418. stack['delete'](other);
  13419. return result;
  13420. }
  13421. /**
  13422. * Gets the data for `map`.
  13423. *
  13424. * @private
  13425. * @param {Object} map The map to query.
  13426. * @param {string} key The reference key.
  13427. * @returns {*} Returns the map data.
  13428. */
  13429. function getMapData(map, key) {
  13430. var data = map.__data__;
  13431. return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map;
  13432. }
  13433. /**
  13434. * Gets the property names, values, and compare flags of `object`.
  13435. *
  13436. * @private
  13437. * @param {Object} object The object to query.
  13438. * @returns {Array} Returns the match data of `object`.
  13439. */
  13440. function getMatchData(object) {
  13441. var result = keys(object),
  13442. length = result.length;
  13443. while (length--) {
  13444. var key = result[length],
  13445. value = object[key];
  13446. result[length] = [key, value, isStrictComparable(value)];
  13447. }
  13448. return result;
  13449. }
  13450. /**
  13451. * Gets the native function at `key` of `object`.
  13452. *
  13453. * @private
  13454. * @param {Object} object The object to query.
  13455. * @param {string} key The key of the method to get.
  13456. * @returns {*} Returns the function if it's native, else `undefined`.
  13457. */
  13458. function getNative(object, key) {
  13459. var value = getValue(object, key);
  13460. return baseIsNative(value) ? value : undefined;
  13461. }
  13462. /**
  13463. * Gets the `toStringTag` of `value`.
  13464. *
  13465. * @private
  13466. * @param {*} value The value to query.
  13467. * @returns {string} Returns the `toStringTag`.
  13468. */
  13469. var getTag = baseGetTag; // Fallback for data views, maps, sets, and weak maps in IE 11,
  13470. // for data views in Edge < 14, and promises in Node.js.
  13471. if (DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag || Map && getTag(new Map()) != mapTag || Promise && getTag(Promise.resolve()) != promiseTag || Set && getTag(new Set()) != setTag || WeakMap && getTag(new WeakMap()) != weakMapTag) {
  13472. getTag = function getTag(value) {
  13473. var result = objectToString.call(value),
  13474. Ctor = result == objectTag ? value.constructor : undefined,
  13475. ctorString = Ctor ? toSource(Ctor) : undefined;
  13476. if (ctorString) {
  13477. switch (ctorString) {
  13478. case dataViewCtorString:
  13479. return dataViewTag;
  13480. case mapCtorString:
  13481. return mapTag;
  13482. case promiseCtorString:
  13483. return promiseTag;
  13484. case setCtorString:
  13485. return setTag;
  13486. case weakMapCtorString:
  13487. return weakMapTag;
  13488. }
  13489. }
  13490. return result;
  13491. };
  13492. }
  13493. /**
  13494. * Checks if `path` exists on `object`.
  13495. *
  13496. * @private
  13497. * @param {Object} object The object to query.
  13498. * @param {Array|string} path The path to check.
  13499. * @param {Function} hasFunc The function to check properties.
  13500. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  13501. */
  13502. function hasPath(object, path$$1, hasFunc) {
  13503. path$$1 = isKey(path$$1, object) ? [path$$1] : castPath(path$$1);
  13504. var result,
  13505. index = -1,
  13506. length = path$$1.length;
  13507. while (++index < length) {
  13508. var key = toKey(path$$1[index]);
  13509. if (!(result = object != null && hasFunc(object, key))) {
  13510. break;
  13511. }
  13512. object = object[key];
  13513. }
  13514. if (result) {
  13515. return result;
  13516. }
  13517. var length = object ? object.length : 0;
  13518. return !!length && isLength(length) && isIndex(key, length) && (isArray(object) || isArguments(object));
  13519. }
  13520. /**
  13521. * Checks if `value` is a valid array-like index.
  13522. *
  13523. * @private
  13524. * @param {*} value The value to check.
  13525. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  13526. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  13527. */
  13528. function isIndex(value, length) {
  13529. length = length == null ? MAX_SAFE_INTEGER : length;
  13530. return !!length && (typeof value == 'number' || reIsUint.test(value)) && value > -1 && value % 1 == 0 && value < length;
  13531. }
  13532. /**
  13533. * Checks if `value` is a property name and not a property path.
  13534. *
  13535. * @private
  13536. * @param {*} value The value to check.
  13537. * @param {Object} [object] The object to query keys on.
  13538. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  13539. */
  13540. function isKey(value, object) {
  13541. if (isArray(value)) {
  13542. return false;
  13543. }
  13544. var type = typeof value;
  13545. if (type == 'number' || type == 'symbol' || type == 'boolean' || value == null || isSymbol(value)) {
  13546. return true;
  13547. }
  13548. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
  13549. }
  13550. /**
  13551. * Checks if `value` is suitable for use as unique object key.
  13552. *
  13553. * @private
  13554. * @param {*} value The value to check.
  13555. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  13556. */
  13557. function isKeyable(value) {
  13558. var type = typeof value;
  13559. return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null;
  13560. }
  13561. /**
  13562. * Checks if `func` has its source masked.
  13563. *
  13564. * @private
  13565. * @param {Function} func The function to check.
  13566. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  13567. */
  13568. function isMasked(func) {
  13569. return !!maskSrcKey && maskSrcKey in func;
  13570. }
  13571. /**
  13572. * Checks if `value` is likely a prototype object.
  13573. *
  13574. * @private
  13575. * @param {*} value The value to check.
  13576. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  13577. */
  13578. function isPrototype(value) {
  13579. var Ctor = value && value.constructor,
  13580. proto = typeof Ctor == 'function' && Ctor.prototype || objectProto;
  13581. return value === proto;
  13582. }
  13583. /**
  13584. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  13585. *
  13586. * @private
  13587. * @param {*} value The value to check.
  13588. * @returns {boolean} Returns `true` if `value` if suitable for strict
  13589. * equality comparisons, else `false`.
  13590. */
  13591. function isStrictComparable(value) {
  13592. return value === value && !isObject(value);
  13593. }
  13594. /**
  13595. * A specialized version of `matchesProperty` for source values suitable
  13596. * for strict equality comparisons, i.e. `===`.
  13597. *
  13598. * @private
  13599. * @param {string} key The key of the property to get.
  13600. * @param {*} srcValue The value to match.
  13601. * @returns {Function} Returns the new spec function.
  13602. */
  13603. function matchesStrictComparable(key, srcValue) {
  13604. return function (object) {
  13605. if (object == null) {
  13606. return false;
  13607. }
  13608. return object[key] === srcValue && (srcValue !== undefined || key in Object(object));
  13609. };
  13610. }
  13611. /**
  13612. * Converts `string` to a property path array.
  13613. *
  13614. * @private
  13615. * @param {string} string The string to convert.
  13616. * @returns {Array} Returns the property path array.
  13617. */
  13618. var stringToPath = memoize(function (string) {
  13619. string = toString(string);
  13620. var result = [];
  13621. if (reLeadingDot.test(string)) {
  13622. result.push('');
  13623. }
  13624. string.replace(rePropName, function (match, number, quote, string) {
  13625. result.push(quote ? string.replace(reEscapeChar, '$1') : number || match);
  13626. });
  13627. return result;
  13628. });
  13629. /**
  13630. * Converts `value` to a string key if it's not a string or symbol.
  13631. *
  13632. * @private
  13633. * @param {*} value The value to inspect.
  13634. * @returns {string|symbol} Returns the key.
  13635. */
  13636. function toKey(value) {
  13637. if (typeof value == 'string' || isSymbol(value)) {
  13638. return value;
  13639. }
  13640. var result = value + '';
  13641. return result == '0' && 1 / value == -INFINITY ? '-0' : result;
  13642. }
  13643. /**
  13644. * Converts `func` to its source code.
  13645. *
  13646. * @private
  13647. * @param {Function} func The function to process.
  13648. * @returns {string} Returns the source code.
  13649. */
  13650. function toSource(func) {
  13651. if (func != null) {
  13652. try {
  13653. return funcToString.call(func);
  13654. } catch (e) {}
  13655. try {
  13656. return func + '';
  13657. } catch (e) {}
  13658. }
  13659. return '';
  13660. }
  13661. /**
  13662. * This method is like `_.uniq` except that it accepts `iteratee` which is
  13663. * invoked for each element in `array` to generate the criterion by which
  13664. * uniqueness is computed. The iteratee is invoked with one argument: (value).
  13665. *
  13666. * @static
  13667. * @memberOf _
  13668. * @since 4.0.0
  13669. * @category Array
  13670. * @param {Array} array The array to inspect.
  13671. * @param {Function} [iteratee=_.identity]
  13672. * The iteratee invoked per element.
  13673. * @returns {Array} Returns the new duplicate free array.
  13674. * @example
  13675. *
  13676. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  13677. * // => [2.1, 1.2]
  13678. *
  13679. * // The `_.property` iteratee shorthand.
  13680. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  13681. * // => [{ 'x': 1 }, { 'x': 2 }]
  13682. */
  13683. function uniqBy(array, iteratee) {
  13684. return array && array.length ? baseUniq(array, baseIteratee(iteratee, 2)) : [];
  13685. }
  13686. /**
  13687. * Creates a function that memoizes the result of `func`. If `resolver` is
  13688. * provided, it determines the cache key for storing the result based on the
  13689. * arguments provided to the memoized function. By default, the first argument
  13690. * provided to the memoized function is used as the map cache key. The `func`
  13691. * is invoked with the `this` binding of the memoized function.
  13692. *
  13693. * **Note:** The cache is exposed as the `cache` property on the memoized
  13694. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  13695. * constructor with one whose instances implement the
  13696. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  13697. * method interface of `delete`, `get`, `has`, and `set`.
  13698. *
  13699. * @static
  13700. * @memberOf _
  13701. * @since 0.1.0
  13702. * @category Function
  13703. * @param {Function} func The function to have its output memoized.
  13704. * @param {Function} [resolver] The function to resolve the cache key.
  13705. * @returns {Function} Returns the new memoized function.
  13706. * @example
  13707. *
  13708. * var object = { 'a': 1, 'b': 2 };
  13709. * var other = { 'c': 3, 'd': 4 };
  13710. *
  13711. * var values = _.memoize(_.values);
  13712. * values(object);
  13713. * // => [1, 2]
  13714. *
  13715. * values(other);
  13716. * // => [3, 4]
  13717. *
  13718. * object.a = 2;
  13719. * values(object);
  13720. * // => [1, 2]
  13721. *
  13722. * // Modify the result cache.
  13723. * values.cache.set(object, ['a', 'b']);
  13724. * values(object);
  13725. * // => ['a', 'b']
  13726. *
  13727. * // Replace `_.memoize.Cache`.
  13728. * _.memoize.Cache = WeakMap;
  13729. */
  13730. function memoize(func, resolver) {
  13731. if (typeof func != 'function' || resolver && typeof resolver != 'function') {
  13732. throw new TypeError(FUNC_ERROR_TEXT);
  13733. }
  13734. var memoized = function memoized() {
  13735. var args = arguments,
  13736. key = resolver ? resolver.apply(this, args) : args[0],
  13737. cache = memoized.cache;
  13738. if (cache.has(key)) {
  13739. return cache.get(key);
  13740. }
  13741. var result = func.apply(this, args);
  13742. memoized.cache = cache.set(key, result);
  13743. return result;
  13744. };
  13745. memoized.cache = new (memoize.Cache || MapCache)();
  13746. return memoized;
  13747. } // Assign cache to `_.memoize`.
  13748. memoize.Cache = MapCache;
  13749. /**
  13750. * Performs a
  13751. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  13752. * comparison between two values to determine if they are equivalent.
  13753. *
  13754. * @static
  13755. * @memberOf _
  13756. * @since 4.0.0
  13757. * @category Lang
  13758. * @param {*} value The value to compare.
  13759. * @param {*} other The other value to compare.
  13760. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  13761. * @example
  13762. *
  13763. * var object = { 'a': 1 };
  13764. * var other = { 'a': 1 };
  13765. *
  13766. * _.eq(object, object);
  13767. * // => true
  13768. *
  13769. * _.eq(object, other);
  13770. * // => false
  13771. *
  13772. * _.eq('a', 'a');
  13773. * // => true
  13774. *
  13775. * _.eq('a', Object('a'));
  13776. * // => false
  13777. *
  13778. * _.eq(NaN, NaN);
  13779. * // => true
  13780. */
  13781. function eq(value, other) {
  13782. return value === other || value !== value && other !== other;
  13783. }
  13784. /**
  13785. * Checks if `value` is likely an `arguments` object.
  13786. *
  13787. * @static
  13788. * @memberOf _
  13789. * @since 0.1.0
  13790. * @category Lang
  13791. * @param {*} value The value to check.
  13792. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  13793. * else `false`.
  13794. * @example
  13795. *
  13796. * _.isArguments(function() { return arguments; }());
  13797. * // => true
  13798. *
  13799. * _.isArguments([1, 2, 3]);
  13800. * // => false
  13801. */
  13802. function isArguments(value) {
  13803. // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
  13804. return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') && (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
  13805. }
  13806. /**
  13807. * Checks if `value` is classified as an `Array` object.
  13808. *
  13809. * @static
  13810. * @memberOf _
  13811. * @since 0.1.0
  13812. * @category Lang
  13813. * @param {*} value The value to check.
  13814. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  13815. * @example
  13816. *
  13817. * _.isArray([1, 2, 3]);
  13818. * // => true
  13819. *
  13820. * _.isArray(document.body.children);
  13821. * // => false
  13822. *
  13823. * _.isArray('abc');
  13824. * // => false
  13825. *
  13826. * _.isArray(_.noop);
  13827. * // => false
  13828. */
  13829. var isArray = Array.isArray;
  13830. /**
  13831. * Checks if `value` is array-like. A value is considered array-like if it's
  13832. * not a function and has a `value.length` that's an integer greater than or
  13833. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  13834. *
  13835. * @static
  13836. * @memberOf _
  13837. * @since 4.0.0
  13838. * @category Lang
  13839. * @param {*} value The value to check.
  13840. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  13841. * @example
  13842. *
  13843. * _.isArrayLike([1, 2, 3]);
  13844. * // => true
  13845. *
  13846. * _.isArrayLike(document.body.children);
  13847. * // => true
  13848. *
  13849. * _.isArrayLike('abc');
  13850. * // => true
  13851. *
  13852. * _.isArrayLike(_.noop);
  13853. * // => false
  13854. */
  13855. function isArrayLike(value) {
  13856. return value != null && isLength(value.length) && !isFunction(value);
  13857. }
  13858. /**
  13859. * This method is like `_.isArrayLike` except that it also checks if `value`
  13860. * is an object.
  13861. *
  13862. * @static
  13863. * @memberOf _
  13864. * @since 4.0.0
  13865. * @category Lang
  13866. * @param {*} value The value to check.
  13867. * @returns {boolean} Returns `true` if `value` is an array-like object,
  13868. * else `false`.
  13869. * @example
  13870. *
  13871. * _.isArrayLikeObject([1, 2, 3]);
  13872. * // => true
  13873. *
  13874. * _.isArrayLikeObject(document.body.children);
  13875. * // => true
  13876. *
  13877. * _.isArrayLikeObject('abc');
  13878. * // => false
  13879. *
  13880. * _.isArrayLikeObject(_.noop);
  13881. * // => false
  13882. */
  13883. function isArrayLikeObject(value) {
  13884. return isObjectLike(value) && isArrayLike(value);
  13885. }
  13886. /**
  13887. * Checks if `value` is classified as a `Function` object.
  13888. *
  13889. * @static
  13890. * @memberOf _
  13891. * @since 0.1.0
  13892. * @category Lang
  13893. * @param {*} value The value to check.
  13894. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  13895. * @example
  13896. *
  13897. * _.isFunction(_);
  13898. * // => true
  13899. *
  13900. * _.isFunction(/abc/);
  13901. * // => false
  13902. */
  13903. function isFunction(value) {
  13904. // The use of `Object#toString` avoids issues with the `typeof` operator
  13905. // in Safari 8-9 which returns 'object' for typed array and other constructors.
  13906. var tag = isObject(value) ? objectToString.call(value) : '';
  13907. return tag == funcTag || tag == genTag;
  13908. }
  13909. /**
  13910. * Checks if `value` is a valid array-like length.
  13911. *
  13912. * **Note:** This method is loosely based on
  13913. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  13914. *
  13915. * @static
  13916. * @memberOf _
  13917. * @since 4.0.0
  13918. * @category Lang
  13919. * @param {*} value The value to check.
  13920. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  13921. * @example
  13922. *
  13923. * _.isLength(3);
  13924. * // => true
  13925. *
  13926. * _.isLength(Number.MIN_VALUE);
  13927. * // => false
  13928. *
  13929. * _.isLength(Infinity);
  13930. * // => false
  13931. *
  13932. * _.isLength('3');
  13933. * // => false
  13934. */
  13935. function isLength(value) {
  13936. return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  13937. }
  13938. /**
  13939. * Checks if `value` is the
  13940. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  13941. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  13942. *
  13943. * @static
  13944. * @memberOf _
  13945. * @since 0.1.0
  13946. * @category Lang
  13947. * @param {*} value The value to check.
  13948. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  13949. * @example
  13950. *
  13951. * _.isObject({});
  13952. * // => true
  13953. *
  13954. * _.isObject([1, 2, 3]);
  13955. * // => true
  13956. *
  13957. * _.isObject(_.noop);
  13958. * // => true
  13959. *
  13960. * _.isObject(null);
  13961. * // => false
  13962. */
  13963. function isObject(value) {
  13964. var type = typeof value;
  13965. return !!value && (type == 'object' || type == 'function');
  13966. }
  13967. /**
  13968. * Checks if `value` is object-like. A value is object-like if it's not `null`
  13969. * and has a `typeof` result of "object".
  13970. *
  13971. * @static
  13972. * @memberOf _
  13973. * @since 4.0.0
  13974. * @category Lang
  13975. * @param {*} value The value to check.
  13976. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  13977. * @example
  13978. *
  13979. * _.isObjectLike({});
  13980. * // => true
  13981. *
  13982. * _.isObjectLike([1, 2, 3]);
  13983. * // => true
  13984. *
  13985. * _.isObjectLike(_.noop);
  13986. * // => false
  13987. *
  13988. * _.isObjectLike(null);
  13989. * // => false
  13990. */
  13991. function isObjectLike(value) {
  13992. return !!value && typeof value == 'object';
  13993. }
  13994. /**
  13995. * Checks if `value` is classified as a `Symbol` primitive or object.
  13996. *
  13997. * @static
  13998. * @memberOf _
  13999. * @since 4.0.0
  14000. * @category Lang
  14001. * @param {*} value The value to check.
  14002. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  14003. * @example
  14004. *
  14005. * _.isSymbol(Symbol.iterator);
  14006. * // => true
  14007. *
  14008. * _.isSymbol('abc');
  14009. * // => false
  14010. */
  14011. function isSymbol(value) {
  14012. return typeof value == 'symbol' || isObjectLike(value) && objectToString.call(value) == symbolTag;
  14013. }
  14014. /**
  14015. * Checks if `value` is classified as a typed array.
  14016. *
  14017. * @static
  14018. * @memberOf _
  14019. * @since 3.0.0
  14020. * @category Lang
  14021. * @param {*} value The value to check.
  14022. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  14023. * @example
  14024. *
  14025. * _.isTypedArray(new Uint8Array);
  14026. * // => true
  14027. *
  14028. * _.isTypedArray([]);
  14029. * // => false
  14030. */
  14031. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  14032. /**
  14033. * Converts `value` to a string. An empty string is returned for `null`
  14034. * and `undefined` values. The sign of `-0` is preserved.
  14035. *
  14036. * @static
  14037. * @memberOf _
  14038. * @since 4.0.0
  14039. * @category Lang
  14040. * @param {*} value The value to process.
  14041. * @returns {string} Returns the string.
  14042. * @example
  14043. *
  14044. * _.toString(null);
  14045. * // => ''
  14046. *
  14047. * _.toString(-0);
  14048. * // => '-0'
  14049. *
  14050. * _.toString([1, 2, 3]);
  14051. * // => '1,2,3'
  14052. */
  14053. function toString(value) {
  14054. return value == null ? '' : baseToString(value);
  14055. }
  14056. /**
  14057. * Gets the value at `path` of `object`. If the resolved value is
  14058. * `undefined`, the `defaultValue` is returned in its place.
  14059. *
  14060. * @static
  14061. * @memberOf _
  14062. * @since 3.7.0
  14063. * @category Object
  14064. * @param {Object} object The object to query.
  14065. * @param {Array|string} path The path of the property to get.
  14066. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  14067. * @returns {*} Returns the resolved value.
  14068. * @example
  14069. *
  14070. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  14071. *
  14072. * _.get(object, 'a[0].b.c');
  14073. * // => 3
  14074. *
  14075. * _.get(object, ['a', '0', 'b', 'c']);
  14076. * // => 3
  14077. *
  14078. * _.get(object, 'a.b.c', 'default');
  14079. * // => 'default'
  14080. */
  14081. function get(object, path$$1, defaultValue) {
  14082. var result = object == null ? undefined : baseGet(object, path$$1);
  14083. return result === undefined ? defaultValue : result;
  14084. }
  14085. /**
  14086. * Checks if `path` is a direct or inherited property of `object`.
  14087. *
  14088. * @static
  14089. * @memberOf _
  14090. * @since 4.0.0
  14091. * @category Object
  14092. * @param {Object} object The object to query.
  14093. * @param {Array|string} path The path to check.
  14094. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  14095. * @example
  14096. *
  14097. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  14098. *
  14099. * _.hasIn(object, 'a');
  14100. * // => true
  14101. *
  14102. * _.hasIn(object, 'a.b');
  14103. * // => true
  14104. *
  14105. * _.hasIn(object, ['a', 'b']);
  14106. * // => true
  14107. *
  14108. * _.hasIn(object, 'b');
  14109. * // => false
  14110. */
  14111. function hasIn(object, path$$1) {
  14112. return object != null && hasPath(object, path$$1, baseHasIn);
  14113. }
  14114. /**
  14115. * Creates an array of the own enumerable property names of `object`.
  14116. *
  14117. * **Note:** Non-object values are coerced to objects. See the
  14118. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  14119. * for more details.
  14120. *
  14121. * @static
  14122. * @since 0.1.0
  14123. * @memberOf _
  14124. * @category Object
  14125. * @param {Object} object The object to query.
  14126. * @returns {Array} Returns the array of property names.
  14127. * @example
  14128. *
  14129. * function Foo() {
  14130. * this.a = 1;
  14131. * this.b = 2;
  14132. * }
  14133. *
  14134. * Foo.prototype.c = 3;
  14135. *
  14136. * _.keys(new Foo);
  14137. * // => ['a', 'b'] (iteration order is not guaranteed)
  14138. *
  14139. * _.keys('hi');
  14140. * // => ['0', '1']
  14141. */
  14142. function keys(object) {
  14143. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  14144. }
  14145. /**
  14146. * This method returns the first argument it receives.
  14147. *
  14148. * @static
  14149. * @since 0.1.0
  14150. * @memberOf _
  14151. * @category Util
  14152. * @param {*} value Any value.
  14153. * @returns {*} Returns `value`.
  14154. * @example
  14155. *
  14156. * var object = { 'a': 1 };
  14157. *
  14158. * console.log(_.identity(object) === object);
  14159. * // => true
  14160. */
  14161. function identity(value) {
  14162. return value;
  14163. }
  14164. /**
  14165. * This method returns `undefined`.
  14166. *
  14167. * @static
  14168. * @memberOf _
  14169. * @since 2.3.0
  14170. * @category Util
  14171. * @example
  14172. *
  14173. * _.times(2, _.noop);
  14174. * // => [undefined, undefined]
  14175. */
  14176. function noop() {} // No operation performed.
  14177. /**
  14178. * Creates a function that returns the value at `path` of a given object.
  14179. *
  14180. * @static
  14181. * @memberOf _
  14182. * @since 2.4.0
  14183. * @category Util
  14184. * @param {Array|string} path The path of the property to get.
  14185. * @returns {Function} Returns the new accessor function.
  14186. * @example
  14187. *
  14188. * var objects = [
  14189. * { 'a': { 'b': 2 } },
  14190. * { 'a': { 'b': 1 } }
  14191. * ];
  14192. *
  14193. * _.map(objects, _.property('a.b'));
  14194. * // => [2, 1]
  14195. *
  14196. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  14197. * // => [1, 2]
  14198. */
  14199. function property(path$$1) {
  14200. return isKey(path$$1) ? baseProperty(toKey(path$$1)) : basePropertyDeep(path$$1);
  14201. }
  14202. module.exports = uniqBy;
  14203. });
  14204. var PENDING = 'pending';
  14205. var SETTLED = 'settled';
  14206. var FULFILLED = 'fulfilled';
  14207. var REJECTED = 'rejected';
  14208. var NOOP = function NOOP() {};
  14209. var isNode = typeof commonjsGlobal !== 'undefined' && typeof commonjsGlobal.process !== 'undefined' && typeof commonjsGlobal.process.emit === 'function';
  14210. var asyncSetTimer = typeof setImmediate === 'undefined' ? setTimeout : setImmediate;
  14211. var asyncQueue = [];
  14212. var asyncTimer;
  14213. function asyncFlush() {
  14214. // run promise callbacks
  14215. for (var i = 0; i < asyncQueue.length; i++) {
  14216. asyncQueue[i][0](asyncQueue[i][1]);
  14217. } // reset async asyncQueue
  14218. asyncQueue = [];
  14219. asyncTimer = false;
  14220. }
  14221. function asyncCall(callback, arg) {
  14222. asyncQueue.push([callback, arg]);
  14223. if (!asyncTimer) {
  14224. asyncTimer = true;
  14225. asyncSetTimer(asyncFlush, 0);
  14226. }
  14227. }
  14228. function invokeResolver(resolver, promise) {
  14229. function resolvePromise(value) {
  14230. resolve(promise, value);
  14231. }
  14232. function rejectPromise(reason) {
  14233. reject(promise, reason);
  14234. }
  14235. try {
  14236. resolver(resolvePromise, rejectPromise);
  14237. } catch (e) {
  14238. rejectPromise(e);
  14239. }
  14240. }
  14241. function invokeCallback(subscriber) {
  14242. var owner = subscriber.owner;
  14243. var settled = owner._state;
  14244. var value = owner._data;
  14245. var callback = subscriber[settled];
  14246. var promise = subscriber.then;
  14247. if (typeof callback === 'function') {
  14248. settled = FULFILLED;
  14249. try {
  14250. value = callback(value);
  14251. } catch (e) {
  14252. reject(promise, e);
  14253. }
  14254. }
  14255. if (!handleThenable(promise, value)) {
  14256. if (settled === FULFILLED) {
  14257. resolve(promise, value);
  14258. }
  14259. if (settled === REJECTED) {
  14260. reject(promise, value);
  14261. }
  14262. }
  14263. }
  14264. function handleThenable(promise, value) {
  14265. var resolved;
  14266. try {
  14267. if (promise === value) {
  14268. throw new TypeError('A promises callback cannot return that same promise.');
  14269. }
  14270. if (value && (typeof value === 'function' || typeof value === 'object')) {
  14271. // then should be retrieved only once
  14272. var then = value.then;
  14273. if (typeof then === 'function') {
  14274. then.call(value, function (val) {
  14275. if (!resolved) {
  14276. resolved = true;
  14277. if (value === val) {
  14278. fulfill(promise, val);
  14279. } else {
  14280. resolve(promise, val);
  14281. }
  14282. }
  14283. }, function (reason) {
  14284. if (!resolved) {
  14285. resolved = true;
  14286. reject(promise, reason);
  14287. }
  14288. });
  14289. return true;
  14290. }
  14291. }
  14292. } catch (e) {
  14293. if (!resolved) {
  14294. reject(promise, e);
  14295. }
  14296. return true;
  14297. }
  14298. return false;
  14299. }
  14300. function resolve(promise, value) {
  14301. if (promise === value || !handleThenable(promise, value)) {
  14302. fulfill(promise, value);
  14303. }
  14304. }
  14305. function fulfill(promise, value) {
  14306. if (promise._state === PENDING) {
  14307. promise._state = SETTLED;
  14308. promise._data = value;
  14309. asyncCall(publishFulfillment, promise);
  14310. }
  14311. }
  14312. function reject(promise, reason) {
  14313. if (promise._state === PENDING) {
  14314. promise._state = SETTLED;
  14315. promise._data = reason;
  14316. asyncCall(publishRejection, promise);
  14317. }
  14318. }
  14319. function publish(promise) {
  14320. promise._then = promise._then.forEach(invokeCallback);
  14321. }
  14322. function publishFulfillment(promise) {
  14323. promise._state = FULFILLED;
  14324. publish(promise);
  14325. }
  14326. function publishRejection(promise) {
  14327. promise._state = REJECTED;
  14328. publish(promise);
  14329. if (!promise._handled && isNode) {
  14330. commonjsGlobal.process.emit('unhandledRejection', promise._data, promise);
  14331. }
  14332. }
  14333. function notifyRejectionHandled(promise) {
  14334. commonjsGlobal.process.emit('rejectionHandled', promise);
  14335. }
  14336. /**
  14337. * @class
  14338. */
  14339. function Promise$1(resolver) {
  14340. if (typeof resolver !== 'function') {
  14341. throw new TypeError('Promise resolver ' + resolver + ' is not a function');
  14342. }
  14343. if (this instanceof Promise$1 === false) {
  14344. throw new TypeError('Failed to construct \'Promise\': Please use the \'new\' operator, this object constructor cannot be called as a function.');
  14345. }
  14346. this._then = [];
  14347. invokeResolver(resolver, this);
  14348. }
  14349. Promise$1.prototype = {
  14350. constructor: Promise$1,
  14351. _state: PENDING,
  14352. _then: null,
  14353. _data: undefined,
  14354. _handled: false,
  14355. then: function then(onFulfillment, onRejection) {
  14356. var subscriber = {
  14357. owner: this,
  14358. then: new this.constructor(NOOP),
  14359. fulfilled: onFulfillment,
  14360. rejected: onRejection
  14361. };
  14362. if ((onRejection || onFulfillment) && !this._handled) {
  14363. this._handled = true;
  14364. if (this._state === REJECTED && isNode) {
  14365. asyncCall(notifyRejectionHandled, this);
  14366. }
  14367. }
  14368. if (this._state === FULFILLED || this._state === REJECTED) {
  14369. // already resolved, call callback async
  14370. asyncCall(invokeCallback, subscriber);
  14371. } else {
  14372. // subscribe
  14373. this._then.push(subscriber);
  14374. }
  14375. return subscriber.then;
  14376. },
  14377. catch: function _catch(onRejection) {
  14378. return this.then(null, onRejection);
  14379. }
  14380. };
  14381. Promise$1.all = function (promises) {
  14382. if (!Array.isArray(promises)) {
  14383. throw new TypeError('You must pass an array to Promise.all().');
  14384. }
  14385. return new Promise$1(function (resolve, reject) {
  14386. var results = [];
  14387. var remaining = 0;
  14388. function resolver(index) {
  14389. remaining++;
  14390. return function (value) {
  14391. results[index] = value;
  14392. if (! --remaining) {
  14393. resolve(results);
  14394. }
  14395. };
  14396. }
  14397. for (var i = 0, promise; i < promises.length; i++) {
  14398. promise = promises[i];
  14399. if (promise && typeof promise.then === 'function') {
  14400. promise.then(resolver(i), reject);
  14401. } else {
  14402. results[i] = promise;
  14403. }
  14404. }
  14405. if (!remaining) {
  14406. resolve(results);
  14407. }
  14408. });
  14409. };
  14410. Promise$1.race = function (promises) {
  14411. if (!Array.isArray(promises)) {
  14412. throw new TypeError('You must pass an array to Promise.race().');
  14413. }
  14414. return new Promise$1(function (resolve, reject) {
  14415. for (var i = 0, promise; i < promises.length; i++) {
  14416. promise = promises[i];
  14417. if (promise && typeof promise.then === 'function') {
  14418. promise.then(resolve, reject);
  14419. } else {
  14420. resolve(promise);
  14421. }
  14422. }
  14423. });
  14424. };
  14425. Promise$1.resolve = function (value) {
  14426. if (value && typeof value === 'object' && value.constructor === Promise$1) {
  14427. return value;
  14428. }
  14429. return new Promise$1(function (resolve) {
  14430. resolve(value);
  14431. });
  14432. };
  14433. Promise$1.reject = function (reason) {
  14434. return new Promise$1(function (resolve, reject) {
  14435. reject(reason);
  14436. });
  14437. };
  14438. var pinkie = Promise$1;
  14439. var pinkiePromise = typeof Promise === 'function' ? Promise : pinkie;
  14440. var arrayUniq = createCommonjsModule(function (module) {
  14441. 'use strict'; // there's 3 implementations written in increasing order of efficiency
  14442. // 1 - no Set type is defined
  14443. function uniqNoSet(arr) {
  14444. var ret = [];
  14445. for (var i = 0; i < arr.length; i++) {
  14446. if (ret.indexOf(arr[i]) === -1) {
  14447. ret.push(arr[i]);
  14448. }
  14449. }
  14450. return ret;
  14451. } // 2 - a simple Set type is defined
  14452. function uniqSet(arr) {
  14453. var seen = new Set();
  14454. return arr.filter(function (el) {
  14455. if (!seen.has(el)) {
  14456. seen.add(el);
  14457. return true;
  14458. }
  14459. return false;
  14460. });
  14461. } // 3 - a standard Set type is defined and it has a forEach method
  14462. function uniqSetWithForEach(arr) {
  14463. var ret = [];
  14464. new Set(arr).forEach(function (el) {
  14465. ret.push(el);
  14466. });
  14467. return ret;
  14468. } // V8 currently has a broken implementation
  14469. // https://github.com/joyent/node/issues/8449
  14470. function doesForEachActuallyWork() {
  14471. var ret = false;
  14472. new Set([true]).forEach(function (el) {
  14473. ret = el;
  14474. });
  14475. return ret === true;
  14476. }
  14477. if ('Set' in commonjsGlobal) {
  14478. if (typeof Set.prototype.forEach === 'function' && doesForEachActuallyWork()) {
  14479. module.exports = uniqSetWithForEach;
  14480. } else {
  14481. module.exports = uniqSet;
  14482. }
  14483. } else {
  14484. module.exports = uniqNoSet;
  14485. }
  14486. });
  14487. var arrayUnion = function arrayUnion() {
  14488. return arrayUniq([].concat.apply([], arguments));
  14489. };
  14490. /*
  14491. object-assign
  14492. (c) Sindre Sorhus
  14493. @license MIT
  14494. */
  14495. /* eslint-disable no-unused-vars */
  14496. var getOwnPropertySymbols = Object.getOwnPropertySymbols;
  14497. var hasOwnProperty = Object.prototype.hasOwnProperty;
  14498. var propIsEnumerable = Object.prototype.propertyIsEnumerable;
  14499. function toObject(val) {
  14500. if (val === null || val === undefined) {
  14501. throw new TypeError('Object.assign cannot be called with null or undefined');
  14502. }
  14503. return Object(val);
  14504. }
  14505. function shouldUseNative() {
  14506. try {
  14507. if (!Object.assign) {
  14508. return false;
  14509. } // Detect buggy property enumeration order in older V8 versions.
  14510. // https://bugs.chromium.org/p/v8/issues/detail?id=4118
  14511. var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
  14512. test1[5] = 'de';
  14513. if (Object.getOwnPropertyNames(test1)[0] === '5') {
  14514. return false;
  14515. } // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  14516. var test2 = {};
  14517. for (var i = 0; i < 10; i++) {
  14518. test2['_' + String.fromCharCode(i)] = i;
  14519. }
  14520. var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
  14521. return test2[n];
  14522. });
  14523. if (order2.join('') !== '0123456789') {
  14524. return false;
  14525. } // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  14526. var test3 = {};
  14527. 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
  14528. test3[letter] = letter;
  14529. });
  14530. if (Object.keys(Object.assign({}, test3)).join('') !== 'abcdefghijklmnopqrst') {
  14531. return false;
  14532. }
  14533. return true;
  14534. } catch (err) {
  14535. // We don't expect any of the above to throw, but better to be safe.
  14536. return false;
  14537. }
  14538. }
  14539. var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
  14540. var from;
  14541. var to = toObject(target);
  14542. var symbols;
  14543. for (var s = 1; s < arguments.length; s++) {
  14544. from = Object(arguments[s]);
  14545. for (var key in from) {
  14546. if (hasOwnProperty.call(from, key)) {
  14547. to[key] = from[key];
  14548. }
  14549. }
  14550. if (getOwnPropertySymbols) {
  14551. symbols = getOwnPropertySymbols(from);
  14552. for (var i = 0; i < symbols.length; i++) {
  14553. if (propIsEnumerable.call(from, symbols[i])) {
  14554. to[symbols[i]] = from[symbols[i]];
  14555. }
  14556. }
  14557. }
  14558. }
  14559. return to;
  14560. };
  14561. //
  14562. // Permission is hereby granted, free of charge, to any person obtaining a
  14563. // copy of this software and associated documentation files (the
  14564. // "Software"), to deal in the Software without restriction, including
  14565. // without limitation the rights to use, copy, modify, merge, publish,
  14566. // distribute, sublicense, and/or sell copies of the Software, and to permit
  14567. // persons to whom the Software is furnished to do so, subject to the
  14568. // following conditions:
  14569. //
  14570. // The above copyright notice and this permission notice shall be included
  14571. // in all copies or substantial portions of the Software.
  14572. //
  14573. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  14574. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  14575. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  14576. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  14577. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  14578. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  14579. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  14580. var isWindows = process.platform === 'win32'; // JavaScript implementation of realpath, ported from node pre-v6
  14581. var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG);
  14582. function rethrow() {
  14583. // Only enable in debug mode. A backtrace uses ~1000 bytes of heap space and
  14584. // is fairly slow to generate.
  14585. var callback;
  14586. if (DEBUG) {
  14587. var backtrace = new Error();
  14588. callback = debugCallback;
  14589. } else callback = missingCallback;
  14590. return callback;
  14591. function debugCallback(err) {
  14592. if (err) {
  14593. backtrace.message = err.message;
  14594. err = backtrace;
  14595. missingCallback(err);
  14596. }
  14597. }
  14598. function missingCallback(err) {
  14599. if (err) {
  14600. if (process.throwDeprecation) throw err; // Forgot a callback but don't know where? Use NODE_DEBUG=fs
  14601. else if (!process.noDeprecation) {
  14602. var msg = 'fs: missing callback ' + (err.stack || err.message);
  14603. if (process.traceDeprecation) console.trace(msg);else console.error(msg);
  14604. }
  14605. }
  14606. }
  14607. }
  14608. function maybeCallback(cb) {
  14609. return typeof cb === 'function' ? cb : rethrow();
  14610. }
  14611. // result is [base_with_slash, base], e.g. ['somedir/', 'somedir']
  14612. if (isWindows) {
  14613. var nextPartRe = /(.*?)(?:[\/\\]+|$)/g;
  14614. } else {
  14615. var nextPartRe = /(.*?)(?:[\/]+|$)/g;
  14616. } // Regex to find the device root, including trailing slash. E.g. 'c:\\'.
  14617. if (isWindows) {
  14618. var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;
  14619. } else {
  14620. var splitRootRe = /^[\/]*/;
  14621. }
  14622. var realpathSync$1 = function realpathSync(p, cache) {
  14623. // make p is absolute
  14624. p = path.resolve(p);
  14625. if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
  14626. return cache[p];
  14627. }
  14628. var original = p,
  14629. seenLinks = {},
  14630. knownHard = {}; // current character position in p
  14631. var pos; // the partial path so far, including a trailing slash if any
  14632. var current; // the partial path without a trailing slash (except when pointing at a root)
  14633. var base; // the partial path scanned in the previous round, with slash
  14634. var previous;
  14635. start();
  14636. function start() {
  14637. // Skip over roots
  14638. var m = splitRootRe.exec(p);
  14639. pos = m[0].length;
  14640. current = m[0];
  14641. base = m[0];
  14642. previous = ''; // On windows, check that the root exists. On unix there is no need.
  14643. if (isWindows && !knownHard[base]) {
  14644. fs.lstatSync(base);
  14645. knownHard[base] = true;
  14646. }
  14647. } // walk down the path, swapping out linked pathparts for their real
  14648. // values
  14649. // NB: p.length changes.
  14650. while (pos < p.length) {
  14651. // find the next part
  14652. nextPartRe.lastIndex = pos;
  14653. var result = nextPartRe.exec(p);
  14654. previous = current;
  14655. current += result[0];
  14656. base = previous + result[1];
  14657. pos = nextPartRe.lastIndex; // continue if not a symlink
  14658. if (knownHard[base] || cache && cache[base] === base) {
  14659. continue;
  14660. }
  14661. var resolvedLink;
  14662. if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
  14663. // some known symbolic link. no need to stat again.
  14664. resolvedLink = cache[base];
  14665. } else {
  14666. var stat = fs.lstatSync(base);
  14667. if (!stat.isSymbolicLink()) {
  14668. knownHard[base] = true;
  14669. if (cache) cache[base] = base;
  14670. continue;
  14671. } // read the link if it wasn't read before
  14672. // dev/ino always return 0 on windows, so skip the check.
  14673. var linkTarget = null;
  14674. if (!isWindows) {
  14675. var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
  14676. if (seenLinks.hasOwnProperty(id)) {
  14677. linkTarget = seenLinks[id];
  14678. }
  14679. }
  14680. if (linkTarget === null) {
  14681. fs.statSync(base);
  14682. linkTarget = fs.readlinkSync(base);
  14683. }
  14684. resolvedLink = path.resolve(previous, linkTarget); // track this, if given a cache.
  14685. if (cache) cache[base] = resolvedLink;
  14686. if (!isWindows) seenLinks[id] = linkTarget;
  14687. } // resolve the link, then start over
  14688. p = path.resolve(resolvedLink, p.slice(pos));
  14689. start();
  14690. }
  14691. if (cache) cache[original] = p;
  14692. return p;
  14693. };
  14694. var realpath$1 = function realpath(p, cache, cb) {
  14695. if (typeof cb !== 'function') {
  14696. cb = maybeCallback(cache);
  14697. cache = null;
  14698. } // make p is absolute
  14699. p = path.resolve(p);
  14700. if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
  14701. return process.nextTick(cb.bind(null, null, cache[p]));
  14702. }
  14703. var original = p,
  14704. seenLinks = {},
  14705. knownHard = {}; // current character position in p
  14706. var pos; // the partial path so far, including a trailing slash if any
  14707. var current; // the partial path without a trailing slash (except when pointing at a root)
  14708. var base; // the partial path scanned in the previous round, with slash
  14709. var previous;
  14710. start();
  14711. function start() {
  14712. // Skip over roots
  14713. var m = splitRootRe.exec(p);
  14714. pos = m[0].length;
  14715. current = m[0];
  14716. base = m[0];
  14717. previous = ''; // On windows, check that the root exists. On unix there is no need.
  14718. if (isWindows && !knownHard[base]) {
  14719. fs.lstat(base, function (err) {
  14720. if (err) return cb(err);
  14721. knownHard[base] = true;
  14722. LOOP();
  14723. });
  14724. } else {
  14725. process.nextTick(LOOP);
  14726. }
  14727. } // walk down the path, swapping out linked pathparts for their real
  14728. // values
  14729. function LOOP() {
  14730. // stop if scanned past end of path
  14731. if (pos >= p.length) {
  14732. if (cache) cache[original] = p;
  14733. return cb(null, p);
  14734. } // find the next part
  14735. nextPartRe.lastIndex = pos;
  14736. var result = nextPartRe.exec(p);
  14737. previous = current;
  14738. current += result[0];
  14739. base = previous + result[1];
  14740. pos = nextPartRe.lastIndex; // continue if not a symlink
  14741. if (knownHard[base] || cache && cache[base] === base) {
  14742. return process.nextTick(LOOP);
  14743. }
  14744. if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
  14745. // known symbolic link. no need to stat again.
  14746. return gotResolvedLink(cache[base]);
  14747. }
  14748. return fs.lstat(base, gotStat);
  14749. }
  14750. function gotStat(err, stat) {
  14751. if (err) return cb(err); // if not a symlink, skip to the next path part
  14752. if (!stat.isSymbolicLink()) {
  14753. knownHard[base] = true;
  14754. if (cache) cache[base] = base;
  14755. return process.nextTick(LOOP);
  14756. } // stat & read the link if not read before
  14757. // call gotTarget as soon as the link target is known
  14758. // dev/ino always return 0 on windows, so skip the check.
  14759. if (!isWindows) {
  14760. var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
  14761. if (seenLinks.hasOwnProperty(id)) {
  14762. return gotTarget(null, seenLinks[id], base);
  14763. }
  14764. }
  14765. fs.stat(base, function (err) {
  14766. if (err) return cb(err);
  14767. fs.readlink(base, function (err, target) {
  14768. if (!isWindows) seenLinks[id] = target;
  14769. gotTarget(err, target);
  14770. });
  14771. });
  14772. }
  14773. function gotTarget(err, target, base) {
  14774. if (err) return cb(err);
  14775. var resolvedLink = path.resolve(previous, target);
  14776. if (cache) cache[base] = resolvedLink;
  14777. gotResolvedLink(resolvedLink);
  14778. }
  14779. function gotResolvedLink(resolvedLink) {
  14780. // resolve the link, then start over
  14781. p = path.resolve(resolvedLink, p.slice(pos));
  14782. start();
  14783. }
  14784. };
  14785. var old = {
  14786. realpathSync: realpathSync$1,
  14787. realpath: realpath$1
  14788. };
  14789. var fs_realpath = realpath;
  14790. realpath.realpath = realpath;
  14791. realpath.sync = realpathSync;
  14792. realpath.realpathSync = realpathSync;
  14793. realpath.monkeypatch = monkeypatch;
  14794. realpath.unmonkeypatch = unmonkeypatch;
  14795. var origRealpath = fs.realpath;
  14796. var origRealpathSync = fs.realpathSync;
  14797. var version$2 = process.version;
  14798. var ok = /^v[0-5]\./.test(version$2);
  14799. function newError(er) {
  14800. return er && er.syscall === 'realpath' && (er.code === 'ELOOP' || er.code === 'ENOMEM' || er.code === 'ENAMETOOLONG');
  14801. }
  14802. function realpath(p, cache, cb) {
  14803. if (ok) {
  14804. return origRealpath(p, cache, cb);
  14805. }
  14806. if (typeof cache === 'function') {
  14807. cb = cache;
  14808. cache = null;
  14809. }
  14810. origRealpath(p, cache, function (er, result) {
  14811. if (newError(er)) {
  14812. old.realpath(p, cache, cb);
  14813. } else {
  14814. cb(er, result);
  14815. }
  14816. });
  14817. }
  14818. function realpathSync(p, cache) {
  14819. if (ok) {
  14820. return origRealpathSync(p, cache);
  14821. }
  14822. try {
  14823. return origRealpathSync(p, cache);
  14824. } catch (er) {
  14825. if (newError(er)) {
  14826. return old.realpathSync(p, cache);
  14827. } else {
  14828. throw er;
  14829. }
  14830. }
  14831. }
  14832. function monkeypatch() {
  14833. fs.realpath = realpath;
  14834. fs.realpathSync = realpathSync;
  14835. }
  14836. function unmonkeypatch() {
  14837. fs.realpath = origRealpath;
  14838. fs.realpathSync = origRealpathSync;
  14839. }
  14840. var concatMap = function concatMap(xs, fn) {
  14841. var res = [];
  14842. for (var i = 0; i < xs.length; i++) {
  14843. var x = fn(xs[i], i);
  14844. if (isArray(x)) res.push.apply(res, x);else res.push(x);
  14845. }
  14846. return res;
  14847. };
  14848. var isArray = Array.isArray || function (xs) {
  14849. return Object.prototype.toString.call(xs) === '[object Array]';
  14850. };
  14851. var balancedMatch = balanced;
  14852. function balanced(a, b, str) {
  14853. if (a instanceof RegExp) a = maybeMatch(a, str);
  14854. if (b instanceof RegExp) b = maybeMatch(b, str);
  14855. var r = range(a, b, str);
  14856. return r && {
  14857. start: r[0],
  14858. end: r[1],
  14859. pre: str.slice(0, r[0]),
  14860. body: str.slice(r[0] + a.length, r[1]),
  14861. post: str.slice(r[1] + b.length)
  14862. };
  14863. }
  14864. function maybeMatch(reg, str) {
  14865. var m = str.match(reg);
  14866. return m ? m[0] : null;
  14867. }
  14868. balanced.range = range;
  14869. function range(a, b, str) {
  14870. var begs, beg, left, right, result;
  14871. var ai = str.indexOf(a);
  14872. var bi = str.indexOf(b, ai + 1);
  14873. var i = ai;
  14874. if (ai >= 0 && bi > 0) {
  14875. begs = [];
  14876. left = str.length;
  14877. while (i >= 0 && !result) {
  14878. if (i == ai) {
  14879. begs.push(i);
  14880. ai = str.indexOf(a, i + 1);
  14881. } else if (begs.length == 1) {
  14882. result = [begs.pop(), bi];
  14883. } else {
  14884. beg = begs.pop();
  14885. if (beg < left) {
  14886. left = beg;
  14887. right = bi;
  14888. }
  14889. bi = str.indexOf(b, i + 1);
  14890. }
  14891. i = ai < bi && ai >= 0 ? ai : bi;
  14892. }
  14893. if (begs.length) {
  14894. result = [left, right];
  14895. }
  14896. }
  14897. return result;
  14898. }
  14899. var braceExpansion = expandTop;
  14900. var escSlash = '\0SLASH' + Math.random() + '\0';
  14901. var escOpen = '\0OPEN' + Math.random() + '\0';
  14902. var escClose = '\0CLOSE' + Math.random() + '\0';
  14903. var escComma = '\0COMMA' + Math.random() + '\0';
  14904. var escPeriod = '\0PERIOD' + Math.random() + '\0';
  14905. function numeric(str) {
  14906. return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
  14907. }
  14908. function escapeBraces(str) {
  14909. return str.split('\\\\').join(escSlash).split('\\{').join(escOpen).split('\\}').join(escClose).split('\\,').join(escComma).split('\\.').join(escPeriod);
  14910. }
  14911. function unescapeBraces(str) {
  14912. return str.split(escSlash).join('\\').split(escOpen).join('{').split(escClose).join('}').split(escComma).join(',').split(escPeriod).join('.');
  14913. } // Basically just str.split(","), but handling cases
  14914. // where we have nested braced sections, which should be
  14915. // treated as individual members, like {a,{b,c},d}
  14916. function parseCommaParts(str) {
  14917. if (!str) return [''];
  14918. var parts = [];
  14919. var m = balancedMatch('{', '}', str);
  14920. if (!m) return str.split(',');
  14921. var pre = m.pre;
  14922. var body = m.body;
  14923. var post = m.post;
  14924. var p = pre.split(',');
  14925. p[p.length - 1] += '{' + body + '}';
  14926. var postParts = parseCommaParts(post);
  14927. if (post.length) {
  14928. p[p.length - 1] += postParts.shift();
  14929. p.push.apply(p, postParts);
  14930. }
  14931. parts.push.apply(parts, p);
  14932. return parts;
  14933. }
  14934. function expandTop(str) {
  14935. if (!str) return []; // I don't know why Bash 4.3 does this, but it does.
  14936. // Anything starting with {} will have the first two bytes preserved
  14937. // but *only* at the top level, so {},a}b will not expand to anything,
  14938. // but a{},b}c will be expanded to [a}c,abc].
  14939. // One could argue that this is a bug in Bash, but since the goal of
  14940. // this module is to match Bash's rules, we escape a leading {}
  14941. if (str.substr(0, 2) === '{}') {
  14942. str = '\\{\\}' + str.substr(2);
  14943. }
  14944. return expand(escapeBraces(str), true).map(unescapeBraces);
  14945. }
  14946. function embrace(str) {
  14947. return '{' + str + '}';
  14948. }
  14949. function isPadded(el) {
  14950. return /^-?0\d/.test(el);
  14951. }
  14952. function lte(i, y) {
  14953. return i <= y;
  14954. }
  14955. function gte(i, y) {
  14956. return i >= y;
  14957. }
  14958. function expand(str, isTop) {
  14959. var expansions = [];
  14960. var m = balancedMatch('{', '}', str);
  14961. if (!m || /\$$/.test(m.pre)) return [str];
  14962. var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
  14963. var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
  14964. var isSequence = isNumericSequence || isAlphaSequence;
  14965. var isOptions = m.body.indexOf(',') >= 0;
  14966. if (!isSequence && !isOptions) {
  14967. // {a},b}
  14968. if (m.post.match(/,.*\}/)) {
  14969. str = m.pre + '{' + m.body + escClose + m.post;
  14970. return expand(str);
  14971. }
  14972. return [str];
  14973. }
  14974. var n;
  14975. if (isSequence) {
  14976. n = m.body.split(/\.\./);
  14977. } else {
  14978. n = parseCommaParts(m.body);
  14979. if (n.length === 1) {
  14980. // x{{a,b}}y ==> x{a}y x{b}y
  14981. n = expand(n[0], false).map(embrace);
  14982. if (n.length === 1) {
  14983. var post = m.post.length ? expand(m.post, false) : [''];
  14984. return post.map(function (p) {
  14985. return m.pre + n[0] + p;
  14986. });
  14987. }
  14988. }
  14989. } // at this point, n is the parts, and we know it's not a comma set
  14990. // with a single entry.
  14991. // no need to expand pre, since it is guaranteed to be free of brace-sets
  14992. var pre = m.pre;
  14993. var post = m.post.length ? expand(m.post, false) : [''];
  14994. var N;
  14995. if (isSequence) {
  14996. var x = numeric(n[0]);
  14997. var y = numeric(n[1]);
  14998. var width = Math.max(n[0].length, n[1].length);
  14999. var incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1;
  15000. var test = lte;
  15001. var reverse = y < x;
  15002. if (reverse) {
  15003. incr *= -1;
  15004. test = gte;
  15005. }
  15006. var pad = n.some(isPadded);
  15007. N = [];
  15008. for (var i = x; test(i, y); i += incr) {
  15009. var c;
  15010. if (isAlphaSequence) {
  15011. c = String.fromCharCode(i);
  15012. if (c === '\\') c = '';
  15013. } else {
  15014. c = String(i);
  15015. if (pad) {
  15016. var need = width - c.length;
  15017. if (need > 0) {
  15018. var z = new Array(need + 1).join('0');
  15019. if (i < 0) c = '-' + z + c.slice(1);else c = z + c;
  15020. }
  15021. }
  15022. }
  15023. N.push(c);
  15024. }
  15025. } else {
  15026. N = concatMap(n, function (el) {
  15027. return expand(el, false);
  15028. });
  15029. }
  15030. for (var j = 0; j < N.length; j++) {
  15031. for (var k = 0; k < post.length; k++) {
  15032. var expansion = pre + N[j] + post[k];
  15033. if (!isTop || isSequence || expansion) expansions.push(expansion);
  15034. }
  15035. }
  15036. return expansions;
  15037. }
  15038. var minimatch_1 = minimatch;
  15039. minimatch.Minimatch = Minimatch$1;
  15040. var path$2 = {
  15041. sep: '/'
  15042. };
  15043. try {
  15044. path$2 = path;
  15045. } catch (er) {}
  15046. var GLOBSTAR = minimatch.GLOBSTAR = Minimatch$1.GLOBSTAR = {};
  15047. var plTypes = {
  15048. '!': {
  15049. open: '(?:(?!(?:',
  15050. close: '))[^/]*?)'
  15051. },
  15052. '?': {
  15053. open: '(?:',
  15054. close: ')?'
  15055. },
  15056. '+': {
  15057. open: '(?:',
  15058. close: ')+'
  15059. },
  15060. '*': {
  15061. open: '(?:',
  15062. close: ')*'
  15063. },
  15064. '@': {
  15065. open: '(?:',
  15066. close: ')'
  15067. } // any single thing other than /
  15068. // don't need to escape / when using new RegExp()
  15069. };
  15070. var qmark = '[^/]'; // * => any number of characters
  15071. var star = qmark + '*?'; // ** when dots are allowed. Anything goes, except .. and .
  15072. // not (^ or / followed by one or two dots followed by $ or /),
  15073. // followed by anything, any number of times.
  15074. var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?'; // not a ^ or / followed by a dot,
  15075. // followed by anything, any number of times.
  15076. var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?'; // characters that need to be escaped in RegExp.
  15077. var reSpecials = charSet('().*{}+?[]^$\\!'); // "abc" -> { a:true, b:true, c:true }
  15078. function charSet(s) {
  15079. return s.split('').reduce(function (set, c) {
  15080. set[c] = true;
  15081. return set;
  15082. }, {});
  15083. } // normalizes slashes.
  15084. var slashSplit = /\/+/;
  15085. minimatch.filter = filter$1;
  15086. function filter$1(pattern, options) {
  15087. options = options || {};
  15088. return function (p, i, list) {
  15089. return minimatch(p, pattern, options);
  15090. };
  15091. }
  15092. function ext(a, b) {
  15093. a = a || {};
  15094. b = b || {};
  15095. var t = {};
  15096. Object.keys(b).forEach(function (k) {
  15097. t[k] = b[k];
  15098. });
  15099. Object.keys(a).forEach(function (k) {
  15100. t[k] = a[k];
  15101. });
  15102. return t;
  15103. }
  15104. minimatch.defaults = function (def) {
  15105. if (!def || !Object.keys(def).length) return minimatch;
  15106. var orig = minimatch;
  15107. var m = function minimatch(p, pattern, options) {
  15108. return orig.minimatch(p, pattern, ext(def, options));
  15109. };
  15110. m.Minimatch = function Minimatch(pattern, options) {
  15111. return new orig.Minimatch(pattern, ext(def, options));
  15112. };
  15113. return m;
  15114. };
  15115. Minimatch$1.defaults = function (def) {
  15116. if (!def || !Object.keys(def).length) return Minimatch$1;
  15117. return minimatch.defaults(def).Minimatch;
  15118. };
  15119. function minimatch(p, pattern, options) {
  15120. if (typeof pattern !== 'string') {
  15121. throw new TypeError('glob pattern string required');
  15122. }
  15123. if (!options) options = {}; // shortcut: comments match nothing.
  15124. if (!options.nocomment && pattern.charAt(0) === '#') {
  15125. return false;
  15126. } // "" only matches ""
  15127. if (pattern.trim() === '') return p === '';
  15128. return new Minimatch$1(pattern, options).match(p);
  15129. }
  15130. function Minimatch$1(pattern, options) {
  15131. if (!(this instanceof Minimatch$1)) {
  15132. return new Minimatch$1(pattern, options);
  15133. }
  15134. if (typeof pattern !== 'string') {
  15135. throw new TypeError('glob pattern string required');
  15136. }
  15137. if (!options) options = {};
  15138. pattern = pattern.trim(); // windows support: need to use /, not \
  15139. if (path$2.sep !== '/') {
  15140. pattern = pattern.split(path$2.sep).join('/');
  15141. }
  15142. this.options = options;
  15143. this.set = [];
  15144. this.pattern = pattern;
  15145. this.regexp = null;
  15146. this.negate = false;
  15147. this.comment = false;
  15148. this.empty = false; // make the set of regexps etc.
  15149. this.make();
  15150. }
  15151. Minimatch$1.prototype.debug = function () {};
  15152. Minimatch$1.prototype.make = make;
  15153. function make() {
  15154. // don't do it more than once.
  15155. if (this._made) return;
  15156. var pattern = this.pattern;
  15157. var options = this.options; // empty patterns and comments match nothing.
  15158. if (!options.nocomment && pattern.charAt(0) === '#') {
  15159. this.comment = true;
  15160. return;
  15161. }
  15162. if (!pattern) {
  15163. this.empty = true;
  15164. return;
  15165. } // step 1: figure out negation, etc.
  15166. this.parseNegate(); // step 2: expand braces
  15167. var set = this.globSet = this.braceExpand();
  15168. if (options.debug) this.debug = console.error;
  15169. this.debug(this.pattern, set); // step 3: now we have a set, so turn each one into a series of path-portion
  15170. // matching patterns.
  15171. // These will be regexps, except in the case of "**", which is
  15172. // set to the GLOBSTAR object for globstar behavior,
  15173. // and will not contain any / characters
  15174. set = this.globParts = set.map(function (s) {
  15175. return s.split(slashSplit);
  15176. });
  15177. this.debug(this.pattern, set); // glob --> regexps
  15178. set = set.map(function (s, si, set) {
  15179. return s.map(this.parse, this);
  15180. }, this);
  15181. this.debug(this.pattern, set); // filter out everything that didn't compile properly.
  15182. set = set.filter(function (s) {
  15183. return s.indexOf(false) === -1;
  15184. });
  15185. this.debug(this.pattern, set);
  15186. this.set = set;
  15187. }
  15188. Minimatch$1.prototype.parseNegate = parseNegate;
  15189. function parseNegate() {
  15190. var pattern = this.pattern;
  15191. var negate = false;
  15192. var options = this.options;
  15193. var negateOffset = 0;
  15194. if (options.nonegate) return;
  15195. for (var i = 0, l = pattern.length; i < l && pattern.charAt(i) === '!'; i++) {
  15196. negate = !negate;
  15197. negateOffset++;
  15198. }
  15199. if (negateOffset) this.pattern = pattern.substr(negateOffset);
  15200. this.negate = negate;
  15201. } // Brace expansion:
  15202. // a{b,c}d -> abd acd
  15203. // a{b,}c -> abc ac
  15204. // a{0..3}d -> a0d a1d a2d a3d
  15205. // a{b,c{d,e}f}g -> abg acdfg acefg
  15206. // a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg
  15207. //
  15208. // Invalid sets are not expanded.
  15209. // a{2..}b -> a{2..}b
  15210. // a{b}c -> a{b}c
  15211. minimatch.braceExpand = function (pattern, options) {
  15212. return braceExpand(pattern, options);
  15213. };
  15214. Minimatch$1.prototype.braceExpand = braceExpand;
  15215. function braceExpand(pattern, options) {
  15216. if (!options) {
  15217. if (this instanceof Minimatch$1) {
  15218. options = this.options;
  15219. } else {
  15220. options = {};
  15221. }
  15222. }
  15223. pattern = typeof pattern === 'undefined' ? this.pattern : pattern;
  15224. if (typeof pattern === 'undefined') {
  15225. throw new TypeError('undefined pattern');
  15226. }
  15227. if (options.nobrace || !pattern.match(/\{.*\}/)) {
  15228. // shortcut. no need to expand.
  15229. return [pattern];
  15230. }
  15231. return braceExpansion(pattern);
  15232. } // parse a component of the expanded set.
  15233. // At this point, no pattern may contain "/" in it
  15234. // so we're going to return a 2d array, where each entry is the full
  15235. // pattern, split on '/', and then turned into a regular expression.
  15236. // A regexp is made at the end which joins each array with an
  15237. // escaped /, and another full one which joins each regexp with |.
  15238. //
  15239. // Following the lead of Bash 4.1, note that "**" only has special meaning
  15240. // when it is the *only* thing in a path portion. Otherwise, any series
  15241. // of * is equivalent to a single *. Globstar behavior is enabled by
  15242. // default, and can be disabled by setting options.noglobstar.
  15243. Minimatch$1.prototype.parse = parse$3;
  15244. var SUBPARSE = {};
  15245. function parse$3(pattern, isSub) {
  15246. if (pattern.length > 1024 * 64) {
  15247. throw new TypeError('pattern is too long');
  15248. }
  15249. var options = this.options; // shortcuts
  15250. if (!options.noglobstar && pattern === '**') return GLOBSTAR;
  15251. if (pattern === '') return '';
  15252. var re = '';
  15253. var hasMagic = !!options.nocase;
  15254. var escaping = false; // ? => one single character
  15255. var patternListStack = [];
  15256. var negativeLists = [];
  15257. var stateChar;
  15258. var inClass = false;
  15259. var reClassStart = -1;
  15260. var classStart = -1; // . and .. never match anything that doesn't start with .,
  15261. // even when options.dot is set.
  15262. var patternStart = pattern.charAt(0) === '.' ? '' // anything
  15263. // not (start or / followed by . or .. followed by / or end)
  15264. : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))' : '(?!\\.)';
  15265. var self = this;
  15266. function clearStateChar() {
  15267. if (stateChar) {
  15268. // we had some state-tracking character
  15269. // that wasn't consumed by this pass.
  15270. switch (stateChar) {
  15271. case '*':
  15272. re += star;
  15273. hasMagic = true;
  15274. break;
  15275. case '?':
  15276. re += qmark;
  15277. hasMagic = true;
  15278. break;
  15279. default:
  15280. re += '\\' + stateChar;
  15281. break;
  15282. }
  15283. self.debug('clearStateChar %j %j', stateChar, re);
  15284. stateChar = false;
  15285. }
  15286. }
  15287. for (var i = 0, len = pattern.length, c; i < len && (c = pattern.charAt(i)); i++) {
  15288. this.debug('%s\t%s %s %j', pattern, i, re, c); // skip over any that are escaped.
  15289. if (escaping && reSpecials[c]) {
  15290. re += '\\' + c;
  15291. escaping = false;
  15292. continue;
  15293. }
  15294. switch (c) {
  15295. case '/':
  15296. // completely not allowed, even escaped.
  15297. // Should already be path-split by now.
  15298. return false;
  15299. case '\\':
  15300. clearStateChar();
  15301. escaping = true;
  15302. continue;
  15303. // the various stateChar values
  15304. // for the "extglob" stuff.
  15305. case '?':
  15306. case '*':
  15307. case '+':
  15308. case '@':
  15309. case '!':
  15310. this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c); // all of those are literals inside a class, except that
  15311. // the glob [!a] means [^a] in regexp
  15312. if (inClass) {
  15313. this.debug(' in class');
  15314. if (c === '!' && i === classStart + 1) c = '^';
  15315. re += c;
  15316. continue;
  15317. } // if we already have a stateChar, then it means
  15318. // that there was something like ** or +? in there.
  15319. // Handle the stateChar, then proceed with this one.
  15320. self.debug('call clearStateChar %j', stateChar);
  15321. clearStateChar();
  15322. stateChar = c; // if extglob is disabled, then +(asdf|foo) isn't a thing.
  15323. // just clear the statechar *now*, rather than even diving into
  15324. // the patternList stuff.
  15325. if (options.noext) clearStateChar();
  15326. continue;
  15327. case '(':
  15328. if (inClass) {
  15329. re += '(';
  15330. continue;
  15331. }
  15332. if (!stateChar) {
  15333. re += '\\(';
  15334. continue;
  15335. }
  15336. patternListStack.push({
  15337. type: stateChar,
  15338. start: i - 1,
  15339. reStart: re.length,
  15340. open: plTypes[stateChar].open,
  15341. close: plTypes[stateChar].close
  15342. }); // negation is (?:(?!js)[^/]*)
  15343. re += stateChar === '!' ? '(?:(?!(?:' : '(?:';
  15344. this.debug('plType %j %j', stateChar, re);
  15345. stateChar = false;
  15346. continue;
  15347. case ')':
  15348. if (inClass || !patternListStack.length) {
  15349. re += '\\)';
  15350. continue;
  15351. }
  15352. clearStateChar();
  15353. hasMagic = true;
  15354. var pl = patternListStack.pop(); // negation is (?:(?!js)[^/]*)
  15355. // The others are (?:<pattern>)<type>
  15356. re += pl.close;
  15357. if (pl.type === '!') {
  15358. negativeLists.push(pl);
  15359. }
  15360. pl.reEnd = re.length;
  15361. continue;
  15362. case '|':
  15363. if (inClass || !patternListStack.length || escaping) {
  15364. re += '\\|';
  15365. escaping = false;
  15366. continue;
  15367. }
  15368. clearStateChar();
  15369. re += '|';
  15370. continue;
  15371. // these are mostly the same in regexp and glob
  15372. case '[':
  15373. // swallow any state-tracking char before the [
  15374. clearStateChar();
  15375. if (inClass) {
  15376. re += '\\' + c;
  15377. continue;
  15378. }
  15379. inClass = true;
  15380. classStart = i;
  15381. reClassStart = re.length;
  15382. re += c;
  15383. continue;
  15384. case ']':
  15385. // a right bracket shall lose its special
  15386. // meaning and represent itself in
  15387. // a bracket expression if it occurs
  15388. // first in the list. -- POSIX.2 2.8.3.2
  15389. if (i === classStart + 1 || !inClass) {
  15390. re += '\\' + c;
  15391. escaping = false;
  15392. continue;
  15393. } // handle the case where we left a class open.
  15394. // "[z-a]" is valid, equivalent to "\[z-a\]"
  15395. if (inClass) {
  15396. // split where the last [ was, make sure we don't have
  15397. // an invalid re. if so, re-walk the contents of the
  15398. // would-be class to re-translate any characters that
  15399. // were passed through as-is
  15400. // TODO: It would probably be faster to determine this
  15401. // without a try/catch and a new RegExp, but it's tricky
  15402. // to do safely. For now, this is safe and works.
  15403. var cs = pattern.substring(classStart + 1, i);
  15404. try {
  15405. RegExp('[' + cs + ']');
  15406. } catch (er) {
  15407. // not a valid class!
  15408. var sp = this.parse(cs, SUBPARSE);
  15409. re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]';
  15410. hasMagic = hasMagic || sp[1];
  15411. inClass = false;
  15412. continue;
  15413. }
  15414. } // finish up the class.
  15415. hasMagic = true;
  15416. inClass = false;
  15417. re += c;
  15418. continue;
  15419. default:
  15420. // swallow any state char that wasn't consumed
  15421. clearStateChar();
  15422. if (escaping) {
  15423. // no need
  15424. escaping = false;
  15425. } else if (reSpecials[c] && !(c === '^' && inClass)) {
  15426. re += '\\';
  15427. }
  15428. re += c;
  15429. } // switch
  15430. } // for
  15431. // handle the case where we left a class open.
  15432. // "[abc" is valid, equivalent to "\[abc"
  15433. if (inClass) {
  15434. // split where the last [ was, and escape it
  15435. // this is a huge pita. We now have to re-walk
  15436. // the contents of the would-be class to re-translate
  15437. // any characters that were passed through as-is
  15438. cs = pattern.substr(classStart + 1);
  15439. sp = this.parse(cs, SUBPARSE);
  15440. re = re.substr(0, reClassStart) + '\\[' + sp[0];
  15441. hasMagic = hasMagic || sp[1];
  15442. } // handle the case where we had a +( thing at the *end*
  15443. // of the pattern.
  15444. // each pattern list stack adds 3 chars, and we need to go through
  15445. // and escape any | chars that were passed through as-is for the regexp.
  15446. // Go through and escape them, taking care not to double-escape any
  15447. // | chars that were already escaped.
  15448. for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) {
  15449. var tail = re.slice(pl.reStart + pl.open.length);
  15450. this.debug('setting tail', re, pl); // maybe some even number of \, then maybe 1 \, followed by a |
  15451. tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, function (_, $1, $2) {
  15452. if (!$2) {
  15453. // the | isn't already escaped, so escape it.
  15454. $2 = '\\';
  15455. } // need to escape all those slashes *again*, without escaping the
  15456. // one that we need for escaping the | character. As it works out,
  15457. // escaping an even number of slashes can be done by simply repeating
  15458. // it exactly after itself. That's why this trick works.
  15459. //
  15460. // I am sorry that you have to see this.
  15461. return $1 + $1 + $2 + '|';
  15462. });
  15463. this.debug('tail=%j\n %s', tail, tail, pl, re);
  15464. var t = pl.type === '*' ? star : pl.type === '?' ? qmark : '\\' + pl.type;
  15465. hasMagic = true;
  15466. re = re.slice(0, pl.reStart) + t + '\\(' + tail;
  15467. } // handle trailing things that only matter at the very end.
  15468. clearStateChar();
  15469. if (escaping) {
  15470. // trailing \\
  15471. re += '\\\\';
  15472. } // only need to apply the nodot start if the re starts with
  15473. // something that could conceivably capture a dot
  15474. var addPatternStart = false;
  15475. switch (re.charAt(0)) {
  15476. case '.':
  15477. case '[':
  15478. case '(':
  15479. addPatternStart = true;
  15480. } // Hack to work around lack of negative lookbehind in JS
  15481. // A pattern like: *.!(x).!(y|z) needs to ensure that a name
  15482. // like 'a.xyz.yz' doesn't match. So, the first negative
  15483. // lookahead, has to look ALL the way ahead, to the end of
  15484. // the pattern.
  15485. for (var n = negativeLists.length - 1; n > -1; n--) {
  15486. var nl = negativeLists[n];
  15487. var nlBefore = re.slice(0, nl.reStart);
  15488. var nlFirst = re.slice(nl.reStart, nl.reEnd - 8);
  15489. var nlLast = re.slice(nl.reEnd - 8, nl.reEnd);
  15490. var nlAfter = re.slice(nl.reEnd);
  15491. nlLast += nlAfter; // Handle nested stuff like *(*.js|!(*.json)), where open parens
  15492. // mean that we should *not* include the ) in the bit that is considered
  15493. // "after" the negated section.
  15494. var openParensBefore = nlBefore.split('(').length - 1;
  15495. var cleanAfter = nlAfter;
  15496. for (i = 0; i < openParensBefore; i++) {
  15497. cleanAfter = cleanAfter.replace(/\)[+*?]?/, '');
  15498. }
  15499. nlAfter = cleanAfter;
  15500. var dollar = '';
  15501. if (nlAfter === '' && isSub !== SUBPARSE) {
  15502. dollar = '$';
  15503. }
  15504. var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast;
  15505. re = newRe;
  15506. } // if the re is not "" at this point, then we need to make sure
  15507. // it doesn't match against an empty path part.
  15508. // Otherwise a/* will match a/, which it should not.
  15509. if (re !== '' && hasMagic) {
  15510. re = '(?=.)' + re;
  15511. }
  15512. if (addPatternStart) {
  15513. re = patternStart + re;
  15514. } // parsing just a piece of a larger pattern.
  15515. if (isSub === SUBPARSE) {
  15516. return [re, hasMagic];
  15517. } // skip the regexp for non-magical patterns
  15518. // unescape anything in it, though, so that it'll be
  15519. // an exact match against a file etc.
  15520. if (!hasMagic) {
  15521. return globUnescape(pattern);
  15522. }
  15523. var flags = options.nocase ? 'i' : '';
  15524. try {
  15525. var regExp = new RegExp('^' + re + '$', flags);
  15526. } catch (er) {
  15527. // If it was an invalid regular expression, then it can't match
  15528. // anything. This trick looks for a character after the end of
  15529. // the string, which is of course impossible, except in multi-line
  15530. // mode, but it's not a /m regex.
  15531. return new RegExp('$.');
  15532. }
  15533. regExp._glob = pattern;
  15534. regExp._src = re;
  15535. return regExp;
  15536. }
  15537. minimatch.makeRe = function (pattern, options) {
  15538. return new Minimatch$1(pattern, options || {}).makeRe();
  15539. };
  15540. Minimatch$1.prototype.makeRe = makeRe;
  15541. function makeRe() {
  15542. if (this.regexp || this.regexp === false) return this.regexp; // at this point, this.set is a 2d array of partial
  15543. // pattern strings, or "**".
  15544. //
  15545. // It's better to use .match(). This function shouldn't
  15546. // be used, really, but it's pretty convenient sometimes,
  15547. // when you just want to work with a regex.
  15548. var set = this.set;
  15549. if (!set.length) {
  15550. this.regexp = false;
  15551. return this.regexp;
  15552. }
  15553. var options = this.options;
  15554. var twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot;
  15555. var flags = options.nocase ? 'i' : '';
  15556. var re = set.map(function (pattern) {
  15557. return pattern.map(function (p) {
  15558. return p === GLOBSTAR ? twoStar : typeof p === 'string' ? regExpEscape(p) : p._src;
  15559. }).join('\\\/');
  15560. }).join('|'); // must match entire pattern
  15561. // ending in a * or ** will make it less strict.
  15562. re = '^(?:' + re + ')$'; // can match anything, as long as it's not this.
  15563. if (this.negate) re = '^(?!' + re + ').*$';
  15564. try {
  15565. this.regexp = new RegExp(re, flags);
  15566. } catch (ex) {
  15567. this.regexp = false;
  15568. }
  15569. return this.regexp;
  15570. }
  15571. minimatch.match = function (list, pattern, options) {
  15572. options = options || {};
  15573. var mm = new Minimatch$1(pattern, options);
  15574. list = list.filter(function (f) {
  15575. return mm.match(f);
  15576. });
  15577. if (mm.options.nonull && !list.length) {
  15578. list.push(pattern);
  15579. }
  15580. return list;
  15581. };
  15582. Minimatch$1.prototype.match = match;
  15583. function match(f, partial) {
  15584. this.debug('match', f, this.pattern); // short-circuit in the case of busted things.
  15585. // comments, etc.
  15586. if (this.comment) return false;
  15587. if (this.empty) return f === '';
  15588. if (f === '/' && partial) return true;
  15589. var options = this.options; // windows: need to use /, not \
  15590. if (path$2.sep !== '/') {
  15591. f = f.split(path$2.sep).join('/');
  15592. } // treat the test path as a set of pathparts.
  15593. f = f.split(slashSplit);
  15594. this.debug(this.pattern, 'split', f); // just ONE of the pattern sets in this.set needs to match
  15595. // in order for it to be valid. If negating, then just one
  15596. // match means that we have failed.
  15597. // Either way, return on the first hit.
  15598. var set = this.set;
  15599. this.debug(this.pattern, 'set', set); // Find the basename of the path by looking for the last non-empty segment
  15600. var filename;
  15601. var i;
  15602. for (i = f.length - 1; i >= 0; i--) {
  15603. filename = f[i];
  15604. if (filename) break;
  15605. }
  15606. for (i = 0; i < set.length; i++) {
  15607. var pattern = set[i];
  15608. var file = f;
  15609. if (options.matchBase && pattern.length === 1) {
  15610. file = [filename];
  15611. }
  15612. var hit = this.matchOne(file, pattern, partial);
  15613. if (hit) {
  15614. if (options.flipNegate) return true;
  15615. return !this.negate;
  15616. }
  15617. } // didn't get any hits. this is success if it's a negative
  15618. // pattern, failure otherwise.
  15619. if (options.flipNegate) return false;
  15620. return this.negate;
  15621. } // set partial to true to test if, for example,
  15622. // "/a/b" matches the start of "/*/b/*/d"
  15623. // Partial means, if you run out of file before you run
  15624. // out of pattern, then that's fine, as long as all
  15625. // the parts match.
  15626. Minimatch$1.prototype.matchOne = function (file, pattern, partial) {
  15627. var options = this.options;
  15628. this.debug('matchOne', {
  15629. 'this': this,
  15630. file: file,
  15631. pattern: pattern
  15632. });
  15633. this.debug('matchOne', file.length, pattern.length);
  15634. for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
  15635. this.debug('matchOne loop');
  15636. var p = pattern[pi];
  15637. var f = file[fi];
  15638. this.debug(pattern, p, f); // should be impossible.
  15639. // some invalid regexp stuff in the set.
  15640. if (p === false) return false;
  15641. if (p === GLOBSTAR) {
  15642. this.debug('GLOBSTAR', [pattern, p, f]); // "**"
  15643. // a/**/b/**/c would match the following:
  15644. // a/b/x/y/z/c
  15645. // a/x/y/z/b/c
  15646. // a/b/x/b/x/c
  15647. // a/b/c
  15648. // To do this, take the rest of the pattern after
  15649. // the **, and see if it would match the file remainder.
  15650. // If so, return success.
  15651. // If not, the ** "swallows" a segment, and try again.
  15652. // This is recursively awful.
  15653. //
  15654. // a/**/b/**/c matching a/b/x/y/z/c
  15655. // - a matches a
  15656. // - doublestar
  15657. // - matchOne(b/x/y/z/c, b/**/c)
  15658. // - b matches b
  15659. // - doublestar
  15660. // - matchOne(x/y/z/c, c) -> no
  15661. // - matchOne(y/z/c, c) -> no
  15662. // - matchOne(z/c, c) -> no
  15663. // - matchOne(c, c) yes, hit
  15664. var fr = fi;
  15665. var pr = pi + 1;
  15666. if (pr === pl) {
  15667. this.debug('** at the end'); // a ** at the end will just swallow the rest.
  15668. // We have found a match.
  15669. // however, it will not swallow /.x, unless
  15670. // options.dot is set.
  15671. // . and .. are *never* matched by **, for explosively
  15672. // exponential reasons.
  15673. for (; fi < fl; fi++) {
  15674. if (file[fi] === '.' || file[fi] === '..' || !options.dot && file[fi].charAt(0) === '.') return false;
  15675. }
  15676. return true;
  15677. } // ok, let's see if we can swallow whatever we can.
  15678. while (fr < fl) {
  15679. var swallowee = file[fr];
  15680. this.debug('\nglobstar while', file, fr, pattern, pr, swallowee); // XXX remove this slice. Just pass the start index.
  15681. if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
  15682. this.debug('globstar found match!', fr, fl, swallowee); // found a match.
  15683. return true;
  15684. } else {
  15685. // can't swallow "." or ".." ever.
  15686. // can only swallow ".foo" when explicitly asked.
  15687. if (swallowee === '.' || swallowee === '..' || !options.dot && swallowee.charAt(0) === '.') {
  15688. this.debug('dot detected!', file, fr, pattern, pr);
  15689. break;
  15690. } // ** swallows a segment, and continue.
  15691. this.debug('globstar swallow a segment, and continue');
  15692. fr++;
  15693. }
  15694. } // no match was found.
  15695. // However, in partial mode, we can't say this is necessarily over.
  15696. // If there's more *pattern* left, then
  15697. if (partial) {
  15698. // ran out of file
  15699. this.debug('\n>>> no match, partial?', file, fr, pattern, pr);
  15700. if (fr === fl) return true;
  15701. }
  15702. return false;
  15703. } // something other than **
  15704. // non-magic patterns just have to match exactly
  15705. // patterns with magic have been turned into regexps.
  15706. var hit;
  15707. if (typeof p === 'string') {
  15708. if (options.nocase) {
  15709. hit = f.toLowerCase() === p.toLowerCase();
  15710. } else {
  15711. hit = f === p;
  15712. }
  15713. this.debug('string match', p, f, hit);
  15714. } else {
  15715. hit = f.match(p);
  15716. this.debug('pattern match', p, f, hit);
  15717. }
  15718. if (!hit) return false;
  15719. } // Note: ending in / means that we'll get a final ""
  15720. // at the end of the pattern. This can only match a
  15721. // corresponding "" at the end of the file.
  15722. // If the file ends in /, then it can only match a
  15723. // a pattern that ends in /, unless the pattern just
  15724. // doesn't have any more for it. But, a/b/ should *not*
  15725. // match "a/b/*", even though "" matches against the
  15726. // [^/]*? pattern, except in partial mode, where it might
  15727. // simply not be reached yet.
  15728. // However, a/b/ should still satisfy a/*
  15729. // now either we fell off the end of the pattern, or we're done.
  15730. if (fi === fl && pi === pl) {
  15731. // ran out of pattern and filename at the same time.
  15732. // an exact hit!
  15733. return true;
  15734. } else if (fi === fl) {
  15735. // ran out of file, but still had pattern left.
  15736. // this is ok if we're doing the match as part of
  15737. // a glob fs traversal.
  15738. return partial;
  15739. } else if (pi === pl) {
  15740. // ran out of pattern, still have file left.
  15741. // this is only acceptable if we're on the very last
  15742. // empty segment of a file with a trailing slash.
  15743. // a/* should match a/b/
  15744. var emptyFileEnd = fi === fl - 1 && file[fi] === '';
  15745. return emptyFileEnd;
  15746. } // should be unreachable.
  15747. throw new Error('wtf?');
  15748. }; // replace stuff like \* with *
  15749. function globUnescape(s) {
  15750. return s.replace(/\\(.)/g, '$1');
  15751. }
  15752. function regExpEscape(s) {
  15753. return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
  15754. }
  15755. var inherits_browser = createCommonjsModule(function (module) {
  15756. if (typeof Object.create === 'function') {
  15757. // implementation from standard node.js 'util' module
  15758. module.exports = function inherits(ctor, superCtor) {
  15759. ctor.super_ = superCtor;
  15760. ctor.prototype = Object.create(superCtor.prototype, {
  15761. constructor: {
  15762. value: ctor,
  15763. enumerable: false,
  15764. writable: true,
  15765. configurable: true
  15766. }
  15767. });
  15768. };
  15769. } else {
  15770. // old school shim for old browsers
  15771. module.exports = function inherits(ctor, superCtor) {
  15772. ctor.super_ = superCtor;
  15773. var TempCtor = function TempCtor() {};
  15774. TempCtor.prototype = superCtor.prototype;
  15775. ctor.prototype = new TempCtor();
  15776. ctor.prototype.constructor = ctor;
  15777. };
  15778. }
  15779. });
  15780. var inherits = createCommonjsModule(function (module) {
  15781. try {
  15782. var util$$1 = util;
  15783. if (typeof util$$1.inherits !== 'function') throw '';
  15784. module.exports = util$$1.inherits;
  15785. } catch (e) {
  15786. module.exports = inherits_browser;
  15787. }
  15788. });
  15789. function posix(path$$1) {
  15790. return path$$1.charAt(0) === '/';
  15791. }
  15792. function win32(path$$1) {
  15793. // https://github.com/nodejs/node/blob/b3fcc245fb25539909ef1d5eaa01dbf92e168633/lib/path.js#L56
  15794. var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/;
  15795. var result = splitDeviceRe.exec(path$$1);
  15796. var device = result[1] || '';
  15797. var isUnc = Boolean(device && device.charAt(1) !== ':'); // UNC paths are always absolute
  15798. return Boolean(result[2] || isUnc);
  15799. }
  15800. var pathIsAbsolute = process.platform === 'win32' ? win32 : posix;
  15801. var posix_1 = posix;
  15802. var win32_1 = win32;
  15803. pathIsAbsolute.posix = posix_1;
  15804. pathIsAbsolute.win32 = win32_1;
  15805. var alphasort_1 = alphasort$2;
  15806. var alphasorti_1 = alphasorti$2;
  15807. var setopts_1 = setopts$2;
  15808. var ownProp_1 = ownProp$2;
  15809. var makeAbs_1 = makeAbs;
  15810. var finish_1 = finish;
  15811. var mark_1 = mark;
  15812. var isIgnored_1 = isIgnored$2;
  15813. var childrenIgnored_1 = childrenIgnored$2;
  15814. function ownProp$2(obj, field) {
  15815. return Object.prototype.hasOwnProperty.call(obj, field);
  15816. }
  15817. var Minimatch$3 = minimatch_1.Minimatch;
  15818. function alphasorti$2(a, b) {
  15819. return a.toLowerCase().localeCompare(b.toLowerCase());
  15820. }
  15821. function alphasort$2(a, b) {
  15822. return a.localeCompare(b);
  15823. }
  15824. function setupIgnores(self, options) {
  15825. self.ignore = options.ignore || [];
  15826. if (!Array.isArray(self.ignore)) self.ignore = [self.ignore];
  15827. if (self.ignore.length) {
  15828. self.ignore = self.ignore.map(ignoreMap);
  15829. }
  15830. } // ignore patterns are always in dot:true mode.
  15831. function ignoreMap(pattern) {
  15832. var gmatcher = null;
  15833. if (pattern.slice(-3) === '/**') {
  15834. var gpattern = pattern.replace(/(\/\*\*)+$/, '');
  15835. gmatcher = new Minimatch$3(gpattern, {
  15836. dot: true
  15837. });
  15838. }
  15839. return {
  15840. matcher: new Minimatch$3(pattern, {
  15841. dot: true
  15842. }),
  15843. gmatcher: gmatcher
  15844. };
  15845. }
  15846. function setopts$2(self, pattern, options) {
  15847. if (!options) options = {}; // base-matching: just use globstar for that.
  15848. if (options.matchBase && -1 === pattern.indexOf("/")) {
  15849. if (options.noglobstar) {
  15850. throw new Error("base matching requires globstar");
  15851. }
  15852. pattern = "**/" + pattern;
  15853. }
  15854. self.silent = !!options.silent;
  15855. self.pattern = pattern;
  15856. self.strict = options.strict !== false;
  15857. self.realpath = !!options.realpath;
  15858. self.realpathCache = options.realpathCache || Object.create(null);
  15859. self.follow = !!options.follow;
  15860. self.dot = !!options.dot;
  15861. self.mark = !!options.mark;
  15862. self.nodir = !!options.nodir;
  15863. if (self.nodir) self.mark = true;
  15864. self.sync = !!options.sync;
  15865. self.nounique = !!options.nounique;
  15866. self.nonull = !!options.nonull;
  15867. self.nosort = !!options.nosort;
  15868. self.nocase = !!options.nocase;
  15869. self.stat = !!options.stat;
  15870. self.noprocess = !!options.noprocess;
  15871. self.absolute = !!options.absolute;
  15872. self.maxLength = options.maxLength || Infinity;
  15873. self.cache = options.cache || Object.create(null);
  15874. self.statCache = options.statCache || Object.create(null);
  15875. self.symlinks = options.symlinks || Object.create(null);
  15876. setupIgnores(self, options);
  15877. self.changedCwd = false;
  15878. var cwd = process.cwd();
  15879. if (!ownProp$2(options, "cwd")) self.cwd = cwd;else {
  15880. self.cwd = path.resolve(options.cwd);
  15881. self.changedCwd = self.cwd !== cwd;
  15882. }
  15883. self.root = options.root || path.resolve(self.cwd, "/");
  15884. self.root = path.resolve(self.root);
  15885. if (process.platform === "win32") self.root = self.root.replace(/\\/g, "/"); // TODO: is an absolute `cwd` supposed to be resolved against `root`?
  15886. // e.g. { cwd: '/test', root: __dirname } === path.join(__dirname, '/test')
  15887. self.cwdAbs = pathIsAbsolute(self.cwd) ? self.cwd : makeAbs(self, self.cwd);
  15888. if (process.platform === "win32") self.cwdAbs = self.cwdAbs.replace(/\\/g, "/");
  15889. self.nomount = !!options.nomount; // disable comments and negation in Minimatch.
  15890. // Note that they are not supported in Glob itself anyway.
  15891. options.nonegate = true;
  15892. options.nocomment = true;
  15893. self.minimatch = new Minimatch$3(pattern, options);
  15894. self.options = self.minimatch.options;
  15895. }
  15896. function finish(self) {
  15897. var nou = self.nounique;
  15898. var all = nou ? [] : Object.create(null);
  15899. for (var i = 0, l = self.matches.length; i < l; i++) {
  15900. var matches = self.matches[i];
  15901. if (!matches || Object.keys(matches).length === 0) {
  15902. if (self.nonull) {
  15903. // do like the shell, and spit out the literal glob
  15904. var literal = self.minimatch.globSet[i];
  15905. if (nou) all.push(literal);else all[literal] = true;
  15906. }
  15907. } else {
  15908. // had matches
  15909. var m = Object.keys(matches);
  15910. if (nou) all.push.apply(all, m);else m.forEach(function (m) {
  15911. all[m] = true;
  15912. });
  15913. }
  15914. }
  15915. if (!nou) all = Object.keys(all);
  15916. if (!self.nosort) all = all.sort(self.nocase ? alphasorti$2 : alphasort$2); // at *some* point we statted all of these
  15917. if (self.mark) {
  15918. for (var i = 0; i < all.length; i++) {
  15919. all[i] = self._mark(all[i]);
  15920. }
  15921. if (self.nodir) {
  15922. all = all.filter(function (e) {
  15923. var notDir = !/\/$/.test(e);
  15924. var c = self.cache[e] || self.cache[makeAbs(self, e)];
  15925. if (notDir && c) notDir = c !== 'DIR' && !Array.isArray(c);
  15926. return notDir;
  15927. });
  15928. }
  15929. }
  15930. if (self.ignore.length) all = all.filter(function (m) {
  15931. return !isIgnored$2(self, m);
  15932. });
  15933. self.found = all;
  15934. }
  15935. function mark(self, p) {
  15936. var abs = makeAbs(self, p);
  15937. var c = self.cache[abs];
  15938. var m = p;
  15939. if (c) {
  15940. var isDir = c === 'DIR' || Array.isArray(c);
  15941. var slash = p.slice(-1) === '/';
  15942. if (isDir && !slash) m += '/';else if (!isDir && slash) m = m.slice(0, -1);
  15943. if (m !== p) {
  15944. var mabs = makeAbs(self, m);
  15945. self.statCache[mabs] = self.statCache[abs];
  15946. self.cache[mabs] = self.cache[abs];
  15947. }
  15948. }
  15949. return m;
  15950. } // lotta situps...
  15951. function makeAbs(self, f) {
  15952. var abs = f;
  15953. if (f.charAt(0) === '/') {
  15954. abs = path.join(self.root, f);
  15955. } else if (pathIsAbsolute(f) || f === '') {
  15956. abs = f;
  15957. } else if (self.changedCwd) {
  15958. abs = path.resolve(self.cwd, f);
  15959. } else {
  15960. abs = path.resolve(f);
  15961. }
  15962. if (process.platform === 'win32') abs = abs.replace(/\\/g, '/');
  15963. return abs;
  15964. } // Return true, if pattern ends with globstar '**', for the accompanying parent directory.
  15965. // Ex:- If node_modules/** is the pattern, add 'node_modules' to ignore list along with it's contents
  15966. function isIgnored$2(self, path$$2) {
  15967. if (!self.ignore.length) return false;
  15968. return self.ignore.some(function (item) {
  15969. return item.matcher.match(path$$2) || !!(item.gmatcher && item.gmatcher.match(path$$2));
  15970. });
  15971. }
  15972. function childrenIgnored$2(self, path$$2) {
  15973. if (!self.ignore.length) return false;
  15974. return self.ignore.some(function (item) {
  15975. return !!(item.gmatcher && item.gmatcher.match(path$$2));
  15976. });
  15977. }
  15978. var common$4 = {
  15979. alphasort: alphasort_1,
  15980. alphasorti: alphasorti_1,
  15981. setopts: setopts_1,
  15982. ownProp: ownProp_1,
  15983. makeAbs: makeAbs_1,
  15984. finish: finish_1,
  15985. mark: mark_1,
  15986. isIgnored: isIgnored_1,
  15987. childrenIgnored: childrenIgnored_1
  15988. };
  15989. var sync$1 = globSync;
  15990. globSync.GlobSync = GlobSync$1;
  15991. var setopts$1 = common$4.setopts;
  15992. var ownProp$1 = common$4.ownProp;
  15993. var childrenIgnored$1 = common$4.childrenIgnored;
  15994. var isIgnored$1 = common$4.isIgnored;
  15995. function globSync(pattern, options) {
  15996. if (typeof options === 'function' || arguments.length === 3) throw new TypeError('callback provided to sync glob\n' + 'See: https://github.com/isaacs/node-glob/issues/167');
  15997. return new GlobSync$1(pattern, options).found;
  15998. }
  15999. function GlobSync$1(pattern, options) {
  16000. if (!pattern) throw new Error('must provide pattern');
  16001. if (typeof options === 'function' || arguments.length === 3) throw new TypeError('callback provided to sync glob\n' + 'See: https://github.com/isaacs/node-glob/issues/167');
  16002. if (!(this instanceof GlobSync$1)) return new GlobSync$1(pattern, options);
  16003. setopts$1(this, pattern, options);
  16004. if (this.noprocess) return this;
  16005. var n = this.minimatch.set.length;
  16006. this.matches = new Array(n);
  16007. for (var i = 0; i < n; i++) {
  16008. this._process(this.minimatch.set[i], i, false);
  16009. }
  16010. this._finish();
  16011. }
  16012. GlobSync$1.prototype._finish = function () {
  16013. assert(this instanceof GlobSync$1);
  16014. if (this.realpath) {
  16015. var self = this;
  16016. this.matches.forEach(function (matchset, index) {
  16017. var set = self.matches[index] = Object.create(null);
  16018. for (var p in matchset) {
  16019. try {
  16020. p = self._makeAbs(p);
  16021. var real = fs_realpath.realpathSync(p, self.realpathCache);
  16022. set[real] = true;
  16023. } catch (er) {
  16024. if (er.syscall === 'stat') set[self._makeAbs(p)] = true;else throw er;
  16025. }
  16026. }
  16027. });
  16028. }
  16029. common$4.finish(this);
  16030. };
  16031. GlobSync$1.prototype._process = function (pattern, index, inGlobStar) {
  16032. assert(this instanceof GlobSync$1); // Get the first [n] parts of pattern that are all strings.
  16033. var n = 0;
  16034. while (typeof pattern[n] === 'string') {
  16035. n++;
  16036. } // now n is the index of the first one that is *not* a string.
  16037. // See if there's anything else
  16038. var prefix;
  16039. switch (n) {
  16040. // if not, then this is rather simple
  16041. case pattern.length:
  16042. this._processSimple(pattern.join('/'), index);
  16043. return;
  16044. case 0:
  16045. // pattern *starts* with some non-trivial item.
  16046. // going to readdir(cwd), but not include the prefix in matches.
  16047. prefix = null;
  16048. break;
  16049. default:
  16050. // pattern has some string bits in the front.
  16051. // whatever it starts with, whether that's 'absolute' like /foo/bar,
  16052. // or 'relative' like '../baz'
  16053. prefix = pattern.slice(0, n).join('/');
  16054. break;
  16055. }
  16056. var remain = pattern.slice(n); // get the list of entries.
  16057. var read;
  16058. if (prefix === null) read = '.';else if (pathIsAbsolute(prefix) || pathIsAbsolute(pattern.join('/'))) {
  16059. if (!prefix || !pathIsAbsolute(prefix)) prefix = '/' + prefix;
  16060. read = prefix;
  16061. } else read = prefix;
  16062. var abs = this._makeAbs(read); //if ignored, skip processing
  16063. if (childrenIgnored$1(this, read)) return;
  16064. var isGlobStar = remain[0] === minimatch_1.GLOBSTAR;
  16065. if (isGlobStar) this._processGlobStar(prefix, read, abs, remain, index, inGlobStar);else this._processReaddir(prefix, read, abs, remain, index, inGlobStar);
  16066. };
  16067. GlobSync$1.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar) {
  16068. var entries = this._readdir(abs, inGlobStar); // if the abs isn't a dir, then nothing can match!
  16069. if (!entries) return; // It will only match dot entries if it starts with a dot, or if
  16070. // dot is set. Stuff like @(.foo|.bar) isn't allowed.
  16071. var pn = remain[0];
  16072. var negate = !!this.minimatch.negate;
  16073. var rawGlob = pn._glob;
  16074. var dotOk = this.dot || rawGlob.charAt(0) === '.';
  16075. var matchedEntries = [];
  16076. for (var i = 0; i < entries.length; i++) {
  16077. var e = entries[i];
  16078. if (e.charAt(0) !== '.' || dotOk) {
  16079. var m;
  16080. if (negate && !prefix) {
  16081. m = !e.match(pn);
  16082. } else {
  16083. m = e.match(pn);
  16084. }
  16085. if (m) matchedEntries.push(e);
  16086. }
  16087. }
  16088. var len = matchedEntries.length; // If there are no matched entries, then nothing matches.
  16089. if (len === 0) return; // if this is the last remaining pattern bit, then no need for
  16090. // an additional stat *unless* the user has specified mark or
  16091. // stat explicitly. We know they exist, since readdir returned
  16092. // them.
  16093. if (remain.length === 1 && !this.mark && !this.stat) {
  16094. if (!this.matches[index]) this.matches[index] = Object.create(null);
  16095. for (var i = 0; i < len; i++) {
  16096. var e = matchedEntries[i];
  16097. if (prefix) {
  16098. if (prefix.slice(-1) !== '/') e = prefix + '/' + e;else e = prefix + e;
  16099. }
  16100. if (e.charAt(0) === '/' && !this.nomount) {
  16101. e = path.join(this.root, e);
  16102. }
  16103. this._emitMatch(index, e);
  16104. } // This was the last one, and no stats were needed
  16105. return;
  16106. } // now test all matched entries as stand-ins for that part
  16107. // of the pattern.
  16108. remain.shift();
  16109. for (var i = 0; i < len; i++) {
  16110. var e = matchedEntries[i];
  16111. var newPattern;
  16112. if (prefix) newPattern = [prefix, e];else newPattern = [e];
  16113. this._process(newPattern.concat(remain), index, inGlobStar);
  16114. }
  16115. };
  16116. GlobSync$1.prototype._emitMatch = function (index, e) {
  16117. if (isIgnored$1(this, e)) return;
  16118. var abs = this._makeAbs(e);
  16119. if (this.mark) e = this._mark(e);
  16120. if (this.absolute) {
  16121. e = abs;
  16122. }
  16123. if (this.matches[index][e]) return;
  16124. if (this.nodir) {
  16125. var c = this.cache[abs];
  16126. if (c === 'DIR' || Array.isArray(c)) return;
  16127. }
  16128. this.matches[index][e] = true;
  16129. if (this.stat) this._stat(e);
  16130. };
  16131. GlobSync$1.prototype._readdirInGlobStar = function (abs) {
  16132. // follow all symlinked directories forever
  16133. // just proceed as if this is a non-globstar situation
  16134. if (this.follow) return this._readdir(abs, false);
  16135. var entries;
  16136. var lstat;
  16137. var stat;
  16138. try {
  16139. lstat = fs.lstatSync(abs);
  16140. } catch (er) {
  16141. if (er.code === 'ENOENT') {
  16142. // lstat failed, doesn't exist
  16143. return null;
  16144. }
  16145. }
  16146. var isSym = lstat && lstat.isSymbolicLink();
  16147. this.symlinks[abs] = isSym; // If it's not a symlink or a dir, then it's definitely a regular file.
  16148. // don't bother doing a readdir in that case.
  16149. if (!isSym && lstat && !lstat.isDirectory()) this.cache[abs] = 'FILE';else entries = this._readdir(abs, false);
  16150. return entries;
  16151. };
  16152. GlobSync$1.prototype._readdir = function (abs, inGlobStar) {
  16153. var entries;
  16154. if (inGlobStar && !ownProp$1(this.symlinks, abs)) return this._readdirInGlobStar(abs);
  16155. if (ownProp$1(this.cache, abs)) {
  16156. var c = this.cache[abs];
  16157. if (!c || c === 'FILE') return null;
  16158. if (Array.isArray(c)) return c;
  16159. }
  16160. try {
  16161. return this._readdirEntries(abs, fs.readdirSync(abs));
  16162. } catch (er) {
  16163. this._readdirError(abs, er);
  16164. return null;
  16165. }
  16166. };
  16167. GlobSync$1.prototype._readdirEntries = function (abs, entries) {
  16168. // if we haven't asked to stat everything, then just
  16169. // assume that everything in there exists, so we can avoid
  16170. // having to stat it a second time.
  16171. if (!this.mark && !this.stat) {
  16172. for (var i = 0; i < entries.length; i++) {
  16173. var e = entries[i];
  16174. if (abs === '/') e = abs + e;else e = abs + '/' + e;
  16175. this.cache[e] = true;
  16176. }
  16177. }
  16178. this.cache[abs] = entries; // mark and cache dir-ness
  16179. return entries;
  16180. };
  16181. GlobSync$1.prototype._readdirError = function (f, er) {
  16182. // handle errors, and cache the information
  16183. switch (er.code) {
  16184. case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205
  16185. case 'ENOTDIR':
  16186. // totally normal. means it *does* exist.
  16187. var abs = this._makeAbs(f);
  16188. this.cache[abs] = 'FILE';
  16189. if (abs === this.cwdAbs) {
  16190. var error = new Error(er.code + ' invalid cwd ' + this.cwd);
  16191. error.path = this.cwd;
  16192. error.code = er.code;
  16193. throw error;
  16194. }
  16195. break;
  16196. case 'ENOENT': // not terribly unusual
  16197. case 'ELOOP':
  16198. case 'ENAMETOOLONG':
  16199. case 'UNKNOWN':
  16200. this.cache[this._makeAbs(f)] = false;
  16201. break;
  16202. default:
  16203. // some unusual error. Treat as failure.
  16204. this.cache[this._makeAbs(f)] = false;
  16205. if (this.strict) throw er;
  16206. if (!this.silent) console.error('glob error', er);
  16207. break;
  16208. }
  16209. };
  16210. GlobSync$1.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar) {
  16211. var entries = this._readdir(abs, inGlobStar); // no entries means not a dir, so it can never have matches
  16212. // foo.txt/** doesn't match foo.txt
  16213. if (!entries) return; // test without the globstar, and with every child both below
  16214. // and replacing the globstar.
  16215. var remainWithoutGlobStar = remain.slice(1);
  16216. var gspref = prefix ? [prefix] : [];
  16217. var noGlobStar = gspref.concat(remainWithoutGlobStar); // the noGlobStar pattern exits the inGlobStar state
  16218. this._process(noGlobStar, index, false);
  16219. var len = entries.length;
  16220. var isSym = this.symlinks[abs]; // If it's a symlink, and we're in a globstar, then stop
  16221. if (isSym && inGlobStar) return;
  16222. for (var i = 0; i < len; i++) {
  16223. var e = entries[i];
  16224. if (e.charAt(0) === '.' && !this.dot) continue; // these two cases enter the inGlobStar state
  16225. var instead = gspref.concat(entries[i], remainWithoutGlobStar);
  16226. this._process(instead, index, true);
  16227. var below = gspref.concat(entries[i], remain);
  16228. this._process(below, index, true);
  16229. }
  16230. };
  16231. GlobSync$1.prototype._processSimple = function (prefix, index) {
  16232. // XXX review this. Shouldn't it be doing the mounting etc
  16233. // before doing stat? kinda weird?
  16234. var exists = this._stat(prefix);
  16235. if (!this.matches[index]) this.matches[index] = Object.create(null); // If it doesn't exist, then just mark the lack of results
  16236. if (!exists) return;
  16237. if (prefix && pathIsAbsolute(prefix) && !this.nomount) {
  16238. var trail = /[\/\\]$/.test(prefix);
  16239. if (prefix.charAt(0) === '/') {
  16240. prefix = path.join(this.root, prefix);
  16241. } else {
  16242. prefix = path.resolve(this.root, prefix);
  16243. if (trail) prefix += '/';
  16244. }
  16245. }
  16246. if (process.platform === 'win32') prefix = prefix.replace(/\\/g, '/'); // Mark this as a match
  16247. this._emitMatch(index, prefix);
  16248. }; // Returns either 'DIR', 'FILE', or false
  16249. GlobSync$1.prototype._stat = function (f) {
  16250. var abs = this._makeAbs(f);
  16251. var needDir = f.slice(-1) === '/';
  16252. if (f.length > this.maxLength) return false;
  16253. if (!this.stat && ownProp$1(this.cache, abs)) {
  16254. var c = this.cache[abs];
  16255. if (Array.isArray(c)) c = 'DIR'; // It exists, but maybe not how we need it
  16256. if (!needDir || c === 'DIR') return c;
  16257. if (needDir && c === 'FILE') return false; // otherwise we have to stat, because maybe c=true
  16258. // if we know it exists, but not what it is.
  16259. }
  16260. var exists;
  16261. var stat = this.statCache[abs];
  16262. if (!stat) {
  16263. var lstat;
  16264. try {
  16265. lstat = fs.lstatSync(abs);
  16266. } catch (er) {
  16267. if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) {
  16268. this.statCache[abs] = false;
  16269. return false;
  16270. }
  16271. }
  16272. if (lstat && lstat.isSymbolicLink()) {
  16273. try {
  16274. stat = fs.statSync(abs);
  16275. } catch (er) {
  16276. stat = lstat;
  16277. }
  16278. } else {
  16279. stat = lstat;
  16280. }
  16281. }
  16282. this.statCache[abs] = stat;
  16283. var c = true;
  16284. if (stat) c = stat.isDirectory() ? 'DIR' : 'FILE';
  16285. this.cache[abs] = this.cache[abs] || c;
  16286. if (needDir && c === 'FILE') return false;
  16287. return c;
  16288. };
  16289. GlobSync$1.prototype._mark = function (p) {
  16290. return common$4.mark(this, p);
  16291. };
  16292. GlobSync$1.prototype._makeAbs = function (f) {
  16293. return common$4.makeAbs(this, f);
  16294. };
  16295. // Returns a wrapper function that returns a wrapped callback
  16296. // The wrapper function should do some stuff, and return a
  16297. // presumably different callback function.
  16298. // This makes sure that own properties are retained, so that
  16299. // decorations and such are not lost along the way.
  16300. var wrappy_1 = wrappy;
  16301. function wrappy(fn, cb) {
  16302. if (fn && cb) return wrappy(fn)(cb);
  16303. if (typeof fn !== 'function') throw new TypeError('need wrapper function');
  16304. Object.keys(fn).forEach(function (k) {
  16305. wrapper[k] = fn[k];
  16306. });
  16307. return wrapper;
  16308. function wrapper() {
  16309. var args = new Array(arguments.length);
  16310. for (var i = 0; i < args.length; i++) {
  16311. args[i] = arguments[i];
  16312. }
  16313. var ret = fn.apply(this, args);
  16314. var cb = args[args.length - 1];
  16315. if (typeof ret === 'function' && ret !== cb) {
  16316. Object.keys(cb).forEach(function (k) {
  16317. ret[k] = cb[k];
  16318. });
  16319. }
  16320. return ret;
  16321. }
  16322. }
  16323. var once_1 = wrappy_1(once);
  16324. var strict = wrappy_1(onceStrict);
  16325. once.proto = once(function () {
  16326. Object.defineProperty(Function.prototype, 'once', {
  16327. value: function value() {
  16328. return once(this);
  16329. },
  16330. configurable: true
  16331. });
  16332. Object.defineProperty(Function.prototype, 'onceStrict', {
  16333. value: function value() {
  16334. return onceStrict(this);
  16335. },
  16336. configurable: true
  16337. });
  16338. });
  16339. function once(fn) {
  16340. var f = function f() {
  16341. if (f.called) return f.value;
  16342. f.called = true;
  16343. return f.value = fn.apply(this, arguments);
  16344. };
  16345. f.called = false;
  16346. return f;
  16347. }
  16348. function onceStrict(fn) {
  16349. var f = function f() {
  16350. if (f.called) throw new Error(f.onceError);
  16351. f.called = true;
  16352. return f.value = fn.apply(this, arguments);
  16353. };
  16354. var name = fn.name || 'Function wrapped with `once`';
  16355. f.onceError = name + " shouldn't be called more than once";
  16356. f.called = false;
  16357. return f;
  16358. }
  16359. once_1.strict = strict;
  16360. var reqs = Object.create(null);
  16361. var inflight_1 = wrappy_1(inflight);
  16362. function inflight(key, cb) {
  16363. if (reqs[key]) {
  16364. reqs[key].push(cb);
  16365. return null;
  16366. } else {
  16367. reqs[key] = [cb];
  16368. return makeres(key);
  16369. }
  16370. }
  16371. function makeres(key) {
  16372. return once_1(function RES() {
  16373. var cbs = reqs[key];
  16374. var len = cbs.length;
  16375. var args = slice(arguments); // XXX It's somewhat ambiguous whether a new callback added in this
  16376. // pass should be queued for later execution if something in the
  16377. // list of callbacks throws, or if it should just be discarded.
  16378. // However, it's such an edge case that it hardly matters, and either
  16379. // choice is likely as surprising as the other.
  16380. // As it happens, we do go ahead and schedule it for later execution.
  16381. try {
  16382. for (var i = 0; i < len; i++) {
  16383. cbs[i].apply(null, args);
  16384. }
  16385. } finally {
  16386. if (cbs.length > len) {
  16387. // added more in the interim.
  16388. // de-zalgo, just in case, but don't call again.
  16389. cbs.splice(0, len);
  16390. process.nextTick(function () {
  16391. RES.apply(null, args);
  16392. });
  16393. } else {
  16394. delete reqs[key];
  16395. }
  16396. }
  16397. });
  16398. }
  16399. function slice(args) {
  16400. var length = args.length;
  16401. var array = [];
  16402. for (var i = 0; i < length; i++) {
  16403. array[i] = args[i];
  16404. }
  16405. return array;
  16406. }
  16407. //
  16408. // 1. Get the minimatch set
  16409. // 2. For each pattern in the set, PROCESS(pattern, false)
  16410. // 3. Store matches per-set, then uniq them
  16411. //
  16412. // PROCESS(pattern, inGlobStar)
  16413. // Get the first [n] items from pattern that are all strings
  16414. // Join these together. This is PREFIX.
  16415. // If there is no more remaining, then stat(PREFIX) and
  16416. // add to matches if it succeeds. END.
  16417. //
  16418. // If inGlobStar and PREFIX is symlink and points to dir
  16419. // set ENTRIES = []
  16420. // else readdir(PREFIX) as ENTRIES
  16421. // If fail, END
  16422. //
  16423. // with ENTRIES
  16424. // If pattern[n] is GLOBSTAR
  16425. // // handle the case where the globstar match is empty
  16426. // // by pruning it out, and testing the resulting pattern
  16427. // PROCESS(pattern[0..n] + pattern[n+1 .. $], false)
  16428. // // handle other cases.
  16429. // for ENTRY in ENTRIES (not dotfiles)
  16430. // // attach globstar + tail onto the entry
  16431. // // Mark that this entry is a globstar match
  16432. // PROCESS(pattern[0..n] + ENTRY + pattern[n .. $], true)
  16433. //
  16434. // else // not globstar
  16435. // for ENTRY in ENTRIES (not dotfiles, unless pattern[n] is dot)
  16436. // Test ENTRY against pattern[n]
  16437. // If fails, continue
  16438. // If passes, PROCESS(pattern[0..n] + item + pattern[n+1 .. $])
  16439. //
  16440. // Caveat:
  16441. // Cache all stats and readdirs results to minimize syscall. Since all
  16442. // we ever care about is existence and directory-ness, we can just keep
  16443. // `true` for files, and [children,...] for directories, or `false` for
  16444. // things that don't exist.
  16445. var glob_1 = glob;
  16446. var EE = events.EventEmitter;
  16447. var setopts = common$4.setopts;
  16448. var ownProp = common$4.ownProp;
  16449. var childrenIgnored = common$4.childrenIgnored;
  16450. var isIgnored = common$4.isIgnored;
  16451. function glob(pattern, options, cb) {
  16452. if (typeof options === 'function') cb = options, options = {};
  16453. if (!options) options = {};
  16454. if (options.sync) {
  16455. if (cb) throw new TypeError('callback provided to sync glob');
  16456. return sync$1(pattern, options);
  16457. }
  16458. return new Glob(pattern, options, cb);
  16459. }
  16460. glob.sync = sync$1;
  16461. var GlobSync = glob.GlobSync = sync$1.GlobSync; // old api surface
  16462. glob.glob = glob;
  16463. function extend(origin, add) {
  16464. if (add === null || typeof add !== 'object') {
  16465. return origin;
  16466. }
  16467. var keys = Object.keys(add);
  16468. var i = keys.length;
  16469. while (i--) {
  16470. origin[keys[i]] = add[keys[i]];
  16471. }
  16472. return origin;
  16473. }
  16474. glob.hasMagic = function (pattern, options_) {
  16475. var options = extend({}, options_);
  16476. options.noprocess = true;
  16477. var g = new Glob(pattern, options);
  16478. var set = g.minimatch.set;
  16479. if (!pattern) return false;
  16480. if (set.length > 1) return true;
  16481. for (var j = 0; j < set[0].length; j++) {
  16482. if (typeof set[0][j] !== 'string') return true;
  16483. }
  16484. return false;
  16485. };
  16486. glob.Glob = Glob;
  16487. inherits(Glob, EE);
  16488. function Glob(pattern, options, cb) {
  16489. if (typeof options === 'function') {
  16490. cb = options;
  16491. options = null;
  16492. }
  16493. if (options && options.sync) {
  16494. if (cb) throw new TypeError('callback provided to sync glob');
  16495. return new GlobSync(pattern, options);
  16496. }
  16497. if (!(this instanceof Glob)) return new Glob(pattern, options, cb);
  16498. setopts(this, pattern, options);
  16499. this._didRealPath = false; // process each pattern in the minimatch set
  16500. var n = this.minimatch.set.length; // The matches are stored as {<filename>: true,...} so that
  16501. // duplicates are automagically pruned.
  16502. // Later, we do an Object.keys() on these.
  16503. // Keep them as a list so we can fill in when nonull is set.
  16504. this.matches = new Array(n);
  16505. if (typeof cb === 'function') {
  16506. cb = once_1(cb);
  16507. this.on('error', cb);
  16508. this.on('end', function (matches) {
  16509. cb(null, matches);
  16510. });
  16511. }
  16512. var self = this;
  16513. this._processing = 0;
  16514. this._emitQueue = [];
  16515. this._processQueue = [];
  16516. this.paused = false;
  16517. if (this.noprocess) return this;
  16518. if (n === 0) return done();
  16519. var sync = true;
  16520. for (var i = 0; i < n; i++) {
  16521. this._process(this.minimatch.set[i], i, false, done);
  16522. }
  16523. sync = false;
  16524. function done() {
  16525. --self._processing;
  16526. if (self._processing <= 0) {
  16527. if (sync) {
  16528. process.nextTick(function () {
  16529. self._finish();
  16530. });
  16531. } else {
  16532. self._finish();
  16533. }
  16534. }
  16535. }
  16536. }
  16537. Glob.prototype._finish = function () {
  16538. assert(this instanceof Glob);
  16539. if (this.aborted) return;
  16540. if (this.realpath && !this._didRealpath) return this._realpath();
  16541. common$4.finish(this);
  16542. this.emit('end', this.found);
  16543. };
  16544. Glob.prototype._realpath = function () {
  16545. if (this._didRealpath) return;
  16546. this._didRealpath = true;
  16547. var n = this.matches.length;
  16548. if (n === 0) return this._finish();
  16549. var self = this;
  16550. for (var i = 0; i < this.matches.length; i++) {
  16551. this._realpathSet(i, next);
  16552. }
  16553. function next() {
  16554. if (--n === 0) self._finish();
  16555. }
  16556. };
  16557. Glob.prototype._realpathSet = function (index, cb) {
  16558. var matchset = this.matches[index];
  16559. if (!matchset) return cb();
  16560. var found = Object.keys(matchset);
  16561. var self = this;
  16562. var n = found.length;
  16563. if (n === 0) return cb();
  16564. var set = this.matches[index] = Object.create(null);
  16565. found.forEach(function (p, i) {
  16566. // If there's a problem with the stat, then it means that
  16567. // one or more of the links in the realpath couldn't be
  16568. // resolved. just return the abs value in that case.
  16569. p = self._makeAbs(p);
  16570. fs_realpath.realpath(p, self.realpathCache, function (er, real) {
  16571. if (!er) set[real] = true;else if (er.syscall === 'stat') set[p] = true;else self.emit('error', er); // srsly wtf right here
  16572. if (--n === 0) {
  16573. self.matches[index] = set;
  16574. cb();
  16575. }
  16576. });
  16577. });
  16578. };
  16579. Glob.prototype._mark = function (p) {
  16580. return common$4.mark(this, p);
  16581. };
  16582. Glob.prototype._makeAbs = function (f) {
  16583. return common$4.makeAbs(this, f);
  16584. };
  16585. Glob.prototype.abort = function () {
  16586. this.aborted = true;
  16587. this.emit('abort');
  16588. };
  16589. Glob.prototype.pause = function () {
  16590. if (!this.paused) {
  16591. this.paused = true;
  16592. this.emit('pause');
  16593. }
  16594. };
  16595. Glob.prototype.resume = function () {
  16596. if (this.paused) {
  16597. this.emit('resume');
  16598. this.paused = false;
  16599. if (this._emitQueue.length) {
  16600. var eq = this._emitQueue.slice(0);
  16601. this._emitQueue.length = 0;
  16602. for (var i = 0; i < eq.length; i++) {
  16603. var e = eq[i];
  16604. this._emitMatch(e[0], e[1]);
  16605. }
  16606. }
  16607. if (this._processQueue.length) {
  16608. var pq = this._processQueue.slice(0);
  16609. this._processQueue.length = 0;
  16610. for (var i = 0; i < pq.length; i++) {
  16611. var p = pq[i];
  16612. this._processing--;
  16613. this._process(p[0], p[1], p[2], p[3]);
  16614. }
  16615. }
  16616. }
  16617. };
  16618. Glob.prototype._process = function (pattern, index, inGlobStar, cb) {
  16619. assert(this instanceof Glob);
  16620. assert(typeof cb === 'function');
  16621. if (this.aborted) return;
  16622. this._processing++;
  16623. if (this.paused) {
  16624. this._processQueue.push([pattern, index, inGlobStar, cb]);
  16625. return;
  16626. } //console.error('PROCESS %d', this._processing, pattern)
  16627. // Get the first [n] parts of pattern that are all strings.
  16628. var n = 0;
  16629. while (typeof pattern[n] === 'string') {
  16630. n++;
  16631. } // now n is the index of the first one that is *not* a string.
  16632. // see if there's anything else
  16633. var prefix;
  16634. switch (n) {
  16635. // if not, then this is rather simple
  16636. case pattern.length:
  16637. this._processSimple(pattern.join('/'), index, cb);
  16638. return;
  16639. case 0:
  16640. // pattern *starts* with some non-trivial item.
  16641. // going to readdir(cwd), but not include the prefix in matches.
  16642. prefix = null;
  16643. break;
  16644. default:
  16645. // pattern has some string bits in the front.
  16646. // whatever it starts with, whether that's 'absolute' like /foo/bar,
  16647. // or 'relative' like '../baz'
  16648. prefix = pattern.slice(0, n).join('/');
  16649. break;
  16650. }
  16651. var remain = pattern.slice(n); // get the list of entries.
  16652. var read;
  16653. if (prefix === null) read = '.';else if (pathIsAbsolute(prefix) || pathIsAbsolute(pattern.join('/'))) {
  16654. if (!prefix || !pathIsAbsolute(prefix)) prefix = '/' + prefix;
  16655. read = prefix;
  16656. } else read = prefix;
  16657. var abs = this._makeAbs(read); //if ignored, skip _processing
  16658. if (childrenIgnored(this, read)) return cb();
  16659. var isGlobStar = remain[0] === minimatch_1.GLOBSTAR;
  16660. if (isGlobStar) this._processGlobStar(prefix, read, abs, remain, index, inGlobStar, cb);else this._processReaddir(prefix, read, abs, remain, index, inGlobStar, cb);
  16661. };
  16662. Glob.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar, cb) {
  16663. var self = this;
  16664. this._readdir(abs, inGlobStar, function (er, entries) {
  16665. return self._processReaddir2(prefix, read, abs, remain, index, inGlobStar, entries, cb);
  16666. });
  16667. };
  16668. Glob.prototype._processReaddir2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) {
  16669. // if the abs isn't a dir, then nothing can match!
  16670. if (!entries) return cb(); // It will only match dot entries if it starts with a dot, or if
  16671. // dot is set. Stuff like @(.foo|.bar) isn't allowed.
  16672. var pn = remain[0];
  16673. var negate = !!this.minimatch.negate;
  16674. var rawGlob = pn._glob;
  16675. var dotOk = this.dot || rawGlob.charAt(0) === '.';
  16676. var matchedEntries = [];
  16677. for (var i = 0; i < entries.length; i++) {
  16678. var e = entries[i];
  16679. if (e.charAt(0) !== '.' || dotOk) {
  16680. var m;
  16681. if (negate && !prefix) {
  16682. m = !e.match(pn);
  16683. } else {
  16684. m = e.match(pn);
  16685. }
  16686. if (m) matchedEntries.push(e);
  16687. }
  16688. } //console.error('prd2', prefix, entries, remain[0]._glob, matchedEntries)
  16689. var len = matchedEntries.length; // If there are no matched entries, then nothing matches.
  16690. if (len === 0) return cb(); // if this is the last remaining pattern bit, then no need for
  16691. // an additional stat *unless* the user has specified mark or
  16692. // stat explicitly. We know they exist, since readdir returned
  16693. // them.
  16694. if (remain.length === 1 && !this.mark && !this.stat) {
  16695. if (!this.matches[index]) this.matches[index] = Object.create(null);
  16696. for (var i = 0; i < len; i++) {
  16697. var e = matchedEntries[i];
  16698. if (prefix) {
  16699. if (prefix !== '/') e = prefix + '/' + e;else e = prefix + e;
  16700. }
  16701. if (e.charAt(0) === '/' && !this.nomount) {
  16702. e = path.join(this.root, e);
  16703. }
  16704. this._emitMatch(index, e);
  16705. } // This was the last one, and no stats were needed
  16706. return cb();
  16707. } // now test all matched entries as stand-ins for that part
  16708. // of the pattern.
  16709. remain.shift();
  16710. for (var i = 0; i < len; i++) {
  16711. var e = matchedEntries[i];
  16712. var newPattern;
  16713. if (prefix) {
  16714. if (prefix !== '/') e = prefix + '/' + e;else e = prefix + e;
  16715. }
  16716. this._process([e].concat(remain), index, inGlobStar, cb);
  16717. }
  16718. cb();
  16719. };
  16720. Glob.prototype._emitMatch = function (index, e) {
  16721. if (this.aborted) return;
  16722. if (isIgnored(this, e)) return;
  16723. if (this.paused) {
  16724. this._emitQueue.push([index, e]);
  16725. return;
  16726. }
  16727. var abs = pathIsAbsolute(e) ? e : this._makeAbs(e);
  16728. if (this.mark) e = this._mark(e);
  16729. if (this.absolute) e = abs;
  16730. if (this.matches[index][e]) return;
  16731. if (this.nodir) {
  16732. var c = this.cache[abs];
  16733. if (c === 'DIR' || Array.isArray(c)) return;
  16734. }
  16735. this.matches[index][e] = true;
  16736. var st = this.statCache[abs];
  16737. if (st) this.emit('stat', e, st);
  16738. this.emit('match', e);
  16739. };
  16740. Glob.prototype._readdirInGlobStar = function (abs, cb) {
  16741. if (this.aborted) return; // follow all symlinked directories forever
  16742. // just proceed as if this is a non-globstar situation
  16743. if (this.follow) return this._readdir(abs, false, cb);
  16744. var lstatkey = 'lstat\0' + abs;
  16745. var self = this;
  16746. var lstatcb = inflight_1(lstatkey, lstatcb_);
  16747. if (lstatcb) fs.lstat(abs, lstatcb);
  16748. function lstatcb_(er, lstat) {
  16749. if (er && er.code === 'ENOENT') return cb();
  16750. var isSym = lstat && lstat.isSymbolicLink();
  16751. self.symlinks[abs] = isSym; // If it's not a symlink or a dir, then it's definitely a regular file.
  16752. // don't bother doing a readdir in that case.
  16753. if (!isSym && lstat && !lstat.isDirectory()) {
  16754. self.cache[abs] = 'FILE';
  16755. cb();
  16756. } else self._readdir(abs, false, cb);
  16757. }
  16758. };
  16759. Glob.prototype._readdir = function (abs, inGlobStar, cb) {
  16760. if (this.aborted) return;
  16761. cb = inflight_1('readdir\0' + abs + '\0' + inGlobStar, cb);
  16762. if (!cb) return; //console.error('RD %j %j', +inGlobStar, abs)
  16763. if (inGlobStar && !ownProp(this.symlinks, abs)) return this._readdirInGlobStar(abs, cb);
  16764. if (ownProp(this.cache, abs)) {
  16765. var c = this.cache[abs];
  16766. if (!c || c === 'FILE') return cb();
  16767. if (Array.isArray(c)) return cb(null, c);
  16768. }
  16769. var self = this;
  16770. fs.readdir(abs, readdirCb(this, abs, cb));
  16771. };
  16772. function readdirCb(self, abs, cb) {
  16773. return function (er, entries) {
  16774. if (er) self._readdirError(abs, er, cb);else self._readdirEntries(abs, entries, cb);
  16775. };
  16776. }
  16777. Glob.prototype._readdirEntries = function (abs, entries, cb) {
  16778. if (this.aborted) return; // if we haven't asked to stat everything, then just
  16779. // assume that everything in there exists, so we can avoid
  16780. // having to stat it a second time.
  16781. if (!this.mark && !this.stat) {
  16782. for (var i = 0; i < entries.length; i++) {
  16783. var e = entries[i];
  16784. if (abs === '/') e = abs + e;else e = abs + '/' + e;
  16785. this.cache[e] = true;
  16786. }
  16787. }
  16788. this.cache[abs] = entries;
  16789. return cb(null, entries);
  16790. };
  16791. Glob.prototype._readdirError = function (f, er, cb) {
  16792. if (this.aborted) return; // handle errors, and cache the information
  16793. switch (er.code) {
  16794. case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205
  16795. case 'ENOTDIR':
  16796. // totally normal. means it *does* exist.
  16797. var abs = this._makeAbs(f);
  16798. this.cache[abs] = 'FILE';
  16799. if (abs === this.cwdAbs) {
  16800. var error = new Error(er.code + ' invalid cwd ' + this.cwd);
  16801. error.path = this.cwd;
  16802. error.code = er.code;
  16803. this.emit('error', error);
  16804. this.abort();
  16805. }
  16806. break;
  16807. case 'ENOENT': // not terribly unusual
  16808. case 'ELOOP':
  16809. case 'ENAMETOOLONG':
  16810. case 'UNKNOWN':
  16811. this.cache[this._makeAbs(f)] = false;
  16812. break;
  16813. default:
  16814. // some unusual error. Treat as failure.
  16815. this.cache[this._makeAbs(f)] = false;
  16816. if (this.strict) {
  16817. this.emit('error', er); // If the error is handled, then we abort
  16818. // if not, we threw out of here
  16819. this.abort();
  16820. }
  16821. if (!this.silent) console.error('glob error', er);
  16822. break;
  16823. }
  16824. return cb();
  16825. };
  16826. Glob.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar, cb) {
  16827. var self = this;
  16828. this._readdir(abs, inGlobStar, function (er, entries) {
  16829. self._processGlobStar2(prefix, read, abs, remain, index, inGlobStar, entries, cb);
  16830. });
  16831. };
  16832. Glob.prototype._processGlobStar2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) {
  16833. //console.error('pgs2', prefix, remain[0], entries)
  16834. // no entries means not a dir, so it can never have matches
  16835. // foo.txt/** doesn't match foo.txt
  16836. if (!entries) return cb(); // test without the globstar, and with every child both below
  16837. // and replacing the globstar.
  16838. var remainWithoutGlobStar = remain.slice(1);
  16839. var gspref = prefix ? [prefix] : [];
  16840. var noGlobStar = gspref.concat(remainWithoutGlobStar); // the noGlobStar pattern exits the inGlobStar state
  16841. this._process(noGlobStar, index, false, cb);
  16842. var isSym = this.symlinks[abs];
  16843. var len = entries.length; // If it's a symlink, and we're in a globstar, then stop
  16844. if (isSym && inGlobStar) return cb();
  16845. for (var i = 0; i < len; i++) {
  16846. var e = entries[i];
  16847. if (e.charAt(0) === '.' && !this.dot) continue; // these two cases enter the inGlobStar state
  16848. var instead = gspref.concat(entries[i], remainWithoutGlobStar);
  16849. this._process(instead, index, true, cb);
  16850. var below = gspref.concat(entries[i], remain);
  16851. this._process(below, index, true, cb);
  16852. }
  16853. cb();
  16854. };
  16855. Glob.prototype._processSimple = function (prefix, index, cb) {
  16856. // XXX review this. Shouldn't it be doing the mounting etc
  16857. // before doing stat? kinda weird?
  16858. var self = this;
  16859. this._stat(prefix, function (er, exists) {
  16860. self._processSimple2(prefix, index, er, exists, cb);
  16861. });
  16862. };
  16863. Glob.prototype._processSimple2 = function (prefix, index, er, exists, cb) {
  16864. //console.error('ps2', prefix, exists)
  16865. if (!this.matches[index]) this.matches[index] = Object.create(null); // If it doesn't exist, then just mark the lack of results
  16866. if (!exists) return cb();
  16867. if (prefix && pathIsAbsolute(prefix) && !this.nomount) {
  16868. var trail = /[\/\\]$/.test(prefix);
  16869. if (prefix.charAt(0) === '/') {
  16870. prefix = path.join(this.root, prefix);
  16871. } else {
  16872. prefix = path.resolve(this.root, prefix);
  16873. if (trail) prefix += '/';
  16874. }
  16875. }
  16876. if (process.platform === 'win32') prefix = prefix.replace(/\\/g, '/'); // Mark this as a match
  16877. this._emitMatch(index, prefix);
  16878. cb();
  16879. }; // Returns either 'DIR', 'FILE', or false
  16880. Glob.prototype._stat = function (f, cb) {
  16881. var abs = this._makeAbs(f);
  16882. var needDir = f.slice(-1) === '/';
  16883. if (f.length > this.maxLength) return cb();
  16884. if (!this.stat && ownProp(this.cache, abs)) {
  16885. var c = this.cache[abs];
  16886. if (Array.isArray(c)) c = 'DIR'; // It exists, but maybe not how we need it
  16887. if (!needDir || c === 'DIR') return cb(null, c);
  16888. if (needDir && c === 'FILE') return cb(); // otherwise we have to stat, because maybe c=true
  16889. // if we know it exists, but not what it is.
  16890. }
  16891. var exists;
  16892. var stat = this.statCache[abs];
  16893. if (stat !== undefined) {
  16894. if (stat === false) return cb(null, stat);else {
  16895. var type = stat.isDirectory() ? 'DIR' : 'FILE';
  16896. if (needDir && type === 'FILE') return cb();else return cb(null, type, stat);
  16897. }
  16898. }
  16899. var self = this;
  16900. var statcb = inflight_1('stat\0' + abs, lstatcb_);
  16901. if (statcb) fs.lstat(abs, statcb);
  16902. function lstatcb_(er, lstat) {
  16903. if (lstat && lstat.isSymbolicLink()) {
  16904. // If it's a symlink, then treat it as the target, unless
  16905. // the target does not exist, then treat it as a file.
  16906. return fs.stat(abs, function (er, stat) {
  16907. if (er) self._stat2(f, abs, null, lstat, cb);else self._stat2(f, abs, er, stat, cb);
  16908. });
  16909. } else {
  16910. self._stat2(f, abs, er, lstat, cb);
  16911. }
  16912. }
  16913. };
  16914. Glob.prototype._stat2 = function (f, abs, er, stat, cb) {
  16915. if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) {
  16916. this.statCache[abs] = false;
  16917. return cb();
  16918. }
  16919. var needDir = f.slice(-1) === '/';
  16920. this.statCache[abs] = stat;
  16921. if (abs.slice(-1) === '/' && stat && !stat.isDirectory()) return cb(null, false, stat);
  16922. var c = true;
  16923. if (stat) c = stat.isDirectory() ? 'DIR' : 'FILE';
  16924. this.cache[abs] = this.cache[abs] || c;
  16925. if (needDir && c === 'FILE') return cb();
  16926. return cb(null, c, stat);
  16927. };
  16928. var pify_1 = createCommonjsModule(function (module) {
  16929. 'use strict';
  16930. var processFn = function processFn(fn, P, opts) {
  16931. return function () {
  16932. var that = this;
  16933. var args = new Array(arguments.length);
  16934. for (var i = 0; i < arguments.length; i++) {
  16935. args[i] = arguments[i];
  16936. }
  16937. return new P(function (resolve, reject) {
  16938. args.push(function (err, result) {
  16939. if (err) {
  16940. reject(err);
  16941. } else if (opts.multiArgs) {
  16942. var results = new Array(arguments.length - 1);
  16943. for (var i = 1; i < arguments.length; i++) {
  16944. results[i - 1] = arguments[i];
  16945. }
  16946. resolve(results);
  16947. } else {
  16948. resolve(result);
  16949. }
  16950. });
  16951. fn.apply(that, args);
  16952. });
  16953. };
  16954. };
  16955. var pify = module.exports = function (obj, P, opts) {
  16956. if (typeof P !== 'function') {
  16957. opts = P;
  16958. P = Promise;
  16959. }
  16960. opts = opts || {};
  16961. opts.exclude = opts.exclude || [/.+Sync$/];
  16962. var filter = function filter(key) {
  16963. var match = function match(pattern) {
  16964. return typeof pattern === 'string' ? key === pattern : pattern.test(key);
  16965. };
  16966. return opts.include ? opts.include.some(match) : !opts.exclude.some(match);
  16967. };
  16968. var ret = typeof obj === 'function' ? function () {
  16969. if (opts.excludeMain) {
  16970. return obj.apply(this, arguments);
  16971. }
  16972. return processFn(obj, P, opts).apply(this, arguments);
  16973. } : {};
  16974. return Object.keys(obj).reduce(function (ret, key) {
  16975. var x = obj[key];
  16976. ret[key] = typeof x === 'function' && filter(key) ? processFn(x, P, opts) : x;
  16977. return ret;
  16978. }, ret);
  16979. };
  16980. pify.all = pify;
  16981. });
  16982. var globP = pify_1(glob_1, pinkiePromise).bind(glob_1);
  16983. function isNegative(pattern) {
  16984. return pattern[0] === '!';
  16985. }
  16986. function isString(value) {
  16987. return typeof value === 'string';
  16988. }
  16989. function assertPatternsInput(patterns) {
  16990. if (!patterns.every(isString)) {
  16991. throw new TypeError('patterns must be a string or an array of strings');
  16992. }
  16993. }
  16994. function generateGlobTasks(patterns, opts) {
  16995. patterns = [].concat(patterns);
  16996. assertPatternsInput(patterns);
  16997. var globTasks = [];
  16998. opts = objectAssign({
  16999. cache: Object.create(null),
  17000. statCache: Object.create(null),
  17001. realpathCache: Object.create(null),
  17002. symlinks: Object.create(null),
  17003. ignore: []
  17004. }, opts);
  17005. patterns.forEach(function (pattern, i) {
  17006. if (isNegative(pattern)) {
  17007. return;
  17008. }
  17009. var ignore = patterns.slice(i).filter(isNegative).map(function (pattern) {
  17010. return pattern.slice(1);
  17011. });
  17012. globTasks.push({
  17013. pattern: pattern,
  17014. opts: objectAssign({}, opts, {
  17015. ignore: opts.ignore.concat(ignore)
  17016. })
  17017. });
  17018. });
  17019. return globTasks;
  17020. }
  17021. var globby = function globby(patterns, opts) {
  17022. var globTasks;
  17023. try {
  17024. globTasks = generateGlobTasks(patterns, opts);
  17025. } catch (err) {
  17026. return pinkiePromise.reject(err);
  17027. }
  17028. return pinkiePromise.all(globTasks.map(function (task) {
  17029. return globP(task.pattern, task.opts);
  17030. })).then(function (paths) {
  17031. return arrayUnion.apply(null, paths);
  17032. });
  17033. };
  17034. var sync = function sync(patterns, opts) {
  17035. var globTasks = generateGlobTasks(patterns, opts);
  17036. return globTasks.reduce(function (matches, task) {
  17037. return arrayUnion(matches, glob_1.sync(task.pattern, task.opts));
  17038. }, []);
  17039. };
  17040. var generateGlobTasks_1 = generateGlobTasks;
  17041. var hasMagic = function hasMagic(patterns, opts) {
  17042. return [].concat(patterns).some(function (pattern) {
  17043. return glob_1.hasMagic(pattern, opts);
  17044. });
  17045. };
  17046. globby.sync = sync;
  17047. globby.generateGlobTasks = generateGlobTasks_1;
  17048. globby.hasMagic = hasMagic;
  17049. var assert$2 = true;
  17050. var buffer_ieee754 = "< 0.9.7";
  17051. var buffer = true;
  17052. var child_process = true;
  17053. var cluster = true;
  17054. var console$1 = true;
  17055. var constants = true;
  17056. var crypto = true;
  17057. var _debugger = "< 8";
  17058. var dgram = true;
  17059. var dns = true;
  17060. var domain = true;
  17061. var events$1 = true;
  17062. var freelist = "< 6";
  17063. var fs$2 = true;
  17064. var http = true;
  17065. var http2 = ">= 8.8";
  17066. var https = true;
  17067. var _http_server = ">= 0.11";
  17068. var _linklist = "< 8";
  17069. var module$1 = true;
  17070. var net = true;
  17071. var os$1 = true;
  17072. var path$3 = true;
  17073. var perf_hooks = ">= 8.5";
  17074. var process$1 = ">= 1";
  17075. var punycode = true;
  17076. var querystring = true;
  17077. var readline = true;
  17078. var repl = true;
  17079. var stream = true;
  17080. var string_decoder = true;
  17081. var sys = true;
  17082. var timers = true;
  17083. var tls = true;
  17084. var tty = true;
  17085. var url = true;
  17086. var util$4 = true;
  17087. var v8 = ">= 1";
  17088. var vm = true;
  17089. var zlib = true;
  17090. var core$3 = {
  17091. assert: assert$2,
  17092. buffer_ieee754: buffer_ieee754,
  17093. buffer: buffer,
  17094. child_process: child_process,
  17095. cluster: cluster,
  17096. console: console$1,
  17097. constants: constants,
  17098. crypto: crypto,
  17099. _debugger: _debugger,
  17100. dgram: dgram,
  17101. dns: dns,
  17102. domain: domain,
  17103. events: events$1,
  17104. freelist: freelist,
  17105. fs: fs$2,
  17106. http: http,
  17107. http2: http2,
  17108. https: https,
  17109. _http_server: _http_server,
  17110. _linklist: _linklist,
  17111. module: module$1,
  17112. net: net,
  17113. os: os$1,
  17114. path: path$3,
  17115. perf_hooks: perf_hooks,
  17116. process: process$1,
  17117. punycode: punycode,
  17118. querystring: querystring,
  17119. readline: readline,
  17120. repl: repl,
  17121. stream: stream,
  17122. string_decoder: string_decoder,
  17123. sys: sys,
  17124. timers: timers,
  17125. tls: tls,
  17126. tty: tty,
  17127. url: url,
  17128. util: util$4,
  17129. v8: v8,
  17130. vm: vm,
  17131. zlib: zlib
  17132. };
  17133. var core$4 = Object.freeze({
  17134. assert: assert$2,
  17135. buffer_ieee754: buffer_ieee754,
  17136. buffer: buffer,
  17137. child_process: child_process,
  17138. cluster: cluster,
  17139. console: console$1,
  17140. constants: constants,
  17141. crypto: crypto,
  17142. _debugger: _debugger,
  17143. dgram: dgram,
  17144. dns: dns,
  17145. domain: domain,
  17146. events: events$1,
  17147. freelist: freelist,
  17148. fs: fs$2,
  17149. http: http,
  17150. http2: http2,
  17151. https: https,
  17152. _http_server: _http_server,
  17153. _linklist: _linklist,
  17154. module: module$1,
  17155. net: net,
  17156. os: os$1,
  17157. path: path$3,
  17158. perf_hooks: perf_hooks,
  17159. process: process$1,
  17160. punycode: punycode,
  17161. querystring: querystring,
  17162. readline: readline,
  17163. repl: repl,
  17164. stream: stream,
  17165. string_decoder: string_decoder,
  17166. sys: sys,
  17167. timers: timers,
  17168. tls: tls,
  17169. tty: tty,
  17170. url: url,
  17171. util: util$4,
  17172. v8: v8,
  17173. vm: vm,
  17174. zlib: zlib,
  17175. default: core$3
  17176. });
  17177. var data = ( core$4 && core$3 ) || core$4;
  17178. var current = process.versions && process.versions.node && process.versions.node.split('.') || [];
  17179. function versionIncluded(specifier) {
  17180. if (specifier === true) {
  17181. return true;
  17182. }
  17183. var parts = specifier.split(' ');
  17184. var op = parts[0];
  17185. var versionParts = parts[1].split('.');
  17186. for (var i = 0; i < 3; ++i) {
  17187. var cur = Number(current[i] || 0);
  17188. var ver = Number(versionParts[i] || 0);
  17189. if (cur === ver) {
  17190. continue; // eslint-disable-line no-restricted-syntax, no-continue
  17191. }
  17192. if (op === '<') {
  17193. return cur < ver;
  17194. } else if (op === '>=') {
  17195. return cur >= ver;
  17196. } else {
  17197. return false;
  17198. }
  17199. }
  17200. return false;
  17201. }
  17202. var core$2 = {};
  17203. for (var mod in data) {
  17204. // eslint-disable-line no-restricted-syntax
  17205. if (Object.prototype.hasOwnProperty.call(data, mod)) {
  17206. core$2[mod] = versionIncluded(data[mod]);
  17207. }
  17208. }
  17209. var core_1 = core$2;
  17210. var caller = function caller() {
  17211. // see https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi
  17212. var origPrepareStackTrace = Error.prepareStackTrace;
  17213. Error.prepareStackTrace = function (_, stack) {
  17214. return stack;
  17215. };
  17216. var stack = new Error().stack;
  17217. Error.prepareStackTrace = origPrepareStackTrace;
  17218. return stack[2].getFileName();
  17219. };
  17220. var pathParse = createCommonjsModule(function (module) {
  17221. 'use strict';
  17222. var isWindows = process.platform === 'win32'; // Regex to split a windows path into three parts: [*, device, slash,
  17223. // tail] windows-only
  17224. var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/; // Regex to split the tail part of the above into [*, dir, basename, ext]
  17225. var splitTailRe = /^([\s\S]*?)((?:\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))(?:[\\\/]*)$/;
  17226. var win32 = {}; // Function to split a filename into [root, dir, basename, ext]
  17227. function win32SplitPath(filename) {
  17228. // Separate device+slash from tail
  17229. var result = splitDeviceRe.exec(filename),
  17230. device = (result[1] || '') + (result[2] || ''),
  17231. tail = result[3] || ''; // Split the tail into dir, basename and extension
  17232. var result2 = splitTailRe.exec(tail),
  17233. dir = result2[1],
  17234. basename = result2[2],
  17235. ext = result2[3];
  17236. return [device, dir, basename, ext];
  17237. }
  17238. win32.parse = function (pathString) {
  17239. if (typeof pathString !== 'string') {
  17240. throw new TypeError("Parameter 'pathString' must be a string, not " + typeof pathString);
  17241. }
  17242. var allParts = win32SplitPath(pathString);
  17243. if (!allParts || allParts.length !== 4) {
  17244. throw new TypeError("Invalid path '" + pathString + "'");
  17245. }
  17246. return {
  17247. root: allParts[0],
  17248. dir: allParts[0] + allParts[1].slice(0, -1),
  17249. base: allParts[2],
  17250. ext: allParts[3],
  17251. name: allParts[2].slice(0, allParts[2].length - allParts[3].length)
  17252. };
  17253. }; // Split a filename into [root, dir, basename, ext], unix version
  17254. // 'root' is just a slash, or nothing.
  17255. var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
  17256. var posix = {};
  17257. function posixSplitPath(filename) {
  17258. return splitPathRe.exec(filename).slice(1);
  17259. }
  17260. posix.parse = function (pathString) {
  17261. if (typeof pathString !== 'string') {
  17262. throw new TypeError("Parameter 'pathString' must be a string, not " + typeof pathString);
  17263. }
  17264. var allParts = posixSplitPath(pathString);
  17265. if (!allParts || allParts.length !== 4) {
  17266. throw new TypeError("Invalid path '" + pathString + "'");
  17267. }
  17268. allParts[1] = allParts[1] || '';
  17269. allParts[2] = allParts[2] || '';
  17270. allParts[3] = allParts[3] || '';
  17271. return {
  17272. root: allParts[0],
  17273. dir: allParts[0] + allParts[1].slice(0, -1),
  17274. base: allParts[2],
  17275. ext: allParts[3],
  17276. name: allParts[2].slice(0, allParts[2].length - allParts[3].length)
  17277. };
  17278. };
  17279. if (isWindows) module.exports = win32.parse;else
  17280. /* posix */
  17281. module.exports = posix.parse;
  17282. module.exports.posix = posix.parse;
  17283. module.exports.win32 = win32.parse;
  17284. });
  17285. var parse$4 = path.parse || pathParse;
  17286. var nodeModulesPaths = function nodeModulesPaths(start, opts) {
  17287. var modules = opts && opts.moduleDirectory ? [].concat(opts.moduleDirectory) : ['node_modules']; // ensure that `start` is an absolute path at this point,
  17288. // resolving against the process' current working directory
  17289. var absoluteStart = path.resolve(start);
  17290. if (opts && opts.preserveSymlinks === false) {
  17291. try {
  17292. absoluteStart = fs.realpathSync(absoluteStart);
  17293. } catch (err) {
  17294. if (err.code !== 'ENOENT') {
  17295. throw err;
  17296. }
  17297. }
  17298. }
  17299. var prefix = '/';
  17300. if (/^([A-Za-z]:)/.test(absoluteStart)) {
  17301. prefix = '';
  17302. } else if (/^\\\\/.test(absoluteStart)) {
  17303. prefix = '\\\\';
  17304. }
  17305. var paths = [absoluteStart];
  17306. var parsed = parse$4(absoluteStart);
  17307. while (parsed.dir !== paths[paths.length - 1]) {
  17308. paths.push(parsed.dir);
  17309. parsed = parse$4(parsed.dir);
  17310. }
  17311. var dirs = paths.reduce(function (dirs, aPath) {
  17312. return dirs.concat(modules.map(function (moduleDir) {
  17313. return path.join(prefix, aPath, moduleDir);
  17314. }));
  17315. }, []);
  17316. return opts && opts.paths ? dirs.concat(opts.paths) : dirs;
  17317. };
  17318. var async = function resolve(x, options, callback) {
  17319. var cb = callback;
  17320. var opts = options || {};
  17321. if (typeof opts === 'function') {
  17322. cb = opts;
  17323. opts = {};
  17324. }
  17325. if (typeof x !== 'string') {
  17326. var err = new TypeError('Path must be a string.');
  17327. return process.nextTick(function () {
  17328. cb(err);
  17329. });
  17330. }
  17331. var isFile = opts.isFile || function (file, cb) {
  17332. fs.stat(file, function (err, stat) {
  17333. if (!err) {
  17334. return cb(null, stat.isFile() || stat.isFIFO());
  17335. }
  17336. if (err.code === 'ENOENT' || err.code === 'ENOTDIR') return cb(null, false);
  17337. return cb(err);
  17338. });
  17339. };
  17340. var readFile = opts.readFile || fs.readFile;
  17341. var extensions = opts.extensions || ['.js'];
  17342. var y = opts.basedir || path.dirname(caller());
  17343. opts.paths = opts.paths || [];
  17344. if (/^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/.test(x)) {
  17345. var res = path.resolve(y, x);
  17346. if (x === '..' || x.slice(-1) === '/') res += '/';
  17347. if (/\/$/.test(x) && res === y) {
  17348. loadAsDirectory(res, opts.package, onfile);
  17349. } else loadAsFile(res, opts.package, onfile);
  17350. } else loadNodeModules(x, y, function (err, n, pkg) {
  17351. if (err) cb(err);else if (n) cb(null, n, pkg);else if (core_1[x]) return cb(null, x);else {
  17352. var moduleError = new Error("Cannot find module '" + x + "' from '" + y + "'");
  17353. moduleError.code = 'MODULE_NOT_FOUND';
  17354. cb(moduleError);
  17355. }
  17356. });
  17357. function onfile(err, m, pkg) {
  17358. if (err) cb(err);else if (m) cb(null, m, pkg);else loadAsDirectory(res, function (err, d, pkg) {
  17359. if (err) cb(err);else if (d) cb(null, d, pkg);else {
  17360. var moduleError = new Error("Cannot find module '" + x + "' from '" + y + "'");
  17361. moduleError.code = 'MODULE_NOT_FOUND';
  17362. cb(moduleError);
  17363. }
  17364. });
  17365. }
  17366. function loadAsFile(x, thePackage, callback) {
  17367. var loadAsFilePackage = thePackage;
  17368. var cb = callback;
  17369. if (typeof loadAsFilePackage === 'function') {
  17370. cb = loadAsFilePackage;
  17371. loadAsFilePackage = undefined;
  17372. }
  17373. var exts = [''].concat(extensions);
  17374. load(exts, x, loadAsFilePackage);
  17375. function load(exts, x, loadPackage) {
  17376. if (exts.length === 0) return cb(null, undefined, loadPackage);
  17377. var file = x + exts[0];
  17378. var pkg = loadPackage;
  17379. if (pkg) onpkg(null, pkg);else loadpkg(path.dirname(file), onpkg);
  17380. function onpkg(err, pkg_, dir) {
  17381. pkg = pkg_;
  17382. if (err) return cb(err);
  17383. if (dir && pkg && opts.pathFilter) {
  17384. var rfile = path.relative(dir, file);
  17385. var rel = rfile.slice(0, rfile.length - exts[0].length);
  17386. var r = opts.pathFilter(pkg, x, rel);
  17387. if (r) return load([''].concat(extensions.slice()), path.resolve(dir, r), pkg);
  17388. }
  17389. isFile(file, onex);
  17390. }
  17391. function onex(err, ex) {
  17392. if (err) return cb(err);
  17393. if (ex) return cb(null, file, pkg);
  17394. load(exts.slice(1), x, pkg);
  17395. }
  17396. }
  17397. }
  17398. function loadpkg(dir, cb) {
  17399. if (dir === '' || dir === '/') return cb(null);
  17400. if (process.platform === 'win32' && /^\w:[/\\]*$/.test(dir)) {
  17401. return cb(null);
  17402. }
  17403. if (/[/\\]node_modules[/\\]*$/.test(dir)) return cb(null);
  17404. var pkgfile = path.join(dir, 'package.json');
  17405. isFile(pkgfile, function (err, ex) {
  17406. // on err, ex is false
  17407. if (!ex) return loadpkg(path.dirname(dir), cb);
  17408. readFile(pkgfile, function (err, body) {
  17409. if (err) cb(err);
  17410. try {
  17411. var pkg = JSON.parse(body);
  17412. } catch (jsonErr) {}
  17413. if (pkg && opts.packageFilter) {
  17414. pkg = opts.packageFilter(pkg, pkgfile);
  17415. }
  17416. cb(null, pkg, dir);
  17417. });
  17418. });
  17419. }
  17420. function loadAsDirectory(x, loadAsDirectoryPackage, callback) {
  17421. var cb = callback;
  17422. var fpkg = loadAsDirectoryPackage;
  17423. if (typeof fpkg === 'function') {
  17424. cb = fpkg;
  17425. fpkg = opts.package;
  17426. }
  17427. var pkgfile = path.join(x, 'package.json');
  17428. isFile(pkgfile, function (err, ex) {
  17429. if (err) return cb(err);
  17430. if (!ex) return loadAsFile(path.join(x, 'index'), fpkg, cb);
  17431. readFile(pkgfile, function (err, body) {
  17432. if (err) return cb(err);
  17433. try {
  17434. var pkg = JSON.parse(body);
  17435. } catch (jsonErr) {}
  17436. if (opts.packageFilter) {
  17437. pkg = opts.packageFilter(pkg, pkgfile);
  17438. }
  17439. if (pkg.main) {
  17440. if (pkg.main === '.' || pkg.main === './') {
  17441. pkg.main = 'index';
  17442. }
  17443. loadAsFile(path.resolve(x, pkg.main), pkg, function (err, m, pkg) {
  17444. if (err) return cb(err);
  17445. if (m) return cb(null, m, pkg);
  17446. if (!pkg) return loadAsFile(path.join(x, 'index'), pkg, cb);
  17447. var dir = path.resolve(x, pkg.main);
  17448. loadAsDirectory(dir, pkg, function (err, n, pkg) {
  17449. if (err) return cb(err);
  17450. if (n) return cb(null, n, pkg);
  17451. loadAsFile(path.join(x, 'index'), pkg, cb);
  17452. });
  17453. });
  17454. return;
  17455. }
  17456. loadAsFile(path.join(x, '/index'), pkg, cb);
  17457. });
  17458. });
  17459. }
  17460. function processDirs(cb, dirs) {
  17461. if (dirs.length === 0) return cb(null, undefined);
  17462. var dir = dirs[0];
  17463. var file = path.join(dir, x);
  17464. loadAsFile(file, undefined, onfile);
  17465. function onfile(err, m, pkg) {
  17466. if (err) return cb(err);
  17467. if (m) return cb(null, m, pkg);
  17468. loadAsDirectory(path.join(dir, x), undefined, ondir);
  17469. }
  17470. function ondir(err, n, pkg) {
  17471. if (err) return cb(err);
  17472. if (n) return cb(null, n, pkg);
  17473. processDirs(cb, dirs.slice(1));
  17474. }
  17475. }
  17476. function loadNodeModules(x, start, cb) {
  17477. processDirs(cb, nodeModulesPaths(start, opts));
  17478. }
  17479. };
  17480. var sync$3 = function sync(x, options) {
  17481. if (typeof x !== 'string') {
  17482. throw new TypeError('Path must be a string.');
  17483. }
  17484. var opts = options || {};
  17485. var isFile = opts.isFile || function (file) {
  17486. try {
  17487. var stat = fs.statSync(file);
  17488. } catch (e) {
  17489. if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) return false;
  17490. throw e;
  17491. }
  17492. return stat.isFile() || stat.isFIFO();
  17493. };
  17494. var readFileSync = opts.readFileSync || fs.readFileSync;
  17495. var extensions = opts.extensions || ['.js'];
  17496. var y = opts.basedir || path.dirname(caller());
  17497. opts.paths = opts.paths || [];
  17498. if (/^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/.test(x)) {
  17499. var res = path.resolve(y, x);
  17500. if (x === '..' || x.slice(-1) === '/') res += '/';
  17501. var m = loadAsFileSync(res) || loadAsDirectorySync(res);
  17502. if (m) return m;
  17503. } else {
  17504. var n = loadNodeModulesSync(x, y);
  17505. if (n) return n;
  17506. }
  17507. if (core_1[x]) return x;
  17508. var err = new Error("Cannot find module '" + x + "' from '" + y + "'");
  17509. err.code = 'MODULE_NOT_FOUND';
  17510. throw err;
  17511. function loadAsFileSync(x) {
  17512. if (isFile(x)) {
  17513. return x;
  17514. }
  17515. for (var i = 0; i < extensions.length; i++) {
  17516. var file = x + extensions[i];
  17517. if (isFile(file)) {
  17518. return file;
  17519. }
  17520. }
  17521. }
  17522. function loadAsDirectorySync(x) {
  17523. var pkgfile = path.join(x, '/package.json');
  17524. if (isFile(pkgfile)) {
  17525. try {
  17526. var body = readFileSync(pkgfile, 'UTF8');
  17527. var pkg = JSON.parse(body);
  17528. if (opts.packageFilter) {
  17529. pkg = opts.packageFilter(pkg, x);
  17530. }
  17531. if (pkg.main) {
  17532. if (pkg.main === '.' || pkg.main === './') {
  17533. pkg.main = 'index';
  17534. }
  17535. var m = loadAsFileSync(path.resolve(x, pkg.main));
  17536. if (m) return m;
  17537. var n = loadAsDirectorySync(path.resolve(x, pkg.main));
  17538. if (n) return n;
  17539. }
  17540. } catch (e) {}
  17541. }
  17542. return loadAsFileSync(path.join(x, '/index'));
  17543. }
  17544. function loadNodeModulesSync(x, start) {
  17545. var dirs = nodeModulesPaths(start, opts);
  17546. for (var i = 0; i < dirs.length; i++) {
  17547. var dir = dirs[i];
  17548. var m = loadAsFileSync(path.join(dir, '/', x));
  17549. if (m) return m;
  17550. var n = loadAsDirectorySync(path.join(dir, '/', x));
  17551. if (n) return n;
  17552. }
  17553. }
  17554. };
  17555. var resolve$1 = createCommonjsModule(function (module, exports) {
  17556. async.core = core_1;
  17557. async.isCore = function isCore(x) {
  17558. return core_1[x];
  17559. };
  17560. async.sync = sync$3;
  17561. exports = async;
  17562. module.exports = async;
  17563. });
  17564. var addLeadingComment$2 = utilShared.addLeadingComment;
  17565. var addTrailingComment$2 = utilShared.addTrailingComment;
  17566. var addDanglingComment$2 = utilShared.addDanglingComment;
  17567. function handleOwnLineComment(comment, text, options, ast, isLastComment) {
  17568. var precedingNode = comment.precedingNode,
  17569. enclosingNode = comment.enclosingNode,
  17570. followingNode = comment.followingNode;
  17571. if (handleLastFunctionArgComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleMemberExpressionComments(enclosingNode, followingNode, comment) || handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleWhileComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleTryStatementComments(enclosingNode, precedingNode, followingNode, comment) || handleClassComments(enclosingNode, precedingNode, followingNode, comment) || handleImportSpecifierComments(enclosingNode, comment) || handleForComments(enclosingNode, precedingNode, comment) || handleUnionTypeComments(precedingNode, enclosingNode, followingNode, comment) || handleOnlyComments(enclosingNode, ast, comment, isLastComment) || handleImportDeclarationComments(text, enclosingNode, precedingNode, comment, options) || handleAssignmentPatternComments(enclosingNode, comment) || handleMethodNameComments(text, enclosingNode, precedingNode, comment, options)) {
  17572. return true;
  17573. }
  17574. return false;
  17575. }
  17576. function handleEndOfLineComment(comment, text, options, ast, isLastComment) {
  17577. var precedingNode = comment.precedingNode,
  17578. enclosingNode = comment.enclosingNode,
  17579. followingNode = comment.followingNode;
  17580. if (handleLastFunctionArgComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleConditionalExpressionComments(enclosingNode, precedingNode, followingNode, comment, text, options) || handleImportSpecifierComments(enclosingNode, comment) || handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleWhileComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleTryStatementComments(enclosingNode, precedingNode, followingNode, comment) || handleClassComments(enclosingNode, precedingNode, followingNode, comment) || handleLabeledStatementComments(enclosingNode, comment) || handleCallExpressionComments(precedingNode, enclosingNode, comment) || handlePropertyComments(enclosingNode, comment) || handleOnlyComments(enclosingNode, ast, comment, isLastComment) || handleTypeAliasComments(enclosingNode, followingNode, comment) || handleVariableDeclaratorComments(enclosingNode, followingNode, comment)) {
  17581. return true;
  17582. }
  17583. return false;
  17584. }
  17585. function handleRemainingComment(comment, text, options, ast, isLastComment) {
  17586. var precedingNode = comment.precedingNode,
  17587. enclosingNode = comment.enclosingNode,
  17588. followingNode = comment.followingNode;
  17589. if (handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleWhileComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleObjectPropertyAssignment(enclosingNode, precedingNode, comment) || handleCommentInEmptyParens(text, enclosingNode, comment, options) || handleMethodNameComments(text, enclosingNode, precedingNode, comment, options) || handleOnlyComments(enclosingNode, ast, comment, isLastComment) || handleCommentAfterArrowParams(text, enclosingNode, comment, options) || handleFunctionNameComments(text, enclosingNode, precedingNode, comment, options) || handleTSMappedTypeComments(text, enclosingNode, precedingNode, followingNode, comment) || handleBreakAndContinueStatementComments(enclosingNode, comment)) {
  17590. return true;
  17591. }
  17592. return false;
  17593. }
  17594. function addBlockStatementFirstComment(node, comment) {
  17595. var body = node.body.filter(function (n) {
  17596. return n.type !== "EmptyStatement";
  17597. });
  17598. if (body.length === 0) {
  17599. addDanglingComment$2(node, comment);
  17600. } else {
  17601. addLeadingComment$2(body[0], comment);
  17602. }
  17603. }
  17604. function addBlockOrNotComment(node, comment) {
  17605. if (node.type === "BlockStatement") {
  17606. addBlockStatementFirstComment(node, comment);
  17607. } else {
  17608. addLeadingComment$2(node, comment);
  17609. }
  17610. } // There are often comments before the else clause of if statements like
  17611. //
  17612. // if (1) { ... }
  17613. // // comment
  17614. // else { ... }
  17615. //
  17616. // They are being attached as leading comments of the BlockExpression which
  17617. // is not well printed. What we want is to instead move the comment inside
  17618. // of the block and make it leadingComment of the first element of the block
  17619. // or dangling comment of the block if there is nothing inside
  17620. //
  17621. // if (1) { ... }
  17622. // else {
  17623. // // comment
  17624. // ...
  17625. // }
  17626. function handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) {
  17627. if (!enclosingNode || enclosingNode.type !== "IfStatement" || !followingNode) {
  17628. return false;
  17629. } // We unfortunately have no way using the AST or location of nodes to know
  17630. // if the comment is positioned before the condition parenthesis:
  17631. // if (a /* comment */) {}
  17632. // The only workaround I found is to look at the next character to see if
  17633. // it is a ).
  17634. var nextCharacter = util$1.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd);
  17635. if (nextCharacter === ")") {
  17636. addTrailingComment$2(precedingNode, comment);
  17637. return true;
  17638. } // Comments before `else`:
  17639. // - treat as trailing comments of the consequent, if it's a BlockStatement
  17640. // - treat as a dangling comment otherwise
  17641. if (precedingNode === enclosingNode.consequent && followingNode === enclosingNode.alternate) {
  17642. if (precedingNode.type === "BlockStatement") {
  17643. addTrailingComment$2(precedingNode, comment);
  17644. } else {
  17645. addDanglingComment$2(enclosingNode, comment);
  17646. }
  17647. return true;
  17648. }
  17649. if (followingNode.type === "BlockStatement") {
  17650. addBlockStatementFirstComment(followingNode, comment);
  17651. return true;
  17652. }
  17653. if (followingNode.type === "IfStatement") {
  17654. addBlockOrNotComment(followingNode.consequent, comment);
  17655. return true;
  17656. } // For comments positioned after the condition parenthesis in an if statement
  17657. // before the consequent without brackets on, such as
  17658. // if (a) /* comment */ true,
  17659. // we look at the next character to see if the following node
  17660. // is the consequent for the if statement
  17661. if (enclosingNode.consequent === followingNode) {
  17662. addLeadingComment$2(followingNode, comment);
  17663. return true;
  17664. }
  17665. return false;
  17666. }
  17667. function handleWhileComments(text, precedingNode, enclosingNode, followingNode, comment, options) {
  17668. if (!enclosingNode || enclosingNode.type !== "WhileStatement" || !followingNode) {
  17669. return false;
  17670. } // We unfortunately have no way using the AST or location of nodes to know
  17671. // if the comment is positioned before the condition parenthesis:
  17672. // while (a /* comment */) {}
  17673. // The only workaround I found is to look at the next character to see if
  17674. // it is a ).
  17675. var nextCharacter = util$1.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd);
  17676. if (nextCharacter === ")") {
  17677. addTrailingComment$2(precedingNode, comment);
  17678. return true;
  17679. }
  17680. if (followingNode.type === "BlockStatement") {
  17681. addBlockStatementFirstComment(followingNode, comment);
  17682. return true;
  17683. }
  17684. return false;
  17685. } // Same as IfStatement but for TryStatement
  17686. function handleTryStatementComments(enclosingNode, precedingNode, followingNode, comment) {
  17687. if (!enclosingNode || enclosingNode.type !== "TryStatement" && enclosingNode.type !== "CatchClause" || !followingNode) {
  17688. return false;
  17689. }
  17690. if (enclosingNode.type === "CatchClause" && precedingNode) {
  17691. addTrailingComment$2(precedingNode, comment);
  17692. return true;
  17693. }
  17694. if (followingNode.type === "BlockStatement") {
  17695. addBlockStatementFirstComment(followingNode, comment);
  17696. return true;
  17697. }
  17698. if (followingNode.type === "TryStatement") {
  17699. addBlockOrNotComment(followingNode.finalizer, comment);
  17700. return true;
  17701. }
  17702. if (followingNode.type === "CatchClause") {
  17703. addBlockOrNotComment(followingNode.body, comment);
  17704. return true;
  17705. }
  17706. return false;
  17707. }
  17708. function handleMemberExpressionComments(enclosingNode, followingNode, comment) {
  17709. if (enclosingNode && enclosingNode.type === "MemberExpression" && followingNode && followingNode.type === "Identifier") {
  17710. addLeadingComment$2(enclosingNode, comment);
  17711. return true;
  17712. }
  17713. return false;
  17714. }
  17715. function handleConditionalExpressionComments(enclosingNode, precedingNode, followingNode, comment, text, options) {
  17716. var isSameLineAsPrecedingNode = precedingNode && !util$1.hasNewlineInRange(text, options.locEnd(precedingNode), options.locStart(comment));
  17717. if ((!precedingNode || !isSameLineAsPrecedingNode) && enclosingNode && enclosingNode.type === "ConditionalExpression" && followingNode) {
  17718. addLeadingComment$2(followingNode, comment);
  17719. return true;
  17720. }
  17721. return false;
  17722. }
  17723. function handleObjectPropertyAssignment(enclosingNode, precedingNode, comment) {
  17724. if (enclosingNode && (enclosingNode.type === "ObjectProperty" || enclosingNode.type === "Property") && enclosingNode.shorthand && enclosingNode.key === precedingNode && enclosingNode.value.type === "AssignmentPattern") {
  17725. addTrailingComment$2(enclosingNode.value.left, comment);
  17726. return true;
  17727. }
  17728. return false;
  17729. }
  17730. function handleClassComments(enclosingNode, precedingNode, followingNode, comment) {
  17731. if (enclosingNode && (enclosingNode.type === "ClassDeclaration" || enclosingNode.type === "ClassExpression") && enclosingNode.decorators && enclosingNode.decorators.length > 0 && !(followingNode && followingNode.type === "Decorator")) {
  17732. if (!enclosingNode.decorators || enclosingNode.decorators.length === 0) {
  17733. addLeadingComment$2(enclosingNode, comment);
  17734. } else {
  17735. addTrailingComment$2(enclosingNode.decorators[enclosingNode.decorators.length - 1], comment);
  17736. }
  17737. return true;
  17738. }
  17739. return false;
  17740. }
  17741. function handleMethodNameComments(text, enclosingNode, precedingNode, comment, options) {
  17742. // This is only needed for estree parsers (flow, typescript) to attach
  17743. // after a method name:
  17744. // obj = { fn /*comment*/() {} };
  17745. if (enclosingNode && precedingNode && (enclosingNode.type === "Property" || enclosingNode.type === "MethodDefinition") && precedingNode.type === "Identifier" && enclosingNode.key === precedingNode && // special Property case: { key: /*comment*/(value) };
  17746. // comment should be attached to value instead of key
  17747. util$1.getNextNonSpaceNonCommentCharacter(text, precedingNode, options.locEnd) !== ":") {
  17748. addTrailingComment$2(precedingNode, comment);
  17749. return true;
  17750. } // Print comments between decorators and class methods as a trailing comment
  17751. // on the decorator node instead of the method node
  17752. if (precedingNode && enclosingNode && precedingNode.type === "Decorator" && (enclosingNode.type === "ClassMethod" || enclosingNode.type === "ClassProperty" || enclosingNode.type === "TSAbstractClassProperty" || enclosingNode.type === "TSAbstractMethodDefinition" || enclosingNode.type === "MethodDefinition")) {
  17753. addTrailingComment$2(precedingNode, comment);
  17754. return true;
  17755. }
  17756. return false;
  17757. }
  17758. function handleFunctionNameComments(text, enclosingNode, precedingNode, comment, options) {
  17759. if (util$1.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd) !== "(") {
  17760. return false;
  17761. }
  17762. if (precedingNode && enclosingNode && (enclosingNode.type === "FunctionDeclaration" || enclosingNode.type === "FunctionExpression" || enclosingNode.type === "ClassMethod" || enclosingNode.type === "MethodDefinition" || enclosingNode.type === "ObjectMethod")) {
  17763. addTrailingComment$2(precedingNode, comment);
  17764. return true;
  17765. }
  17766. return false;
  17767. }
  17768. function handleCommentAfterArrowParams(text, enclosingNode, comment, options) {
  17769. if (!(enclosingNode && enclosingNode.type === "ArrowFunctionExpression")) {
  17770. return false;
  17771. }
  17772. var index = utilShared.getNextNonSpaceNonCommentCharacterIndex(text, comment, options);
  17773. if (text.substr(index, 2) === "=>") {
  17774. addDanglingComment$2(enclosingNode, comment);
  17775. return true;
  17776. }
  17777. return false;
  17778. }
  17779. function handleCommentInEmptyParens(text, enclosingNode, comment, options) {
  17780. if (util$1.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd) !== ")") {
  17781. return false;
  17782. } // Only add dangling comments to fix the case when no params are present,
  17783. // i.e. a function without any argument.
  17784. if (enclosingNode && ((enclosingNode.type === "FunctionDeclaration" || enclosingNode.type === "FunctionExpression" || enclosingNode.type === "ArrowFunctionExpression" && (enclosingNode.body.type !== "CallExpression" || enclosingNode.body.arguments.length === 0) || enclosingNode.type === "ClassMethod" || enclosingNode.type === "ObjectMethod") && enclosingNode.params.length === 0 || (enclosingNode.type === "CallExpression" || enclosingNode.type === "NewExpression") && enclosingNode.arguments.length === 0)) {
  17785. addDanglingComment$2(enclosingNode, comment);
  17786. return true;
  17787. }
  17788. if (enclosingNode && enclosingNode.type === "MethodDefinition" && enclosingNode.value.params.length === 0) {
  17789. addDanglingComment$2(enclosingNode.value, comment);
  17790. return true;
  17791. }
  17792. return false;
  17793. }
  17794. function handleLastFunctionArgComments(text, precedingNode, enclosingNode, followingNode, comment, options) {
  17795. // Type definitions functions
  17796. if (precedingNode && precedingNode.type === "FunctionTypeParam" && enclosingNode && enclosingNode.type === "FunctionTypeAnnotation" && followingNode && followingNode.type !== "FunctionTypeParam") {
  17797. addTrailingComment$2(precedingNode, comment);
  17798. return true;
  17799. } // Real functions
  17800. if (precedingNode && (precedingNode.type === "Identifier" || precedingNode.type === "AssignmentPattern") && enclosingNode && (enclosingNode.type === "ArrowFunctionExpression" || enclosingNode.type === "FunctionExpression" || enclosingNode.type === "FunctionDeclaration" || enclosingNode.type === "ObjectMethod" || enclosingNode.type === "ClassMethod") && util$1.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd) === ")") {
  17801. addTrailingComment$2(precedingNode, comment);
  17802. return true;
  17803. }
  17804. if (enclosingNode && enclosingNode.type === "FunctionDeclaration" && followingNode && followingNode.type === "BlockStatement") {
  17805. var functionParamRightParenIndex = function () {
  17806. if (enclosingNode.params.length !== 0) {
  17807. return util$1.getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, options.locEnd(util$1.getLast(enclosingNode.params)));
  17808. }
  17809. var functionParamLeftParenIndex = util$1.getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, options.locEnd(enclosingNode.id));
  17810. return util$1.getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, functionParamLeftParenIndex + 1);
  17811. }();
  17812. if (options.locStart(comment) > functionParamRightParenIndex) {
  17813. addBlockStatementFirstComment(followingNode, comment);
  17814. return true;
  17815. }
  17816. }
  17817. return false;
  17818. }
  17819. function handleImportSpecifierComments(enclosingNode, comment) {
  17820. if (enclosingNode && enclosingNode.type === "ImportSpecifier") {
  17821. addLeadingComment$2(enclosingNode, comment);
  17822. return true;
  17823. }
  17824. return false;
  17825. }
  17826. function handleLabeledStatementComments(enclosingNode, comment) {
  17827. if (enclosingNode && enclosingNode.type === "LabeledStatement") {
  17828. addLeadingComment$2(enclosingNode, comment);
  17829. return true;
  17830. }
  17831. return false;
  17832. }
  17833. function handleBreakAndContinueStatementComments(enclosingNode, comment) {
  17834. if (enclosingNode && (enclosingNode.type === "ContinueStatement" || enclosingNode.type === "BreakStatement") && !enclosingNode.label) {
  17835. addTrailingComment$2(enclosingNode, comment);
  17836. return true;
  17837. }
  17838. return false;
  17839. }
  17840. function handleCallExpressionComments(precedingNode, enclosingNode, comment) {
  17841. if (enclosingNode && enclosingNode.type === "CallExpression" && precedingNode && enclosingNode.callee === precedingNode && enclosingNode.arguments.length > 0) {
  17842. addLeadingComment$2(enclosingNode.arguments[0], comment);
  17843. return true;
  17844. }
  17845. return false;
  17846. }
  17847. function handleUnionTypeComments(precedingNode, enclosingNode, followingNode, comment) {
  17848. if (enclosingNode && (enclosingNode.type === "UnionTypeAnnotation" || enclosingNode.type === "TSUnionType")) {
  17849. addTrailingComment$2(precedingNode, comment);
  17850. return true;
  17851. }
  17852. return false;
  17853. }
  17854. function handlePropertyComments(enclosingNode, comment) {
  17855. if (enclosingNode && (enclosingNode.type === "Property" || enclosingNode.type === "ObjectProperty")) {
  17856. addLeadingComment$2(enclosingNode, comment);
  17857. return true;
  17858. }
  17859. return false;
  17860. }
  17861. function handleOnlyComments(enclosingNode, ast, comment, isLastComment) {
  17862. // With Flow the enclosingNode is undefined so use the AST instead.
  17863. if (ast && ast.body && ast.body.length === 0) {
  17864. if (isLastComment) {
  17865. addDanglingComment$2(ast, comment);
  17866. } else {
  17867. addLeadingComment$2(ast, comment);
  17868. }
  17869. return true;
  17870. } else if (enclosingNode && enclosingNode.type === "Program" && enclosingNode.body.length === 0 && enclosingNode.directives && enclosingNode.directives.length === 0) {
  17871. if (isLastComment) {
  17872. addDanglingComment$2(enclosingNode, comment);
  17873. } else {
  17874. addLeadingComment$2(enclosingNode, comment);
  17875. }
  17876. return true;
  17877. }
  17878. return false;
  17879. }
  17880. function handleForComments(enclosingNode, precedingNode, comment) {
  17881. if (enclosingNode && (enclosingNode.type === "ForInStatement" || enclosingNode.type === "ForOfStatement")) {
  17882. addLeadingComment$2(enclosingNode, comment);
  17883. return true;
  17884. }
  17885. return false;
  17886. }
  17887. function handleImportDeclarationComments(text, enclosingNode, precedingNode, comment, options) {
  17888. if (precedingNode && precedingNode.type === "ImportSpecifier" && enclosingNode && enclosingNode.type === "ImportDeclaration" && util$1.hasNewline(text, options.locEnd(comment))) {
  17889. addTrailingComment$2(precedingNode, comment);
  17890. return true;
  17891. }
  17892. return false;
  17893. }
  17894. function handleAssignmentPatternComments(enclosingNode, comment) {
  17895. if (enclosingNode && enclosingNode.type === "AssignmentPattern") {
  17896. addLeadingComment$2(enclosingNode, comment);
  17897. return true;
  17898. }
  17899. return false;
  17900. }
  17901. function handleTypeAliasComments(enclosingNode, followingNode, comment) {
  17902. if (enclosingNode && enclosingNode.type === "TypeAlias") {
  17903. addLeadingComment$2(enclosingNode, comment);
  17904. return true;
  17905. }
  17906. return false;
  17907. }
  17908. function handleVariableDeclaratorComments(enclosingNode, followingNode, comment) {
  17909. if (enclosingNode && (enclosingNode.type === "VariableDeclarator" || enclosingNode.type === "AssignmentExpression") && followingNode && (followingNode.type === "ObjectExpression" || followingNode.type === "ArrayExpression" || followingNode.type === "TemplateLiteral" || followingNode.type === "TaggedTemplateExpression")) {
  17910. addLeadingComment$2(followingNode, comment);
  17911. return true;
  17912. }
  17913. return false;
  17914. }
  17915. function handleTSMappedTypeComments(text, enclosingNode, precedingNode, followingNode, comment) {
  17916. if (!enclosingNode || enclosingNode.type !== "TSMappedType") {
  17917. return false;
  17918. }
  17919. if (followingNode && followingNode.type === "TSTypeParameter" && followingNode.name) {
  17920. addLeadingComment$2(followingNode.name, comment);
  17921. return true;
  17922. }
  17923. if (precedingNode && precedingNode.type === "TSTypeParameter" && precedingNode.constraint) {
  17924. addTrailingComment$2(precedingNode.constraint, comment);
  17925. return true;
  17926. }
  17927. return false;
  17928. }
  17929. function isBlockComment$1(comment) {
  17930. return comment.type === "Block" || comment.type === "CommentBlock";
  17931. }
  17932. function hasLeadingComment$2(node) {
  17933. var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {
  17934. return true;
  17935. };
  17936. if (node.leadingComments) {
  17937. return node.leadingComments.some(fn);
  17938. }
  17939. if (node.comments) {
  17940. return node.comments.some(function (comment) {
  17941. return comment.leading && fn(comment);
  17942. });
  17943. }
  17944. return false;
  17945. }
  17946. var comments$3 = {
  17947. handleOwnLineComment,
  17948. handleEndOfLineComment,
  17949. handleRemainingComment,
  17950. hasLeadingComment: hasLeadingComment$2,
  17951. isBlockComment: isBlockComment$1
  17952. };
  17953. var isBlockComment = comments$3.isBlockComment;
  17954. var hasLeadingComment$1 = comments$3.hasLeadingComment;
  17955. var _require$$1$builders = doc.builders;
  17956. var indent$3 = _require$$1$builders.indent;
  17957. var join$3 = _require$$1$builders.join;
  17958. var hardline$4 = _require$$1$builders.hardline;
  17959. var softline$2 = _require$$1$builders.softline;
  17960. var literalline$2 = _require$$1$builders.literalline;
  17961. var concat$5 = _require$$1$builders.concat;
  17962. var group$2 = _require$$1$builders.group;
  17963. var dedentToRoot$1 = _require$$1$builders.dedentToRoot;
  17964. var _require$$1$utils = doc.utils;
  17965. var mapDoc$3 = _require$$1$utils.mapDoc;
  17966. var stripTrailingHardline$1 = _require$$1$utils.stripTrailingHardline;
  17967. function embed(path$$1, print, textToDoc
  17968. /*, options */
  17969. ) {
  17970. var node = path$$1.getValue();
  17971. var parent = path$$1.getParentNode();
  17972. var parentParent = path$$1.getParentNode(1);
  17973. switch (node.type) {
  17974. case "TemplateLiteral":
  17975. {
  17976. var isCss = [isStyledJsx, isStyledComponents, isCssProp, isAngularComponentStyles].some(function (isIt) {
  17977. return isIt(path$$1);
  17978. });
  17979. if (isCss) {
  17980. // Get full template literal with expressions replaced by placeholders
  17981. var rawQuasis = node.quasis.map(function (q) {
  17982. return q.value.raw;
  17983. });
  17984. var placeholderID = 0;
  17985. var text = rawQuasis.reduce(function (prevVal, currVal, idx) {
  17986. return idx == 0 ? currVal : prevVal + "@prettier-placeholder-" + placeholderID++ + "-id" + currVal;
  17987. }, "");
  17988. var doc$$2 = textToDoc(text, {
  17989. parser: "css"
  17990. });
  17991. return transformCssDoc(doc$$2, path$$1, print);
  17992. }
  17993. /*
  17994. * react-relay and graphql-tag
  17995. * graphql`...`
  17996. * graphql.experimental`...`
  17997. * gql`...`
  17998. *
  17999. * This intentionally excludes Relay Classic tags, as Prettier does not
  18000. * support Relay Classic formatting.
  18001. */
  18002. if (isGraphQL(path$$1)) {
  18003. var expressionDocs = node.expressions ? path$$1.map(print, "expressions") : [];
  18004. var numQuasis = node.quasis.length;
  18005. if (numQuasis === 1 && node.quasis[0].value.raw.trim() === "") {
  18006. return "``";
  18007. }
  18008. var parts = [];
  18009. for (var i = 0; i < numQuasis; i++) {
  18010. var templateElement = node.quasis[i];
  18011. var isFirst = i === 0;
  18012. var isLast = i === numQuasis - 1;
  18013. var _text = templateElement.value.cooked; // Bail out if any of the quasis have an invalid escape sequence
  18014. // (which would make the `cooked` value be `null` or `undefined`)
  18015. if (typeof _text !== "string") {
  18016. return null;
  18017. }
  18018. var lines = _text.split("\n");
  18019. var numLines = lines.length;
  18020. var expressionDoc = expressionDocs[i];
  18021. var startsWithBlankLine = numLines > 2 && lines[0].trim() === "" && lines[1].trim() === "";
  18022. var endsWithBlankLine = numLines > 2 && lines[numLines - 1].trim() === "" && lines[numLines - 2].trim() === "";
  18023. var commentsAndWhitespaceOnly = lines.every(function (line) {
  18024. return /^\s*(?:#[^\r\n]*)?$/.test(line);
  18025. }); // Bail out if an interpolation occurs within a comment.
  18026. if (!isLast && /#[^\r\n]*$/.test(lines[numLines - 1])) {
  18027. return null;
  18028. }
  18029. var _doc = null;
  18030. if (commentsAndWhitespaceOnly) {
  18031. _doc = printGraphqlComments(lines);
  18032. } else {
  18033. _doc = stripTrailingHardline$1(textToDoc(_text, {
  18034. parser: "graphql"
  18035. }));
  18036. }
  18037. if (_doc) {
  18038. _doc = escapeTemplateCharacters(_doc, false);
  18039. if (!isFirst && startsWithBlankLine) {
  18040. parts.push("");
  18041. }
  18042. parts.push(_doc);
  18043. if (!isLast && endsWithBlankLine) {
  18044. parts.push("");
  18045. }
  18046. } else if (!isFirst && !isLast && startsWithBlankLine) {
  18047. parts.push("");
  18048. }
  18049. if (expressionDoc) {
  18050. parts.push(concat$5(["${", expressionDoc, "}"]));
  18051. }
  18052. }
  18053. return concat$5(["`", indent$3(concat$5([hardline$4, join$3(hardline$4, parts)])), hardline$4, "`"]);
  18054. }
  18055. if (isHtml(path$$1)) {
  18056. return printHtmlTemplateLiteral(path$$1, print, textToDoc, "html");
  18057. }
  18058. if (isAngularComponentTemplate(path$$1)) {
  18059. return printHtmlTemplateLiteral(path$$1, print, textToDoc, "angular");
  18060. }
  18061. break;
  18062. }
  18063. case "TemplateElement":
  18064. {
  18065. /**
  18066. * md`...`
  18067. * markdown`...`
  18068. */
  18069. if (parentParent && parentParent.type === "TaggedTemplateExpression" && parent.quasis.length === 1 && parentParent.tag.type === "Identifier" && (parentParent.tag.name === "md" || parentParent.tag.name === "markdown")) {
  18070. var _text2 = parent.quasis[0].value.raw.replace(/((?:\\\\)*)\\`/g, function (_, backslashes) {
  18071. return "\\".repeat(backslashes.length / 2) + "`";
  18072. });
  18073. var indentation = getIndentation(_text2);
  18074. var hasIndent = indentation !== "";
  18075. return concat$5([hasIndent ? indent$3(concat$5([softline$2, printMarkdown(_text2.replace(new RegExp(`^${indentation}`, "gm"), ""))])) : concat$5([literalline$2, dedentToRoot$1(printMarkdown(_text2))]), softline$2]);
  18076. }
  18077. break;
  18078. }
  18079. }
  18080. function printMarkdown(text) {
  18081. var doc$$2 = textToDoc(text, {
  18082. parser: "markdown",
  18083. __inJsTemplate: true
  18084. });
  18085. return stripTrailingHardline$1(escapeTemplateCharacters(doc$$2, true));
  18086. }
  18087. }
  18088. function getIndentation(str) {
  18089. var firstMatchedIndent = str.match(/^([^\S\n]*)\S/m);
  18090. return firstMatchedIndent === null ? "" : firstMatchedIndent[1];
  18091. }
  18092. function escapeTemplateCharacters(doc$$2, raw) {
  18093. return mapDoc$3(doc$$2, function (currentDoc) {
  18094. if (!currentDoc.parts) {
  18095. return currentDoc;
  18096. }
  18097. var parts = [];
  18098. currentDoc.parts.forEach(function (part) {
  18099. if (typeof part === "string") {
  18100. parts.push(raw ? part.replace(/(\\*)`/g, "$1$1\\`") : part.replace(/([\\`]|\$\{)/g, "\\$1"));
  18101. } else {
  18102. parts.push(part);
  18103. }
  18104. });
  18105. return Object.assign({}, currentDoc, {
  18106. parts
  18107. });
  18108. });
  18109. }
  18110. function transformCssDoc(quasisDoc, path$$1, print) {
  18111. var parentNode = path$$1.getValue();
  18112. var isEmpty = parentNode.quasis.length === 1 && !parentNode.quasis[0].value.raw.trim();
  18113. if (isEmpty) {
  18114. return "``";
  18115. }
  18116. var expressionDocs = parentNode.expressions ? path$$1.map(print, "expressions") : [];
  18117. var newDoc = replacePlaceholders(quasisDoc, expressionDocs);
  18118. /* istanbul ignore if */
  18119. if (!newDoc) {
  18120. throw new Error("Couldn't insert all the expressions");
  18121. }
  18122. return concat$5(["`", indent$3(concat$5([hardline$4, stripTrailingHardline$1(newDoc)])), softline$2, "`"]);
  18123. } // Search all the placeholders in the quasisDoc tree
  18124. // and replace them with the expression docs one by one
  18125. // returns a new doc with all the placeholders replaced,
  18126. // or null if it couldn't replace any expression
  18127. function replacePlaceholders(quasisDoc, expressionDocs) {
  18128. if (!expressionDocs || !expressionDocs.length) {
  18129. return quasisDoc;
  18130. }
  18131. var expressions = expressionDocs.slice();
  18132. var replaceCounter = 0;
  18133. var newDoc = mapDoc$3(quasisDoc, function (doc$$2) {
  18134. if (!doc$$2 || !doc$$2.parts || !doc$$2.parts.length) {
  18135. return doc$$2;
  18136. }
  18137. var parts = doc$$2.parts;
  18138. var atIndex = parts.indexOf("@");
  18139. var placeholderIndex = atIndex + 1;
  18140. if (atIndex > -1 && typeof parts[placeholderIndex] === "string" && parts[placeholderIndex].startsWith("prettier-placeholder")) {
  18141. // If placeholder is split, join it
  18142. var at = parts[atIndex];
  18143. var placeholder = parts[placeholderIndex];
  18144. var rest = parts.slice(placeholderIndex + 1);
  18145. parts = parts.slice(0, atIndex).concat([at + placeholder]).concat(rest);
  18146. }
  18147. var atPlaceholderIndex = parts.findIndex(function (part) {
  18148. return typeof part === "string" && part.startsWith("@prettier-placeholder");
  18149. });
  18150. if (atPlaceholderIndex > -1) {
  18151. var _placeholder = parts[atPlaceholderIndex];
  18152. var _rest = parts.slice(atPlaceholderIndex + 1);
  18153. var placeholderMatch = _placeholder.match(/@prettier-placeholder-(.+)-id([\s\S]*)/);
  18154. var placeholderID = placeholderMatch[1]; // When the expression has a suffix appended, like:
  18155. // animation: linear ${time}s ease-out;
  18156. var suffix = placeholderMatch[2];
  18157. var expression = expressions[placeholderID];
  18158. replaceCounter++;
  18159. parts = parts.slice(0, atPlaceholderIndex).concat(["${", expression, "}" + suffix]).concat(_rest);
  18160. }
  18161. return Object.assign({}, doc$$2, {
  18162. parts: parts
  18163. });
  18164. });
  18165. return expressions.length === replaceCounter ? newDoc : null;
  18166. }
  18167. function printGraphqlComments(lines) {
  18168. var parts = [];
  18169. var seenComment = false;
  18170. lines.map(function (textLine) {
  18171. return textLine.trim();
  18172. }).forEach(function (textLine, i, array) {
  18173. // Lines are either whitespace only, or a comment (with poential whitespace
  18174. // around it). Drop whitespace-only lines.
  18175. if (textLine === "") {
  18176. return;
  18177. }
  18178. if (array[i - 1] === "" && seenComment) {
  18179. // If a non-first comment is preceded by a blank (whitespace only) line,
  18180. // add in a blank line.
  18181. parts.push(concat$5([hardline$4, textLine]));
  18182. } else {
  18183. parts.push(textLine);
  18184. }
  18185. seenComment = true;
  18186. }); // If `lines` was whitespace only, return `null`.
  18187. return parts.length === 0 ? null : join$3(hardline$4, parts);
  18188. }
  18189. /**
  18190. * Template literal in this context:
  18191. * <style jsx>{`div{color:red}`}</style>
  18192. */
  18193. function isStyledJsx(path$$1) {
  18194. var node = path$$1.getValue();
  18195. var parent = path$$1.getParentNode();
  18196. var parentParent = path$$1.getParentNode(1);
  18197. return parentParent && node.quasis && parent.type === "JSXExpressionContainer" && parentParent.type === "JSXElement" && parentParent.openingElement.name.name === "style" && parentParent.openingElement.attributes.some(function (attribute) {
  18198. return attribute.name.name === "jsx";
  18199. });
  18200. }
  18201. /**
  18202. * Angular Components can have:
  18203. * - Inline HTML template
  18204. * - Inline CSS styles
  18205. *
  18206. * ...which are both within template literals somewhere
  18207. * inside of the Component decorator factory.
  18208. *
  18209. * E.g.
  18210. * @Component({
  18211. * template: `<div>...</div>`,
  18212. * styles: [`h1 { color: blue; }`]
  18213. * })
  18214. */
  18215. function isAngularComponentStyles(path$$1) {
  18216. return isPathMatch(path$$1, [function (node) {
  18217. return node.type === "TemplateLiteral";
  18218. }, function (node, name) {
  18219. return node.type === "ArrayExpression" && name === "elements";
  18220. }, function (node, name) {
  18221. return node.type === "Property" && node.key.type === "Identifier" && node.key.name === "styles" && name === "value";
  18222. }].concat(getAngularComponentObjectExpressionPredicates()));
  18223. }
  18224. function isAngularComponentTemplate(path$$1) {
  18225. return isPathMatch(path$$1, [function (node) {
  18226. return node.type === "TemplateLiteral";
  18227. }, function (node, name) {
  18228. return node.type === "Property" && node.key.type === "Identifier" && node.key.name === "template" && name === "value";
  18229. }].concat(getAngularComponentObjectExpressionPredicates()));
  18230. }
  18231. function getAngularComponentObjectExpressionPredicates() {
  18232. return [function (node, name) {
  18233. return node.type === "ObjectExpression" && name === "properties";
  18234. }, function (node, name) {
  18235. return node.type === "CallExpression" && node.callee.type === "Identifier" && node.callee.name === "Component" && name === "arguments";
  18236. }, function (node, name) {
  18237. return node.type === "Decorator" && name === "expression";
  18238. }];
  18239. }
  18240. /**
  18241. * styled-components template literals
  18242. */
  18243. function isStyledComponents(path$$1) {
  18244. var parent = path$$1.getParentNode();
  18245. if (!parent || parent.type !== "TaggedTemplateExpression") {
  18246. return false;
  18247. }
  18248. var tag = parent.tag;
  18249. switch (tag.type) {
  18250. case "MemberExpression":
  18251. return (// styled.foo``
  18252. isStyledIdentifier(tag.object) || // Component.extend``
  18253. isStyledExtend(tag)
  18254. );
  18255. case "CallExpression":
  18256. return (// styled(Component)``
  18257. isStyledIdentifier(tag.callee) || tag.callee.type === "MemberExpression" && (tag.callee.object.type === "MemberExpression" && ( // styled.foo.attr({})``
  18258. isStyledIdentifier(tag.callee.object.object) || // Component.extend.attr({)``
  18259. isStyledExtend(tag.callee.object)) || // styled(Component).attr({})``
  18260. tag.callee.object.type === "CallExpression" && isStyledIdentifier(tag.callee.object.callee))
  18261. );
  18262. case "Identifier":
  18263. // css``
  18264. return tag.name === "css";
  18265. default:
  18266. return false;
  18267. }
  18268. }
  18269. /**
  18270. * JSX element with CSS prop
  18271. */
  18272. function isCssProp(path$$1) {
  18273. var parent = path$$1.getParentNode();
  18274. var parentParent = path$$1.getParentNode(1);
  18275. return parentParent && parent.type === "JSXExpressionContainer" && parentParent.type === "JSXAttribute" && parentParent.name.type === "JSXIdentifier" && parentParent.name.name === "css";
  18276. }
  18277. function isStyledIdentifier(node) {
  18278. return node.type === "Identifier" && node.name === "styled";
  18279. }
  18280. function isStyledExtend(node) {
  18281. return /^[A-Z]/.test(node.object.name) && node.property.name === "extend";
  18282. }
  18283. /*
  18284. * react-relay and graphql-tag
  18285. * graphql`...`
  18286. * graphql.experimental`...`
  18287. * gql`...`
  18288. * GraphQL comment block
  18289. *
  18290. * This intentionally excludes Relay Classic tags, as Prettier does not
  18291. * support Relay Classic formatting.
  18292. */
  18293. function isGraphQL(path$$1) {
  18294. var node = path$$1.getValue();
  18295. var parent = path$$1.getParentNode();
  18296. return hasLanguageComment(node, "GraphQL") || parent && (parent.type === "TaggedTemplateExpression" && (parent.tag.type === "MemberExpression" && parent.tag.object.name === "graphql" && parent.tag.property.name === "experimental" || parent.tag.type === "Identifier" && (parent.tag.name === "gql" || parent.tag.name === "graphql")) || parent.type === "CallExpression" && parent.callee.type === "Identifier" && parent.callee.name === "graphql");
  18297. }
  18298. function hasLanguageComment(node, languageName) {
  18299. // This checks for a leading comment that is exactly `/* GraphQL */`
  18300. // In order to be in line with other implementations of this comment tag
  18301. // we will not trim the comment value and we will expect exactly one space on
  18302. // either side of the GraphQL string
  18303. // Also see ./clean.js
  18304. return hasLeadingComment$1(node, function (comment) {
  18305. return isBlockComment(comment) && comment.value === ` ${languageName} `;
  18306. });
  18307. }
  18308. function isPathMatch(path$$1, predicateStack) {
  18309. var stack = path$$1.stack.slice();
  18310. var name = null;
  18311. var node = stack.pop();
  18312. var _iteratorNormalCompletion = true;
  18313. var _didIteratorError = false;
  18314. var _iteratorError = undefined;
  18315. try {
  18316. for (var _iterator = predicateStack[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  18317. var predicate = _step.value;
  18318. if (node === undefined) {
  18319. return false;
  18320. } // skip index/array
  18321. if (typeof name === "number") {
  18322. name = stack.pop();
  18323. node = stack.pop();
  18324. }
  18325. if (!predicate(node, name)) {
  18326. return false;
  18327. }
  18328. name = stack.pop();
  18329. node = stack.pop();
  18330. }
  18331. } catch (err) {
  18332. _didIteratorError = true;
  18333. _iteratorError = err;
  18334. } finally {
  18335. try {
  18336. if (!_iteratorNormalCompletion && _iterator.return != null) {
  18337. _iterator.return();
  18338. }
  18339. } finally {
  18340. if (_didIteratorError) {
  18341. throw _iteratorError;
  18342. }
  18343. }
  18344. }
  18345. return true;
  18346. }
  18347. /**
  18348. * - html`...`
  18349. * - HTML comment block
  18350. */
  18351. function isHtml(path$$1) {
  18352. var node = path$$1.getValue();
  18353. return hasLanguageComment(node, "HTML") || isPathMatch(path$$1, [function (node) {
  18354. return node.type === "TemplateLiteral";
  18355. }, function (node, name) {
  18356. return node.type === "TaggedTemplateExpression" && node.tag.type === "Identifier" && node.tag.name === "html" && name === "quasi";
  18357. }]);
  18358. }
  18359. function printHtmlTemplateLiteral(path$$1, print, textToDoc, parser) {
  18360. var node = path$$1.getValue();
  18361. var placeholderPattern = "PRETTIER_HTML_PLACEHOLDER_(\\d+)_IN_JS";
  18362. var placeholders = node.expressions.map(function (_, i) {
  18363. return `PRETTIER_HTML_PLACEHOLDER_${i}_IN_JS`;
  18364. });
  18365. var text = node.quasis.map(function (quasi, index, quasis) {
  18366. return index === quasis.length - 1 ? quasi.value.raw : quasi.value.raw + placeholders[index];
  18367. }).join("");
  18368. var expressionDocs = path$$1.map(print, "expressions");
  18369. if (expressionDocs.length === 0 && text.trim().length === 0) {
  18370. return "``";
  18371. }
  18372. var contentDoc = mapDoc$3(stripTrailingHardline$1(textToDoc(text, {
  18373. parser
  18374. })), function (doc$$2) {
  18375. var placeholderRegex = new RegExp(placeholderPattern, "g");
  18376. var hasPlaceholder = typeof doc$$2 === "string" && placeholderRegex.test(doc$$2);
  18377. if (!hasPlaceholder) {
  18378. return doc$$2;
  18379. }
  18380. var parts = [];
  18381. var components = doc$$2.split(placeholderRegex);
  18382. for (var i = 0; i < components.length; i++) {
  18383. var component = components[i];
  18384. if (i % 2 === 0) {
  18385. if (component) {
  18386. parts.push(component);
  18387. }
  18388. continue;
  18389. }
  18390. var placeholderIndex = +component;
  18391. parts.push(concat$5(["${", group$2(expressionDocs[placeholderIndex]), "}"]));
  18392. }
  18393. return concat$5(parts);
  18394. });
  18395. return group$2(concat$5(["`", indent$3(concat$5([hardline$4, group$2(contentDoc)])), softline$2, "`"]));
  18396. }
  18397. var embed_1 = embed;
  18398. function clean(ast, newObj, parent) {
  18399. ["range", "raw", "comments", "leadingComments", "trailingComments", "extra", "start", "end", "flags"].forEach(function (name) {
  18400. delete newObj[name];
  18401. });
  18402. if (ast.type === "BigIntLiteral") {
  18403. newObj.value = newObj.value.toLowerCase();
  18404. } // We remove extra `;` and add them when needed
  18405. if (ast.type === "EmptyStatement") {
  18406. return null;
  18407. } // We move text around, including whitespaces and add {" "}
  18408. if (ast.type === "JSXText") {
  18409. return null;
  18410. }
  18411. if (ast.type === "JSXExpressionContainer" && ast.expression.type === "Literal" && ast.expression.value === " ") {
  18412. return null;
  18413. } // (TypeScript) Ignore `static` in `constructor(static p) {}`
  18414. // and `export` in `constructor(export p) {}`
  18415. if (ast.type === "TSParameterProperty" && ast.accessibility === null && !ast.readonly) {
  18416. return {
  18417. type: "Identifier",
  18418. name: ast.parameter.name,
  18419. typeAnnotation: newObj.parameter.typeAnnotation,
  18420. decorators: newObj.decorators
  18421. };
  18422. } // (TypeScript) ignore empty `specifiers` array
  18423. if (ast.type === "TSNamespaceExportDeclaration" && ast.specifiers && ast.specifiers.length === 0) {
  18424. delete newObj.specifiers;
  18425. } // (TypeScript) bypass TSParenthesizedType
  18426. if (ast.type === "TSParenthesizedType") {
  18427. return newObj.typeAnnotation;
  18428. } // We convert <div></div> to <div />
  18429. if (ast.type === "JSXOpeningElement") {
  18430. delete newObj.selfClosing;
  18431. }
  18432. if (ast.type === "JSXElement") {
  18433. delete newObj.closingElement;
  18434. } // We change {'key': value} into {key: value}
  18435. if ((ast.type === "Property" || ast.type === "ObjectProperty" || ast.type === "MethodDefinition" || ast.type === "ClassProperty" || ast.type === "TSPropertySignature" || ast.type === "ObjectTypeProperty") && typeof ast.key === "object" && ast.key && (ast.key.type === "Literal" || ast.key.type === "StringLiteral" || ast.key.type === "Identifier")) {
  18436. delete newObj.key;
  18437. }
  18438. if (ast.type === "OptionalMemberExpression" && ast.optional === false) {
  18439. newObj.type = "MemberExpression";
  18440. delete newObj.optional;
  18441. } // Remove raw and cooked values from TemplateElement when it's CSS
  18442. // styled-jsx
  18443. if (ast.type === "JSXElement" && ast.openingElement.name.name === "style" && ast.openingElement.attributes.some(function (attr) {
  18444. return attr.name.name === "jsx";
  18445. })) {
  18446. var templateLiterals = newObj.children.filter(function (child) {
  18447. return child.type === "JSXExpressionContainer" && child.expression.type === "TemplateLiteral";
  18448. }).map(function (container) {
  18449. return container.expression;
  18450. });
  18451. var quasis = templateLiterals.reduce(function (quasis, templateLiteral) {
  18452. return quasis.concat(templateLiteral.quasis);
  18453. }, []);
  18454. quasis.forEach(function (q) {
  18455. return delete q.value;
  18456. });
  18457. } // CSS template literals in css prop
  18458. if (ast.type === "JSXAttribute" && ast.name.name === "css" && ast.value.type === "JSXExpressionContainer" && ast.value.expression.type === "TemplateLiteral") {
  18459. newObj.value.expression.quasis.forEach(function (q) {
  18460. return delete q.value;
  18461. });
  18462. } // Angular Components: Inline HTML template and Inline CSS styles
  18463. var expression = ast.expression || ast.callee;
  18464. if (ast.type === "Decorator" && expression.type === "CallExpression" && expression.callee.name === "Component" && expression.arguments.length === 1) {
  18465. var astProps = ast.expression.arguments[0].properties;
  18466. newObj.expression.arguments[0].properties.forEach(function (prop, index) {
  18467. var templateLiteral = null;
  18468. switch (astProps[index].key.name) {
  18469. case "styles":
  18470. if (prop.value.type === "ArrayExpression") {
  18471. templateLiteral = prop.value.elements[0];
  18472. }
  18473. break;
  18474. case "template":
  18475. if (prop.value.type === "TemplateLiteral") {
  18476. templateLiteral = prop.value;
  18477. }
  18478. break;
  18479. }
  18480. if (templateLiteral) {
  18481. templateLiteral.quasis.forEach(function (q) {
  18482. return delete q.value;
  18483. });
  18484. }
  18485. });
  18486. } // styled-components, graphql, markdown
  18487. if (ast.type === "TaggedTemplateExpression" && (ast.tag.type === "MemberExpression" || ast.tag.type === "Identifier" && (ast.tag.name === "gql" || ast.tag.name === "graphql" || ast.tag.name === "css" || ast.tag.name === "md" || ast.tag.name === "markdown" || ast.tag.name === "html") || ast.tag.type === "CallExpression")) {
  18488. newObj.quasi.quasis.forEach(function (quasi) {
  18489. return delete quasi.value;
  18490. });
  18491. }
  18492. if (ast.type === "TemplateLiteral") {
  18493. // This checks for a leading comment that is exactly `/* GraphQL */`
  18494. // In order to be in line with other implementations of this comment tag
  18495. // we will not trim the comment value and we will expect exactly one space on
  18496. // either side of the GraphQL string
  18497. // Also see ./embed.js
  18498. var hasLanguageComment = ast.leadingComments && ast.leadingComments.some(function (comment) {
  18499. return comment.type === "CommentBlock" && ["GraphQL", "HTML"].some(function (languageName) {
  18500. return comment.value === ` ${languageName} `;
  18501. });
  18502. });
  18503. if (hasLanguageComment || parent.type === "CallExpression" && parent.callee.name === "graphql") {
  18504. newObj.quasis.forEach(function (quasi) {
  18505. return delete quasi.value;
  18506. });
  18507. }
  18508. }
  18509. }
  18510. var clean_1 = clean;
  18511. var detectNewline = createCommonjsModule(function (module) {
  18512. 'use strict';
  18513. module.exports = function (str) {
  18514. if (typeof str !== 'string') {
  18515. throw new TypeError('Expected a string');
  18516. }
  18517. var newlines = str.match(/(?:\r?\n)/g) || [];
  18518. if (newlines.length === 0) {
  18519. return null;
  18520. }
  18521. var crlf = newlines.filter(function (el) {
  18522. return el === '\r\n';
  18523. }).length;
  18524. var lf = newlines.length - crlf;
  18525. return crlf > lf ? '\r\n' : '\n';
  18526. };
  18527. module.exports.graceful = function (str) {
  18528. return module.exports(str) || '\n';
  18529. };
  18530. });
  18531. var build$1 = createCommonjsModule(function (module, exports) {
  18532. 'use strict';
  18533. Object.defineProperty(exports, '__esModule', {
  18534. value: true
  18535. });
  18536. exports.extract = extract;
  18537. exports.strip = strip;
  18538. exports.parse = parse;
  18539. exports.parseWithComments = parseWithComments;
  18540. exports.print = print;
  18541. var _detectNewline;
  18542. function _load_detectNewline() {
  18543. return _detectNewline = _interopRequireDefault(detectNewline);
  18544. }
  18545. var _os;
  18546. function _load_os() {
  18547. return _os = os;
  18548. }
  18549. function _interopRequireDefault(obj) {
  18550. return obj && obj.__esModule ? obj : {
  18551. default: obj
  18552. };
  18553. }
  18554. /**
  18555. * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
  18556. *
  18557. * This source code is licensed under the MIT license found in the
  18558. * LICENSE file in the root directory of this source tree.
  18559. *
  18560. *
  18561. */
  18562. var commentEndRe = /\*\/$/;
  18563. var commentStartRe = /^\/\*\*/;
  18564. var docblockRe = /^\s*(\/\*\*?(.|\r?\n)*?\*\/)/;
  18565. var lineCommentRe = /(^|\s+)\/\/([^\r\n]*)/g;
  18566. var ltrimNewlineRe = /^(\r?\n)+/;
  18567. var multilineRe = /(?:^|\r?\n) *(@[^\r\n]*?) *\r?\n *(?![^@\r\n]*\/\/[^]*)([^@\r\n\s][^@\r\n]+?) *\r?\n/g;
  18568. var propertyRe = /(?:^|\r?\n) *@(\S+) *([^\r\n]*)/g;
  18569. var stringStartRe = /(\r?\n|^) *\* ?/g;
  18570. function extract(contents) {
  18571. var match = contents.match(docblockRe);
  18572. return match ? match[0].trimLeft() : '';
  18573. }
  18574. function strip(contents) {
  18575. var match = contents.match(docblockRe);
  18576. return match && match[0] ? contents.substring(match[0].length) : contents;
  18577. }
  18578. function parse(docblock) {
  18579. return parseWithComments(docblock).pragmas;
  18580. }
  18581. function parseWithComments(docblock) {
  18582. var line = (0, (_detectNewline || _load_detectNewline()).default)(docblock) || (_os || _load_os()).EOL;
  18583. docblock = docblock.replace(commentStartRe, '').replace(commentEndRe, '').replace(stringStartRe, '$1'); // Normalize multi-line directives
  18584. var prev = '';
  18585. while (prev !== docblock) {
  18586. prev = docblock;
  18587. docblock = docblock.replace(multilineRe, `${line}$1 $2${line}`);
  18588. }
  18589. docblock = docblock.replace(ltrimNewlineRe, '').trimRight();
  18590. var result = Object.create(null);
  18591. var comments = docblock.replace(propertyRe, '').replace(ltrimNewlineRe, '').trimRight();
  18592. var match;
  18593. while (match = propertyRe.exec(docblock)) {
  18594. // strip linecomments from pragmas
  18595. var nextPragma = match[2].replace(lineCommentRe, '');
  18596. if (typeof result[match[1]] === 'string' || Array.isArray(result[match[1]])) {
  18597. result[match[1]] = [].concat(result[match[1]], nextPragma);
  18598. } else {
  18599. result[match[1]] = nextPragma;
  18600. }
  18601. }
  18602. return {
  18603. comments,
  18604. pragmas: result
  18605. };
  18606. }
  18607. function print(_ref) {
  18608. var _ref$comments = _ref.comments;
  18609. var comments = _ref$comments === undefined ? '' : _ref$comments;
  18610. var _ref$pragmas = _ref.pragmas;
  18611. var pragmas = _ref$pragmas === undefined ? {} : _ref$pragmas;
  18612. var line = (0, (_detectNewline || _load_detectNewline()).default)(comments) || (_os || _load_os()).EOL;
  18613. var head = '/**';
  18614. var start = ' *';
  18615. var tail = ' */';
  18616. var keys = Object.keys(pragmas);
  18617. var printedObject = keys.map(function (key) {
  18618. return printKeyValues(key, pragmas[key]);
  18619. }).reduce(function (arr, next) {
  18620. return arr.concat(next);
  18621. }, []).map(function (keyValue) {
  18622. return start + ' ' + keyValue + line;
  18623. }).join('');
  18624. if (!comments) {
  18625. if (keys.length === 0) {
  18626. return '';
  18627. }
  18628. if (keys.length === 1 && !Array.isArray(pragmas[keys[0]])) {
  18629. var value = pragmas[keys[0]];
  18630. return `${head} ${printKeyValues(keys[0], value)[0]}${tail}`;
  18631. }
  18632. }
  18633. var printedComments = comments.split(line).map(function (textLine) {
  18634. return `${start} ${textLine}`;
  18635. }).join(line) + line;
  18636. return head + line + (comments ? printedComments : '') + (comments && keys.length ? start + line : '') + printedObject + tail;
  18637. }
  18638. function printKeyValues(key, valueOrArray) {
  18639. return [].concat(valueOrArray).map(function (value) {
  18640. return `@${key} ${value}`.trim();
  18641. });
  18642. }
  18643. });
  18644. unwrapExports(build$1);
  18645. function hasPragma(text) {
  18646. var pragmas = Object.keys(build$1.parse(build$1.extract(text)));
  18647. return pragmas.indexOf("prettier") !== -1 || pragmas.indexOf("format") !== -1;
  18648. }
  18649. function insertPragma$1(text) {
  18650. var parsedDocblock = build$1.parseWithComments(build$1.extract(text));
  18651. var pragmas = Object.assign({
  18652. format: ""
  18653. }, parsedDocblock.pragmas);
  18654. var newDocblock = build$1.print({
  18655. pragmas,
  18656. comments: parsedDocblock.comments.replace(/^(\s+?\r?\n)+/, "") // remove leading newlines
  18657. }).replace(/(\r\n|\r)/g, "\n"); // normalise newlines (mitigate use of os.EOL by jest-docblock)
  18658. var strippedText = build$1.strip(text);
  18659. var separatingNewlines = strippedText.startsWith("\n") ? "\n" : "\n\n";
  18660. return newDocblock + separatingNewlines + strippedText;
  18661. }
  18662. var pragma = {
  18663. hasPragma,
  18664. insertPragma: insertPragma$1
  18665. };
  18666. // Flow annotation comments cannot be split across lines. For example:
  18667. //
  18668. // (this /*
  18669. // : any */).foo = 5;
  18670. //
  18671. // is not picked up by Flow (see https://github.com/facebook/flow/issues/7050), so
  18672. // removing the newline would create a type annotation that the user did not intend
  18673. // to create.
  18674. var NON_LINE_TERMINATING_WHITE_SPACE = "(?:(?=.)\\s)";
  18675. var FLOW_SHORTHAND_ANNOTATION = new RegExp(`^${NON_LINE_TERMINATING_WHITE_SPACE}*:`);
  18676. var FLOW_ANNOTATION = new RegExp(`^${NON_LINE_TERMINATING_WHITE_SPACE}*::`);
  18677. function hasFlowShorthandAnnotationComment$2(node) {
  18678. // https://flow.org/en/docs/types/comments/
  18679. // Syntax example: const r = new (window.Request /*: Class<Request> */)("");
  18680. return node.extra && node.extra.parenthesized && node.trailingComments && node.trailingComments[0].value.match(FLOW_SHORTHAND_ANNOTATION);
  18681. }
  18682. function hasFlowAnnotationComment$1(comments) {
  18683. return comments && comments[0].value.match(FLOW_ANNOTATION);
  18684. }
  18685. function hasNode$1(node, fn) {
  18686. if (!node || typeof node !== "object") {
  18687. return false;
  18688. }
  18689. if (Array.isArray(node)) {
  18690. return node.some(function (value) {
  18691. return hasNode$1(value, fn);
  18692. });
  18693. }
  18694. var result = fn(node);
  18695. return typeof result === "boolean" ? result : Object.keys(node).some(function (key) {
  18696. return hasNode$1(node[key], fn);
  18697. });
  18698. }
  18699. var utils$4 = {
  18700. hasNode: hasNode$1,
  18701. hasFlowShorthandAnnotationComment: hasFlowShorthandAnnotationComment$2,
  18702. hasFlowAnnotationComment: hasFlowAnnotationComment$1
  18703. };
  18704. var hasFlowShorthandAnnotationComment$1 = utils$4.hasFlowShorthandAnnotationComment;
  18705. function hasClosureCompilerTypeCastComment(text, path$$1, locStart, locEnd) {
  18706. // https://github.com/google/closure-compiler/wiki/Annotating-Types#type-casts
  18707. // Syntax example: var x = /** @type {string} */ (fruit);
  18708. var n = path$$1.getValue();
  18709. return util$1.getNextNonSpaceNonCommentCharacter(text, n, locEnd) === ")" && (hasTypeCastComment(n) || hasAncestorTypeCastComment(0)); // for sub-item: /** @type {array} */ (numberOrString).map(x => x);
  18710. function hasAncestorTypeCastComment(index) {
  18711. var ancestor = path$$1.getParentNode(index);
  18712. return ancestor && util$1.getNextNonSpaceNonCommentCharacter(text, ancestor, locEnd) !== ")" && /^[\s(]*$/.test(text.slice(locStart(ancestor), locStart(n))) ? hasTypeCastComment(ancestor) || hasAncestorTypeCastComment(index + 1) : false;
  18713. }
  18714. function hasTypeCastComment(node) {
  18715. return node.comments && node.comments.some(function (comment) {
  18716. return comment.leading && comments$3.isBlockComment(comment) && isTypeCastComment(comment.value) && util$1.getNextNonSpaceNonCommentCharacter(text, comment, locEnd) === "(";
  18717. });
  18718. }
  18719. function isTypeCastComment(comment) {
  18720. var trimmed = comment.trim();
  18721. if (!/^\*\s*@type\s*\{[^]+\}$/.test(trimmed)) {
  18722. return false;
  18723. }
  18724. var isCompletelyClosed = false;
  18725. var unpairedBracketCount = 0;
  18726. var _iteratorNormalCompletion = true;
  18727. var _didIteratorError = false;
  18728. var _iteratorError = undefined;
  18729. try {
  18730. for (var _iterator = trimmed[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  18731. var char = _step.value;
  18732. if (char === "{") {
  18733. if (isCompletelyClosed) {
  18734. return false;
  18735. }
  18736. unpairedBracketCount++;
  18737. } else if (char === "}") {
  18738. if (unpairedBracketCount === 0) {
  18739. return false;
  18740. }
  18741. unpairedBracketCount--;
  18742. if (unpairedBracketCount === 0) {
  18743. isCompletelyClosed = true;
  18744. }
  18745. }
  18746. }
  18747. } catch (err) {
  18748. _didIteratorError = true;
  18749. _iteratorError = err;
  18750. } finally {
  18751. try {
  18752. if (!_iteratorNormalCompletion && _iterator.return != null) {
  18753. _iterator.return();
  18754. }
  18755. } finally {
  18756. if (_didIteratorError) {
  18757. throw _iteratorError;
  18758. }
  18759. }
  18760. }
  18761. return unpairedBracketCount === 0;
  18762. }
  18763. }
  18764. function needsParens(path$$1, options) {
  18765. var parent = path$$1.getParentNode();
  18766. if (!parent) {
  18767. return false;
  18768. }
  18769. var name = path$$1.getName();
  18770. var node = path$$1.getNode(); // If the value of this path is some child of a Node and not a Node
  18771. // itself, then it doesn't need parentheses. Only Node objects (in
  18772. // fact, only Expression nodes) need parentheses.
  18773. if (path$$1.getValue() !== node) {
  18774. return false;
  18775. } // to avoid unexpected `}}` in HTML interpolations
  18776. if (options.__isInHtmlInterpolation && !options.bracketSpacing && endsWithRightBracket(node) && isFollowedByRightBracket(path$$1)) {
  18777. return true;
  18778. } // Only statements don't need parentheses.
  18779. if (isStatement(node)) {
  18780. return false;
  18781. } // Closure compiler requires that type casted expressions to be surrounded by
  18782. // parentheses.
  18783. if (hasClosureCompilerTypeCastComment(options.originalText, path$$1, options.locStart, options.locEnd)) {
  18784. return true;
  18785. }
  18786. if ( // Preserve parens if we have a Flow annotation comment, unless we're using the Flow
  18787. // parser. The Flow parser turns Flow comments into type annotation nodes in its
  18788. // AST, which we handle separately.
  18789. options.parser !== "flow" && hasFlowShorthandAnnotationComment$1(path$$1.getValue())) {
  18790. return true;
  18791. } // Identifiers never need parentheses.
  18792. if (node.type === "Identifier") {
  18793. return false;
  18794. }
  18795. if (parent.type === "ParenthesizedExpression") {
  18796. return false;
  18797. } // Add parens around the extends clause of a class. It is needed for almost
  18798. // all expressions.
  18799. if ((parent.type === "ClassDeclaration" || parent.type === "ClassExpression") && parent.superClass === node && (node.type === "ArrowFunctionExpression" || node.type === "AssignmentExpression" || node.type === "AwaitExpression" || node.type === "BinaryExpression" || node.type === "ConditionalExpression" || node.type === "LogicalExpression" || node.type === "NewExpression" || node.type === "ObjectExpression" || node.type === "ParenthesizedExpression" || node.type === "SequenceExpression" || node.type === "TaggedTemplateExpression" || node.type === "UnaryExpression" || node.type === "UpdateExpression" || node.type === "YieldExpression")) {
  18800. return true;
  18801. }
  18802. if (parent.type === "Decorator" && parent.expression === node) {
  18803. var hasCallExpression = false;
  18804. var hasMemberExpression = false;
  18805. var current = node;
  18806. while (current) {
  18807. switch (current.type) {
  18808. case "MemberExpression":
  18809. hasMemberExpression = true;
  18810. current = current.object;
  18811. break;
  18812. case "CallExpression":
  18813. if (
  18814. /** @(x().y) */
  18815. hasMemberExpression ||
  18816. /** @(x().y()) */
  18817. hasCallExpression) {
  18818. return true;
  18819. }
  18820. hasCallExpression = true;
  18821. current = current.callee;
  18822. break;
  18823. case "Identifier":
  18824. return false;
  18825. default:
  18826. return true;
  18827. }
  18828. }
  18829. return true;
  18830. }
  18831. if (parent.type === "ArrowFunctionExpression" && parent.body === node && node.type !== "SequenceExpression" && // these have parens added anyway
  18832. util$1.startsWithNoLookaheadToken(node,
  18833. /* forbidFunctionClassAndDoExpr */
  18834. false) || parent.type === "ExpressionStatement" && util$1.startsWithNoLookaheadToken(node,
  18835. /* forbidFunctionClassAndDoExpr */
  18836. true)) {
  18837. return true;
  18838. }
  18839. switch (node.type) {
  18840. case "CallExpression":
  18841. {
  18842. var firstParentNotMemberExpression = parent;
  18843. var i = 0;
  18844. while (firstParentNotMemberExpression && firstParentNotMemberExpression.type === "MemberExpression") {
  18845. firstParentNotMemberExpression = path$$1.getParentNode(++i);
  18846. }
  18847. if (firstParentNotMemberExpression.type === "NewExpression" && firstParentNotMemberExpression.callee === path$$1.getParentNode(i - 1)) {
  18848. return true;
  18849. }
  18850. if (parent.type === "BindExpression" && parent.callee === node) {
  18851. return true;
  18852. }
  18853. return false;
  18854. }
  18855. case "SpreadElement":
  18856. case "SpreadProperty":
  18857. return parent.type === "MemberExpression" && name === "object" && parent.object === node;
  18858. case "UpdateExpression":
  18859. if (parent.type === "UnaryExpression") {
  18860. return node.prefix && (node.operator === "++" && parent.operator === "+" || node.operator === "--" && parent.operator === "-");
  18861. }
  18862. // else fallthrough
  18863. case "UnaryExpression":
  18864. switch (parent.type) {
  18865. case "UnaryExpression":
  18866. return node.operator === parent.operator && (node.operator === "+" || node.operator === "-");
  18867. case "BindExpression":
  18868. return true;
  18869. case "MemberExpression":
  18870. return name === "object" && parent.object === node;
  18871. case "TaggedTemplateExpression":
  18872. return true;
  18873. case "NewExpression":
  18874. case "CallExpression":
  18875. return name === "callee" && parent.callee === node;
  18876. case "BinaryExpression":
  18877. return parent.operator === "**" && name === "left";
  18878. case "TSNonNullExpression":
  18879. return true;
  18880. default:
  18881. return false;
  18882. }
  18883. case "BinaryExpression":
  18884. {
  18885. if (parent.type === "UpdateExpression") {
  18886. return true;
  18887. }
  18888. var isLeftOfAForStatement = function isLeftOfAForStatement(node) {
  18889. var i = 0;
  18890. while (node) {
  18891. var _parent = path$$1.getParentNode(i++);
  18892. if (!_parent) {
  18893. return false;
  18894. }
  18895. if (_parent.type === "ForStatement" && _parent.init === node) {
  18896. return true;
  18897. }
  18898. node = _parent;
  18899. }
  18900. return false;
  18901. };
  18902. if (node.operator === "in" && isLeftOfAForStatement(node)) {
  18903. return true;
  18904. }
  18905. }
  18906. // fallthrough
  18907. case "TSTypeAssertion":
  18908. case "TSAsExpression":
  18909. case "LogicalExpression":
  18910. switch (parent.type) {
  18911. case "ConditionalExpression":
  18912. return node.type === "TSAsExpression";
  18913. case "CallExpression":
  18914. case "NewExpression":
  18915. return name === "callee" && parent.callee === node;
  18916. case "ClassExpression":
  18917. case "ClassDeclaration":
  18918. case "TSAbstractClassDeclaration":
  18919. return name === "superClass" && parent.superClass === node;
  18920. case "TSTypeAssertion":
  18921. case "TaggedTemplateExpression":
  18922. case "UnaryExpression":
  18923. case "SpreadElement":
  18924. case "SpreadProperty":
  18925. case "BindExpression":
  18926. case "AwaitExpression":
  18927. case "TSAsExpression":
  18928. case "TSNonNullExpression":
  18929. case "UpdateExpression":
  18930. return true;
  18931. case "MemberExpression":
  18932. case "OptionalMemberExpression":
  18933. return name === "object" && parent.object === node;
  18934. case "AssignmentExpression":
  18935. return parent.left === node && (node.type === "TSTypeAssertion" || node.type === "TSAsExpression");
  18936. case "BinaryExpression":
  18937. case "LogicalExpression":
  18938. {
  18939. if (!node.operator && node.type !== "TSTypeAssertion") {
  18940. return true;
  18941. }
  18942. var po = parent.operator;
  18943. var pp = util$1.getPrecedence(po);
  18944. var no = node.operator;
  18945. var np = util$1.getPrecedence(no);
  18946. if (pp > np) {
  18947. return true;
  18948. }
  18949. if ((po === "||" || po === "??") && no === "&&") {
  18950. return true;
  18951. }
  18952. if (pp === np && name === "right") {
  18953. assert.strictEqual(parent.right, node);
  18954. return true;
  18955. }
  18956. if (pp === np && !util$1.shouldFlatten(po, no)) {
  18957. return true;
  18958. }
  18959. if (pp < np && no === "%") {
  18960. return po === "+" || po === "-";
  18961. } // Add parenthesis when working with bitwise operators
  18962. // It's not stricly needed but helps with code understanding
  18963. if (util$1.isBitwiseOperator(po)) {
  18964. return true;
  18965. }
  18966. return false;
  18967. }
  18968. default:
  18969. return false;
  18970. }
  18971. case "TSParenthesizedType":
  18972. {
  18973. var grandParent = path$$1.getParentNode(1);
  18974. /**
  18975. * const foo = (): (() => void) => (): void => null;
  18976. * ^ ^
  18977. */
  18978. if (getUnparenthesizedNode(node).type === "TSFunctionType" && parent.type === "TSTypeAnnotation" && grandParent.type === "ArrowFunctionExpression" && grandParent.returnType === parent) {
  18979. return true;
  18980. }
  18981. if ((parent.type === "TSTypeParameter" || parent.type === "TypeParameter" || parent.type === "TSTypeAliasDeclaration" || parent.type === "TSTypeAnnotation" || parent.type === "TSParenthesizedType" || parent.type === "TSTypeParameterInstantiation") && grandParent.type !== "TSTypeOperator" && grandParent.type !== "TSOptionalType") {
  18982. return false;
  18983. } // Delegate to inner TSParenthesizedType
  18984. if (node.typeAnnotation.type === "TSParenthesizedType") {
  18985. return false;
  18986. }
  18987. return true;
  18988. }
  18989. case "SequenceExpression":
  18990. switch (parent.type) {
  18991. case "ReturnStatement":
  18992. return false;
  18993. case "ForStatement":
  18994. // Although parentheses wouldn't hurt around sequence
  18995. // expressions in the head of for loops, traditional style
  18996. // dictates that e.g. i++, j++ should not be wrapped with
  18997. // parentheses.
  18998. return false;
  18999. case "ExpressionStatement":
  19000. return name !== "expression";
  19001. case "ArrowFunctionExpression":
  19002. // We do need parentheses, but SequenceExpressions are handled
  19003. // specially when printing bodies of arrow functions.
  19004. return name !== "body";
  19005. default:
  19006. // Otherwise err on the side of overparenthesization, adding
  19007. // explicit exceptions above if this proves overzealous.
  19008. return true;
  19009. }
  19010. case "YieldExpression":
  19011. if (parent.type === "UnaryExpression" || parent.type === "AwaitExpression" || parent.type === "TSAsExpression" || parent.type === "TSNonNullExpression") {
  19012. return true;
  19013. }
  19014. // else fallthrough
  19015. case "AwaitExpression":
  19016. switch (parent.type) {
  19017. case "TaggedTemplateExpression":
  19018. case "UnaryExpression":
  19019. case "BinaryExpression":
  19020. case "LogicalExpression":
  19021. case "SpreadElement":
  19022. case "SpreadProperty":
  19023. case "TSAsExpression":
  19024. case "TSNonNullExpression":
  19025. case "BindExpression":
  19026. return true;
  19027. case "MemberExpression":
  19028. return parent.object === node;
  19029. case "NewExpression":
  19030. case "CallExpression":
  19031. return parent.callee === node;
  19032. case "ConditionalExpression":
  19033. return parent.test === node;
  19034. default:
  19035. return false;
  19036. }
  19037. case "ArrayTypeAnnotation":
  19038. return parent.type === "NullableTypeAnnotation";
  19039. case "IntersectionTypeAnnotation":
  19040. case "UnionTypeAnnotation":
  19041. return parent.type === "ArrayTypeAnnotation" || parent.type === "NullableTypeAnnotation" || parent.type === "IntersectionTypeAnnotation" || parent.type === "UnionTypeAnnotation";
  19042. case "NullableTypeAnnotation":
  19043. return parent.type === "ArrayTypeAnnotation";
  19044. case "FunctionTypeAnnotation":
  19045. {
  19046. var ancestor = parent.type === "NullableTypeAnnotation" ? path$$1.getParentNode(1) : parent;
  19047. return ancestor.type === "UnionTypeAnnotation" || ancestor.type === "IntersectionTypeAnnotation" || ancestor.type === "ArrayTypeAnnotation" || // We should check ancestor's parent to know whether the parentheses
  19048. // are really needed, but since ??T doesn't make sense this check
  19049. // will almost never be true.
  19050. ancestor.type === "NullableTypeAnnotation";
  19051. }
  19052. case "StringLiteral":
  19053. case "NumericLiteral":
  19054. case "Literal":
  19055. if (typeof node.value === "string" && parent.type === "ExpressionStatement" && ( // TypeScript workaround for https://github.com/JamesHenry/typescript-estree/issues/2
  19056. // See corresponding workaround in printer.js case: "Literal"
  19057. options.parser !== "typescript" && !parent.directive || options.parser === "typescript" && options.originalText.substr(options.locStart(node) - 1, 1) === "(")) {
  19058. // To avoid becoming a directive
  19059. var _grandParent = path$$1.getParentNode(1);
  19060. return _grandParent.type === "Program" || _grandParent.type === "BlockStatement";
  19061. }
  19062. return parent.type === "MemberExpression" && typeof node.value === "number" && name === "object" && parent.object === node;
  19063. case "AssignmentExpression":
  19064. {
  19065. var _grandParent2 = path$$1.getParentNode(1);
  19066. if (parent.type === "ArrowFunctionExpression" && parent.body === node) {
  19067. return true;
  19068. } else if (parent.type === "ClassProperty" && parent.key === node && parent.computed) {
  19069. return false;
  19070. } else if (parent.type === "TSPropertySignature" && parent.name === node) {
  19071. return false;
  19072. } else if (parent.type === "ForStatement" && (parent.init === node || parent.update === node)) {
  19073. return false;
  19074. } else if (parent.type === "ExpressionStatement") {
  19075. return node.left.type === "ObjectPattern";
  19076. } else if (parent.type === "TSPropertySignature" && parent.key === node) {
  19077. return false;
  19078. } else if (parent.type === "AssignmentExpression") {
  19079. return false;
  19080. } else if (parent.type === "SequenceExpression" && _grandParent2 && _grandParent2.type === "ForStatement" && (_grandParent2.init === parent || _grandParent2.update === parent)) {
  19081. return false;
  19082. } else if (parent.type === "Property" && parent.value === node) {
  19083. return false;
  19084. } else if (parent.type === "NGChainedExpression") {
  19085. return false;
  19086. }
  19087. return true;
  19088. }
  19089. case "ConditionalExpression":
  19090. switch (parent.type) {
  19091. case "TaggedTemplateExpression":
  19092. case "UnaryExpression":
  19093. case "SpreadElement":
  19094. case "SpreadProperty":
  19095. case "BinaryExpression":
  19096. case "LogicalExpression":
  19097. case "NGPipeExpression":
  19098. case "ExportDefaultDeclaration":
  19099. case "AwaitExpression":
  19100. case "JSXSpreadAttribute":
  19101. case "TSTypeAssertion":
  19102. case "TypeCastExpression":
  19103. case "TSAsExpression":
  19104. case "TSNonNullExpression":
  19105. case "OptionalMemberExpression":
  19106. return true;
  19107. case "NewExpression":
  19108. case "CallExpression":
  19109. return name === "callee" && parent.callee === node;
  19110. case "ConditionalExpression":
  19111. return name === "test" && parent.test === node;
  19112. case "MemberExpression":
  19113. return name === "object" && parent.object === node;
  19114. default:
  19115. return false;
  19116. }
  19117. case "FunctionExpression":
  19118. switch (parent.type) {
  19119. case "CallExpression":
  19120. return name === "callee";
  19121. // Not strictly necessary, but it's clearer to the reader if IIFEs are wrapped in parentheses.
  19122. case "TaggedTemplateExpression":
  19123. return true;
  19124. // This is basically a kind of IIFE.
  19125. case "ExportDefaultDeclaration":
  19126. return true;
  19127. default:
  19128. return false;
  19129. }
  19130. case "ArrowFunctionExpression":
  19131. switch (parent.type) {
  19132. case "CallExpression":
  19133. return name === "callee";
  19134. case "NewExpression":
  19135. return name === "callee";
  19136. case "MemberExpression":
  19137. return name === "object";
  19138. case "TSAsExpression":
  19139. case "BindExpression":
  19140. case "TaggedTemplateExpression":
  19141. case "UnaryExpression":
  19142. case "LogicalExpression":
  19143. case "BinaryExpression":
  19144. case "AwaitExpression":
  19145. case "TSTypeAssertion":
  19146. return true;
  19147. case "ConditionalExpression":
  19148. return name === "test";
  19149. default:
  19150. return false;
  19151. }
  19152. case "ClassExpression":
  19153. return parent.type === "ExportDefaultDeclaration";
  19154. case "OptionalMemberExpression":
  19155. return parent.type === "MemberExpression";
  19156. case "MemberExpression":
  19157. if (parent.type === "BindExpression" && name === "callee" && parent.callee === node) {
  19158. var object = node.object;
  19159. while (object) {
  19160. if (object.type === "CallExpression") {
  19161. return true;
  19162. }
  19163. if (object.type !== "MemberExpression" && object.type !== "BindExpression") {
  19164. break;
  19165. }
  19166. object = object.object;
  19167. }
  19168. }
  19169. return false;
  19170. case "BindExpression":
  19171. if (parent.type === "BindExpression" && name === "callee" && parent.callee === node || parent.type === "MemberExpression") {
  19172. return true;
  19173. }
  19174. return false;
  19175. case "NGPipeExpression":
  19176. if (parent.type === "NGRoot" || parent.type === "ObjectProperty" || parent.type === "ArrayExpression" || (parent.type === "CallExpression" || parent.type === "OptionalCallExpression") && parent.arguments[name] === node || parent.type === "NGPipeExpression" && name === "right" || parent.type === "MemberExpression" && name === "property" || parent.type === "AssignmentExpression") {
  19177. return false;
  19178. }
  19179. return true;
  19180. }
  19181. return false;
  19182. }
  19183. function isStatement(node) {
  19184. return node.type === "BlockStatement" || node.type === "BreakStatement" || node.type === "ClassBody" || node.type === "ClassDeclaration" || node.type === "ClassMethod" || node.type === "ClassProperty" || node.type === "ClassPrivateProperty" || node.type === "ContinueStatement" || node.type === "DebuggerStatement" || node.type === "DeclareClass" || node.type === "DeclareExportAllDeclaration" || node.type === "DeclareExportDeclaration" || node.type === "DeclareFunction" || node.type === "DeclareInterface" || node.type === "DeclareModule" || node.type === "DeclareModuleExports" || node.type === "DeclareVariable" || node.type === "DoWhileStatement" || node.type === "ExportAllDeclaration" || node.type === "ExportDefaultDeclaration" || node.type === "ExportNamedDeclaration" || node.type === "ExpressionStatement" || node.type === "ForAwaitStatement" || node.type === "ForInStatement" || node.type === "ForOfStatement" || node.type === "ForStatement" || node.type === "FunctionDeclaration" || node.type === "IfStatement" || node.type === "ImportDeclaration" || node.type === "InterfaceDeclaration" || node.type === "LabeledStatement" || node.type === "MethodDefinition" || node.type === "ReturnStatement" || node.type === "SwitchStatement" || node.type === "ThrowStatement" || node.type === "TryStatement" || node.type === "TSAbstractClassDeclaration" || node.type === "TSDeclareFunction" || node.type === "TSEnumDeclaration" || node.type === "TSImportEqualsDeclaration" || node.type === "TSInterfaceDeclaration" || node.type === "TSModuleDeclaration" || node.type === "TSNamespaceExportDeclaration" || node.type === "TypeAlias" || node.type === "VariableDeclaration" || node.type === "WhileStatement" || node.type === "WithStatement";
  19185. }
  19186. function getUnparenthesizedNode(node) {
  19187. return node.type === "TSParenthesizedType" ? getUnparenthesizedNode(node.typeAnnotation) : node;
  19188. }
  19189. function endsWithRightBracket(node) {
  19190. switch (node.type) {
  19191. case "ObjectExpression":
  19192. return true;
  19193. default:
  19194. return false;
  19195. }
  19196. }
  19197. function isFollowedByRightBracket(path$$1) {
  19198. var node = path$$1.getValue();
  19199. var parent = path$$1.getParentNode();
  19200. var name = path$$1.getName();
  19201. switch (parent.type) {
  19202. case "NGPipeExpression":
  19203. if (typeof name === "number" && parent.arguments[name] === node && parent.arguments.length - 1 === name) {
  19204. return path$$1.callParent(isFollowedByRightBracket);
  19205. }
  19206. break;
  19207. case "ObjectProperty":
  19208. if (name === "value") {
  19209. var parentParent = path$$1.getParentNode(1);
  19210. return parentParent.properties[parentParent.properties.length - 1] === parent;
  19211. }
  19212. break;
  19213. case "BinaryExpression":
  19214. case "LogicalExpression":
  19215. if (name === "right") {
  19216. return path$$1.callParent(isFollowedByRightBracket);
  19217. }
  19218. break;
  19219. case "ConditionalExpression":
  19220. if (name === "alternate") {
  19221. return path$$1.callParent(isFollowedByRightBracket);
  19222. }
  19223. break;
  19224. case "UnaryExpression":
  19225. if (parent.prefix) {
  19226. return path$$1.callParent(isFollowedByRightBracket);
  19227. }
  19228. break;
  19229. }
  19230. return false;
  19231. }
  19232. var needsParens_1 = needsParens;
  19233. var _require$$0$builders$1 = doc.builders;
  19234. var concat$6 = _require$$0$builders$1.concat;
  19235. var join$4 = _require$$0$builders$1.join;
  19236. var line$4 = _require$$0$builders$1.line;
  19237. function printHtmlBinding$1(path$$1, options, print) {
  19238. var node = path$$1.getValue();
  19239. if (options.__onHtmlBindingRoot && path$$1.getName() === null) {
  19240. options.__onHtmlBindingRoot(node);
  19241. }
  19242. if (node.type !== "File") {
  19243. return;
  19244. }
  19245. if (options.__isVueForBindingLeft) {
  19246. return path$$1.call(function (functionDeclarationPath) {
  19247. var _functionDeclarationP = functionDeclarationPath.getValue(),
  19248. params = _functionDeclarationP.params;
  19249. return concat$6([params.length > 1 ? "(" : "", join$4(concat$6([",", line$4]), functionDeclarationPath.map(print, "params")), params.length > 1 ? ")" : ""]);
  19250. }, "program", "body", 0);
  19251. }
  19252. if (options.__isVueSlotScope) {
  19253. return path$$1.call(function (functionDeclarationPath) {
  19254. return join$4(concat$6([",", line$4]), functionDeclarationPath.map(print, "params"));
  19255. }, "program", "body", 0);
  19256. }
  19257. } // based on https://github.com/prettier/prettier/blob/master/src/language-html/syntax-vue.js isVueEventBindingExpression()
  19258. function isVueEventBindingExpression$1(node) {
  19259. switch (node.type) {
  19260. case "MemberExpression":
  19261. switch (node.property.type) {
  19262. case "Identifier":
  19263. case "NumericLiteral":
  19264. case "StringLiteral":
  19265. return isVueEventBindingExpression$1(node.object);
  19266. }
  19267. return false;
  19268. case "Identifier":
  19269. return true;
  19270. default:
  19271. return false;
  19272. }
  19273. }
  19274. var htmlBinding = {
  19275. isVueEventBindingExpression: isVueEventBindingExpression$1,
  19276. printHtmlBinding: printHtmlBinding$1
  19277. };
  19278. function preprocess(ast, options) {
  19279. switch (options.parser) {
  19280. case "json":
  19281. case "json5":
  19282. case "json-stringify":
  19283. case "__js_expression":
  19284. case "__vue_expression":
  19285. return Object.assign({}, ast, {
  19286. type: options.parser.startsWith("__") ? "JsExpressionRoot" : "JsonRoot",
  19287. node: ast,
  19288. comments: []
  19289. });
  19290. default:
  19291. return ast;
  19292. }
  19293. }
  19294. var preprocess_1 = preprocess;
  19295. var getParentExportDeclaration$1 = util$1.getParentExportDeclaration;
  19296. var isExportDeclaration$1 = util$1.isExportDeclaration;
  19297. var shouldFlatten$1 = util$1.shouldFlatten;
  19298. var getNextNonSpaceNonCommentCharacter$1 = util$1.getNextNonSpaceNonCommentCharacter;
  19299. var hasNewline$2 = util$1.hasNewline;
  19300. var hasNewlineInRange$1 = util$1.hasNewlineInRange;
  19301. var getLast$4 = util$1.getLast;
  19302. var getStringWidth$2 = util$1.getStringWidth;
  19303. var printString$1 = util$1.printString;
  19304. var printNumber$1 = util$1.printNumber;
  19305. var hasIgnoreComment$1 = util$1.hasIgnoreComment;
  19306. var skipWhitespace$1 = util$1.skipWhitespace;
  19307. var hasNodeIgnoreComment$1 = util$1.hasNodeIgnoreComment;
  19308. var getPenultimate$1 = util$1.getPenultimate;
  19309. var startsWithNoLookaheadToken$1 = util$1.startsWithNoLookaheadToken;
  19310. var getIndentSize$1 = util$1.getIndentSize;
  19311. var matchAncestorTypes$1 = util$1.matchAncestorTypes;
  19312. var getPreferredQuote$1 = util$1.getPreferredQuote;
  19313. var isNextLineEmpty$2 = utilShared.isNextLineEmpty;
  19314. var isNextLineEmptyAfterIndex$1 = utilShared.isNextLineEmptyAfterIndex;
  19315. var getNextNonSpaceNonCommentCharacterIndex$2 = utilShared.getNextNonSpaceNonCommentCharacterIndex;
  19316. var isIdentifierName = utils$2.keyword.isIdentifierNameES5;
  19317. var insertPragma = pragma.insertPragma;
  19318. var printHtmlBinding = htmlBinding.printHtmlBinding;
  19319. var isVueEventBindingExpression = htmlBinding.isVueEventBindingExpression;
  19320. var hasNode = utils$4.hasNode;
  19321. var hasFlowAnnotationComment = utils$4.hasFlowAnnotationComment;
  19322. var hasFlowShorthandAnnotationComment = utils$4.hasFlowShorthandAnnotationComment;
  19323. var _require$$6$builders = doc.builders;
  19324. var concat$4 = _require$$6$builders.concat;
  19325. var join$2 = _require$$6$builders.join;
  19326. var line$3 = _require$$6$builders.line;
  19327. var hardline$3 = _require$$6$builders.hardline;
  19328. var softline$1 = _require$$6$builders.softline;
  19329. var literalline$1 = _require$$6$builders.literalline;
  19330. var group$1 = _require$$6$builders.group;
  19331. var indent$2 = _require$$6$builders.indent;
  19332. var align$1 = _require$$6$builders.align;
  19333. var conditionalGroup$1 = _require$$6$builders.conditionalGroup;
  19334. var fill$2 = _require$$6$builders.fill;
  19335. var ifBreak$1 = _require$$6$builders.ifBreak;
  19336. var breakParent$2 = _require$$6$builders.breakParent;
  19337. var lineSuffixBoundary$1 = _require$$6$builders.lineSuffixBoundary;
  19338. var addAlignmentToDoc$2 = _require$$6$builders.addAlignmentToDoc;
  19339. var dedent$2 = _require$$6$builders.dedent;
  19340. var _require$$6$utils = doc.utils;
  19341. var willBreak$1 = _require$$6$utils.willBreak;
  19342. var isLineNext$1 = _require$$6$utils.isLineNext;
  19343. var isEmpty$1 = _require$$6$utils.isEmpty;
  19344. var removeLines$1 = _require$$6$utils.removeLines;
  19345. var printDocToString$2 = doc.printer.printDocToString;
  19346. var uid = 0;
  19347. function shouldPrintComma(options, level) {
  19348. level = level || "es5";
  19349. switch (options.trailingComma) {
  19350. case "all":
  19351. if (level === "all") {
  19352. return true;
  19353. }
  19354. // fallthrough
  19355. case "es5":
  19356. if (level === "es5") {
  19357. return true;
  19358. }
  19359. // fallthrough
  19360. case "none":
  19361. default:
  19362. return false;
  19363. }
  19364. }
  19365. function genericPrint(path$$1, options, printPath, args) {
  19366. var node = path$$1.getValue();
  19367. var needsParens = false;
  19368. var linesWithoutParens = printPathNoParens(path$$1, options, printPath, args);
  19369. if (!node || isEmpty$1(linesWithoutParens)) {
  19370. return linesWithoutParens;
  19371. }
  19372. var parentExportDecl = getParentExportDeclaration$1(path$$1);
  19373. var decorators = [];
  19374. if (node.type === "ClassMethod" || node.type === "ClassPrivateMethod" || node.type === "ClassProperty" || node.type === "TSAbstractClassProperty" || node.type === "ClassPrivateProperty" || node.type === "MethodDefinition" || node.type === "TSAbstractMethodDefinition") {// their decorators are handled themselves
  19375. } else if (node.decorators && node.decorators.length > 0 && // If the parent node is an export declaration and the decorator
  19376. // was written before the export, the export will be responsible
  19377. // for printing the decorators.
  19378. !(parentExportDecl && options.locStart(parentExportDecl, {
  19379. ignoreDecorators: true
  19380. }) > options.locStart(node.decorators[0]))) {
  19381. var shouldBreak = node.type === "ClassExpression" || node.type === "ClassDeclaration" || hasNewlineBetweenOrAfterDecorators(node, options);
  19382. var separator = shouldBreak ? hardline$3 : line$3;
  19383. path$$1.each(function (decoratorPath) {
  19384. var decorator = decoratorPath.getValue();
  19385. if (decorator.expression) {
  19386. decorator = decorator.expression;
  19387. } else {
  19388. decorator = decorator.callee;
  19389. }
  19390. decorators.push(printPath(decoratorPath), separator);
  19391. }, "decorators");
  19392. if (parentExportDecl) {
  19393. decorators.unshift(hardline$3);
  19394. }
  19395. } else if (isExportDeclaration$1(node) && node.declaration && node.declaration.decorators && node.declaration.decorators.length > 0 && // Only print decorators here if they were written before the export,
  19396. // otherwise they are printed by the node.declaration
  19397. options.locStart(node, {
  19398. ignoreDecorators: true
  19399. }) > options.locStart(node.declaration.decorators[0])) {
  19400. // Export declarations are responsible for printing any decorators
  19401. // that logically apply to node.declaration.
  19402. path$$1.each(function (decoratorPath) {
  19403. var decorator = decoratorPath.getValue();
  19404. var prefix = decorator.type === "Decorator" ? "" : "@";
  19405. decorators.push(prefix, printPath(decoratorPath), hardline$3);
  19406. }, "declaration", "decorators");
  19407. } else {
  19408. // Nodes with decorators can't have parentheses, so we can avoid
  19409. // computing pathNeedsParens() except in this case.
  19410. needsParens = needsParens_1(path$$1, options);
  19411. }
  19412. var parts = [];
  19413. if (needsParens) {
  19414. parts.unshift("(");
  19415. }
  19416. parts.push(linesWithoutParens);
  19417. if (needsParens) {
  19418. var _node = path$$1.getValue();
  19419. if (hasFlowShorthandAnnotationComment(_node)) {
  19420. parts.push(" /*");
  19421. parts.push(_node.trailingComments[0].value.trimLeft());
  19422. parts.push("*/");
  19423. _node.trailingComments[0].printed = true;
  19424. }
  19425. parts.push(")");
  19426. }
  19427. if (decorators.length > 0) {
  19428. return group$1(concat$4(decorators.concat(parts)));
  19429. }
  19430. return concat$4(parts);
  19431. }
  19432. function hasNewlineBetweenOrAfterDecorators(node, options) {
  19433. return hasNewlineInRange$1(options.originalText, options.locStart(node.decorators[0]), options.locEnd(getLast$4(node.decorators))) || hasNewline$2(options.originalText, options.locEnd(getLast$4(node.decorators)));
  19434. }
  19435. function printDecorators(path$$1, options, print) {
  19436. var node = path$$1.getValue();
  19437. return group$1(concat$4([join$2(line$3, path$$1.map(print, "decorators")), hasNewlineBetweenOrAfterDecorators(node, options) ? hardline$3 : line$3]));
  19438. }
  19439. function hasPrettierIgnore(path$$1) {
  19440. return hasIgnoreComment$1(path$$1) || hasJsxIgnoreComment(path$$1);
  19441. }
  19442. function hasJsxIgnoreComment(path$$1) {
  19443. var node = path$$1.getValue();
  19444. var parent = path$$1.getParentNode();
  19445. if (!parent || !node || !isJSXNode(node) || !isJSXNode(parent)) {
  19446. return false;
  19447. } // Lookup the previous sibling, ignoring any empty JSXText elements
  19448. var index = parent.children.indexOf(node);
  19449. var prevSibling = null;
  19450. for (var i = index; i > 0; i--) {
  19451. var candidate = parent.children[i - 1];
  19452. if (candidate.type === "JSXText" && !isMeaningfulJSXText(candidate)) {
  19453. continue;
  19454. }
  19455. prevSibling = candidate;
  19456. break;
  19457. }
  19458. return prevSibling && prevSibling.type === "JSXExpressionContainer" && prevSibling.expression.type === "JSXEmptyExpression" && prevSibling.expression.comments && prevSibling.expression.comments.find(function (comment) {
  19459. return comment.value.trim() === "prettier-ignore";
  19460. });
  19461. }
  19462. /**
  19463. * The following is the shared logic for
  19464. * ternary operators, namely ConditionalExpression
  19465. * and TSConditionalType
  19466. * @typedef {Object} OperatorOptions
  19467. * @property {() => Array<string | Doc>} beforeParts - Parts to print before the `?`.
  19468. * @property {(breakClosingParen: boolean) => Array<string | Doc>} afterParts - Parts to print after the conditional expression.
  19469. * @property {boolean} shouldCheckJsx - Whether to check for and print in JSX mode.
  19470. * @property {string} conditionalNodeType - The type of the conditional expression node, ie "ConditionalExpression" or "TSConditionalType".
  19471. * @property {string} consequentNodePropertyName - The property at which the consequent node can be found on the main node, eg "consequent".
  19472. * @property {string} alternateNodePropertyName - The property at which the alternate node can be found on the main node, eg "alternate".
  19473. * @property {string} testNodePropertyName - The property at which the test node can be found on the main node, eg "test".
  19474. * @property {boolean} breakNested - Whether to break all nested ternaries when one breaks.
  19475. * @param {FastPath} path - The path to the ConditionalExpression/TSConditionalType node.
  19476. * @param {Options} options - Prettier options
  19477. * @param {Function} print - Print function to call recursively
  19478. * @param {OperatorOptions} operatorOptions
  19479. * @returns Doc
  19480. */
  19481. function printTernaryOperator(path$$1, options, print, operatorOptions) {
  19482. var node = path$$1.getValue();
  19483. var testNode = node[operatorOptions.testNodePropertyName];
  19484. var consequentNode = node[operatorOptions.consequentNodePropertyName];
  19485. var alternateNode = node[operatorOptions.alternateNodePropertyName];
  19486. var parts = []; // We print a ConditionalExpression in either "JSX mode" or "normal mode".
  19487. // See tests/jsx/conditional-expression.js for more info.
  19488. var jsxMode = false;
  19489. var parent = path$$1.getParentNode();
  19490. var forceNoIndent = parent.type === operatorOptions.conditionalNodeType; // Find the outermost non-ConditionalExpression parent, and the outermost
  19491. // ConditionalExpression parent. We'll use these to determine if we should
  19492. // print in JSX mode.
  19493. var currentParent;
  19494. var previousParent;
  19495. var i = 0;
  19496. do {
  19497. previousParent = currentParent || node;
  19498. currentParent = path$$1.getParentNode(i);
  19499. i++;
  19500. } while (currentParent && currentParent.type === operatorOptions.conditionalNodeType);
  19501. var firstNonConditionalParent = currentParent || parent;
  19502. var lastConditionalParent = previousParent;
  19503. if (operatorOptions.shouldCheckJsx && (isJSXNode(testNode) || isJSXNode(consequentNode) || isJSXNode(alternateNode) || conditionalExpressionChainContainsJSX(lastConditionalParent))) {
  19504. jsxMode = true;
  19505. forceNoIndent = true; // Even though they don't need parens, we wrap (almost) everything in
  19506. // parens when using ?: within JSX, because the parens are analogous to
  19507. // curly braces in an if statement.
  19508. var wrap = function wrap(doc$$2) {
  19509. return concat$4([ifBreak$1("(", ""), indent$2(concat$4([softline$1, doc$$2])), softline$1, ifBreak$1(")", "")]);
  19510. }; // The only things we don't wrap are:
  19511. // * Nested conditional expressions in alternates
  19512. // * null
  19513. var isNull = function isNull(node) {
  19514. return node.type === "NullLiteral" || node.type === "Literal" && node.value === null;
  19515. };
  19516. parts.push(" ? ", isNull(consequentNode) ? path$$1.call(print, operatorOptions.consequentNodePropertyName) : wrap(path$$1.call(print, operatorOptions.consequentNodePropertyName)), " : ", alternateNode.type === operatorOptions.conditionalNodeType || isNull(alternateNode) ? path$$1.call(print, operatorOptions.alternateNodePropertyName) : wrap(path$$1.call(print, operatorOptions.alternateNodePropertyName)));
  19517. } else {
  19518. // normal mode
  19519. var part = concat$4([line$3, "? ", consequentNode.type === operatorOptions.conditionalNodeType ? ifBreak$1("", "(") : "", align$1(2, path$$1.call(print, operatorOptions.consequentNodePropertyName)), consequentNode.type === operatorOptions.conditionalNodeType ? ifBreak$1("", ")") : "", line$3, ": ", alternateNode.type === operatorOptions.conditionalNodeType ? path$$1.call(print, operatorOptions.alternateNodePropertyName) : align$1(2, path$$1.call(print, operatorOptions.alternateNodePropertyName))]);
  19520. parts.push(parent.type !== operatorOptions.conditionalNodeType || parent[operatorOptions.alternateNodePropertyName] === node ? part : options.useTabs ? dedent$2(indent$2(part)) : align$1(Math.max(0, options.tabWidth - 2), part));
  19521. } // We want a whole chain of ConditionalExpressions to all
  19522. // break if any of them break. That means we should only group around the
  19523. // outer-most ConditionalExpression.
  19524. var maybeGroup = function maybeGroup(doc$$2) {
  19525. return operatorOptions.breakNested ? parent === firstNonConditionalParent ? group$1(doc$$2) : doc$$2 : group$1(doc$$2);
  19526. }; // Break the closing paren to keep the chain right after it:
  19527. // (a
  19528. // ? b
  19529. // : c
  19530. // ).call()
  19531. var breakClosingParen = !jsxMode && (parent.type === "MemberExpression" || parent.type === "OptionalMemberExpression") && !parent.computed;
  19532. return maybeGroup(concat$4([].concat(function (testDoc) {
  19533. return (
  19534. /**
  19535. * a
  19536. * ? b
  19537. * : multiline
  19538. * test
  19539. * node
  19540. * ^^ align(2)
  19541. * ? d
  19542. * : e
  19543. */
  19544. parent.type === operatorOptions.conditionalNodeType && parent[operatorOptions.alternateNodePropertyName] === node ? align$1(2, testDoc) : testDoc
  19545. );
  19546. }(concat$4(operatorOptions.beforeParts())), forceNoIndent ? concat$4(parts) : indent$2(concat$4(parts)), operatorOptions.afterParts(breakClosingParen))));
  19547. }
  19548. function getTypeScriptMappedTypeModifier(tokenNode, keyword) {
  19549. if (tokenNode === "+") {
  19550. return "+" + keyword;
  19551. } else if (tokenNode === "-") {
  19552. return "-" + keyword;
  19553. }
  19554. return keyword;
  19555. }
  19556. function printPathNoParens(path$$1, options, print, args) {
  19557. var n = path$$1.getValue();
  19558. var semi = options.semi ? ";" : "";
  19559. if (!n) {
  19560. return "";
  19561. }
  19562. if (typeof n === "string") {
  19563. return n;
  19564. }
  19565. var htmlBinding$$1 = printHtmlBinding(path$$1, options, print);
  19566. if (htmlBinding$$1) {
  19567. return htmlBinding$$1;
  19568. }
  19569. var parts = [];
  19570. switch (n.type) {
  19571. case "JsExpressionRoot":
  19572. return path$$1.call(print, "node");
  19573. case "JsonRoot":
  19574. return concat$4([path$$1.call(print, "node"), hardline$3]);
  19575. case "File":
  19576. // Print @babel/parser's InterpreterDirective here so that
  19577. // leading comments on the `Program` node get printed after the hashbang.
  19578. if (n.program && n.program.interpreter) {
  19579. parts.push(path$$1.call(function (programPath) {
  19580. return programPath.call(print, "interpreter");
  19581. }, "program"));
  19582. }
  19583. parts.push(path$$1.call(print, "program"));
  19584. return concat$4(parts);
  19585. case "Program":
  19586. // Babel 6
  19587. if (n.directives) {
  19588. path$$1.each(function (childPath) {
  19589. parts.push(print(childPath), semi, hardline$3);
  19590. if (isNextLineEmpty$2(options.originalText, childPath.getValue(), options)) {
  19591. parts.push(hardline$3);
  19592. }
  19593. }, "directives");
  19594. }
  19595. parts.push(path$$1.call(function (bodyPath) {
  19596. return printStatementSequence(bodyPath, options, print);
  19597. }, "body"));
  19598. parts.push(comments.printDanglingComments(path$$1, options,
  19599. /* sameIndent */
  19600. true)); // Only force a trailing newline if there were any contents.
  19601. if (n.body.length || n.comments) {
  19602. parts.push(hardline$3);
  19603. }
  19604. return concat$4(parts);
  19605. // Babel extension.
  19606. case "EmptyStatement":
  19607. return "";
  19608. case "ExpressionStatement":
  19609. // Detect Flow-parsed directives
  19610. if (n.directive) {
  19611. return concat$4([nodeStr(n.expression, options, true), semi]);
  19612. }
  19613. if (options.parser === "__vue_event_binding") {
  19614. var parent = path$$1.getParentNode();
  19615. if (parent.type === "Program" && parent.body.length === 1 && parent.body[0] === n) {
  19616. return concat$4([path$$1.call(print, "expression"), isVueEventBindingExpression(n.expression) ? ";" : ""]);
  19617. }
  19618. } // Do not append semicolon after the only JSX element in a program
  19619. return concat$4([path$$1.call(print, "expression"), isTheOnlyJSXElementInMarkdown(options, path$$1) ? "" : semi]);
  19620. // Babel extension.
  19621. case "ParenthesizedExpression":
  19622. return concat$4(["(", path$$1.call(print, "expression"), ")"]);
  19623. case "AssignmentExpression":
  19624. return printAssignment(n.left, path$$1.call(print, "left"), concat$4([" ", n.operator]), n.right, path$$1.call(print, "right"), options);
  19625. case "BinaryExpression":
  19626. case "LogicalExpression":
  19627. case "NGPipeExpression":
  19628. {
  19629. var _parent = path$$1.getParentNode();
  19630. var parentParent = path$$1.getParentNode(1);
  19631. var isInsideParenthesis = n !== _parent.body && (_parent.type === "IfStatement" || _parent.type === "WhileStatement" || _parent.type === "DoWhileStatement");
  19632. var _parts = printBinaryishExpressions(path$$1, print, options,
  19633. /* isNested */
  19634. false, isInsideParenthesis); // if (
  19635. // this.hasPlugin("dynamicImports") && this.lookahead().type === tt.parenLeft
  19636. // ) {
  19637. //
  19638. // looks super weird, we want to break the children if the parent breaks
  19639. //
  19640. // if (
  19641. // this.hasPlugin("dynamicImports") &&
  19642. // this.lookahead().type === tt.parenLeft
  19643. // ) {
  19644. if (isInsideParenthesis) {
  19645. return concat$4(_parts);
  19646. } // Break between the parens in unaries or in a member expression, i.e.
  19647. //
  19648. // (
  19649. // a &&
  19650. // b &&
  19651. // c
  19652. // ).call()
  19653. if (_parent.type === "UnaryExpression" || (_parent.type === "MemberExpression" || _parent.type === "OptionalMemberExpression") && !_parent.computed) {
  19654. return group$1(concat$4([indent$2(concat$4([softline$1, concat$4(_parts)])), softline$1]));
  19655. } // Avoid indenting sub-expressions in some cases where the first sub-expression is already
  19656. // indented accordingly. We should indent sub-expressions where the first case isn't indented.
  19657. var shouldNotIndent = _parent.type === "ReturnStatement" || _parent.type === "JSXExpressionContainer" && parentParent.type === "JSXAttribute" || n.type !== "NGPipeExpression" && (_parent.type === "NGRoot" && options.parser === "__ng_binding" || _parent.type === "NGMicrosyntaxExpression" && parentParent.type === "NGMicrosyntax" && parentParent.body.length === 1) || n === _parent.body && _parent.type === "ArrowFunctionExpression" || n !== _parent.body && _parent.type === "ForStatement" || _parent.type === "ConditionalExpression" && parentParent.type !== "ReturnStatement" && parentParent.type !== "CallExpression";
  19658. var shouldIndentIfInlining = _parent.type === "AssignmentExpression" || _parent.type === "VariableDeclarator" || _parent.type === "ClassProperty" || _parent.type === "TSAbstractClassProperty" || _parent.type === "ClassPrivateProperty" || _parent.type === "ObjectProperty" || _parent.type === "Property";
  19659. var samePrecedenceSubExpression = isBinaryish(n.left) && shouldFlatten$1(n.operator, n.left.operator);
  19660. if (shouldNotIndent || shouldInlineLogicalExpression(n) && !samePrecedenceSubExpression || !shouldInlineLogicalExpression(n) && shouldIndentIfInlining) {
  19661. return group$1(concat$4(_parts));
  19662. }
  19663. if (_parts.length === 0) {
  19664. return "";
  19665. } // If the right part is a JSX node, we include it in a separate group to
  19666. // prevent it breaking the whole chain, so we can print the expression like:
  19667. //
  19668. // foo && bar && (
  19669. // <Foo>
  19670. // <Bar />
  19671. // </Foo>
  19672. // )
  19673. var hasJSX = isJSXNode(n.right);
  19674. var rest = concat$4(hasJSX ? _parts.slice(1, -1) : _parts.slice(1));
  19675. var groupId = Symbol("logicalChain-" + ++uid);
  19676. var chain = group$1(concat$4([// Don't include the initial expression in the indentation
  19677. // level. The first item is guaranteed to be the first
  19678. // left-most expression.
  19679. _parts.length > 0 ? _parts[0] : "", indent$2(rest)]), {
  19680. id: groupId
  19681. });
  19682. if (!hasJSX) {
  19683. return chain;
  19684. }
  19685. var jsxPart = getLast$4(_parts);
  19686. return group$1(concat$4([chain, ifBreak$1(indent$2(jsxPart), jsxPart, {
  19687. groupId
  19688. })]));
  19689. }
  19690. case "AssignmentPattern":
  19691. return concat$4([path$$1.call(print, "left"), " = ", path$$1.call(print, "right")]);
  19692. case "TSTypeAssertion":
  19693. {
  19694. var shouldBreakAfterCast = !(n.expression.type === "ArrayExpression" || n.expression.type === "ObjectExpression");
  19695. var castGroup = group$1(concat$4(["<", indent$2(concat$4([softline$1, path$$1.call(print, "typeAnnotation")])), softline$1, ">"]));
  19696. var exprContents = concat$4([ifBreak$1("("), indent$2(concat$4([softline$1, path$$1.call(print, "expression")])), softline$1, ifBreak$1(")")]);
  19697. if (shouldBreakAfterCast) {
  19698. return conditionalGroup$1([concat$4([castGroup, path$$1.call(print, "expression")]), concat$4([castGroup, group$1(exprContents, {
  19699. shouldBreak: true
  19700. })]), concat$4([castGroup, path$$1.call(print, "expression")])]);
  19701. }
  19702. return group$1(concat$4([castGroup, path$$1.call(print, "expression")]));
  19703. }
  19704. case "OptionalMemberExpression":
  19705. case "MemberExpression":
  19706. {
  19707. var _parent2 = path$$1.getParentNode();
  19708. var firstNonMemberParent;
  19709. var i = 0;
  19710. do {
  19711. firstNonMemberParent = path$$1.getParentNode(i);
  19712. i++;
  19713. } while (firstNonMemberParent && (firstNonMemberParent.type === "MemberExpression" || firstNonMemberParent.type === "OptionalMemberExpression" || firstNonMemberParent.type === "TSNonNullExpression"));
  19714. var shouldInline = firstNonMemberParent && (firstNonMemberParent.type === "NewExpression" || firstNonMemberParent.type === "BindExpression" || firstNonMemberParent.type === "VariableDeclarator" && firstNonMemberParent.id.type !== "Identifier" || firstNonMemberParent.type === "AssignmentExpression" && firstNonMemberParent.left.type !== "Identifier") || n.computed || n.object.type === "Identifier" && n.property.type === "Identifier" && _parent2.type !== "MemberExpression" && _parent2.type !== "OptionalMemberExpression";
  19715. return concat$4([path$$1.call(print, "object"), shouldInline ? printMemberLookup(path$$1, options, print) : group$1(indent$2(concat$4([softline$1, printMemberLookup(path$$1, options, print)])))]);
  19716. }
  19717. case "MetaProperty":
  19718. return concat$4([path$$1.call(print, "meta"), ".", path$$1.call(print, "property")]);
  19719. case "BindExpression":
  19720. if (n.object) {
  19721. parts.push(path$$1.call(print, "object"));
  19722. }
  19723. parts.push(group$1(indent$2(concat$4([softline$1, printBindExpressionCallee(path$$1, options, print)]))));
  19724. return concat$4(parts);
  19725. case "Identifier":
  19726. {
  19727. return concat$4([n.name, printOptionalToken(path$$1), printTypeAnnotation(path$$1, options, print)]);
  19728. }
  19729. case "SpreadElement":
  19730. case "SpreadElementPattern":
  19731. case "RestProperty":
  19732. case "SpreadProperty":
  19733. case "SpreadPropertyPattern":
  19734. case "RestElement":
  19735. case "ObjectTypeSpreadProperty":
  19736. return concat$4(["...", path$$1.call(print, "argument"), printTypeAnnotation(path$$1, options, print)]);
  19737. case "FunctionDeclaration":
  19738. case "FunctionExpression":
  19739. parts.push(printFunctionDeclaration(path$$1, print, options));
  19740. if (!n.body) {
  19741. parts.push(semi);
  19742. }
  19743. return concat$4(parts);
  19744. case "ArrowFunctionExpression":
  19745. {
  19746. if (n.async) {
  19747. parts.push("async ");
  19748. }
  19749. if (shouldPrintParamsWithoutParens(path$$1, options)) {
  19750. parts.push(path$$1.call(print, "params", 0));
  19751. } else {
  19752. parts.push(group$1(concat$4([printFunctionParams(path$$1, print, options,
  19753. /* expandLast */
  19754. args && (args.expandLastArg || args.expandFirstArg),
  19755. /* printTypeParams */
  19756. true), printReturnType(path$$1, print, options)])));
  19757. }
  19758. var dangling = comments.printDanglingComments(path$$1, options,
  19759. /* sameIndent */
  19760. true, function (comment) {
  19761. var nextCharacter = getNextNonSpaceNonCommentCharacterIndex$2(options.originalText, comment, options);
  19762. return options.originalText.substr(nextCharacter, 2) === "=>";
  19763. });
  19764. if (dangling) {
  19765. parts.push(" ", dangling);
  19766. }
  19767. parts.push(" =>");
  19768. var body = path$$1.call(function (bodyPath) {
  19769. return print(bodyPath, args);
  19770. }, "body"); // We want to always keep these types of nodes on the same line
  19771. // as the arrow.
  19772. if (!hasLeadingOwnLineComment(options.originalText, n.body, options) && (n.body.type === "ArrayExpression" || n.body.type === "ObjectExpression" || n.body.type === "BlockStatement" || isJSXNode(n.body) || isTemplateOnItsOwnLine(n.body, options.originalText, options) || n.body.type === "ArrowFunctionExpression" || n.body.type === "DoExpression")) {
  19773. return group$1(concat$4([concat$4(parts), " ", body]));
  19774. } // We handle sequence expressions as the body of arrows specially,
  19775. // so that the required parentheses end up on their own lines.
  19776. if (n.body.type === "SequenceExpression") {
  19777. return group$1(concat$4([concat$4(parts), group$1(concat$4([" (", indent$2(concat$4([softline$1, body])), softline$1, ")"]))]));
  19778. } // if the arrow function is expanded as last argument, we are adding a
  19779. // level of indentation and need to add a softline to align the closing )
  19780. // with the opening (, or if it's inside a JSXExpression (e.g. an attribute)
  19781. // we should align the expression's closing } with the line with the opening {.
  19782. var shouldAddSoftLine = (args && args.expandLastArg || path$$1.getParentNode().type === "JSXExpressionContainer") && !(n.comments && n.comments.length);
  19783. var printTrailingComma = args && args.expandLastArg && shouldPrintComma(options, "all"); // In order to avoid confusion between
  19784. // a => a ? a : a
  19785. // a <= a ? a : a
  19786. var shouldAddParens = n.body.type === "ConditionalExpression" && !startsWithNoLookaheadToken$1(n.body,
  19787. /* forbidFunctionAndClass */
  19788. false);
  19789. return group$1(concat$4([concat$4(parts), group$1(concat$4([indent$2(concat$4([line$3, shouldAddParens ? ifBreak$1("", "(") : "", body, shouldAddParens ? ifBreak$1("", ")") : ""])), shouldAddSoftLine ? concat$4([ifBreak$1(printTrailingComma ? "," : ""), softline$1]) : ""]))]));
  19790. }
  19791. case "MethodDefinition":
  19792. case "TSAbstractMethodDefinition":
  19793. if (n.decorators && n.decorators.length !== 0) {
  19794. parts.push(printDecorators(path$$1, options, print));
  19795. }
  19796. if (n.accessibility) {
  19797. parts.push(n.accessibility + " ");
  19798. }
  19799. if (n.static) {
  19800. parts.push("static ");
  19801. }
  19802. if (n.type === "TSAbstractMethodDefinition") {
  19803. parts.push("abstract ");
  19804. }
  19805. parts.push(printMethod(path$$1, options, print));
  19806. return concat$4(parts);
  19807. case "YieldExpression":
  19808. parts.push("yield");
  19809. if (n.delegate) {
  19810. parts.push("*");
  19811. }
  19812. if (n.argument) {
  19813. parts.push(" ", path$$1.call(print, "argument"));
  19814. }
  19815. return concat$4(parts);
  19816. case "AwaitExpression":
  19817. return concat$4(["await ", path$$1.call(print, "argument")]);
  19818. case "ImportSpecifier":
  19819. if (n.importKind) {
  19820. parts.push(path$$1.call(print, "importKind"), " ");
  19821. }
  19822. parts.push(path$$1.call(print, "imported"));
  19823. if (n.local && n.local.name !== n.imported.name) {
  19824. parts.push(" as ", path$$1.call(print, "local"));
  19825. }
  19826. return concat$4(parts);
  19827. case "ExportSpecifier":
  19828. parts.push(path$$1.call(print, "local"));
  19829. if (n.exported && n.exported.name !== n.local.name) {
  19830. parts.push(" as ", path$$1.call(print, "exported"));
  19831. }
  19832. return concat$4(parts);
  19833. case "ImportNamespaceSpecifier":
  19834. parts.push("* as ");
  19835. parts.push(path$$1.call(print, "local"));
  19836. return concat$4(parts);
  19837. case "ImportDefaultSpecifier":
  19838. return path$$1.call(print, "local");
  19839. case "TSExportAssignment":
  19840. return concat$4(["export = ", path$$1.call(print, "expression"), semi]);
  19841. case "ExportDefaultDeclaration":
  19842. case "ExportNamedDeclaration":
  19843. return printExportDeclaration(path$$1, options, print);
  19844. case "ExportAllDeclaration":
  19845. parts.push("export ");
  19846. if (n.exportKind === "type") {
  19847. parts.push("type ");
  19848. }
  19849. parts.push("* from ", path$$1.call(print, "source"), semi);
  19850. return concat$4(parts);
  19851. case "ExportNamespaceSpecifier":
  19852. case "ExportDefaultSpecifier":
  19853. return path$$1.call(print, "exported");
  19854. case "ImportDeclaration":
  19855. {
  19856. parts.push("import ");
  19857. if (n.importKind && n.importKind !== "value") {
  19858. parts.push(n.importKind + " ");
  19859. }
  19860. var standalones = [];
  19861. var grouped = [];
  19862. if (n.specifiers && n.specifiers.length > 0) {
  19863. path$$1.each(function (specifierPath) {
  19864. var value = specifierPath.getValue();
  19865. if (value.type === "ImportDefaultSpecifier" || value.type === "ImportNamespaceSpecifier") {
  19866. standalones.push(print(specifierPath));
  19867. } else {
  19868. grouped.push(print(specifierPath));
  19869. }
  19870. }, "specifiers");
  19871. if (standalones.length > 0) {
  19872. parts.push(join$2(", ", standalones));
  19873. }
  19874. if (standalones.length > 0 && grouped.length > 0) {
  19875. parts.push(", ");
  19876. }
  19877. if (grouped.length === 1 && standalones.length === 0 && n.specifiers && !n.specifiers.some(function (node) {
  19878. return node.comments;
  19879. })) {
  19880. parts.push(concat$4(["{", options.bracketSpacing ? " " : "", concat$4(grouped), options.bracketSpacing ? " " : "", "}"]));
  19881. } else if (grouped.length >= 1) {
  19882. parts.push(group$1(concat$4(["{", indent$2(concat$4([options.bracketSpacing ? line$3 : softline$1, join$2(concat$4([",", line$3]), grouped)])), ifBreak$1(shouldPrintComma(options) ? "," : ""), options.bracketSpacing ? line$3 : softline$1, "}"])));
  19883. }
  19884. parts.push(" from ");
  19885. } else if (n.importKind && n.importKind === "type" || // import {} from 'x'
  19886. /{\s*}/.test(options.originalText.slice(options.locStart(n), options.locStart(n.source)))) {
  19887. parts.push("{} from ");
  19888. }
  19889. parts.push(path$$1.call(print, "source"), semi);
  19890. return concat$4(parts);
  19891. }
  19892. case "Import":
  19893. return "import";
  19894. case "TSModuleBlock":
  19895. case "BlockStatement":
  19896. {
  19897. var naked = path$$1.call(function (bodyPath) {
  19898. return printStatementSequence(bodyPath, options, print);
  19899. }, "body");
  19900. var hasContent = n.body.find(function (node) {
  19901. return node.type !== "EmptyStatement";
  19902. });
  19903. var hasDirectives = n.directives && n.directives.length > 0;
  19904. var _parent3 = path$$1.getParentNode();
  19905. var _parentParent = path$$1.getParentNode(1);
  19906. if (!hasContent && !hasDirectives && !hasDanglingComments(n) && (_parent3.type === "ArrowFunctionExpression" || _parent3.type === "FunctionExpression" || _parent3.type === "FunctionDeclaration" || _parent3.type === "ObjectMethod" || _parent3.type === "ClassMethod" || _parent3.type === "ClassPrivateMethod" || _parent3.type === "ForStatement" || _parent3.type === "WhileStatement" || _parent3.type === "DoWhileStatement" || _parent3.type === "DoExpression" || _parent3.type === "CatchClause" && !_parentParent.finalizer || _parent3.type === "TSModuleDeclaration")) {
  19907. return "{}";
  19908. }
  19909. parts.push("{"); // Babel 6
  19910. if (hasDirectives) {
  19911. path$$1.each(function (childPath) {
  19912. parts.push(indent$2(concat$4([hardline$3, print(childPath), semi])));
  19913. if (isNextLineEmpty$2(options.originalText, childPath.getValue(), options)) {
  19914. parts.push(hardline$3);
  19915. }
  19916. }, "directives");
  19917. }
  19918. if (hasContent) {
  19919. parts.push(indent$2(concat$4([hardline$3, naked])));
  19920. }
  19921. parts.push(comments.printDanglingComments(path$$1, options));
  19922. parts.push(hardline$3, "}");
  19923. return concat$4(parts);
  19924. }
  19925. case "ReturnStatement":
  19926. parts.push("return");
  19927. if (n.argument) {
  19928. if (returnArgumentHasLeadingComment(options, n.argument)) {
  19929. parts.push(concat$4([" (", indent$2(concat$4([hardline$3, path$$1.call(print, "argument")])), hardline$3, ")"]));
  19930. } else if (n.argument.type === "LogicalExpression" || n.argument.type === "BinaryExpression" || n.argument.type === "SequenceExpression") {
  19931. parts.push(group$1(concat$4([ifBreak$1(" (", " "), indent$2(concat$4([softline$1, path$$1.call(print, "argument")])), softline$1, ifBreak$1(")")])));
  19932. } else {
  19933. parts.push(" ", path$$1.call(print, "argument"));
  19934. }
  19935. }
  19936. if (hasDanglingComments(n)) {
  19937. parts.push(" ", comments.printDanglingComments(path$$1, options,
  19938. /* sameIndent */
  19939. true));
  19940. }
  19941. parts.push(semi);
  19942. return concat$4(parts);
  19943. case "NewExpression":
  19944. case "OptionalCallExpression":
  19945. case "CallExpression":
  19946. {
  19947. var isNew = n.type === "NewExpression";
  19948. var optional = printOptionalToken(path$$1);
  19949. if ( // We want to keep CommonJS- and AMD-style require calls, and AMD-style
  19950. // define calls, as a unit.
  19951. // e.g. `define(["some/lib", (lib) => {`
  19952. !isNew && n.callee.type === "Identifier" && (n.callee.name === "require" || n.callee.name === "define") || n.callee.type === "Import" || // Template literals as single arguments
  19953. n.arguments.length === 1 && isTemplateOnItsOwnLine(n.arguments[0], options.originalText, options) || // Keep test declarations on a single line
  19954. // e.g. `it('long name', () => {`
  19955. !isNew && isTestCall(n, path$$1.getParentNode())) {
  19956. return concat$4([isNew ? "new " : "", path$$1.call(print, "callee"), optional, printFunctionTypeParameters(path$$1, options, print), concat$4(["(", join$2(", ", path$$1.map(print, "arguments")), ")"])]);
  19957. } // Inline Flow annotation comments following Identifiers in Call nodes need to
  19958. // stay with the Identifier. For example:
  19959. //
  19960. // foo /*:: <SomeGeneric> */(bar);
  19961. //
  19962. // Here, we ensure that such comments stay between the Identifier and the Callee.
  19963. var isIdentifierWithFlowAnnotation = n.callee.type === "Identifier" && hasFlowAnnotationComment(n.callee.trailingComments);
  19964. if (isIdentifierWithFlowAnnotation) {
  19965. n.callee.trailingComments[0].printed = true;
  19966. } // We detect calls on member lookups and possibly print them in a
  19967. // special chain format. See `printMemberChain` for more info.
  19968. if (!isNew && isMemberish(n.callee)) {
  19969. return printMemberChain(path$$1, options, print);
  19970. }
  19971. return concat$4([isNew ? "new " : "", path$$1.call(print, "callee"), optional, isIdentifierWithFlowAnnotation ? `/*:: ${n.callee.trailingComments[0].value.substring(2).trim()} */` : "", printFunctionTypeParameters(path$$1, options, print), printArgumentsList(path$$1, options, print)]);
  19972. }
  19973. case "TSInterfaceDeclaration":
  19974. if (isNodeStartingWithDeclare(n, options)) {
  19975. parts.push("declare ");
  19976. }
  19977. parts.push(n.abstract ? "abstract " : "", printTypeScriptModifiers(path$$1, options, print), "interface ", path$$1.call(print, "id"), n.typeParameters ? path$$1.call(print, "typeParameters") : "", " ");
  19978. if (n.extends && n.extends.length) {
  19979. parts.push(group$1(indent$2(concat$4([softline$1, "extends ", (n.extends.length === 1 ? identity$1 : indent$2)(join$2(concat$4([",", line$3]), path$$1.map(print, "extends"))), " "]))));
  19980. }
  19981. parts.push(path$$1.call(print, "body"));
  19982. return concat$4(parts);
  19983. case "ObjectTypeInternalSlot":
  19984. return concat$4([n.static ? "static " : "", "[[", path$$1.call(print, "id"), "]]", printOptionalToken(path$$1), n.method ? "" : ": ", path$$1.call(print, "value")]);
  19985. case "ObjectExpression":
  19986. case "ObjectPattern":
  19987. case "ObjectTypeAnnotation":
  19988. case "TSInterfaceBody":
  19989. case "TSTypeLiteral":
  19990. {
  19991. var propertiesField;
  19992. if (n.type === "TSTypeLiteral") {
  19993. propertiesField = "members";
  19994. } else if (n.type === "TSInterfaceBody") {
  19995. propertiesField = "body";
  19996. } else {
  19997. propertiesField = "properties";
  19998. }
  19999. var isTypeAnnotation = n.type === "ObjectTypeAnnotation";
  20000. var fields = [];
  20001. if (isTypeAnnotation) {
  20002. fields.push("indexers", "callProperties", "internalSlots");
  20003. }
  20004. fields.push(propertiesField);
  20005. var firstProperty = fields.map(function (field) {
  20006. return n[field][0];
  20007. }).sort(function (a, b) {
  20008. return options.locStart(a) - options.locStart(b);
  20009. })[0];
  20010. var _parent4 = path$$1.getParentNode(0);
  20011. var isFlowInterfaceLikeBody = isTypeAnnotation && _parent4 && (_parent4.type === "InterfaceDeclaration" || _parent4.type === "DeclareInterface" || _parent4.type === "DeclareClass") && path$$1.getName() === "body";
  20012. var shouldBreak = n.type === "TSInterfaceBody" || isFlowInterfaceLikeBody || n.type === "ObjectPattern" && _parent4.type !== "FunctionDeclaration" && _parent4.type !== "FunctionExpression" && _parent4.type !== "ArrowFunctionExpression" && _parent4.type !== "AssignmentPattern" && _parent4.type !== "CatchClause" && n.properties.some(function (property) {
  20013. return property.value && (property.value.type === "ObjectPattern" || property.value.type === "ArrayPattern");
  20014. }) || n.type !== "ObjectPattern" && firstProperty && hasNewlineInRange$1(options.originalText, options.locStart(n), options.locStart(firstProperty));
  20015. var separator = isFlowInterfaceLikeBody ? ";" : n.type === "TSInterfaceBody" || n.type === "TSTypeLiteral" ? ifBreak$1(semi, ";") : ",";
  20016. var leftBrace = n.exact ? "{|" : "{";
  20017. var rightBrace = n.exact ? "|}" : "}"; // Unfortunately, things are grouped together in the ast can be
  20018. // interleaved in the source code. So we need to reorder them before
  20019. // printing them.
  20020. var propsAndLoc = [];
  20021. fields.forEach(function (field) {
  20022. path$$1.each(function (childPath) {
  20023. var node = childPath.getValue();
  20024. propsAndLoc.push({
  20025. node: node,
  20026. printed: print(childPath),
  20027. loc: options.locStart(node)
  20028. });
  20029. }, field);
  20030. });
  20031. var separatorParts = [];
  20032. var props = propsAndLoc.sort(function (a, b) {
  20033. return a.loc - b.loc;
  20034. }).map(function (prop) {
  20035. var result = concat$4(separatorParts.concat(group$1(prop.printed)));
  20036. separatorParts = [separator, line$3];
  20037. if ((prop.node.type === "TSPropertySignature" || prop.node.type === "TSMethodSignature" || prop.node.type === "TSConstructSignatureDeclaration") && hasNodeIgnoreComment$1(prop.node)) {
  20038. separatorParts.shift();
  20039. }
  20040. if (isNextLineEmpty$2(options.originalText, prop.node, options)) {
  20041. separatorParts.push(hardline$3);
  20042. }
  20043. return result;
  20044. });
  20045. if (n.inexact) {
  20046. props.push(concat$4(separatorParts.concat(group$1("..."))));
  20047. }
  20048. var lastElem = getLast$4(n[propertiesField]);
  20049. var canHaveTrailingSeparator = !(lastElem && (lastElem.type === "RestProperty" || lastElem.type === "RestElement" || hasNodeIgnoreComment$1(lastElem) || n.inexact));
  20050. var content;
  20051. if (props.length === 0 && !n.typeAnnotation) {
  20052. if (!hasDanglingComments(n)) {
  20053. return concat$4([leftBrace, rightBrace]);
  20054. }
  20055. content = group$1(concat$4([leftBrace, comments.printDanglingComments(path$$1, options), softline$1, rightBrace, printOptionalToken(path$$1)]));
  20056. } else {
  20057. content = concat$4([leftBrace, indent$2(concat$4([options.bracketSpacing ? line$3 : softline$1, concat$4(props)])), ifBreak$1(canHaveTrailingSeparator && (separator !== "," || shouldPrintComma(options)) ? separator : ""), concat$4([options.bracketSpacing ? line$3 : softline$1, rightBrace]), printOptionalToken(path$$1), printTypeAnnotation(path$$1, options, print)]);
  20058. } // If we inline the object as first argument of the parent, we don't want
  20059. // to create another group so that the object breaks before the return
  20060. // type
  20061. var parentParentParent = path$$1.getParentNode(2);
  20062. if (n.type === "ObjectPattern" && _parent4 && shouldHugArguments(_parent4) && _parent4.params[0] === n || shouldHugType(n) && parentParentParent && shouldHugArguments(parentParentParent) && parentParentParent.params[0].typeAnnotation && parentParentParent.params[0].typeAnnotation.typeAnnotation === n) {
  20063. return content;
  20064. }
  20065. return group$1(content, {
  20066. shouldBreak
  20067. });
  20068. }
  20069. // Babel 6
  20070. case "ObjectProperty": // Non-standard AST node type.
  20071. case "Property":
  20072. if (n.method || n.kind === "get" || n.kind === "set") {
  20073. return printMethod(path$$1, options, print);
  20074. }
  20075. if (n.shorthand) {
  20076. parts.push(path$$1.call(print, "value"));
  20077. } else {
  20078. var printedLeft;
  20079. if (n.computed) {
  20080. printedLeft = concat$4(["[", path$$1.call(print, "key"), "]"]);
  20081. } else {
  20082. printedLeft = printPropertyKey(path$$1, options, print);
  20083. }
  20084. parts.push(printAssignment(n.key, printedLeft, ":", n.value, path$$1.call(print, "value"), options));
  20085. }
  20086. return concat$4(parts);
  20087. // Babel 6
  20088. case "ClassMethod":
  20089. case "ClassPrivateMethod":
  20090. if (n.decorators && n.decorators.length !== 0) {
  20091. parts.push(printDecorators(path$$1, options, print));
  20092. }
  20093. if (n.static) {
  20094. parts.push("static ");
  20095. }
  20096. parts = parts.concat(printObjectMethod(path$$1, options, print));
  20097. return concat$4(parts);
  20098. // Babel 6
  20099. case "ObjectMethod":
  20100. return printObjectMethod(path$$1, options, print);
  20101. case "Decorator":
  20102. return concat$4(["@", path$$1.call(print, "expression"), path$$1.call(print, "callee")]);
  20103. case "ArrayExpression":
  20104. case "ArrayPattern":
  20105. if (n.elements.length === 0) {
  20106. if (!hasDanglingComments(n)) {
  20107. parts.push("[]");
  20108. } else {
  20109. parts.push(group$1(concat$4(["[", comments.printDanglingComments(path$$1, options), softline$1, "]"])));
  20110. }
  20111. } else {
  20112. var _lastElem = getLast$4(n.elements);
  20113. var canHaveTrailingComma = !(_lastElem && _lastElem.type === "RestElement"); // JavaScript allows you to have empty elements in an array which
  20114. // changes its length based on the number of commas. The algorithm
  20115. // is that if the last argument is null, we need to force insert
  20116. // a comma to ensure JavaScript recognizes it.
  20117. // [,].length === 1
  20118. // [1,].length === 1
  20119. // [1,,].length === 2
  20120. //
  20121. // Note that getLast returns null if the array is empty, but
  20122. // we already check for an empty array just above so we are safe
  20123. var needsForcedTrailingComma = canHaveTrailingComma && _lastElem === null;
  20124. parts.push(group$1(concat$4(["[", indent$2(concat$4([softline$1, printArrayItems(path$$1, options, "elements", print)])), needsForcedTrailingComma ? "," : "", ifBreak$1(canHaveTrailingComma && !needsForcedTrailingComma && shouldPrintComma(options) ? "," : ""), comments.printDanglingComments(path$$1, options,
  20125. /* sameIndent */
  20126. true), softline$1, "]"])));
  20127. }
  20128. parts.push(printOptionalToken(path$$1), printTypeAnnotation(path$$1, options, print));
  20129. return concat$4(parts);
  20130. case "SequenceExpression":
  20131. {
  20132. var _parent5 = path$$1.getParentNode(0);
  20133. if (_parent5.type === "ExpressionStatement" || _parent5.type === "ForStatement") {
  20134. // For ExpressionStatements and for-loop heads, which are among
  20135. // the few places a SequenceExpression appears unparenthesized, we want
  20136. // to indent expressions after the first.
  20137. var _parts2 = [];
  20138. path$$1.each(function (p) {
  20139. if (p.getName() === 0) {
  20140. _parts2.push(print(p));
  20141. } else {
  20142. _parts2.push(",", indent$2(concat$4([line$3, print(p)])));
  20143. }
  20144. }, "expressions");
  20145. return group$1(concat$4(_parts2));
  20146. }
  20147. return group$1(concat$4([join$2(concat$4([",", line$3]), path$$1.map(print, "expressions"))]));
  20148. }
  20149. case "ThisExpression":
  20150. return "this";
  20151. case "Super":
  20152. return "super";
  20153. case "NullLiteral":
  20154. // Babel 6 Literal split
  20155. return "null";
  20156. case "RegExpLiteral":
  20157. // Babel 6 Literal split
  20158. return printRegex(n);
  20159. case "NumericLiteral":
  20160. // Babel 6 Literal split
  20161. return printNumber$1(n.extra.raw);
  20162. case "BigIntLiteral":
  20163. return concat$4([printNumber$1(n.extra ? n.extra.rawValue : // TypeScript
  20164. n.value), "n"]);
  20165. case "BooleanLiteral": // Babel 6 Literal split
  20166. case "StringLiteral": // Babel 6 Literal split
  20167. case "Literal":
  20168. {
  20169. if (n.regex) {
  20170. return printRegex(n.regex);
  20171. }
  20172. if (typeof n.value === "number") {
  20173. return printNumber$1(n.raw);
  20174. }
  20175. if (typeof n.value !== "string") {
  20176. return "" + n.value;
  20177. } // TypeScript workaround for https://github.com/JamesHenry/typescript-estree/issues/2
  20178. // See corresponding workaround in needs-parens.js
  20179. var grandParent = path$$1.getParentNode(1);
  20180. var isTypeScriptDirective = options.parser === "typescript" && typeof n.value === "string" && grandParent && (grandParent.type === "Program" || grandParent.type === "BlockStatement");
  20181. return nodeStr(n, options, isTypeScriptDirective);
  20182. }
  20183. case "Directive":
  20184. return path$$1.call(print, "value");
  20185. // Babel 6
  20186. case "DirectiveLiteral":
  20187. return nodeStr(n, options);
  20188. case "UnaryExpression":
  20189. parts.push(n.operator);
  20190. if (/[a-z]$/.test(n.operator)) {
  20191. parts.push(" ");
  20192. }
  20193. parts.push(path$$1.call(print, "argument"));
  20194. return concat$4(parts);
  20195. case "UpdateExpression":
  20196. parts.push(path$$1.call(print, "argument"), n.operator);
  20197. if (n.prefix) {
  20198. parts.reverse();
  20199. }
  20200. return concat$4(parts);
  20201. case "ConditionalExpression":
  20202. return printTernaryOperator(path$$1, options, print, {
  20203. beforeParts: function beforeParts() {
  20204. return [path$$1.call(print, "test")];
  20205. },
  20206. afterParts: function afterParts(breakClosingParen) {
  20207. return [breakClosingParen ? softline$1 : ""];
  20208. },
  20209. shouldCheckJsx: true,
  20210. conditionalNodeType: "ConditionalExpression",
  20211. consequentNodePropertyName: "consequent",
  20212. alternateNodePropertyName: "alternate",
  20213. testNodePropertyName: "test",
  20214. breakNested: true
  20215. });
  20216. case "VariableDeclaration":
  20217. {
  20218. var printed = path$$1.map(function (childPath) {
  20219. return print(childPath);
  20220. }, "declarations"); // We generally want to terminate all variable declarations with a
  20221. // semicolon, except when they in the () part of for loops.
  20222. var parentNode = path$$1.getParentNode();
  20223. var isParentForLoop = parentNode.type === "ForStatement" || parentNode.type === "ForInStatement" || parentNode.type === "ForOfStatement" || parentNode.type === "ForAwaitStatement";
  20224. var hasValue = n.declarations.some(function (decl) {
  20225. return decl.init;
  20226. });
  20227. var firstVariable;
  20228. if (printed.length === 1 && !n.declarations[0].comments) {
  20229. firstVariable = printed[0];
  20230. } else if (printed.length > 0) {
  20231. // Indent first var to comply with eslint one-var rule
  20232. firstVariable = indent$2(printed[0]);
  20233. }
  20234. parts = [isNodeStartingWithDeclare(n, options) ? "declare " : "", n.kind, firstVariable ? concat$4([" ", firstVariable]) : "", indent$2(concat$4(printed.slice(1).map(function (p) {
  20235. return concat$4([",", hasValue && !isParentForLoop ? hardline$3 : line$3, p]);
  20236. })))];
  20237. if (!(isParentForLoop && parentNode.body !== n)) {
  20238. parts.push(semi);
  20239. }
  20240. return group$1(concat$4(parts));
  20241. }
  20242. case "TSTypeAliasDeclaration":
  20243. {
  20244. if (n.declare) {
  20245. parts.push("declare ");
  20246. }
  20247. var _printed = printAssignmentRight(n.id, n.typeAnnotation, n.typeAnnotation && path$$1.call(print, "typeAnnotation"), options);
  20248. parts.push("type ", path$$1.call(print, "id"), path$$1.call(print, "typeParameters"), " =", _printed, semi);
  20249. return group$1(concat$4(parts));
  20250. }
  20251. case "VariableDeclarator":
  20252. return printAssignment(n.id, path$$1.call(print, "id"), " =", n.init, n.init && path$$1.call(print, "init"), options);
  20253. case "WithStatement":
  20254. return group$1(concat$4(["with (", path$$1.call(print, "object"), ")", adjustClause(n.body, path$$1.call(print, "body"))]));
  20255. case "IfStatement":
  20256. {
  20257. var con = adjustClause(n.consequent, path$$1.call(print, "consequent"));
  20258. var opening = group$1(concat$4(["if (", group$1(concat$4([indent$2(concat$4([softline$1, path$$1.call(print, "test")])), softline$1])), ")", con]));
  20259. parts.push(opening);
  20260. if (n.alternate) {
  20261. var commentOnOwnLine = hasTrailingComment(n.consequent) && n.consequent.comments.some(function (comment) {
  20262. return comment.trailing && !comments$3.isBlockComment(comment);
  20263. }) || needsHardlineAfterDanglingComment(n);
  20264. var elseOnSameLine = n.consequent.type === "BlockStatement" && !commentOnOwnLine;
  20265. parts.push(elseOnSameLine ? " " : hardline$3);
  20266. if (hasDanglingComments(n)) {
  20267. parts.push(comments.printDanglingComments(path$$1, options, true), commentOnOwnLine ? hardline$3 : " ");
  20268. }
  20269. parts.push("else", group$1(adjustClause(n.alternate, path$$1.call(print, "alternate"), n.alternate.type === "IfStatement")));
  20270. }
  20271. return concat$4(parts);
  20272. }
  20273. case "ForStatement":
  20274. {
  20275. var _body = adjustClause(n.body, path$$1.call(print, "body")); // We want to keep dangling comments above the loop to stay consistent.
  20276. // Any comment positioned between the for statement and the parentheses
  20277. // is going to be printed before the statement.
  20278. var _dangling = comments.printDanglingComments(path$$1, options,
  20279. /* sameLine */
  20280. true);
  20281. var printedComments = _dangling ? concat$4([_dangling, softline$1]) : "";
  20282. if (!n.init && !n.test && !n.update) {
  20283. return concat$4([printedComments, group$1(concat$4(["for (;;)", _body]))]);
  20284. }
  20285. return concat$4([printedComments, group$1(concat$4(["for (", group$1(concat$4([indent$2(concat$4([softline$1, path$$1.call(print, "init"), ";", line$3, path$$1.call(print, "test"), ";", line$3, path$$1.call(print, "update")])), softline$1])), ")", _body]))]);
  20286. }
  20287. case "WhileStatement":
  20288. return group$1(concat$4(["while (", group$1(concat$4([indent$2(concat$4([softline$1, path$$1.call(print, "test")])), softline$1])), ")", adjustClause(n.body, path$$1.call(print, "body"))]));
  20289. case "ForInStatement":
  20290. // Note: esprima can't actually parse "for each (".
  20291. return group$1(concat$4([n.each ? "for each (" : "for (", path$$1.call(print, "left"), " in ", path$$1.call(print, "right"), ")", adjustClause(n.body, path$$1.call(print, "body"))]));
  20292. case "ForOfStatement":
  20293. case "ForAwaitStatement":
  20294. {
  20295. // Babel 7 removed ForAwaitStatement in favor of ForOfStatement
  20296. // with `"await": true`:
  20297. // https://github.com/estree/estree/pull/138
  20298. var isAwait = n.type === "ForAwaitStatement" || n.await;
  20299. return group$1(concat$4(["for", isAwait ? " await" : "", " (", path$$1.call(print, "left"), " of ", path$$1.call(print, "right"), ")", adjustClause(n.body, path$$1.call(print, "body"))]));
  20300. }
  20301. case "DoWhileStatement":
  20302. {
  20303. var clause = adjustClause(n.body, path$$1.call(print, "body"));
  20304. var doBody = group$1(concat$4(["do", clause]));
  20305. parts = [doBody];
  20306. if (n.body.type === "BlockStatement") {
  20307. parts.push(" ");
  20308. } else {
  20309. parts.push(hardline$3);
  20310. }
  20311. parts.push("while (");
  20312. parts.push(group$1(concat$4([indent$2(concat$4([softline$1, path$$1.call(print, "test")])), softline$1])), ")", semi);
  20313. return concat$4(parts);
  20314. }
  20315. case "DoExpression":
  20316. return concat$4(["do ", path$$1.call(print, "body")]);
  20317. case "BreakStatement":
  20318. parts.push("break");
  20319. if (n.label) {
  20320. parts.push(" ", path$$1.call(print, "label"));
  20321. }
  20322. parts.push(semi);
  20323. return concat$4(parts);
  20324. case "ContinueStatement":
  20325. parts.push("continue");
  20326. if (n.label) {
  20327. parts.push(" ", path$$1.call(print, "label"));
  20328. }
  20329. parts.push(semi);
  20330. return concat$4(parts);
  20331. case "LabeledStatement":
  20332. if (n.body.type === "EmptyStatement") {
  20333. return concat$4([path$$1.call(print, "label"), ":;"]);
  20334. }
  20335. return concat$4([path$$1.call(print, "label"), ": ", path$$1.call(print, "body")]);
  20336. case "TryStatement":
  20337. return concat$4(["try ", path$$1.call(print, "block"), n.handler ? concat$4([" ", path$$1.call(print, "handler")]) : "", n.finalizer ? concat$4([" finally ", path$$1.call(print, "finalizer")]) : ""]);
  20338. case "CatchClause":
  20339. if (n.param) {
  20340. var hasComments = n.param.comments && n.param.comments.some(function (comment) {
  20341. return !comments$3.isBlockComment(comment) || comment.leading && hasNewline$2(options.originalText, options.locEnd(comment)) || comment.trailing && hasNewline$2(options.originalText, options.locStart(comment), {
  20342. backwards: true
  20343. });
  20344. });
  20345. var param = path$$1.call(print, "param");
  20346. return concat$4(["catch ", hasComments ? concat$4(["(", indent$2(concat$4([softline$1, param])), softline$1, ") "]) : concat$4(["(", param, ") "]), path$$1.call(print, "body")]);
  20347. }
  20348. return concat$4(["catch ", path$$1.call(print, "body")]);
  20349. case "ThrowStatement":
  20350. return concat$4(["throw ", path$$1.call(print, "argument"), semi]);
  20351. // Note: ignoring n.lexical because it has no printing consequences.
  20352. case "SwitchStatement":
  20353. return concat$4([group$1(concat$4(["switch (", indent$2(concat$4([softline$1, path$$1.call(print, "discriminant")])), softline$1, ")"])), " {", n.cases.length > 0 ? indent$2(concat$4([hardline$3, join$2(hardline$3, path$$1.map(function (casePath) {
  20354. var caseNode = casePath.getValue();
  20355. return concat$4([casePath.call(print), n.cases.indexOf(caseNode) !== n.cases.length - 1 && isNextLineEmpty$2(options.originalText, caseNode, options) ? hardline$3 : ""]);
  20356. }, "cases"))])) : "", hardline$3, "}"]);
  20357. case "SwitchCase":
  20358. {
  20359. if (n.test) {
  20360. parts.push("case ", path$$1.call(print, "test"), ":");
  20361. } else {
  20362. parts.push("default:");
  20363. }
  20364. var consequent = n.consequent.filter(function (node) {
  20365. return node.type !== "EmptyStatement";
  20366. });
  20367. if (consequent.length > 0) {
  20368. var cons = path$$1.call(function (consequentPath) {
  20369. return printStatementSequence(consequentPath, options, print);
  20370. }, "consequent");
  20371. parts.push(consequent.length === 1 && consequent[0].type === "BlockStatement" ? concat$4([" ", cons]) : indent$2(concat$4([hardline$3, cons])));
  20372. }
  20373. return concat$4(parts);
  20374. }
  20375. // JSX extensions below.
  20376. case "DebuggerStatement":
  20377. return concat$4(["debugger", semi]);
  20378. case "JSXAttribute":
  20379. parts.push(path$$1.call(print, "name"));
  20380. if (n.value) {
  20381. var res;
  20382. if (isStringLiteral(n.value)) {
  20383. var raw = rawText(n.value); // Unescape all quotes so we get an accurate preferred quote
  20384. var final = raw.replace(/&apos;/g, "'").replace(/&quot;/g, '"');
  20385. var quote = getPreferredQuote$1(final, options.jsxSingleQuote ? "'" : '"');
  20386. var _escape = quote === "'" ? "&apos;" : "&quot;";
  20387. final = final.slice(1, -1).replace(new RegExp(quote, "g"), _escape);
  20388. res = concat$4([quote, final, quote]);
  20389. } else {
  20390. res = path$$1.call(print, "value");
  20391. }
  20392. parts.push("=", res);
  20393. }
  20394. return concat$4(parts);
  20395. case "JSXIdentifier":
  20396. return "" + n.name;
  20397. case "JSXNamespacedName":
  20398. return join$2(":", [path$$1.call(print, "namespace"), path$$1.call(print, "name")]);
  20399. case "JSXMemberExpression":
  20400. return join$2(".", [path$$1.call(print, "object"), path$$1.call(print, "property")]);
  20401. case "TSQualifiedName":
  20402. return join$2(".", [path$$1.call(print, "left"), path$$1.call(print, "right")]);
  20403. case "JSXSpreadAttribute":
  20404. case "JSXSpreadChild":
  20405. {
  20406. return concat$4(["{", path$$1.call(function (p) {
  20407. var printed = concat$4(["...", print(p)]);
  20408. var n = p.getValue();
  20409. if (!n.comments || !n.comments.length) {
  20410. return printed;
  20411. }
  20412. return concat$4([indent$2(concat$4([softline$1, comments.printComments(p, function () {
  20413. return printed;
  20414. }, options)])), softline$1]);
  20415. }, n.type === "JSXSpreadAttribute" ? "argument" : "expression"), "}"]);
  20416. }
  20417. case "JSXExpressionContainer":
  20418. {
  20419. var _parent6 = path$$1.getParentNode(0);
  20420. var preventInline = _parent6.type === "JSXAttribute" && n.expression.comments && n.expression.comments.length > 0;
  20421. var _shouldInline = !preventInline && (n.expression.type === "ArrayExpression" || n.expression.type === "ObjectExpression" || n.expression.type === "ArrowFunctionExpression" || n.expression.type === "CallExpression" || n.expression.type === "OptionalCallExpression" || n.expression.type === "FunctionExpression" || n.expression.type === "JSXEmptyExpression" || n.expression.type === "TemplateLiteral" || n.expression.type === "TaggedTemplateExpression" || n.expression.type === "DoExpression" || isJSXNode(_parent6) && (n.expression.type === "ConditionalExpression" || isBinaryish(n.expression)));
  20422. if (_shouldInline) {
  20423. return group$1(concat$4(["{", path$$1.call(print, "expression"), lineSuffixBoundary$1, "}"]));
  20424. }
  20425. return group$1(concat$4(["{", indent$2(concat$4([softline$1, path$$1.call(print, "expression")])), softline$1, lineSuffixBoundary$1, "}"]));
  20426. }
  20427. case "JSXFragment":
  20428. case "JSXElement":
  20429. {
  20430. var elem = comments.printComments(path$$1, function () {
  20431. return printJSXElement(path$$1, options, print);
  20432. }, options);
  20433. return maybeWrapJSXElementInParens(path$$1, elem);
  20434. }
  20435. case "JSXOpeningElement":
  20436. {
  20437. var _n = path$$1.getValue();
  20438. var nameHasComments = _n.name && _n.name.comments && _n.name.comments.length > 0; // Don't break self-closing elements with no attributes and no comments
  20439. if (_n.selfClosing && !_n.attributes.length && !nameHasComments) {
  20440. return concat$4(["<", path$$1.call(print, "name"), path$$1.call(print, "typeParameters"), " />"]);
  20441. } // don't break up opening elements with a single long text attribute
  20442. if (_n.attributes && _n.attributes.length === 1 && _n.attributes[0].value && isStringLiteral(_n.attributes[0].value) && !_n.attributes[0].value.value.includes("\n") && // We should break for the following cases:
  20443. // <div
  20444. // // comment
  20445. // attr="value"
  20446. // >
  20447. // <div
  20448. // attr="value"
  20449. // // comment
  20450. // >
  20451. !nameHasComments && (!_n.attributes[0].comments || !_n.attributes[0].comments.length)) {
  20452. return group$1(concat$4(["<", path$$1.call(print, "name"), path$$1.call(print, "typeParameters"), " ", concat$4(path$$1.map(print, "attributes")), _n.selfClosing ? " />" : ">"]));
  20453. }
  20454. var lastAttrHasTrailingComments = _n.attributes.length && hasTrailingComment(getLast$4(_n.attributes));
  20455. var bracketSameLine = // Simple tags (no attributes and no comment in tag name) should be
  20456. // kept unbroken regardless of `jsxBracketSameLine`
  20457. !_n.attributes.length && !nameHasComments || options.jsxBracketSameLine && ( // We should print the bracket in a new line for the following cases:
  20458. // <div
  20459. // // comment
  20460. // >
  20461. // <div
  20462. // attr // comment
  20463. // >
  20464. !nameHasComments || _n.attributes.length) && !lastAttrHasTrailingComments; // We should print the opening element expanded if any prop value is a
  20465. // string literal with newlines
  20466. var _shouldBreak = _n.attributes && _n.attributes.some(function (attr) {
  20467. return attr.value && isStringLiteral(attr.value) && attr.value.value.includes("\n");
  20468. });
  20469. return group$1(concat$4(["<", path$$1.call(print, "name"), path$$1.call(print, "typeParameters"), concat$4([indent$2(concat$4(path$$1.map(function (attr) {
  20470. return concat$4([line$3, print(attr)]);
  20471. }, "attributes"))), _n.selfClosing ? line$3 : bracketSameLine ? ">" : softline$1]), _n.selfClosing ? "/>" : bracketSameLine ? "" : ">"]), {
  20472. shouldBreak: _shouldBreak
  20473. });
  20474. }
  20475. case "JSXClosingElement":
  20476. return concat$4(["</", path$$1.call(print, "name"), ">"]);
  20477. case "JSXOpeningFragment":
  20478. case "JSXClosingFragment":
  20479. {
  20480. var hasComment = n.comments && n.comments.length;
  20481. var hasOwnLineComment = hasComment && !n.comments.every(comments$3.isBlockComment);
  20482. var isOpeningFragment = n.type === "JSXOpeningFragment";
  20483. return concat$4([isOpeningFragment ? "<" : "</", indent$2(concat$4([hasOwnLineComment ? hardline$3 : hasComment && !isOpeningFragment ? " " : "", comments.printDanglingComments(path$$1, options, true)])), hasOwnLineComment ? hardline$3 : "", ">"]);
  20484. }
  20485. case "JSXText":
  20486. /* istanbul ignore next */
  20487. throw new Error("JSXTest should be handled by JSXElement");
  20488. case "JSXEmptyExpression":
  20489. {
  20490. var requiresHardline = n.comments && !n.comments.every(comments$3.isBlockComment);
  20491. return concat$4([comments.printDanglingComments(path$$1, options,
  20492. /* sameIndent */
  20493. !requiresHardline), requiresHardline ? hardline$3 : ""]);
  20494. }
  20495. case "ClassBody":
  20496. if (!n.comments && n.body.length === 0) {
  20497. return "{}";
  20498. }
  20499. return concat$4(["{", n.body.length > 0 ? indent$2(concat$4([hardline$3, path$$1.call(function (bodyPath) {
  20500. return printStatementSequence(bodyPath, options, print);
  20501. }, "body")])) : comments.printDanglingComments(path$$1, options), hardline$3, "}"]);
  20502. case "ClassProperty":
  20503. case "TSAbstractClassProperty":
  20504. case "ClassPrivateProperty":
  20505. {
  20506. if (n.decorators && n.decorators.length !== 0) {
  20507. parts.push(printDecorators(path$$1, options, print));
  20508. }
  20509. if (n.accessibility) {
  20510. parts.push(n.accessibility + " ");
  20511. }
  20512. if (n.static) {
  20513. parts.push("static ");
  20514. }
  20515. if (n.type === "TSAbstractClassProperty") {
  20516. parts.push("abstract ");
  20517. }
  20518. if (n.readonly) {
  20519. parts.push("readonly ");
  20520. }
  20521. var variance = getFlowVariance(n);
  20522. if (variance) {
  20523. parts.push(variance);
  20524. }
  20525. if (n.computed) {
  20526. parts.push("[", path$$1.call(print, "key"), "]");
  20527. } else {
  20528. parts.push(printPropertyKey(path$$1, options, print));
  20529. }
  20530. parts.push(printOptionalToken(path$$1));
  20531. parts.push(printTypeAnnotation(path$$1, options, print));
  20532. if (n.value) {
  20533. parts.push(" =", printAssignmentRight(n.key, n.value, path$$1.call(print, "value"), options));
  20534. }
  20535. parts.push(semi);
  20536. return group$1(concat$4(parts));
  20537. }
  20538. case "ClassDeclaration":
  20539. case "ClassExpression":
  20540. case "TSAbstractClassDeclaration":
  20541. if (isNodeStartingWithDeclare(n, options)) {
  20542. parts.push("declare ");
  20543. }
  20544. parts.push(concat$4(printClass(path$$1, options, print)));
  20545. return concat$4(parts);
  20546. case "TSInterfaceHeritage":
  20547. parts.push(path$$1.call(print, "expression"));
  20548. if (n.typeParameters) {
  20549. parts.push(path$$1.call(print, "typeParameters"));
  20550. }
  20551. return concat$4(parts);
  20552. case "TemplateElement":
  20553. return join$2(literalline$1, n.value.raw.split(/\r?\n/g));
  20554. case "TemplateLiteral":
  20555. {
  20556. var expressions = path$$1.map(print, "expressions");
  20557. var _parentNode = path$$1.getParentNode();
  20558. /**
  20559. * describe.each`table`(name, fn)
  20560. * describe.only.each`table`(name, fn)
  20561. * describe.skip.each`table`(name, fn)
  20562. * test.each`table`(name, fn)
  20563. * test.only.each`table`(name, fn)
  20564. * test.skip.each`table`(name, fn)
  20565. *
  20566. * Ref: https://github.com/facebook/jest/pull/6102
  20567. */
  20568. var jestEachTriggerRegex = /^[xf]?(describe|it|test)$/;
  20569. if (_parentNode.type === "TaggedTemplateExpression" && _parentNode.quasi === n && _parentNode.tag.type === "MemberExpression" && _parentNode.tag.property.type === "Identifier" && _parentNode.tag.property.name === "each" && (_parentNode.tag.object.type === "Identifier" && jestEachTriggerRegex.test(_parentNode.tag.object.name) || _parentNode.tag.object.type === "MemberExpression" && _parentNode.tag.object.property.type === "Identifier" && (_parentNode.tag.object.property.name === "only" || _parentNode.tag.object.property.name === "skip") && _parentNode.tag.object.object.type === "Identifier" && jestEachTriggerRegex.test(_parentNode.tag.object.object.name))) {
  20570. /**
  20571. * a | b | expected
  20572. * ${1} | ${1} | ${2}
  20573. * ${1} | ${2} | ${3}
  20574. * ${2} | ${1} | ${3}
  20575. */
  20576. var headerNames = n.quasis[0].value.raw.trim().split(/\s*\|\s*/);
  20577. if (headerNames.length > 1 || headerNames.some(function (headerName) {
  20578. return headerName.length !== 0;
  20579. })) {
  20580. var stringifiedExpressions = expressions.map(function (doc$$2) {
  20581. return "${" + printDocToString$2(doc$$2, Object.assign({}, options, {
  20582. printWidth: Infinity,
  20583. endOfLine: "lf"
  20584. })).formatted + "}";
  20585. });
  20586. var tableBody = [{
  20587. hasLineBreak: false,
  20588. cells: []
  20589. }];
  20590. for (var _i = 1; _i < n.quasis.length; _i++) {
  20591. var row = tableBody[tableBody.length - 1];
  20592. var correspondingExpression = stringifiedExpressions[_i - 1];
  20593. row.cells.push(correspondingExpression);
  20594. if (correspondingExpression.indexOf("\n") !== -1) {
  20595. row.hasLineBreak = true;
  20596. }
  20597. if (n.quasis[_i].value.raw.indexOf("\n") !== -1) {
  20598. tableBody.push({
  20599. hasLineBreak: false,
  20600. cells: []
  20601. });
  20602. }
  20603. }
  20604. var maxColumnCount = tableBody.reduce(function (maxColumnCount, row) {
  20605. return Math.max(maxColumnCount, row.cells.length);
  20606. }, headerNames.length);
  20607. var maxColumnWidths = Array.from(new Array(maxColumnCount), function () {
  20608. return 0;
  20609. });
  20610. var table = [{
  20611. cells: headerNames
  20612. }].concat(tableBody.filter(function (row) {
  20613. return row.cells.length !== 0;
  20614. }));
  20615. table.filter(function (row) {
  20616. return !row.hasLineBreak;
  20617. }).forEach(function (row) {
  20618. row.cells.forEach(function (cell, index) {
  20619. maxColumnWidths[index] = Math.max(maxColumnWidths[index], getStringWidth$2(cell));
  20620. });
  20621. });
  20622. parts.push("`", indent$2(concat$4([hardline$3, join$2(hardline$3, table.map(function (row) {
  20623. return join$2(" | ", row.cells.map(function (cell, index) {
  20624. return row.hasLineBreak ? cell : cell + " ".repeat(maxColumnWidths[index] - getStringWidth$2(cell));
  20625. }));
  20626. }))])), hardline$3, "`");
  20627. return concat$4(parts);
  20628. }
  20629. }
  20630. parts.push("`");
  20631. path$$1.each(function (childPath) {
  20632. var i = childPath.getName();
  20633. parts.push(print(childPath));
  20634. if (i < expressions.length) {
  20635. // For a template literal of the following form:
  20636. // `someQuery {
  20637. // ${call({
  20638. // a,
  20639. // b,
  20640. // })}
  20641. // }`
  20642. // the expression is on its own line (there is a \n in the previous
  20643. // quasi literal), therefore we want to indent the JavaScript
  20644. // expression inside at the beginning of ${ instead of the beginning
  20645. // of the `.
  20646. var tabWidth = options.tabWidth;
  20647. var quasi = childPath.getValue();
  20648. var indentSize = getIndentSize$1(quasi.value.raw, tabWidth);
  20649. var _printed2 = expressions[i];
  20650. if (n.expressions[i].comments && n.expressions[i].comments.length || n.expressions[i].type === "MemberExpression" || n.expressions[i].type === "OptionalMemberExpression" || n.expressions[i].type === "ConditionalExpression") {
  20651. _printed2 = concat$4([indent$2(concat$4([softline$1, _printed2])), softline$1]);
  20652. }
  20653. var aligned = indentSize === 0 && quasi.value.raw.endsWith("\n") ? align$1(-Infinity, _printed2) : addAlignmentToDoc$2(_printed2, indentSize, tabWidth);
  20654. parts.push(group$1(concat$4(["${", aligned, lineSuffixBoundary$1, "}"])));
  20655. }
  20656. }, "quasis");
  20657. parts.push("`");
  20658. return concat$4(parts);
  20659. }
  20660. // These types are unprintable because they serve as abstract
  20661. // supertypes for other (printable) types.
  20662. case "TaggedTemplateExpression":
  20663. return concat$4([path$$1.call(print, "tag"), path$$1.call(print, "typeParameters"), path$$1.call(print, "quasi")]);
  20664. case "Node":
  20665. case "Printable":
  20666. case "SourceLocation":
  20667. case "Position":
  20668. case "Statement":
  20669. case "Function":
  20670. case "Pattern":
  20671. case "Expression":
  20672. case "Declaration":
  20673. case "Specifier":
  20674. case "NamedSpecifier":
  20675. case "Comment":
  20676. case "MemberTypeAnnotation": // Flow
  20677. case "Type":
  20678. /* istanbul ignore next */
  20679. throw new Error("unprintable type: " + JSON.stringify(n.type));
  20680. // Type Annotations for Facebook Flow, typically stripped out or
  20681. // transformed away before printing.
  20682. case "TypeAnnotation":
  20683. case "TSTypeAnnotation":
  20684. if (n.typeAnnotation) {
  20685. return path$$1.call(print, "typeAnnotation");
  20686. }
  20687. /* istanbul ignore next */
  20688. return "";
  20689. case "TSTupleType":
  20690. case "TupleTypeAnnotation":
  20691. {
  20692. var typesField = n.type === "TSTupleType" ? "elementTypes" : "types";
  20693. return group$1(concat$4(["[", indent$2(concat$4([softline$1, printArrayItems(path$$1, options, typesField, print)])), // TypeScript doesn't support trailing commas in tuple types
  20694. n.type === "TSTupleType" ? "" : ifBreak$1(shouldPrintComma(options) ? "," : ""), comments.printDanglingComments(path$$1, options,
  20695. /* sameIndent */
  20696. true), softline$1, "]"]));
  20697. }
  20698. case "ExistsTypeAnnotation":
  20699. return "*";
  20700. case "EmptyTypeAnnotation":
  20701. return "empty";
  20702. case "AnyTypeAnnotation":
  20703. return "any";
  20704. case "MixedTypeAnnotation":
  20705. return "mixed";
  20706. case "ArrayTypeAnnotation":
  20707. return concat$4([path$$1.call(print, "elementType"), "[]"]);
  20708. case "BooleanTypeAnnotation":
  20709. return "boolean";
  20710. case "BooleanLiteralTypeAnnotation":
  20711. return "" + n.value;
  20712. case "DeclareClass":
  20713. return printFlowDeclaration(path$$1, printClass(path$$1, options, print));
  20714. case "TSDeclareFunction":
  20715. // For TypeScript the TSDeclareFunction node shares the AST
  20716. // structure with FunctionDeclaration
  20717. return concat$4([n.declare ? "declare " : "", printFunctionDeclaration(path$$1, print, options), semi]);
  20718. case "DeclareFunction":
  20719. return printFlowDeclaration(path$$1, ["function ", path$$1.call(print, "id"), n.predicate ? " " : "", path$$1.call(print, "predicate"), semi]);
  20720. case "DeclareModule":
  20721. return printFlowDeclaration(path$$1, ["module ", path$$1.call(print, "id"), " ", path$$1.call(print, "body")]);
  20722. case "DeclareModuleExports":
  20723. return printFlowDeclaration(path$$1, ["module.exports", ": ", path$$1.call(print, "typeAnnotation"), semi]);
  20724. case "DeclareVariable":
  20725. return printFlowDeclaration(path$$1, ["var ", path$$1.call(print, "id"), semi]);
  20726. case "DeclareExportAllDeclaration":
  20727. return concat$4(["declare export * from ", path$$1.call(print, "source")]);
  20728. case "DeclareExportDeclaration":
  20729. return concat$4(["declare ", printExportDeclaration(path$$1, options, print)]);
  20730. case "DeclareOpaqueType":
  20731. case "OpaqueType":
  20732. {
  20733. parts.push("opaque type ", path$$1.call(print, "id"), path$$1.call(print, "typeParameters"));
  20734. if (n.supertype) {
  20735. parts.push(": ", path$$1.call(print, "supertype"));
  20736. }
  20737. if (n.impltype) {
  20738. parts.push(" = ", path$$1.call(print, "impltype"));
  20739. }
  20740. parts.push(semi);
  20741. if (n.type === "DeclareOpaqueType") {
  20742. return printFlowDeclaration(path$$1, parts);
  20743. }
  20744. return concat$4(parts);
  20745. }
  20746. case "FunctionTypeAnnotation":
  20747. case "TSFunctionType":
  20748. {
  20749. // FunctionTypeAnnotation is ambiguous:
  20750. // declare function foo(a: B): void; OR
  20751. // var A: (a: B) => void;
  20752. var _parent7 = path$$1.getParentNode(0);
  20753. var _parentParent2 = path$$1.getParentNode(1);
  20754. var _parentParentParent = path$$1.getParentNode(2);
  20755. var isArrowFunctionTypeAnnotation = n.type === "TSFunctionType" || !((_parent7.type === "ObjectTypeProperty" || _parent7.type === "ObjectTypeInternalSlot") && !getFlowVariance(_parent7) && !_parent7.optional && options.locStart(_parent7) === options.locStart(n) || _parent7.type === "ObjectTypeCallProperty" || _parentParentParent && _parentParentParent.type === "DeclareFunction");
  20756. var needsColon = isArrowFunctionTypeAnnotation && (_parent7.type === "TypeAnnotation" || _parent7.type === "TSTypeAnnotation"); // Sadly we can't put it inside of FastPath::needsColon because we are
  20757. // printing ":" as part of the expression and it would put parenthesis
  20758. // around :(
  20759. var needsParens = needsColon && isArrowFunctionTypeAnnotation && (_parent7.type === "TypeAnnotation" || _parent7.type === "TSTypeAnnotation") && _parentParent2.type === "ArrowFunctionExpression";
  20760. if (isObjectTypePropertyAFunction(_parent7, options)) {
  20761. isArrowFunctionTypeAnnotation = true;
  20762. needsColon = true;
  20763. }
  20764. if (needsParens) {
  20765. parts.push("(");
  20766. }
  20767. parts.push(printFunctionParams(path$$1, print, options,
  20768. /* expandArg */
  20769. false,
  20770. /* printTypeParams */
  20771. true)); // The returnType is not wrapped in a TypeAnnotation, so the colon
  20772. // needs to be added separately.
  20773. if (n.returnType || n.predicate || n.typeAnnotation) {
  20774. parts.push(isArrowFunctionTypeAnnotation ? " => " : ": ", path$$1.call(print, "returnType"), path$$1.call(print, "predicate"), path$$1.call(print, "typeAnnotation"));
  20775. }
  20776. if (needsParens) {
  20777. parts.push(")");
  20778. }
  20779. return group$1(concat$4(parts));
  20780. }
  20781. case "TSRestType":
  20782. return concat$4(["...", path$$1.call(print, "typeAnnotation")]);
  20783. case "TSOptionalType":
  20784. return concat$4([path$$1.call(print, "typeAnnotation"), "?"]);
  20785. case "FunctionTypeParam":
  20786. return concat$4([path$$1.call(print, "name"), printOptionalToken(path$$1), n.name ? ": " : "", path$$1.call(print, "typeAnnotation")]);
  20787. case "GenericTypeAnnotation":
  20788. return concat$4([path$$1.call(print, "id"), path$$1.call(print, "typeParameters")]);
  20789. case "DeclareInterface":
  20790. case "InterfaceDeclaration":
  20791. case "InterfaceTypeAnnotation":
  20792. {
  20793. if (n.type === "DeclareInterface" || isNodeStartingWithDeclare(n, options)) {
  20794. parts.push("declare ");
  20795. }
  20796. parts.push("interface");
  20797. if (n.type === "DeclareInterface" || n.type === "InterfaceDeclaration") {
  20798. parts.push(" ", path$$1.call(print, "id"), path$$1.call(print, "typeParameters"));
  20799. }
  20800. if (n["extends"].length > 0) {
  20801. parts.push(group$1(indent$2(concat$4([line$3, "extends ", (n.extends.length === 1 ? identity$1 : indent$2)(join$2(concat$4([",", line$3]), path$$1.map(print, "extends")))]))));
  20802. }
  20803. parts.push(" ", path$$1.call(print, "body"));
  20804. return group$1(concat$4(parts));
  20805. }
  20806. case "ClassImplements":
  20807. case "InterfaceExtends":
  20808. return concat$4([path$$1.call(print, "id"), path$$1.call(print, "typeParameters")]);
  20809. case "TSClassImplements":
  20810. return concat$4([path$$1.call(print, "expression"), path$$1.call(print, "typeParameters")]);
  20811. case "TSIntersectionType":
  20812. case "IntersectionTypeAnnotation":
  20813. {
  20814. var types = path$$1.map(print, "types");
  20815. var result = [];
  20816. var wasIndented = false;
  20817. for (var _i2 = 0; _i2 < types.length; ++_i2) {
  20818. if (_i2 === 0) {
  20819. result.push(types[_i2]);
  20820. } else if (isObjectType(n.types[_i2 - 1]) && isObjectType(n.types[_i2])) {
  20821. // If both are objects, don't indent
  20822. result.push(concat$4([" & ", wasIndented ? indent$2(types[_i2]) : types[_i2]]));
  20823. } else if (!isObjectType(n.types[_i2 - 1]) && !isObjectType(n.types[_i2])) {
  20824. // If no object is involved, go to the next line if it breaks
  20825. result.push(indent$2(concat$4([" &", line$3, types[_i2]])));
  20826. } else {
  20827. // If you go from object to non-object or vis-versa, then inline it
  20828. if (_i2 > 1) {
  20829. wasIndented = true;
  20830. }
  20831. result.push(" & ", _i2 > 1 ? indent$2(types[_i2]) : types[_i2]);
  20832. }
  20833. }
  20834. return group$1(concat$4(result));
  20835. }
  20836. case "TSUnionType":
  20837. case "UnionTypeAnnotation":
  20838. {
  20839. // single-line variation
  20840. // A | B | C
  20841. // multi-line variation
  20842. // | A
  20843. // | B
  20844. // | C
  20845. var _parent8 = path$$1.getParentNode(); // If there's a leading comment, the parent is doing the indentation
  20846. var shouldIndent = _parent8.type !== "TypeParameterInstantiation" && _parent8.type !== "TSTypeParameterInstantiation" && _parent8.type !== "GenericTypeAnnotation" && _parent8.type !== "TSTypeReference" && _parent8.type !== "TSTypeAssertion" && !(_parent8.type === "FunctionTypeParam" && !_parent8.name) && !((_parent8.type === "TypeAlias" || _parent8.type === "VariableDeclarator" || _parent8.type === "TSTypeAliasDeclaration") && hasLeadingOwnLineComment(options.originalText, n, options)); // {
  20847. // a: string
  20848. // } | null | void
  20849. // should be inlined and not be printed in the multi-line variant
  20850. var shouldHug = shouldHugType(n); // We want to align the children but without its comment, so it looks like
  20851. // | child1
  20852. // // comment
  20853. // | child2
  20854. var _printed3 = path$$1.map(function (typePath) {
  20855. var printedType = typePath.call(print);
  20856. if (!shouldHug) {
  20857. printedType = align$1(2, printedType);
  20858. }
  20859. return comments.printComments(typePath, function () {
  20860. return printedType;
  20861. }, options);
  20862. }, "types");
  20863. if (shouldHug) {
  20864. return join$2(" | ", _printed3);
  20865. }
  20866. var shouldAddStartLine = shouldIndent && !hasLeadingOwnLineComment(options.originalText, n, options);
  20867. var code = concat$4([ifBreak$1(concat$4([shouldAddStartLine ? line$3 : "", "| "])), join$2(concat$4([line$3, "| "]), _printed3)]);
  20868. var hasParens;
  20869. if (n.type === "TSUnionType") {
  20870. var greatGrandParent = path$$1.getParentNode(2);
  20871. var greatGreatGrandParent = path$$1.getParentNode(3);
  20872. hasParens = greatGrandParent && greatGrandParent.type === "TSParenthesizedType" && greatGreatGrandParent && (greatGreatGrandParent.type === "TSUnionType" || greatGreatGrandParent.type === "TSIntersectionType");
  20873. } else {
  20874. hasParens = needsParens_1(path$$1, options);
  20875. }
  20876. if (hasParens) {
  20877. return group$1(concat$4([indent$2(code), softline$1]));
  20878. }
  20879. return group$1(shouldIndent ? indent$2(code) : code);
  20880. }
  20881. case "NullableTypeAnnotation":
  20882. return concat$4(["?", path$$1.call(print, "typeAnnotation")]);
  20883. case "TSNullKeyword":
  20884. case "NullLiteralTypeAnnotation":
  20885. return "null";
  20886. case "ThisTypeAnnotation":
  20887. return "this";
  20888. case "NumberTypeAnnotation":
  20889. return "number";
  20890. case "ObjectTypeCallProperty":
  20891. if (n.static) {
  20892. parts.push("static ");
  20893. }
  20894. parts.push(path$$1.call(print, "value"));
  20895. return concat$4(parts);
  20896. case "ObjectTypeIndexer":
  20897. {
  20898. var _variance = getFlowVariance(n);
  20899. return concat$4([_variance || "", "[", path$$1.call(print, "id"), n.id ? ": " : "", path$$1.call(print, "key"), "]: ", path$$1.call(print, "value")]);
  20900. }
  20901. case "ObjectTypeProperty":
  20902. {
  20903. var _variance2 = getFlowVariance(n);
  20904. var modifier = "";
  20905. if (n.proto) {
  20906. modifier = "proto ";
  20907. } else if (n.static) {
  20908. modifier = "static ";
  20909. }
  20910. return concat$4([modifier, isGetterOrSetter(n) ? n.kind + " " : "", _variance2 || "", printPropertyKey(path$$1, options, print), printOptionalToken(path$$1), isFunctionNotation(n, options) ? "" : ": ", path$$1.call(print, "value")]);
  20911. }
  20912. case "QualifiedTypeIdentifier":
  20913. return concat$4([path$$1.call(print, "qualification"), ".", path$$1.call(print, "id")]);
  20914. case "StringLiteralTypeAnnotation":
  20915. return nodeStr(n, options);
  20916. case "NumberLiteralTypeAnnotation":
  20917. assert.strictEqual(typeof n.value, "number");
  20918. if (n.extra != null) {
  20919. return printNumber$1(n.extra.raw);
  20920. }
  20921. return printNumber$1(n.raw);
  20922. case "StringTypeAnnotation":
  20923. return "string";
  20924. case "DeclareTypeAlias":
  20925. case "TypeAlias":
  20926. {
  20927. if (n.type === "DeclareTypeAlias" || isNodeStartingWithDeclare(n, options)) {
  20928. parts.push("declare ");
  20929. }
  20930. var _printed4 = printAssignmentRight(n.id, n.right, path$$1.call(print, "right"), options);
  20931. parts.push("type ", path$$1.call(print, "id"), path$$1.call(print, "typeParameters"), " =", _printed4, semi);
  20932. return group$1(concat$4(parts));
  20933. }
  20934. case "TypeCastExpression":
  20935. {
  20936. var value = path$$1.getValue(); // Flow supports a comment syntax for specifying type annotations: https://flow.org/en/docs/types/comments/.
  20937. // Unfortunately, its parser doesn't differentiate between comment annotations and regular
  20938. // annotations when producing an AST. So to preserve parentheses around type casts that use
  20939. // the comment syntax, we need to hackily read the source itself to see if the code contains
  20940. // a type annotation comment.
  20941. //
  20942. // Note that we're able to use the normal whitespace regex here because the Flow parser has
  20943. // already deemed this AST node to be a type cast. Only the Babel parser needs the
  20944. // non-line-break whitespace regex, which is why hasFlowShorthandAnnotationComment() is
  20945. // implemented differently.
  20946. var commentSyntax = value && value.typeAnnotation && value.typeAnnotation.range && options.originalText.substring(value.typeAnnotation.range[0]).match(/^\/\*\s*:/);
  20947. return concat$4(["(", path$$1.call(print, "expression"), commentSyntax ? " /*" : "", ": ", path$$1.call(print, "typeAnnotation"), commentSyntax ? " */" : "", ")"]);
  20948. }
  20949. case "TypeParameterDeclaration":
  20950. case "TypeParameterInstantiation":
  20951. {
  20952. var _value = path$$1.getValue();
  20953. var commentStart = _value.range ? options.originalText.substring(0, _value.range[0]).lastIndexOf("/*") : -1; // As noted in the TypeCastExpression comments above, we're able to use a normal whitespace regex here
  20954. // because we know for sure that this is a type definition.
  20955. var _commentSyntax = commentStart >= 0 && options.originalText.substring(commentStart).match(/^\/\*\s*::/);
  20956. if (_commentSyntax) {
  20957. return concat$4(["/*:: ", printTypeParameters(path$$1, options, print, "params"), " */"]);
  20958. }
  20959. return printTypeParameters(path$$1, options, print, "params");
  20960. }
  20961. case "TSTypeParameterDeclaration":
  20962. case "TSTypeParameterInstantiation":
  20963. return printTypeParameters(path$$1, options, print, "params");
  20964. case "TSTypeParameter":
  20965. case "TypeParameter":
  20966. {
  20967. var _parent9 = path$$1.getParentNode();
  20968. if (_parent9.type === "TSMappedType") {
  20969. parts.push("[", path$$1.call(print, "name"));
  20970. if (n.constraint) {
  20971. parts.push(" in ", path$$1.call(print, "constraint"));
  20972. }
  20973. parts.push("]");
  20974. return concat$4(parts);
  20975. }
  20976. var _variance3 = getFlowVariance(n);
  20977. if (_variance3) {
  20978. parts.push(_variance3);
  20979. }
  20980. parts.push(path$$1.call(print, "name"));
  20981. if (n.bound) {
  20982. parts.push(": ");
  20983. parts.push(path$$1.call(print, "bound"));
  20984. }
  20985. if (n.constraint) {
  20986. parts.push(" extends ", path$$1.call(print, "constraint"));
  20987. }
  20988. if (n["default"]) {
  20989. parts.push(" = ", path$$1.call(print, "default"));
  20990. }
  20991. return concat$4(parts);
  20992. }
  20993. case "TypeofTypeAnnotation":
  20994. return concat$4(["typeof ", path$$1.call(print, "argument")]);
  20995. case "VoidTypeAnnotation":
  20996. return "void";
  20997. case "InferredPredicate":
  20998. return "%checks";
  20999. // Unhandled types below. If encountered, nodes of these types should
  21000. // be either left alone or desugared into AST types that are fully
  21001. // supported by the pretty-printer.
  21002. case "DeclaredPredicate":
  21003. return concat$4(["%checks(", path$$1.call(print, "value"), ")"]);
  21004. case "TSAbstractKeyword":
  21005. return "abstract";
  21006. case "TSAnyKeyword":
  21007. return "any";
  21008. case "TSAsyncKeyword":
  21009. return "async";
  21010. case "TSBooleanKeyword":
  21011. return "boolean";
  21012. case "TSBigIntKeyword":
  21013. return "bigint";
  21014. case "TSConstKeyword":
  21015. return "const";
  21016. case "TSDeclareKeyword":
  21017. return "declare";
  21018. case "TSExportKeyword":
  21019. return "export";
  21020. case "TSNeverKeyword":
  21021. return "never";
  21022. case "TSNumberKeyword":
  21023. return "number";
  21024. case "TSObjectKeyword":
  21025. return "object";
  21026. case "TSProtectedKeyword":
  21027. return "protected";
  21028. case "TSPrivateKeyword":
  21029. return "private";
  21030. case "TSPublicKeyword":
  21031. return "public";
  21032. case "TSReadonlyKeyword":
  21033. return "readonly";
  21034. case "TSSymbolKeyword":
  21035. return "symbol";
  21036. case "TSStaticKeyword":
  21037. return "static";
  21038. case "TSStringKeyword":
  21039. return "string";
  21040. case "TSUndefinedKeyword":
  21041. return "undefined";
  21042. case "TSUnknownKeyword":
  21043. return "unknown";
  21044. case "TSVoidKeyword":
  21045. return "void";
  21046. case "TSAsExpression":
  21047. return concat$4([path$$1.call(print, "expression"), " as ", path$$1.call(print, "typeAnnotation")]);
  21048. case "TSArrayType":
  21049. return concat$4([path$$1.call(print, "elementType"), "[]"]);
  21050. case "TSPropertySignature":
  21051. {
  21052. if (n.export) {
  21053. parts.push("export ");
  21054. }
  21055. if (n.accessibility) {
  21056. parts.push(n.accessibility + " ");
  21057. }
  21058. if (n.static) {
  21059. parts.push("static ");
  21060. }
  21061. if (n.readonly) {
  21062. parts.push("readonly ");
  21063. }
  21064. if (n.computed) {
  21065. parts.push("[");
  21066. }
  21067. parts.push(printPropertyKey(path$$1, options, print));
  21068. if (n.computed) {
  21069. parts.push("]");
  21070. }
  21071. parts.push(printOptionalToken(path$$1));
  21072. if (n.typeAnnotation) {
  21073. parts.push(": ");
  21074. parts.push(path$$1.call(print, "typeAnnotation"));
  21075. } // This isn't valid semantically, but it's in the AST so we can print it.
  21076. if (n.initializer) {
  21077. parts.push(" = ", path$$1.call(print, "initializer"));
  21078. }
  21079. return concat$4(parts);
  21080. }
  21081. case "TSParameterProperty":
  21082. if (n.accessibility) {
  21083. parts.push(n.accessibility + " ");
  21084. }
  21085. if (n.export) {
  21086. parts.push("export ");
  21087. }
  21088. if (n.static) {
  21089. parts.push("static ");
  21090. }
  21091. if (n.readonly) {
  21092. parts.push("readonly ");
  21093. }
  21094. parts.push(path$$1.call(print, "parameter"));
  21095. return concat$4(parts);
  21096. case "TSTypeReference":
  21097. return concat$4([path$$1.call(print, "typeName"), printTypeParameters(path$$1, options, print, "typeParameters")]);
  21098. case "TSTypeQuery":
  21099. return concat$4(["typeof ", path$$1.call(print, "exprName")]);
  21100. case "TSParenthesizedType":
  21101. {
  21102. return path$$1.call(print, "typeAnnotation");
  21103. }
  21104. case "TSIndexSignature":
  21105. {
  21106. var _parent10 = path$$1.getParentNode();
  21107. return concat$4([n.export ? "export " : "", n.accessibility ? concat$4([n.accessibility, " "]) : "", n.static ? "static " : "", n.readonly ? "readonly " : "", "[", n.parameters ? concat$4(path$$1.map(print, "parameters")) : "", "]: ", path$$1.call(print, "typeAnnotation"), _parent10.type === "ClassBody" ? semi : ""]);
  21108. }
  21109. case "TSTypePredicate":
  21110. return concat$4([path$$1.call(print, "parameterName"), " is ", path$$1.call(print, "typeAnnotation")]);
  21111. case "TSNonNullExpression":
  21112. return concat$4([path$$1.call(print, "expression"), "!"]);
  21113. case "TSThisType":
  21114. return "this";
  21115. case "TSImportType":
  21116. return concat$4([!n.isTypeOf ? "" : "typeof ", "import(", path$$1.call(print, "parameter"), ")", !n.qualifier ? "" : concat$4([".", path$$1.call(print, "qualifier")]), printTypeParameters(path$$1, options, print, "typeParameters")]);
  21117. case "TSLiteralType":
  21118. return path$$1.call(print, "literal");
  21119. case "TSIndexedAccessType":
  21120. return concat$4([path$$1.call(print, "objectType"), "[", path$$1.call(print, "indexType"), "]"]);
  21121. case "TSConstructSignatureDeclaration":
  21122. case "TSCallSignatureDeclaration":
  21123. case "TSConstructorType":
  21124. {
  21125. if (n.type !== "TSCallSignatureDeclaration") {
  21126. parts.push("new ");
  21127. }
  21128. parts.push(group$1(printFunctionParams(path$$1, print, options,
  21129. /* expandArg */
  21130. false,
  21131. /* printTypeParams */
  21132. true)));
  21133. if (n.returnType) {
  21134. var isType = n.type === "TSConstructorType";
  21135. parts.push(isType ? " => " : ": ", path$$1.call(print, "returnType"));
  21136. }
  21137. return concat$4(parts);
  21138. }
  21139. case "TSTypeOperator":
  21140. return concat$4([n.operator, " ", path$$1.call(print, "typeAnnotation")]);
  21141. case "TSMappedType":
  21142. return group$1(concat$4(["{", indent$2(concat$4([options.bracketSpacing ? line$3 : softline$1, n.readonly ? concat$4([getTypeScriptMappedTypeModifier(n.readonly, "readonly"), " "]) : "", printTypeScriptModifiers(path$$1, options, print), path$$1.call(print, "typeParameter"), n.optional ? getTypeScriptMappedTypeModifier(n.optional, "?") : "", ": ", path$$1.call(print, "typeAnnotation")])), comments.printDanglingComments(path$$1, options,
  21143. /* sameIndent */
  21144. true), options.bracketSpacing ? line$3 : softline$1, "}"]));
  21145. case "TSMethodSignature":
  21146. parts.push(n.accessibility ? concat$4([n.accessibility, " "]) : "", n.export ? "export " : "", n.static ? "static " : "", n.readonly ? "readonly " : "", n.computed ? "[" : "", path$$1.call(print, "key"), n.computed ? "]" : "", printOptionalToken(path$$1), printFunctionParams(path$$1, print, options,
  21147. /* expandArg */
  21148. false,
  21149. /* printTypeParams */
  21150. true));
  21151. if (n.returnType) {
  21152. parts.push(": ", path$$1.call(print, "returnType"));
  21153. }
  21154. return group$1(concat$4(parts));
  21155. case "TSNamespaceExportDeclaration":
  21156. parts.push("export as namespace ", path$$1.call(print, "id"));
  21157. if (options.semi) {
  21158. parts.push(";");
  21159. }
  21160. return group$1(concat$4(parts));
  21161. case "TSEnumDeclaration":
  21162. if (isNodeStartingWithDeclare(n, options)) {
  21163. parts.push("declare ");
  21164. }
  21165. if (n.modifiers) {
  21166. parts.push(printTypeScriptModifiers(path$$1, options, print));
  21167. }
  21168. if (n.const) {
  21169. parts.push("const ");
  21170. }
  21171. parts.push("enum ", path$$1.call(print, "id"), " ");
  21172. if (n.members.length === 0) {
  21173. parts.push(group$1(concat$4(["{", comments.printDanglingComments(path$$1, options), softline$1, "}"])));
  21174. } else {
  21175. parts.push(group$1(concat$4(["{", indent$2(concat$4([hardline$3, printArrayItems(path$$1, options, "members", print), shouldPrintComma(options, "es5") ? "," : ""])), comments.printDanglingComments(path$$1, options,
  21176. /* sameIndent */
  21177. true), hardline$3, "}"])));
  21178. }
  21179. return concat$4(parts);
  21180. case "TSEnumMember":
  21181. parts.push(path$$1.call(print, "id"));
  21182. if (n.initializer) {
  21183. parts.push(" = ", path$$1.call(print, "initializer"));
  21184. }
  21185. return concat$4(parts);
  21186. case "TSImportEqualsDeclaration":
  21187. if (n.isExport) {
  21188. parts.push("export ");
  21189. }
  21190. parts.push("import ", path$$1.call(print, "id"), " = ", path$$1.call(print, "moduleReference"));
  21191. if (options.semi) {
  21192. parts.push(";");
  21193. }
  21194. return group$1(concat$4(parts));
  21195. case "TSExternalModuleReference":
  21196. return concat$4(["require(", path$$1.call(print, "expression"), ")"]);
  21197. case "TSModuleDeclaration":
  21198. {
  21199. var _parent11 = path$$1.getParentNode();
  21200. var isExternalModule = isLiteral(n.id);
  21201. var parentIsDeclaration = _parent11.type === "TSModuleDeclaration";
  21202. var bodyIsDeclaration = n.body && n.body.type === "TSModuleDeclaration";
  21203. if (parentIsDeclaration) {
  21204. parts.push(".");
  21205. } else {
  21206. if (n.declare === true) {
  21207. parts.push("declare ");
  21208. }
  21209. parts.push(printTypeScriptModifiers(path$$1, options, print));
  21210. var textBetweenNodeAndItsId = options.originalText.slice(options.locStart(n), options.locStart(n.id)); // Global declaration looks like this:
  21211. // (declare)? global { ... }
  21212. var isGlobalDeclaration = n.id.type === "Identifier" && n.id.name === "global" && !/namespace|module/.test(textBetweenNodeAndItsId);
  21213. if (!isGlobalDeclaration) {
  21214. parts.push(isExternalModule || /(^|\s)module(\s|$)/.test(textBetweenNodeAndItsId) ? "module " : "namespace ");
  21215. }
  21216. }
  21217. parts.push(path$$1.call(print, "id"));
  21218. if (bodyIsDeclaration) {
  21219. parts.push(path$$1.call(print, "body"));
  21220. } else if (n.body) {
  21221. parts.push(" ", group$1(path$$1.call(print, "body")));
  21222. } else {
  21223. parts.push(semi);
  21224. }
  21225. return concat$4(parts);
  21226. }
  21227. case "PrivateName":
  21228. return concat$4(["#", path$$1.call(print, "id")]);
  21229. case "TSConditionalType":
  21230. return printTernaryOperator(path$$1, options, print, {
  21231. beforeParts: function beforeParts() {
  21232. return [path$$1.call(print, "checkType"), " ", "extends", " ", path$$1.call(print, "extendsType")];
  21233. },
  21234. afterParts: function afterParts() {
  21235. return [];
  21236. },
  21237. shouldCheckJsx: false,
  21238. conditionalNodeType: "TSConditionalType",
  21239. consequentNodePropertyName: "trueType",
  21240. alternateNodePropertyName: "falseType",
  21241. testNodePropertyName: "checkType",
  21242. breakNested: true
  21243. });
  21244. case "TSInferType":
  21245. return concat$4(["infer", " ", path$$1.call(print, "typeParameter")]);
  21246. case "InterpreterDirective":
  21247. parts.push("#!", n.value, hardline$3);
  21248. if (isNextLineEmpty$2(options.originalText, n, options)) {
  21249. parts.push(hardline$3);
  21250. }
  21251. return concat$4(parts);
  21252. case "NGRoot":
  21253. return concat$4([].concat(path$$1.call(print, "node"), !n.node.comments || n.node.comments.length === 0 ? [] : concat$4([" //", n.node.comments[0].value.trimRight()])));
  21254. case "NGChainedExpression":
  21255. return group$1(join$2(concat$4([";", line$3]), path$$1.map(function (childPath) {
  21256. return hasNgSideEffect(childPath) ? print(childPath) : concat$4(["(", print(childPath), ")"]);
  21257. }, "expressions")));
  21258. case "NGEmptyExpression":
  21259. return "";
  21260. case "NGQuotedExpression":
  21261. return concat$4([n.prefix, ":", n.value]);
  21262. case "NGMicrosyntax":
  21263. return concat$4(path$$1.map(function (childPath, index) {
  21264. return concat$4([index === 0 ? "" : isNgForOf(childPath.getValue(), index, n) ? " " : concat$4([";", line$3]), print(childPath)]);
  21265. }, "body"));
  21266. case "NGMicrosyntaxKey":
  21267. return /^[a-z_$][a-z0-9_$]*(-[a-z_$][a-z0-9_$])*$/i.test(n.name) ? n.name : JSON.stringify(n.name);
  21268. case "NGMicrosyntaxExpression":
  21269. return concat$4([path$$1.call(print, "expression"), n.alias === null ? "" : concat$4([" as ", path$$1.call(print, "alias")])]);
  21270. case "NGMicrosyntaxKeyedExpression":
  21271. {
  21272. var index = path$$1.getName();
  21273. var _parentNode2 = path$$1.getParentNode();
  21274. var shouldNotPrintColon = isNgForOf(n, index, _parentNode2) || (index === 1 && (n.key.name === "then" || n.key.name === "else") || index === 2 && n.key.name === "else" && _parentNode2.body[index - 1].type === "NGMicrosyntaxKeyedExpression" && _parentNode2.body[index - 1].key.name === "then") && _parentNode2.body[0].type === "NGMicrosyntaxExpression";
  21275. return concat$4([path$$1.call(print, "key"), shouldNotPrintColon ? " " : ": ", path$$1.call(print, "expression")]);
  21276. }
  21277. case "NGMicrosyntaxLet":
  21278. return concat$4(["let ", path$$1.call(print, "key"), n.value === null ? "" : concat$4([" = ", path$$1.call(print, "value")])]);
  21279. case "NGMicrosyntaxAs":
  21280. return concat$4([path$$1.call(print, "key"), " as ", path$$1.call(print, "alias")]);
  21281. default:
  21282. /* istanbul ignore next */
  21283. throw new Error("unknown type: " + JSON.stringify(n.type));
  21284. }
  21285. }
  21286. function isNgForOf(node, index, parentNode) {
  21287. return node.type === "NGMicrosyntaxKeyedExpression" && node.key.name === "of" && index === 1 && parentNode.body[0].type === "NGMicrosyntaxLet" && parentNode.body[0].value === null;
  21288. }
  21289. /** identify if an angular expression seems to have side effects */
  21290. function hasNgSideEffect(path$$1) {
  21291. return hasNode(path$$1.getValue(), function (node) {
  21292. switch (node.type) {
  21293. case undefined:
  21294. return false;
  21295. case "CallExpression":
  21296. case "OptionalCallExpression":
  21297. case "AssignmentExpression":
  21298. return true;
  21299. }
  21300. });
  21301. }
  21302. function printStatementSequence(path$$1, options, print) {
  21303. var printed = [];
  21304. var bodyNode = path$$1.getNode();
  21305. var isClass = bodyNode.type === "ClassBody";
  21306. path$$1.map(function (stmtPath, i) {
  21307. var stmt = stmtPath.getValue(); // Just in case the AST has been modified to contain falsy
  21308. // "statements," it's safer simply to skip them.
  21309. /* istanbul ignore if */
  21310. if (!stmt) {
  21311. return;
  21312. } // Skip printing EmptyStatement nodes to avoid leaving stray
  21313. // semicolons lying around.
  21314. if (stmt.type === "EmptyStatement") {
  21315. return;
  21316. }
  21317. var stmtPrinted = print(stmtPath);
  21318. var text = options.originalText;
  21319. var parts = []; // in no-semi mode, prepend statement with semicolon if it might break ASI
  21320. // don't prepend the only JSX element in a program with semicolon
  21321. if (!options.semi && !isClass && !isTheOnlyJSXElementInMarkdown(options, stmtPath) && stmtNeedsASIProtection(stmtPath, options)) {
  21322. if (stmt.comments && stmt.comments.some(function (comment) {
  21323. return comment.leading;
  21324. })) {
  21325. parts.push(print(stmtPath, {
  21326. needsSemi: true
  21327. }));
  21328. } else {
  21329. parts.push(";", stmtPrinted);
  21330. }
  21331. } else {
  21332. parts.push(stmtPrinted);
  21333. }
  21334. if (!options.semi && isClass) {
  21335. if (classPropMayCauseASIProblems(stmtPath)) {
  21336. parts.push(";");
  21337. } else if (stmt.type === "ClassProperty") {
  21338. var nextChild = bodyNode.body[i + 1];
  21339. if (classChildNeedsASIProtection(nextChild)) {
  21340. parts.push(";");
  21341. }
  21342. }
  21343. }
  21344. if (isNextLineEmpty$2(text, stmt, options) && !isLastStatement(stmtPath)) {
  21345. parts.push(hardline$3);
  21346. }
  21347. printed.push(concat$4(parts));
  21348. });
  21349. return join$2(hardline$3, printed);
  21350. }
  21351. function printPropertyKey(path$$1, options, print) {
  21352. var node = path$$1.getNode();
  21353. var key = node.key;
  21354. if (key.type === "Identifier" && !node.computed && options.parser === "json") {
  21355. // a -> "a"
  21356. return path$$1.call(function (keyPath) {
  21357. return comments.printComments(keyPath, function () {
  21358. return JSON.stringify(key.name);
  21359. }, options);
  21360. }, "key");
  21361. }
  21362. if (isStringLiteral(key) && isIdentifierName(key.value) && !node.computed && options.parser !== "json" && !(options.parser === "typescript" && node.type === "ClassProperty")) {
  21363. // 'a' -> a
  21364. return path$$1.call(function (keyPath) {
  21365. return comments.printComments(keyPath, function () {
  21366. return key.value;
  21367. }, options);
  21368. }, "key");
  21369. }
  21370. return path$$1.call(print, "key");
  21371. }
  21372. function printMethod(path$$1, options, print) {
  21373. var node = path$$1.getNode();
  21374. var semi = options.semi ? ";" : "";
  21375. var kind = node.kind;
  21376. var parts = [];
  21377. if (node.type === "ObjectMethod" || node.type === "ClassMethod" || node.type === "ClassPrivateMethod") {
  21378. node.value = node;
  21379. }
  21380. if (node.value.async) {
  21381. parts.push("async ");
  21382. }
  21383. if (!kind || kind === "init" || kind === "method" || kind === "constructor") {
  21384. if (node.value.generator) {
  21385. parts.push("*");
  21386. }
  21387. } else {
  21388. assert.ok(kind === "get" || kind === "set");
  21389. parts.push(kind, " ");
  21390. }
  21391. var key = printPropertyKey(path$$1, options, print);
  21392. if (node.computed) {
  21393. key = concat$4(["[", key, "]"]);
  21394. }
  21395. parts.push(key, concat$4(path$$1.call(function (valuePath) {
  21396. return [printFunctionTypeParameters(valuePath, options, print), group$1(concat$4([printFunctionParams(valuePath, print, options), printReturnType(valuePath, print, options)]))];
  21397. }, "value")));
  21398. if (!node.value.body || node.value.body.length === 0) {
  21399. parts.push(semi);
  21400. } else {
  21401. parts.push(" ", path$$1.call(print, "value", "body"));
  21402. }
  21403. return concat$4(parts);
  21404. }
  21405. function couldGroupArg(arg) {
  21406. return arg.type === "ObjectExpression" && (arg.properties.length > 0 || arg.comments) || arg.type === "ArrayExpression" && (arg.elements.length > 0 || arg.comments) || arg.type === "TSTypeAssertion" || arg.type === "TSAsExpression" || arg.type === "FunctionExpression" || arg.type === "ArrowFunctionExpression" && !arg.returnType && (arg.body.type === "BlockStatement" || arg.body.type === "ArrowFunctionExpression" || arg.body.type === "ObjectExpression" || arg.body.type === "ArrayExpression" || arg.body.type === "CallExpression" || arg.body.type === "OptionalCallExpression" || arg.body.type === "ConditionalExpression" || isJSXNode(arg.body));
  21407. }
  21408. function shouldGroupLastArg(args) {
  21409. var lastArg = getLast$4(args);
  21410. var penultimateArg = getPenultimate$1(args);
  21411. return !hasLeadingComment(lastArg) && !hasTrailingComment(lastArg) && couldGroupArg(lastArg) && ( // If the last two arguments are of the same type,
  21412. // disable last element expansion.
  21413. !penultimateArg || penultimateArg.type !== lastArg.type);
  21414. }
  21415. function shouldGroupFirstArg(args) {
  21416. if (args.length !== 2) {
  21417. return false;
  21418. }
  21419. var firstArg = args[0];
  21420. var secondArg = args[1];
  21421. return (!firstArg.comments || !firstArg.comments.length) && (firstArg.type === "FunctionExpression" || firstArg.type === "ArrowFunctionExpression" && firstArg.body.type === "BlockStatement") && secondArg.type !== "FunctionExpression" && secondArg.type !== "ArrowFunctionExpression" && secondArg.type !== "ConditionalExpression" && !couldGroupArg(secondArg);
  21422. }
  21423. function isSimpleFlowType(node) {
  21424. var flowTypeAnnotations = ["AnyTypeAnnotation", "NullLiteralTypeAnnotation", "GenericTypeAnnotation", "ThisTypeAnnotation", "NumberTypeAnnotation", "VoidTypeAnnotation", "EmptyTypeAnnotation", "MixedTypeAnnotation", "BooleanTypeAnnotation", "BooleanLiteralTypeAnnotation", "StringTypeAnnotation"];
  21425. return node && flowTypeAnnotations.indexOf(node.type) !== -1 && !(node.type === "GenericTypeAnnotation" && node.typeParameters);
  21426. }
  21427. var functionCompositionFunctionNames = new Set(["pipe", // RxJS, Ramda
  21428. "pipeP", // Ramda
  21429. "pipeK", // Ramda
  21430. "compose", // Ramda, Redux
  21431. "composeFlipped", // Not from any library, but common in Haskell, so supported
  21432. "composeP", // Ramda
  21433. "composeK", // Ramda
  21434. "flow", // Lodash
  21435. "flowRight", // Lodash
  21436. "connect", // Redux
  21437. "createSelector" // Reselect
  21438. ]);
  21439. var ordinaryMethodNames = new Set(["connect" // GObject, MongoDB
  21440. ]);
  21441. function isFunctionCompositionFunction(node) {
  21442. switch (node.type) {
  21443. case "OptionalMemberExpression":
  21444. case "MemberExpression":
  21445. {
  21446. return isFunctionCompositionFunction(node.property) && !ordinaryMethodNames.has(node.property.name);
  21447. }
  21448. case "Identifier":
  21449. {
  21450. return functionCompositionFunctionNames.has(node.name);
  21451. }
  21452. case "StringLiteral":
  21453. case "Literal":
  21454. {
  21455. return functionCompositionFunctionNames.has(node.value);
  21456. }
  21457. }
  21458. }
  21459. function printArgumentsList(path$$1, options, print) {
  21460. var node = path$$1.getValue();
  21461. var args = node.arguments;
  21462. if (args.length === 0) {
  21463. return concat$4(["(", comments.printDanglingComments(path$$1, options,
  21464. /* sameIndent */
  21465. true), ")"]);
  21466. } // useEffect(() => { ... }, [foo, bar, baz])
  21467. if (args.length === 2 && args[0].type === "ArrowFunctionExpression" && args[0].params.length === 0 && args[0].body.type === "BlockStatement" && args[1].type === "ArrayExpression" && !args.find(function (arg) {
  21468. return arg.leadingComments || arg.trailingComments;
  21469. })) {
  21470. return concat$4(["(", path$$1.call(print, "arguments", 0), ", ", path$$1.call(print, "arguments", 1), ")"]);
  21471. }
  21472. var anyArgEmptyLine = false;
  21473. var hasEmptyLineFollowingFirstArg = false;
  21474. var lastArgIndex = args.length - 1;
  21475. var printedArguments = path$$1.map(function (argPath, index) {
  21476. var arg = argPath.getNode();
  21477. var parts = [print(argPath)];
  21478. if (index === lastArgIndex) {// do nothing
  21479. } else if (isNextLineEmpty$2(options.originalText, arg, options)) {
  21480. if (index === 0) {
  21481. hasEmptyLineFollowingFirstArg = true;
  21482. }
  21483. anyArgEmptyLine = true;
  21484. parts.push(",", hardline$3, hardline$3);
  21485. } else {
  21486. parts.push(",", line$3);
  21487. }
  21488. return concat$4(parts);
  21489. }, "arguments");
  21490. var maybeTrailingComma = shouldPrintComma(options, "all") ? "," : "";
  21491. function allArgsBrokenOut() {
  21492. return group$1(concat$4(["(", indent$2(concat$4([line$3, concat$4(printedArguments)])), maybeTrailingComma, line$3, ")"]), {
  21493. shouldBreak: true
  21494. });
  21495. } // We want to get
  21496. // pipe(
  21497. // x => x + 1,
  21498. // x => x - 1
  21499. // )
  21500. // here, but not
  21501. // process.stdout.pipe(socket)
  21502. if (isFunctionCompositionFunction(node.callee) && args.length > 1) {
  21503. return allArgsBrokenOut();
  21504. }
  21505. var shouldGroupFirst = shouldGroupFirstArg(args);
  21506. var shouldGroupLast = shouldGroupLastArg(args);
  21507. if (shouldGroupFirst || shouldGroupLast) {
  21508. var shouldBreak = (shouldGroupFirst ? printedArguments.slice(1).some(willBreak$1) : printedArguments.slice(0, -1).some(willBreak$1)) || anyArgEmptyLine; // We want to print the last argument with a special flag
  21509. var printedExpanded;
  21510. var i = 0;
  21511. path$$1.each(function (argPath) {
  21512. if (shouldGroupFirst && i === 0) {
  21513. printedExpanded = [concat$4([argPath.call(function (p) {
  21514. return print(p, {
  21515. expandFirstArg: true
  21516. });
  21517. }), printedArguments.length > 1 ? "," : "", hasEmptyLineFollowingFirstArg ? hardline$3 : line$3, hasEmptyLineFollowingFirstArg ? hardline$3 : ""])].concat(printedArguments.slice(1));
  21518. }
  21519. if (shouldGroupLast && i === args.length - 1) {
  21520. printedExpanded = printedArguments.slice(0, -1).concat(argPath.call(function (p) {
  21521. return print(p, {
  21522. expandLastArg: true
  21523. });
  21524. }));
  21525. }
  21526. i++;
  21527. }, "arguments");
  21528. var somePrintedArgumentsWillBreak = printedArguments.some(willBreak$1);
  21529. return concat$4([somePrintedArgumentsWillBreak ? breakParent$2 : "", conditionalGroup$1([concat$4([ifBreak$1(indent$2(concat$4(["(", softline$1, concat$4(printedExpanded)])), concat$4(["(", concat$4(printedExpanded)])), somePrintedArgumentsWillBreak ? concat$4([ifBreak$1(maybeTrailingComma), softline$1]) : "", ")"]), shouldGroupFirst ? concat$4(["(", group$1(printedExpanded[0], {
  21530. shouldBreak: true
  21531. }), concat$4(printedExpanded.slice(1)), ")"]) : concat$4(["(", concat$4(printedArguments.slice(0, -1)), group$1(getLast$4(printedExpanded), {
  21532. shouldBreak: true
  21533. }), ")"]), allArgsBrokenOut()], {
  21534. shouldBreak
  21535. })]);
  21536. }
  21537. return group$1(concat$4(["(", indent$2(concat$4([softline$1, concat$4(printedArguments)])), ifBreak$1(shouldPrintComma(options, "all") ? "," : ""), softline$1, ")"]), {
  21538. shouldBreak: printedArguments.some(willBreak$1) || anyArgEmptyLine
  21539. });
  21540. }
  21541. function printTypeAnnotation(path$$1, options, print) {
  21542. var node = path$$1.getValue();
  21543. if (!node.typeAnnotation) {
  21544. return "";
  21545. }
  21546. var parentNode = path$$1.getParentNode();
  21547. var isDefinite = node.definite || parentNode && parentNode.type === "VariableDeclarator" && parentNode.definite;
  21548. var isFunctionDeclarationIdentifier = parentNode.type === "DeclareFunction" && parentNode.id === node;
  21549. if (isFlowAnnotationComment(options.originalText, node.typeAnnotation, options)) {
  21550. return concat$4([" /*: ", path$$1.call(print, "typeAnnotation"), " */"]);
  21551. }
  21552. return concat$4([isFunctionDeclarationIdentifier ? "" : isDefinite ? "!: " : ": ", path$$1.call(print, "typeAnnotation")]);
  21553. }
  21554. function printFunctionTypeParameters(path$$1, options, print) {
  21555. var fun = path$$1.getValue();
  21556. if (fun.typeArguments) {
  21557. return path$$1.call(print, "typeArguments");
  21558. }
  21559. if (fun.typeParameters) {
  21560. return path$$1.call(print, "typeParameters");
  21561. }
  21562. return "";
  21563. }
  21564. function printFunctionParams(path$$1, print, options, expandArg, printTypeParams) {
  21565. var fun = path$$1.getValue();
  21566. var paramsField = fun.parameters ? "parameters" : "params";
  21567. var typeParams = printTypeParams ? printFunctionTypeParameters(path$$1, options, print) : "";
  21568. var printed = [];
  21569. if (fun[paramsField]) {
  21570. printed = path$$1.map(print, paramsField);
  21571. }
  21572. if (fun.rest) {
  21573. printed.push(concat$4(["...", path$$1.call(print, "rest")]));
  21574. }
  21575. if (printed.length === 0) {
  21576. return concat$4([typeParams, "(", comments.printDanglingComments(path$$1, options,
  21577. /* sameIndent */
  21578. true, function (comment) {
  21579. return getNextNonSpaceNonCommentCharacter$1(options.originalText, comment, options.locEnd) === ")";
  21580. }), ")"]);
  21581. }
  21582. var lastParam = getLast$4(fun[paramsField]); // If the parent is a call with the first/last argument expansion and this is the
  21583. // params of the first/last argument, we dont want the arguments to break and instead
  21584. // want the whole expression to be on a new line.
  21585. //
  21586. // Good: Bad:
  21587. // verylongcall( verylongcall((
  21588. // (a, b) => { a,
  21589. // } b,
  21590. // }) ) => {
  21591. // })
  21592. if (expandArg && !(fun[paramsField] && fun[paramsField].some(function (n) {
  21593. return n.comments;
  21594. }))) {
  21595. return group$1(concat$4([removeLines$1(typeParams), "(", join$2(", ", printed.map(removeLines$1)), ")"]));
  21596. } // Single object destructuring should hug
  21597. //
  21598. // function({
  21599. // a,
  21600. // b,
  21601. // c
  21602. // }) {}
  21603. if (shouldHugArguments(fun)) {
  21604. return concat$4([typeParams, "(", join$2(", ", printed), ")"]);
  21605. }
  21606. var parent = path$$1.getParentNode(); // don't break in specs, eg; `it("should maintain parens around done even when long", (done) => {})`
  21607. if (isTestCall(parent)) {
  21608. return concat$4([typeParams, "(", join$2(", ", printed), ")"]);
  21609. }
  21610. var isFlowShorthandWithOneArg = (isObjectTypePropertyAFunction(parent, options) || isTypeAnnotationAFunction(parent, options) || parent.type === "TypeAlias" || parent.type === "UnionTypeAnnotation" || parent.type === "TSUnionType" || parent.type === "IntersectionTypeAnnotation" || parent.type === "FunctionTypeAnnotation" && parent.returnType === fun) && fun[paramsField].length === 1 && fun[paramsField][0].name === null && fun[paramsField][0].typeAnnotation && fun.typeParameters === null && isSimpleFlowType(fun[paramsField][0].typeAnnotation) && !fun.rest;
  21611. if (isFlowShorthandWithOneArg) {
  21612. if (options.arrowParens === "always") {
  21613. return concat$4(["(", concat$4(printed), ")"]);
  21614. }
  21615. return concat$4(printed);
  21616. }
  21617. var canHaveTrailingComma = !(lastParam && lastParam.type === "RestElement") && !fun.rest;
  21618. return concat$4([typeParams, "(", indent$2(concat$4([softline$1, join$2(concat$4([",", line$3]), printed)])), ifBreak$1(canHaveTrailingComma && shouldPrintComma(options, "all") ? "," : ""), softline$1, ")"]);
  21619. }
  21620. function shouldPrintParamsWithoutParens(path$$1, options) {
  21621. if (options.arrowParens === "always") {
  21622. return false;
  21623. }
  21624. if (options.arrowParens === "avoid") {
  21625. var node = path$$1.getValue();
  21626. return canPrintParamsWithoutParens(node);
  21627. } // Fallback default; should be unreachable
  21628. return false;
  21629. }
  21630. function canPrintParamsWithoutParens(node) {
  21631. return node.params.length === 1 && !node.rest && !node.typeParameters && !hasDanglingComments(node) && node.params[0].type === "Identifier" && !node.params[0].typeAnnotation && !node.params[0].comments && !node.params[0].optional && !node.predicate && !node.returnType;
  21632. }
  21633. function printFunctionDeclaration(path$$1, print, options) {
  21634. var n = path$$1.getValue();
  21635. var parts = [];
  21636. if (n.async) {
  21637. parts.push("async ");
  21638. }
  21639. parts.push("function");
  21640. if (n.generator) {
  21641. parts.push("*");
  21642. }
  21643. if (n.id) {
  21644. parts.push(" ", path$$1.call(print, "id"));
  21645. }
  21646. parts.push(printFunctionTypeParameters(path$$1, options, print), group$1(concat$4([printFunctionParams(path$$1, print, options), printReturnType(path$$1, print, options)])), n.body ? " " : "", path$$1.call(print, "body"));
  21647. return concat$4(parts);
  21648. }
  21649. function printObjectMethod(path$$1, options, print) {
  21650. var objMethod = path$$1.getValue();
  21651. var parts = [];
  21652. if (objMethod.async) {
  21653. parts.push("async ");
  21654. }
  21655. if (objMethod.generator) {
  21656. parts.push("*");
  21657. }
  21658. if (objMethod.method || objMethod.kind === "get" || objMethod.kind === "set") {
  21659. return printMethod(path$$1, options, print);
  21660. }
  21661. var key = printPropertyKey(path$$1, options, print);
  21662. if (objMethod.computed) {
  21663. parts.push("[", key, "]");
  21664. } else {
  21665. parts.push(key);
  21666. }
  21667. parts.push(printFunctionTypeParameters(path$$1, options, print), group$1(concat$4([printFunctionParams(path$$1, print, options), printReturnType(path$$1, print, options)])), " ", path$$1.call(print, "body"));
  21668. return concat$4(parts);
  21669. }
  21670. function printReturnType(path$$1, print, options) {
  21671. var n = path$$1.getValue();
  21672. var returnType = path$$1.call(print, "returnType");
  21673. if (n.returnType && isFlowAnnotationComment(options.originalText, n.returnType, options)) {
  21674. return concat$4([" /*: ", returnType, " */"]);
  21675. }
  21676. var parts = [returnType]; // prepend colon to TypeScript type annotation
  21677. if (n.returnType && n.returnType.typeAnnotation) {
  21678. parts.unshift(": ");
  21679. }
  21680. if (n.predicate) {
  21681. // The return type will already add the colon, but otherwise we
  21682. // need to do it ourselves
  21683. parts.push(n.returnType ? " " : ": ", path$$1.call(print, "predicate"));
  21684. }
  21685. return concat$4(parts);
  21686. }
  21687. function printExportDeclaration(path$$1, options, print) {
  21688. var decl = path$$1.getValue();
  21689. var semi = options.semi ? ";" : "";
  21690. var parts = ["export "];
  21691. var isDefault = decl["default"] || decl.type === "ExportDefaultDeclaration";
  21692. if (isDefault) {
  21693. parts.push("default ");
  21694. }
  21695. parts.push(comments.printDanglingComments(path$$1, options,
  21696. /* sameIndent */
  21697. true));
  21698. if (needsHardlineAfterDanglingComment(decl)) {
  21699. parts.push(hardline$3);
  21700. }
  21701. if (decl.declaration) {
  21702. parts.push(path$$1.call(print, "declaration"));
  21703. if (isDefault && decl.declaration.type !== "ClassDeclaration" && decl.declaration.type !== "FunctionDeclaration" && decl.declaration.type !== "TSAbstractClassDeclaration" && decl.declaration.type !== "TSInterfaceDeclaration" && decl.declaration.type !== "DeclareClass" && decl.declaration.type !== "DeclareFunction" && decl.declaration.type !== "TSDeclareFunction") {
  21704. parts.push(semi);
  21705. }
  21706. } else {
  21707. if (decl.specifiers && decl.specifiers.length > 0) {
  21708. var specifiers = [];
  21709. var defaultSpecifiers = [];
  21710. var namespaceSpecifiers = [];
  21711. path$$1.each(function (specifierPath) {
  21712. var specifierType = path$$1.getValue().type;
  21713. if (specifierType === "ExportSpecifier") {
  21714. specifiers.push(print(specifierPath));
  21715. } else if (specifierType === "ExportDefaultSpecifier") {
  21716. defaultSpecifiers.push(print(specifierPath));
  21717. } else if (specifierType === "ExportNamespaceSpecifier") {
  21718. namespaceSpecifiers.push(concat$4(["* as ", print(specifierPath)]));
  21719. }
  21720. }, "specifiers");
  21721. var isNamespaceFollowed = namespaceSpecifiers.length !== 0 && specifiers.length !== 0;
  21722. var isDefaultFollowed = defaultSpecifiers.length !== 0 && (namespaceSpecifiers.length !== 0 || specifiers.length !== 0);
  21723. parts.push(decl.exportKind === "type" ? "type " : "", concat$4(defaultSpecifiers), concat$4([isDefaultFollowed ? ", " : ""]), concat$4(namespaceSpecifiers), concat$4([isNamespaceFollowed ? ", " : ""]), specifiers.length !== 0 ? group$1(concat$4(["{", indent$2(concat$4([options.bracketSpacing ? line$3 : softline$1, join$2(concat$4([",", line$3]), specifiers)])), ifBreak$1(shouldPrintComma(options) ? "," : ""), options.bracketSpacing ? line$3 : softline$1, "}"])) : "");
  21724. } else {
  21725. parts.push("{}");
  21726. }
  21727. if (decl.source) {
  21728. parts.push(" from ", path$$1.call(print, "source"));
  21729. }
  21730. parts.push(semi);
  21731. }
  21732. return concat$4(parts);
  21733. }
  21734. function printFlowDeclaration(path$$1, parts) {
  21735. var parentExportDecl = getParentExportDeclaration$1(path$$1);
  21736. if (parentExportDecl) {
  21737. assert.strictEqual(parentExportDecl.type, "DeclareExportDeclaration");
  21738. } else {
  21739. // If the parent node has type DeclareExportDeclaration, then it
  21740. // will be responsible for printing the "declare" token. Otherwise
  21741. // it needs to be printed with this non-exported declaration node.
  21742. parts.unshift("declare ");
  21743. }
  21744. return concat$4(parts);
  21745. }
  21746. function getFlowVariance(path$$1) {
  21747. if (!path$$1.variance) {
  21748. return null;
  21749. } // Babel 7.0 currently uses variance node type, and flow should
  21750. // follow suit soon:
  21751. // https://github.com/babel/babel/issues/4722
  21752. var variance = path$$1.variance.kind || path$$1.variance;
  21753. switch (variance) {
  21754. case "plus":
  21755. return "+";
  21756. case "minus":
  21757. return "-";
  21758. default:
  21759. /* istanbul ignore next */
  21760. return variance;
  21761. }
  21762. }
  21763. function printTypeScriptModifiers(path$$1, options, print) {
  21764. var n = path$$1.getValue();
  21765. if (!n.modifiers || !n.modifiers.length) {
  21766. return "";
  21767. }
  21768. return concat$4([join$2(" ", path$$1.map(print, "modifiers")), " "]);
  21769. }
  21770. function printTypeParameters(path$$1, options, print, paramsKey) {
  21771. var n = path$$1.getValue();
  21772. if (!n[paramsKey]) {
  21773. return "";
  21774. } // for TypeParameterDeclaration typeParameters is a single node
  21775. if (!Array.isArray(n[paramsKey])) {
  21776. return path$$1.call(print, paramsKey);
  21777. }
  21778. var grandparent = path$$1.getNode(2);
  21779. var isParameterInTestCall = grandparent != null && isTestCall(grandparent);
  21780. var shouldInline = isParameterInTestCall || n[paramsKey].length === 0 || n[paramsKey].length === 1 && (shouldHugType(n[paramsKey][0]) || n[paramsKey][0].type === "GenericTypeAnnotation" && shouldHugType(n[paramsKey][0].id) || n[paramsKey][0].type === "TSTypeReference" && shouldHugType(n[paramsKey][0].typeName) || n[paramsKey][0].type === "NullableTypeAnnotation");
  21781. if (shouldInline) {
  21782. return concat$4(["<", join$2(", ", path$$1.map(print, paramsKey)), ">"]);
  21783. }
  21784. return group$1(concat$4(["<", indent$2(concat$4([softline$1, join$2(concat$4([",", line$3]), path$$1.map(print, paramsKey))])), ifBreak$1(options.parser !== "typescript" && shouldPrintComma(options, "all") ? "," : ""), softline$1, ">"]));
  21785. }
  21786. function printClass(path$$1, options, print) {
  21787. var n = path$$1.getValue();
  21788. var parts = [];
  21789. if (n.type === "TSAbstractClassDeclaration") {
  21790. parts.push("abstract ");
  21791. }
  21792. parts.push("class");
  21793. if (n.id) {
  21794. parts.push(" ", path$$1.call(print, "id"));
  21795. }
  21796. parts.push(path$$1.call(print, "typeParameters"));
  21797. var partsGroup = [];
  21798. if (n.superClass) {
  21799. var printed = concat$4(["extends ", path$$1.call(print, "superClass"), path$$1.call(print, "superTypeParameters")]); // Keep old behaviour of extends in same line
  21800. // If there is only on extends and there are not comments
  21801. if ((!n.implements || n.implements.length === 0) && (!n.superClass.comments || n.superClass.comments.length === 0)) {
  21802. parts.push(concat$4([" ", path$$1.call(function (superClass) {
  21803. return comments.printComments(superClass, function () {
  21804. return printed;
  21805. }, options);
  21806. }, "superClass")]));
  21807. } else {
  21808. partsGroup.push(group$1(concat$4([line$3, path$$1.call(function (superClass) {
  21809. return comments.printComments(superClass, function () {
  21810. return printed;
  21811. }, options);
  21812. }, "superClass")])));
  21813. }
  21814. } else if (n.extends && n.extends.length > 0) {
  21815. parts.push(" extends ", join$2(", ", path$$1.map(print, "extends")));
  21816. }
  21817. if (n["mixins"] && n["mixins"].length > 0) {
  21818. partsGroup.push(line$3, "mixins ", group$1(indent$2(join$2(concat$4([",", line$3]), path$$1.map(print, "mixins")))));
  21819. }
  21820. if (n["implements"] && n["implements"].length > 0) {
  21821. partsGroup.push(line$3, "implements", group$1(indent$2(concat$4([line$3, join$2(concat$4([",", line$3]), path$$1.map(print, "implements"))]))));
  21822. }
  21823. if (partsGroup.length > 0) {
  21824. parts.push(group$1(indent$2(concat$4(partsGroup))));
  21825. }
  21826. if (n.body && n.body.comments && hasLeadingOwnLineComment(options.originalText, n.body, options)) {
  21827. parts.push(hardline$3);
  21828. } else {
  21829. parts.push(" ");
  21830. }
  21831. parts.push(path$$1.call(print, "body"));
  21832. return parts;
  21833. }
  21834. function printOptionalToken(path$$1) {
  21835. var node = path$$1.getValue();
  21836. if (!node.optional) {
  21837. return "";
  21838. }
  21839. if (node.type === "OptionalCallExpression" || node.type === "OptionalMemberExpression" && node.computed) {
  21840. return "?.";
  21841. }
  21842. return "?";
  21843. }
  21844. function printMemberLookup(path$$1, options, print) {
  21845. var property = path$$1.call(print, "property");
  21846. var n = path$$1.getValue();
  21847. var optional = printOptionalToken(path$$1);
  21848. if (!n.computed) {
  21849. return concat$4([optional, ".", property]);
  21850. }
  21851. if (!n.property || isNumericLiteral(n.property)) {
  21852. return concat$4([optional, "[", property, "]"]);
  21853. }
  21854. return group$1(concat$4([optional, "[", indent$2(concat$4([softline$1, property])), softline$1, "]"]));
  21855. }
  21856. function printBindExpressionCallee(path$$1, options, print) {
  21857. return concat$4(["::", path$$1.call(print, "callee")]);
  21858. } // We detect calls on member expressions specially to format a
  21859. // common pattern better. The pattern we are looking for is this:
  21860. //
  21861. // arr
  21862. // .map(x => x + 1)
  21863. // .filter(x => x > 10)
  21864. // .some(x => x % 2)
  21865. //
  21866. // The way it is structured in the AST is via a nested sequence of
  21867. // MemberExpression and CallExpression. We need to traverse the AST
  21868. // and make groups out of it to print it in the desired way.
  21869. function printMemberChain(path$$1, options, print) {
  21870. // The first phase is to linearize the AST by traversing it down.
  21871. //
  21872. // a().b()
  21873. // has the following AST structure:
  21874. // CallExpression(MemberExpression(CallExpression(Identifier)))
  21875. // and we transform it into
  21876. // [Identifier, CallExpression, MemberExpression, CallExpression]
  21877. var printedNodes = []; // Here we try to retain one typed empty line after each call expression or
  21878. // the first group whether it is in parentheses or not
  21879. function shouldInsertEmptyLineAfter(node) {
  21880. var originalText = options.originalText;
  21881. var nextCharIndex = getNextNonSpaceNonCommentCharacterIndex$2(originalText, node, options);
  21882. var nextChar = originalText.charAt(nextCharIndex); // if it is cut off by a parenthesis, we only account for one typed empty
  21883. // line after that parenthesis
  21884. if (nextChar == ")") {
  21885. return isNextLineEmptyAfterIndex$1(originalText, nextCharIndex + 1, options);
  21886. }
  21887. return isNextLineEmpty$2(originalText, node, options);
  21888. }
  21889. function rec(path$$1) {
  21890. var node = path$$1.getValue();
  21891. if ((node.type === "CallExpression" || node.type === "OptionalCallExpression") && (isMemberish(node.callee) || node.callee.type === "CallExpression" || node.callee.type === "OptionalCallExpression")) {
  21892. printedNodes.unshift({
  21893. node: node,
  21894. printed: concat$4([comments.printComments(path$$1, function () {
  21895. return concat$4([printOptionalToken(path$$1), printFunctionTypeParameters(path$$1, options, print), printArgumentsList(path$$1, options, print)]);
  21896. }, options), shouldInsertEmptyLineAfter(node) ? hardline$3 : ""])
  21897. });
  21898. path$$1.call(function (callee) {
  21899. return rec(callee);
  21900. }, "callee");
  21901. } else if (isMemberish(node)) {
  21902. printedNodes.unshift({
  21903. node: node,
  21904. needsParens: needsParens_1(path$$1, options),
  21905. printed: comments.printComments(path$$1, function () {
  21906. return node.type === "OptionalMemberExpression" || node.type === "MemberExpression" ? printMemberLookup(path$$1, options, print) : printBindExpressionCallee(path$$1, options, print);
  21907. }, options)
  21908. });
  21909. path$$1.call(function (object) {
  21910. return rec(object);
  21911. }, "object");
  21912. } else if (node.type === "TSNonNullExpression") {
  21913. printedNodes.unshift({
  21914. node: node,
  21915. printed: comments.printComments(path$$1, function () {
  21916. return "!";
  21917. }, options)
  21918. });
  21919. path$$1.call(function (expression) {
  21920. return rec(expression);
  21921. }, "expression");
  21922. } else {
  21923. printedNodes.unshift({
  21924. node: node,
  21925. printed: path$$1.call(print)
  21926. });
  21927. }
  21928. } // Note: the comments of the root node have already been printed, so we
  21929. // need to extract this first call without printing them as they would
  21930. // if handled inside of the recursive call.
  21931. var node = path$$1.getValue();
  21932. printedNodes.unshift({
  21933. node,
  21934. printed: concat$4([printOptionalToken(path$$1), printFunctionTypeParameters(path$$1, options, print), printArgumentsList(path$$1, options, print)])
  21935. });
  21936. path$$1.call(function (callee) {
  21937. return rec(callee);
  21938. }, "callee"); // Once we have a linear list of printed nodes, we want to create groups out
  21939. // of it.
  21940. //
  21941. // a().b.c().d().e
  21942. // will be grouped as
  21943. // [
  21944. // [Identifier, CallExpression],
  21945. // [MemberExpression, MemberExpression, CallExpression],
  21946. // [MemberExpression, CallExpression],
  21947. // [MemberExpression],
  21948. // ]
  21949. // so that we can print it as
  21950. // a()
  21951. // .b.c()
  21952. // .d()
  21953. // .e
  21954. // The first group is the first node followed by
  21955. // - as many CallExpression as possible
  21956. // < fn()()() >.something()
  21957. // - as many array acessors as possible
  21958. // < fn()[0][1][2] >.something()
  21959. // - then, as many MemberExpression as possible but the last one
  21960. // < this.items >.something()
  21961. var groups = [];
  21962. var currentGroup = [printedNodes[0]];
  21963. var i = 1;
  21964. for (; i < printedNodes.length; ++i) {
  21965. if (printedNodes[i].node.type === "TSNonNullExpression" || printedNodes[i].node.type === "OptionalCallExpression" || printedNodes[i].node.type === "CallExpression" || (printedNodes[i].node.type === "MemberExpression" || printedNodes[i].node.type === "OptionalMemberExpression") && printedNodes[i].node.computed && isNumericLiteral(printedNodes[i].node.property)) {
  21966. currentGroup.push(printedNodes[i]);
  21967. } else {
  21968. break;
  21969. }
  21970. }
  21971. if (printedNodes[0].node.type !== "CallExpression" && printedNodes[0].node.type !== "OptionalCallExpression") {
  21972. for (; i + 1 < printedNodes.length; ++i) {
  21973. if (isMemberish(printedNodes[i].node) && isMemberish(printedNodes[i + 1].node)) {
  21974. currentGroup.push(printedNodes[i]);
  21975. } else {
  21976. break;
  21977. }
  21978. }
  21979. }
  21980. groups.push(currentGroup);
  21981. currentGroup = []; // Then, each following group is a sequence of MemberExpression followed by
  21982. // a sequence of CallExpression. To compute it, we keep adding things to the
  21983. // group until we has seen a CallExpression in the past and reach a
  21984. // MemberExpression
  21985. var hasSeenCallExpression = false;
  21986. for (; i < printedNodes.length; ++i) {
  21987. if (hasSeenCallExpression && isMemberish(printedNodes[i].node)) {
  21988. // [0] should be appended at the end of the group instead of the
  21989. // beginning of the next one
  21990. if (printedNodes[i].node.computed && isNumericLiteral(printedNodes[i].node.property)) {
  21991. currentGroup.push(printedNodes[i]);
  21992. continue;
  21993. }
  21994. groups.push(currentGroup);
  21995. currentGroup = [];
  21996. hasSeenCallExpression = false;
  21997. }
  21998. if (printedNodes[i].node.type === "CallExpression" || printedNodes[i].node.type === "OptionalCallExpression") {
  21999. hasSeenCallExpression = true;
  22000. }
  22001. currentGroup.push(printedNodes[i]);
  22002. if (printedNodes[i].node.comments && printedNodes[i].node.comments.some(function (comment) {
  22003. return comment.trailing;
  22004. })) {
  22005. groups.push(currentGroup);
  22006. currentGroup = [];
  22007. hasSeenCallExpression = false;
  22008. }
  22009. }
  22010. if (currentGroup.length > 0) {
  22011. groups.push(currentGroup);
  22012. } // There are cases like Object.keys(), Observable.of(), _.values() where
  22013. // they are the subject of all the chained calls and therefore should
  22014. // be kept on the same line:
  22015. //
  22016. // Object.keys(items)
  22017. // .filter(x => x)
  22018. // .map(x => x)
  22019. //
  22020. // In order to detect those cases, we use an heuristic: if the first
  22021. // node is an identifier with the name starting with a capital
  22022. // letter or just a sequence of _$. The rationale is that they are
  22023. // likely to be factories.
  22024. function isFactory(name) {
  22025. return /^[A-Z]|^[_$]+$/.test(name);
  22026. } // In case the Identifier is shorter than tab width, we can keep the
  22027. // first call in a single line, if it's an ExpressionStatement.
  22028. //
  22029. // d3.scaleLinear()
  22030. // .domain([0, 100])
  22031. // .range([0, width]);
  22032. //
  22033. function isShort(name) {
  22034. return name.length <= options.tabWidth;
  22035. }
  22036. function shouldNotWrap(groups) {
  22037. var parent = path$$1.getParentNode();
  22038. var isExpression = parent && parent.type === "ExpressionStatement";
  22039. var hasComputed = groups[1].length && groups[1][0].node.computed;
  22040. if (groups[0].length === 1) {
  22041. var firstNode = groups[0][0].node;
  22042. return firstNode.type === "ThisExpression" || firstNode.type === "Identifier" && (isFactory(firstNode.name) || isExpression && isShort(firstNode.name) || hasComputed);
  22043. }
  22044. var lastNode = getLast$4(groups[0]).node;
  22045. return (lastNode.type === "MemberExpression" || lastNode.type === "OptionalMemberExpression") && lastNode.property.type === "Identifier" && (isFactory(lastNode.property.name) || hasComputed);
  22046. }
  22047. var shouldMerge = groups.length >= 2 && !groups[1][0].node.comments && shouldNotWrap(groups);
  22048. function printGroup(printedGroup) {
  22049. var result = [];
  22050. for (var _i3 = 0; _i3 < printedGroup.length; _i3++) {
  22051. // Checks if the next node (i.e. the parent node) needs parens
  22052. // and print accordingly
  22053. if (printedGroup[_i3 + 1] && printedGroup[_i3 + 1].needsParens) {
  22054. result.push("(", printedGroup[_i3].printed, printedGroup[_i3 + 1].printed, ")");
  22055. _i3++;
  22056. } else {
  22057. result.push(printedGroup[_i3].printed);
  22058. }
  22059. }
  22060. return concat$4(result);
  22061. }
  22062. function printIndentedGroup(groups) {
  22063. if (groups.length === 0) {
  22064. return "";
  22065. }
  22066. return indent$2(group$1(concat$4([hardline$3, join$2(hardline$3, groups.map(printGroup))])));
  22067. }
  22068. var printedGroups = groups.map(printGroup);
  22069. var oneLine = concat$4(printedGroups);
  22070. var cutoff = shouldMerge ? 3 : 2;
  22071. var flatGroups = groups.slice(0, cutoff).reduce(function (res, group) {
  22072. return res.concat(group);
  22073. }, []);
  22074. var hasComment = flatGroups.slice(1, -1).some(function (node) {
  22075. return hasLeadingComment(node.node);
  22076. }) || flatGroups.slice(0, -1).some(function (node) {
  22077. return hasTrailingComment(node.node);
  22078. }) || groups[cutoff] && hasLeadingComment(groups[cutoff][0].node); // If we only have a single `.`, we shouldn't do anything fancy and just
  22079. // render everything concatenated together.
  22080. if (groups.length <= cutoff && !hasComment) {
  22081. return group$1(oneLine);
  22082. } // Find out the last node in the first group and check if it has an
  22083. // empty line after
  22084. var lastNodeBeforeIndent = getLast$4(shouldMerge ? groups.slice(1, 2)[0] : groups[0]).node;
  22085. var shouldHaveEmptyLineBeforeIndent = lastNodeBeforeIndent.type !== "CallExpression" && lastNodeBeforeIndent.type !== "OptionalCallExpression" && shouldInsertEmptyLineAfter(lastNodeBeforeIndent);
  22086. var expanded = concat$4([printGroup(groups[0]), shouldMerge ? concat$4(groups.slice(1, 2).map(printGroup)) : "", shouldHaveEmptyLineBeforeIndent ? hardline$3 : "", printIndentedGroup(groups.slice(shouldMerge ? 2 : 1))]);
  22087. var callExpressions = printedNodes.map(function (_ref) {
  22088. var node = _ref.node;
  22089. return node;
  22090. }).filter(isCallOrOptionalCallExpression); // We don't want to print in one line if there's:
  22091. // * A comment.
  22092. // * 3 or more chained calls.
  22093. // * Any group but the last one has a hard line.
  22094. // If the last group is a function it's okay to inline if it fits.
  22095. if (hasComment || callExpressions.length >= 3 || printedGroups.slice(0, -1).some(willBreak$1) ||
  22096. /**
  22097. * scopes.filter(scope => scope.value !== '').map((scope, i) => {
  22098. * // multi line content
  22099. * })
  22100. */
  22101. function (lastGroupDoc, lastGroupNode) {
  22102. return isCallOrOptionalCallExpression(lastGroupNode) && willBreak$1(lastGroupDoc);
  22103. }(getLast$4(printedGroups), getLast$4(getLast$4(groups)).node) && callExpressions.slice(0, -1).some(function (n) {
  22104. return n.arguments.some(isFunctionOrArrowExpression);
  22105. })) {
  22106. return group$1(expanded);
  22107. }
  22108. return concat$4([// We only need to check `oneLine` because if `expanded` is chosen
  22109. // that means that the parent group has already been broken
  22110. // naturally
  22111. willBreak$1(oneLine) || shouldHaveEmptyLineBeforeIndent ? breakParent$2 : "", conditionalGroup$1([oneLine, expanded])]);
  22112. }
  22113. function isCallOrOptionalCallExpression(node) {
  22114. return node.type === "CallExpression" || node.type === "OptionalCallExpression";
  22115. }
  22116. function isJSXNode(node) {
  22117. return node.type === "JSXElement" || node.type === "JSXFragment";
  22118. }
  22119. function isEmptyJSXElement(node) {
  22120. if (node.children.length === 0) {
  22121. return true;
  22122. }
  22123. if (node.children.length > 1) {
  22124. return false;
  22125. } // if there is one text child and does not contain any meaningful text
  22126. // we can treat the element as empty.
  22127. var child = node.children[0];
  22128. return isLiteral(child) && !isMeaningfulJSXText(child);
  22129. } // Only space, newline, carriage return, and tab are treated as whitespace
  22130. // inside JSX.
  22131. var jsxWhitespaceChars = " \n\r\t";
  22132. var containsNonJsxWhitespaceRegex = new RegExp("[^" + jsxWhitespaceChars + "]");
  22133. var matchJsxWhitespaceRegex = new RegExp("([" + jsxWhitespaceChars + "]+)"); // Meaningful if it contains non-whitespace characters,
  22134. // or it contains whitespace without a new line.
  22135. function isMeaningfulJSXText(node) {
  22136. return isLiteral(node) && (containsNonJsxWhitespaceRegex.test(rawText(node)) || !/\n/.test(rawText(node)));
  22137. }
  22138. function conditionalExpressionChainContainsJSX(node) {
  22139. return Boolean(getConditionalChainContents(node).find(isJSXNode));
  22140. } // If we have nested conditional expressions, we want to print them in JSX mode
  22141. // if there's at least one JSXElement somewhere in the tree.
  22142. //
  22143. // A conditional expression chain like this should be printed in normal mode,
  22144. // because there aren't JSXElements anywhere in it:
  22145. //
  22146. // isA ? "A" : isB ? "B" : isC ? "C" : "Unknown";
  22147. //
  22148. // But a conditional expression chain like this should be printed in JSX mode,
  22149. // because there is a JSXElement in the last ConditionalExpression:
  22150. //
  22151. // isA ? "A" : isB ? "B" : isC ? "C" : <span className="warning">Unknown</span>;
  22152. //
  22153. // This type of ConditionalExpression chain is structured like this in the AST:
  22154. //
  22155. // ConditionalExpression {
  22156. // test: ...,
  22157. // consequent: ...,
  22158. // alternate: ConditionalExpression {
  22159. // test: ...,
  22160. // consequent: ...,
  22161. // alternate: ConditionalExpression {
  22162. // test: ...,
  22163. // consequent: ...,
  22164. // alternate: ...,
  22165. // }
  22166. // }
  22167. // }
  22168. //
  22169. // We want to traverse over that shape and convert it into a flat structure so
  22170. // that we can find if there's a JSXElement somewhere inside.
  22171. function getConditionalChainContents(node) {
  22172. // Given this code:
  22173. //
  22174. // // Using a ConditionalExpression as the consequent is uncommon, but should
  22175. // // be handled.
  22176. // A ? B : C ? D : E ? F ? G : H : I
  22177. //
  22178. // which has this AST:
  22179. //
  22180. // ConditionalExpression {
  22181. // test: Identifier(A),
  22182. // consequent: Identifier(B),
  22183. // alternate: ConditionalExpression {
  22184. // test: Identifier(C),
  22185. // consequent: Identifier(D),
  22186. // alternate: ConditionalExpression {
  22187. // test: Identifier(E),
  22188. // consequent: ConditionalExpression {
  22189. // test: Identifier(F),
  22190. // consequent: Identifier(G),
  22191. // alternate: Identifier(H),
  22192. // },
  22193. // alternate: Identifier(I),
  22194. // }
  22195. // }
  22196. // }
  22197. //
  22198. // we should return this Array:
  22199. //
  22200. // [
  22201. // Identifier(A),
  22202. // Identifier(B),
  22203. // Identifier(C),
  22204. // Identifier(D),
  22205. // Identifier(E),
  22206. // Identifier(F),
  22207. // Identifier(G),
  22208. // Identifier(H),
  22209. // Identifier(I)
  22210. // ];
  22211. //
  22212. // This loses the information about whether each node was the test,
  22213. // consequent, or alternate, but we don't care about that here- we are only
  22214. // flattening this structure to find if there's any JSXElements inside.
  22215. var nonConditionalExpressions = [];
  22216. function recurse(node) {
  22217. if (node.type === "ConditionalExpression") {
  22218. recurse(node.test);
  22219. recurse(node.consequent);
  22220. recurse(node.alternate);
  22221. } else {
  22222. nonConditionalExpressions.push(node);
  22223. }
  22224. }
  22225. recurse(node);
  22226. return nonConditionalExpressions;
  22227. } // Detect an expression node representing `{" "}`
  22228. function isJSXWhitespaceExpression(node) {
  22229. return node.type === "JSXExpressionContainer" && isLiteral(node.expression) && node.expression.value === " " && !node.expression.comments;
  22230. }
  22231. function separatorNoWhitespace(isFacebookTranslationTag, child, childNode, nextNode) {
  22232. if (isFacebookTranslationTag) {
  22233. return "";
  22234. }
  22235. if (childNode.type === "JSXElement" && !childNode.closingElement || nextNode && nextNode.type === "JSXElement" && !nextNode.closingElement) {
  22236. return child.length === 1 ? softline$1 : hardline$3;
  22237. }
  22238. return softline$1;
  22239. }
  22240. function separatorWithWhitespace(isFacebookTranslationTag, child, childNode, nextNode) {
  22241. if (isFacebookTranslationTag) {
  22242. return hardline$3;
  22243. }
  22244. if (child.length === 1) {
  22245. return childNode.type === "JSXElement" && !childNode.closingElement || nextNode && nextNode.type === "JSXElement" && !nextNode.closingElement ? hardline$3 : softline$1;
  22246. }
  22247. return hardline$3;
  22248. } // JSX Children are strange, mostly for two reasons:
  22249. // 1. JSX reads newlines into string values, instead of skipping them like JS
  22250. // 2. up to one whitespace between elements within a line is significant,
  22251. // but not between lines.
  22252. //
  22253. // Leading, trailing, and lone whitespace all need to
  22254. // turn themselves into the rather ugly `{' '}` when breaking.
  22255. //
  22256. // We print JSX using the `fill` doc primitive.
  22257. // This requires that we give it an array of alternating
  22258. // content and whitespace elements.
  22259. // To ensure this we add dummy `""` content elements as needed.
  22260. function printJSXChildren(path$$1, options, print, jsxWhitespace, isFacebookTranslationTag) {
  22261. var n = path$$1.getValue();
  22262. var children = []; // using `map` instead of `each` because it provides `i`
  22263. path$$1.map(function (childPath, i) {
  22264. var child = childPath.getValue();
  22265. if (isLiteral(child)) {
  22266. var text = rawText(child); // Contains a non-whitespace character
  22267. if (isMeaningfulJSXText(child)) {
  22268. var words = text.split(matchJsxWhitespaceRegex); // Starts with whitespace
  22269. if (words[0] === "") {
  22270. children.push("");
  22271. words.shift();
  22272. if (/\n/.test(words[0])) {
  22273. var next = n.children[i + 1];
  22274. children.push(separatorWithWhitespace(isFacebookTranslationTag, words[1], child, next));
  22275. } else {
  22276. children.push(jsxWhitespace);
  22277. }
  22278. words.shift();
  22279. }
  22280. var endWhitespace; // Ends with whitespace
  22281. if (getLast$4(words) === "") {
  22282. words.pop();
  22283. endWhitespace = words.pop();
  22284. } // This was whitespace only without a new line.
  22285. if (words.length === 0) {
  22286. return;
  22287. }
  22288. words.forEach(function (word, i) {
  22289. if (i % 2 === 1) {
  22290. children.push(line$3);
  22291. } else {
  22292. children.push(word);
  22293. }
  22294. });
  22295. if (endWhitespace !== undefined) {
  22296. if (/\n/.test(endWhitespace)) {
  22297. var _next = n.children[i + 1];
  22298. children.push(separatorWithWhitespace(isFacebookTranslationTag, getLast$4(children), child, _next));
  22299. } else {
  22300. children.push(jsxWhitespace);
  22301. }
  22302. } else {
  22303. var _next2 = n.children[i + 1];
  22304. children.push(separatorNoWhitespace(isFacebookTranslationTag, getLast$4(children), child, _next2));
  22305. }
  22306. } else if (/\n/.test(text)) {
  22307. // Keep (up to one) blank line between tags/expressions/text.
  22308. // Note: We don't keep blank lines between text elements.
  22309. if (text.match(/\n/g).length > 1) {
  22310. children.push("");
  22311. children.push(hardline$3);
  22312. }
  22313. } else {
  22314. children.push("");
  22315. children.push(jsxWhitespace);
  22316. }
  22317. } else {
  22318. var printedChild = print(childPath);
  22319. children.push(printedChild);
  22320. var _next3 = n.children[i + 1];
  22321. var directlyFollowedByMeaningfulText = _next3 && isMeaningfulJSXText(_next3);
  22322. if (directlyFollowedByMeaningfulText) {
  22323. var firstWord = rawText(_next3).trim().split(matchJsxWhitespaceRegex)[0];
  22324. children.push(separatorNoWhitespace(isFacebookTranslationTag, firstWord, child, _next3));
  22325. } else {
  22326. children.push(hardline$3);
  22327. }
  22328. }
  22329. }, "children");
  22330. return children;
  22331. } // JSX expands children from the inside-out, instead of the outside-in.
  22332. // This is both to break children before attributes,
  22333. // and to ensure that when children break, their parents do as well.
  22334. //
  22335. // Any element that is written without any newlines and fits on a single line
  22336. // is left that way.
  22337. // Not only that, any user-written-line containing multiple JSX siblings
  22338. // should also be kept on one line if possible,
  22339. // so each user-written-line is wrapped in its own group.
  22340. //
  22341. // Elements that contain newlines or don't fit on a single line (recursively)
  22342. // are fully-split, using hardline and shouldBreak: true.
  22343. //
  22344. // To support that case properly, all leading and trailing spaces
  22345. // are stripped from the list of children, and replaced with a single hardline.
  22346. function printJSXElement(path$$1, options, print) {
  22347. var n = path$$1.getValue(); // Turn <div></div> into <div />
  22348. if (n.type === "JSXElement" && isEmptyJSXElement(n)) {
  22349. n.openingElement.selfClosing = true;
  22350. return path$$1.call(print, "openingElement");
  22351. }
  22352. var openingLines = n.type === "JSXElement" ? path$$1.call(print, "openingElement") : path$$1.call(print, "openingFragment");
  22353. var closingLines = n.type === "JSXElement" ? path$$1.call(print, "closingElement") : path$$1.call(print, "closingFragment");
  22354. if (n.children.length === 1 && n.children[0].type === "JSXExpressionContainer" && (n.children[0].expression.type === "TemplateLiteral" || n.children[0].expression.type === "TaggedTemplateExpression")) {
  22355. return concat$4([openingLines, concat$4(path$$1.map(print, "children")), closingLines]);
  22356. } // Convert `{" "}` to text nodes containing a space.
  22357. // This makes it easy to turn them into `jsxWhitespace` which
  22358. // can then print as either a space or `{" "}` when breaking.
  22359. n.children = n.children.map(function (child) {
  22360. if (isJSXWhitespaceExpression(child)) {
  22361. return {
  22362. type: "JSXText",
  22363. value: " ",
  22364. raw: " "
  22365. };
  22366. }
  22367. return child;
  22368. });
  22369. var containsTag = n.children.filter(isJSXNode).length > 0;
  22370. var containsMultipleExpressions = n.children.filter(function (child) {
  22371. return child.type === "JSXExpressionContainer";
  22372. }).length > 1;
  22373. var containsMultipleAttributes = n.type === "JSXElement" && n.openingElement.attributes.length > 1; // Record any breaks. Should never go from true to false, only false to true.
  22374. var forcedBreak = willBreak$1(openingLines) || containsTag || containsMultipleAttributes || containsMultipleExpressions;
  22375. var rawJsxWhitespace = options.singleQuote ? "{' '}" : '{" "}';
  22376. var jsxWhitespace = ifBreak$1(concat$4([rawJsxWhitespace, softline$1]), " ");
  22377. var isFacebookTranslationTag = n.openingElement && n.openingElement.name && n.openingElement.name.name === "fbt";
  22378. var children = printJSXChildren(path$$1, options, print, jsxWhitespace, isFacebookTranslationTag);
  22379. var containsText = n.children.filter(function (child) {
  22380. return isMeaningfulJSXText(child);
  22381. }).length > 0; // We can end up we multiple whitespace elements with empty string
  22382. // content between them.
  22383. // We need to remove empty whitespace and softlines before JSX whitespace
  22384. // to get the correct output.
  22385. for (var i = children.length - 2; i >= 0; i--) {
  22386. var isPairOfEmptyStrings = children[i] === "" && children[i + 1] === "";
  22387. var isPairOfHardlines = children[i] === hardline$3 && children[i + 1] === "" && children[i + 2] === hardline$3;
  22388. var isLineFollowedByJSXWhitespace = (children[i] === softline$1 || children[i] === hardline$3) && children[i + 1] === "" && children[i + 2] === jsxWhitespace;
  22389. var isJSXWhitespaceFollowedByLine = children[i] === jsxWhitespace && children[i + 1] === "" && (children[i + 2] === softline$1 || children[i + 2] === hardline$3);
  22390. var isDoubleJSXWhitespace = children[i] === jsxWhitespace && children[i + 1] === "" && children[i + 2] === jsxWhitespace;
  22391. var isPairOfHardOrSoftLines = children[i] === softline$1 && children[i + 1] === "" && children[i + 2] === hardline$3 || children[i] === hardline$3 && children[i + 1] === "" && children[i + 2] === softline$1;
  22392. if (isPairOfHardlines && containsText || isPairOfEmptyStrings || isLineFollowedByJSXWhitespace || isDoubleJSXWhitespace || isPairOfHardOrSoftLines) {
  22393. children.splice(i, 2);
  22394. } else if (isJSXWhitespaceFollowedByLine) {
  22395. children.splice(i + 1, 2);
  22396. }
  22397. } // Trim trailing lines (or empty strings)
  22398. while (children.length && (isLineNext$1(getLast$4(children)) || isEmpty$1(getLast$4(children)))) {
  22399. children.pop();
  22400. } // Trim leading lines (or empty strings)
  22401. while (children.length && (isLineNext$1(children[0]) || isEmpty$1(children[0])) && (isLineNext$1(children[1]) || isEmpty$1(children[1]))) {
  22402. children.shift();
  22403. children.shift();
  22404. } // Tweak how we format children if outputting this element over multiple lines.
  22405. // Also detect whether we will force this element to output over multiple lines.
  22406. var multilineChildren = [];
  22407. children.forEach(function (child, i) {
  22408. // There are a number of situations where we need to ensure we display
  22409. // whitespace as `{" "}` when outputting this element over multiple lines.
  22410. if (child === jsxWhitespace) {
  22411. if (i === 1 && children[i - 1] === "") {
  22412. if (children.length === 2) {
  22413. // Solitary whitespace
  22414. multilineChildren.push(rawJsxWhitespace);
  22415. return;
  22416. } // Leading whitespace
  22417. multilineChildren.push(concat$4([rawJsxWhitespace, hardline$3]));
  22418. return;
  22419. } else if (i === children.length - 1) {
  22420. // Trailing whitespace
  22421. multilineChildren.push(rawJsxWhitespace);
  22422. return;
  22423. } else if (children[i - 1] === "" && children[i - 2] === hardline$3) {
  22424. // Whitespace after line break
  22425. multilineChildren.push(rawJsxWhitespace);
  22426. return;
  22427. }
  22428. }
  22429. multilineChildren.push(child);
  22430. if (willBreak$1(child)) {
  22431. forcedBreak = true;
  22432. }
  22433. }); // If there is text we use `fill` to fit as much onto each line as possible.
  22434. // When there is no text (just tags and expressions) we use `group`
  22435. // to output each on a separate line.
  22436. var content = containsText ? fill$2(multilineChildren) : group$1(concat$4(multilineChildren), {
  22437. shouldBreak: true
  22438. });
  22439. var multiLineElem = group$1(concat$4([openingLines, indent$2(concat$4([hardline$3, content])), hardline$3, closingLines]));
  22440. if (forcedBreak) {
  22441. return multiLineElem;
  22442. }
  22443. return conditionalGroup$1([group$1(concat$4([openingLines, concat$4(children), closingLines])), multiLineElem]);
  22444. }
  22445. function maybeWrapJSXElementInParens(path$$1, elem) {
  22446. var parent = path$$1.getParentNode();
  22447. if (!parent) {
  22448. return elem;
  22449. }
  22450. var NO_WRAP_PARENTS = {
  22451. ArrayExpression: true,
  22452. JSXAttribute: true,
  22453. JSXElement: true,
  22454. JSXExpressionContainer: true,
  22455. JSXFragment: true,
  22456. ExpressionStatement: true,
  22457. CallExpression: true,
  22458. OptionalCallExpression: true,
  22459. ConditionalExpression: true,
  22460. JsExpressionRoot: true
  22461. };
  22462. if (NO_WRAP_PARENTS[parent.type]) {
  22463. return elem;
  22464. }
  22465. var shouldBreak = matchAncestorTypes$1(path$$1, ["ArrowFunctionExpression", "CallExpression", "JSXExpressionContainer"]);
  22466. return group$1(concat$4([ifBreak$1("("), indent$2(concat$4([softline$1, elem])), softline$1, ifBreak$1(")")]), {
  22467. shouldBreak
  22468. });
  22469. }
  22470. function isBinaryish(node) {
  22471. return node.type === "BinaryExpression" || node.type === "LogicalExpression" || node.type === "NGPipeExpression";
  22472. }
  22473. function isMemberish(node) {
  22474. return node.type === "MemberExpression" || node.type === "OptionalMemberExpression" || node.type === "BindExpression" && node.object;
  22475. }
  22476. function shouldInlineLogicalExpression(node) {
  22477. if (node.type !== "LogicalExpression") {
  22478. return false;
  22479. }
  22480. if (node.right.type === "ObjectExpression" && node.right.properties.length !== 0) {
  22481. return true;
  22482. }
  22483. if (node.right.type === "ArrayExpression" && node.right.elements.length !== 0) {
  22484. return true;
  22485. }
  22486. if (isJSXNode(node.right)) {
  22487. return true;
  22488. }
  22489. return false;
  22490. } // For binary expressions to be consistent, we need to group
  22491. // subsequent operators with the same precedence level under a single
  22492. // group. Otherwise they will be nested such that some of them break
  22493. // onto new lines but not all. Operators with the same precedence
  22494. // level should either all break or not. Because we group them by
  22495. // precedence level and the AST is structured based on precedence
  22496. // level, things are naturally broken up correctly, i.e. `&&` is
  22497. // broken before `+`.
  22498. function printBinaryishExpressions(path$$1, print, options, isNested, isInsideParenthesis) {
  22499. var parts = [];
  22500. var node = path$$1.getValue(); // We treat BinaryExpression and LogicalExpression nodes the same.
  22501. if (isBinaryish(node)) {
  22502. // Put all operators with the same precedence level in the same
  22503. // group. The reason we only need to do this with the `left`
  22504. // expression is because given an expression like `1 + 2 - 3`, it
  22505. // is always parsed like `((1 + 2) - 3)`, meaning the `left` side
  22506. // is where the rest of the expression will exist. Binary
  22507. // expressions on the right side mean they have a difference
  22508. // precedence level and should be treated as a separate group, so
  22509. // print them normally. (This doesn't hold for the `**` operator,
  22510. // which is unique in that it is right-associative.)
  22511. if (shouldFlatten$1(node.operator, node.left.operator)) {
  22512. // Flatten them out by recursively calling this function.
  22513. parts = parts.concat(path$$1.call(function (left) {
  22514. return printBinaryishExpressions(left, print, options,
  22515. /* isNested */
  22516. true, isInsideParenthesis);
  22517. }, "left"));
  22518. } else {
  22519. parts.push(path$$1.call(print, "left"));
  22520. }
  22521. var shouldInline = shouldInlineLogicalExpression(node);
  22522. var lineBeforeOperator = (node.operator === "|>" || node.type === "NGPipeExpression" || node.operator === "|" && options.parser === "__vue_expression") && !hasLeadingOwnLineComment(options.originalText, node.right, options);
  22523. var operator = node.type === "NGPipeExpression" ? "|" : node.operator;
  22524. var rightSuffix = node.type === "NGPipeExpression" && node.arguments.length !== 0 ? group$1(indent$2(concat$4([softline$1, ": ", join$2(concat$4([softline$1, ":", ifBreak$1(" ")]), path$$1.map(print, "arguments").map(function (arg) {
  22525. return align$1(2, group$1(arg));
  22526. }))]))) : "";
  22527. var right = shouldInline ? concat$4([operator, " ", path$$1.call(print, "right"), rightSuffix]) : concat$4([lineBeforeOperator ? softline$1 : "", operator, lineBeforeOperator ? " " : line$3, path$$1.call(print, "right"), rightSuffix]); // If there's only a single binary expression, we want to create a group
  22528. // in order to avoid having a small right part like -1 be on its own line.
  22529. var parent = path$$1.getParentNode();
  22530. var shouldGroup = !(isInsideParenthesis && node.type === "LogicalExpression") && parent.type !== node.type && node.left.type !== node.type && node.right.type !== node.type;
  22531. parts.push(" ", shouldGroup ? group$1(right) : right); // The root comments are already printed, but we need to manually print
  22532. // the other ones since we don't call the normal print on BinaryExpression,
  22533. // only for the left and right parts
  22534. if (isNested && node.comments) {
  22535. parts = comments.printComments(path$$1, function () {
  22536. return concat$4(parts);
  22537. }, options);
  22538. }
  22539. } else {
  22540. // Our stopping case. Simply print the node normally.
  22541. parts.push(path$$1.call(print));
  22542. }
  22543. return parts;
  22544. }
  22545. function printAssignmentRight(leftNode, rightNode, printedRight, options) {
  22546. if (hasLeadingOwnLineComment(options.originalText, rightNode, options)) {
  22547. return indent$2(concat$4([hardline$3, printedRight]));
  22548. }
  22549. var canBreak = isBinaryish(rightNode) && !shouldInlineLogicalExpression(rightNode) || rightNode.type === "ConditionalExpression" && isBinaryish(rightNode.test) && !shouldInlineLogicalExpression(rightNode.test) || rightNode.type === "StringLiteralTypeAnnotation" || rightNode.type === "ClassExpression" && rightNode.decorators && rightNode.decorators.length || (leftNode.type === "Identifier" || isStringLiteral(leftNode) || leftNode.type === "MemberExpression") && (isStringLiteral(rightNode) || isMemberExpressionChain(rightNode)) && // do not put values on a separate line from the key in json
  22550. options.parser !== "json" && options.parser !== "json5";
  22551. if (canBreak) {
  22552. return group$1(indent$2(concat$4([line$3, printedRight])));
  22553. }
  22554. return concat$4([" ", printedRight]);
  22555. }
  22556. function printAssignment(leftNode, printedLeft, operator, rightNode, printedRight, options) {
  22557. if (!rightNode) {
  22558. return printedLeft;
  22559. }
  22560. var printed = printAssignmentRight(leftNode, rightNode, printedRight, options);
  22561. return group$1(concat$4([printedLeft, operator, printed]));
  22562. }
  22563. function adjustClause(node, clause, forceSpace) {
  22564. if (node.type === "EmptyStatement") {
  22565. return ";";
  22566. }
  22567. if (node.type === "BlockStatement" || forceSpace) {
  22568. return concat$4([" ", clause]);
  22569. }
  22570. return indent$2(concat$4([line$3, clause]));
  22571. }
  22572. function nodeStr(node, options, isFlowOrTypeScriptDirectiveLiteral) {
  22573. var raw = rawText(node);
  22574. var isDirectiveLiteral = isFlowOrTypeScriptDirectiveLiteral || node.type === "DirectiveLiteral";
  22575. return printString$1(raw, options, isDirectiveLiteral);
  22576. }
  22577. function printRegex(node) {
  22578. var flags = node.flags.split("").sort().join("");
  22579. return `/${node.pattern}/${flags}`;
  22580. }
  22581. function isLastStatement(path$$1) {
  22582. var parent = path$$1.getParentNode();
  22583. if (!parent) {
  22584. return true;
  22585. }
  22586. var node = path$$1.getValue();
  22587. var body = (parent.body || parent.consequent).filter(function (stmt) {
  22588. return stmt.type !== "EmptyStatement";
  22589. });
  22590. return body && body[body.length - 1] === node;
  22591. }
  22592. function hasLeadingComment(node) {
  22593. return node.comments && node.comments.some(function (comment) {
  22594. return comment.leading;
  22595. });
  22596. }
  22597. function hasTrailingComment(node) {
  22598. return node.comments && node.comments.some(function (comment) {
  22599. return comment.trailing;
  22600. });
  22601. }
  22602. function hasLeadingOwnLineComment(text, node, options) {
  22603. if (isJSXNode(node)) {
  22604. return hasNodeIgnoreComment$1(node);
  22605. }
  22606. var res = node.comments && node.comments.some(function (comment) {
  22607. return comment.leading && hasNewline$2(text, options.locEnd(comment));
  22608. });
  22609. return res;
  22610. }
  22611. function hasNakedLeftSide(node) {
  22612. return node.type === "AssignmentExpression" || node.type === "BinaryExpression" || node.type === "LogicalExpression" || node.type === "NGPipeExpression" || node.type === "ConditionalExpression" || node.type === "CallExpression" || node.type === "OptionalCallExpression" || node.type === "MemberExpression" || node.type === "OptionalMemberExpression" || node.type === "SequenceExpression" || node.type === "TaggedTemplateExpression" || node.type === "BindExpression" || node.type === "UpdateExpression" && !node.prefix || node.type === "TSNonNullExpression";
  22613. }
  22614. function isFlowAnnotationComment(text, typeAnnotation, options) {
  22615. var start = options.locStart(typeAnnotation);
  22616. var end = skipWhitespace$1(text, options.locEnd(typeAnnotation));
  22617. return text.substr(start, 2) === "/*" && text.substr(end, 2) === "*/";
  22618. }
  22619. function getLeftSide(node) {
  22620. if (node.expressions) {
  22621. return node.expressions[0];
  22622. }
  22623. return node.left || node.test || node.callee || node.object || node.tag || node.argument || node.expression;
  22624. }
  22625. function getLeftSidePathName(path$$1, node) {
  22626. if (node.expressions) {
  22627. return ["expressions", 0];
  22628. }
  22629. if (node.left) {
  22630. return ["left"];
  22631. }
  22632. if (node.test) {
  22633. return ["test"];
  22634. }
  22635. if (node.object) {
  22636. return ["object"];
  22637. }
  22638. if (node.callee) {
  22639. return ["callee"];
  22640. }
  22641. if (node.tag) {
  22642. return ["tag"];
  22643. }
  22644. if (node.argument) {
  22645. return ["argument"];
  22646. }
  22647. if (node.expression) {
  22648. return ["expression"];
  22649. }
  22650. throw new Error("Unexpected node has no left side", node);
  22651. }
  22652. function exprNeedsASIProtection(path$$1, options) {
  22653. var node = path$$1.getValue();
  22654. var maybeASIProblem = needsParens_1(path$$1, options) || node.type === "ParenthesizedExpression" || node.type === "TypeCastExpression" || node.type === "ArrowFunctionExpression" && !shouldPrintParamsWithoutParens(path$$1, options) || node.type === "ArrayExpression" || node.type === "ArrayPattern" || node.type === "UnaryExpression" && node.prefix && (node.operator === "+" || node.operator === "-") || node.type === "TemplateLiteral" || node.type === "TemplateElement" || isJSXNode(node) || node.type === "BindExpression" && !node.object || node.type === "RegExpLiteral" || node.type === "Literal" && node.pattern || node.type === "Literal" && node.regex;
  22655. if (maybeASIProblem) {
  22656. return true;
  22657. }
  22658. if (!hasNakedLeftSide(node)) {
  22659. return false;
  22660. }
  22661. return path$$1.call.apply(path$$1, [function (childPath) {
  22662. return exprNeedsASIProtection(childPath, options);
  22663. }].concat(getLeftSidePathName(path$$1, node)));
  22664. }
  22665. function stmtNeedsASIProtection(path$$1, options) {
  22666. var node = path$$1.getNode();
  22667. if (node.type !== "ExpressionStatement") {
  22668. return false;
  22669. }
  22670. return path$$1.call(function (childPath) {
  22671. return exprNeedsASIProtection(childPath, options);
  22672. }, "expression");
  22673. }
  22674. function classPropMayCauseASIProblems(path$$1) {
  22675. var node = path$$1.getNode();
  22676. if (node.type !== "ClassProperty") {
  22677. return false;
  22678. }
  22679. var name = node.key && node.key.name; // this isn't actually possible yet with most parsers available today
  22680. // so isn't properly tested yet.
  22681. if ((name === "static" || name === "get" || name === "set") && !node.value && !node.typeAnnotation) {
  22682. return true;
  22683. }
  22684. }
  22685. function classChildNeedsASIProtection(node) {
  22686. if (!node) {
  22687. return;
  22688. }
  22689. if (node.static || node.accessibility // TypeScript
  22690. ) {
  22691. return false;
  22692. }
  22693. if (!node.computed) {
  22694. var name = node.key && node.key.name;
  22695. if (name === "in" || name === "instanceof") {
  22696. return true;
  22697. }
  22698. }
  22699. switch (node.type) {
  22700. case "ClassProperty":
  22701. case "TSAbstractClassProperty":
  22702. return node.computed;
  22703. case "MethodDefinition": // Flow
  22704. case "TSAbstractMethodDefinition": // TypeScript
  22705. case "ClassMethod":
  22706. case "ClassPrivateMethod":
  22707. {
  22708. // Babel
  22709. var isAsync = node.value ? node.value.async : node.async;
  22710. var isGenerator = node.value ? node.value.generator : node.generator;
  22711. if (isAsync || node.kind === "get" || node.kind === "set") {
  22712. return false;
  22713. }
  22714. if (node.computed || isGenerator) {
  22715. return true;
  22716. }
  22717. return false;
  22718. }
  22719. default:
  22720. /* istanbul ignore next */
  22721. return false;
  22722. }
  22723. } // This recurses the return argument, looking for the first token
  22724. // (the leftmost leaf node) and, if it (or its parents) has any
  22725. // leadingComments, returns true (so it can be wrapped in parens).
  22726. function returnArgumentHasLeadingComment(options, argument) {
  22727. if (hasLeadingOwnLineComment(options.originalText, argument, options)) {
  22728. return true;
  22729. }
  22730. if (hasNakedLeftSide(argument)) {
  22731. var leftMost = argument;
  22732. var newLeftMost;
  22733. while (newLeftMost = getLeftSide(leftMost)) {
  22734. leftMost = newLeftMost;
  22735. if (hasLeadingOwnLineComment(options.originalText, leftMost, options)) {
  22736. return true;
  22737. }
  22738. }
  22739. }
  22740. return false;
  22741. }
  22742. function isMemberExpressionChain(node) {
  22743. if (node.type !== "MemberExpression" && node.type !== "OptionalMemberExpression") {
  22744. return false;
  22745. }
  22746. if (node.object.type === "Identifier") {
  22747. return true;
  22748. }
  22749. return isMemberExpressionChain(node.object);
  22750. } // Hack to differentiate between the following two which have the same ast
  22751. // type T = { method: () => void };
  22752. // type T = { method(): void };
  22753. function isObjectTypePropertyAFunction(node, options) {
  22754. return (node.type === "ObjectTypeProperty" || node.type === "ObjectTypeInternalSlot") && node.value.type === "FunctionTypeAnnotation" && !node.static && !isFunctionNotation(node, options);
  22755. } // TODO: This is a bad hack and we need a better way to distinguish between
  22756. // arrow functions and otherwise
  22757. function isFunctionNotation(node, options) {
  22758. return isGetterOrSetter(node) || sameLocStart(node, node.value, options);
  22759. }
  22760. function isGetterOrSetter(node) {
  22761. return node.kind === "get" || node.kind === "set";
  22762. }
  22763. function sameLocStart(nodeA, nodeB, options) {
  22764. return options.locStart(nodeA) === options.locStart(nodeB);
  22765. } // Hack to differentiate between the following two which have the same ast
  22766. // declare function f(a): void;
  22767. // var f: (a) => void;
  22768. function isTypeAnnotationAFunction(node, options) {
  22769. return (node.type === "TypeAnnotation" || node.type === "TSTypeAnnotation") && node.typeAnnotation.type === "FunctionTypeAnnotation" && !node.static && !sameLocStart(node, node.typeAnnotation, options);
  22770. }
  22771. function isNodeStartingWithDeclare(node, options) {
  22772. if (!(options.parser === "flow" || options.parser === "typescript")) {
  22773. return false;
  22774. }
  22775. return options.originalText.slice(0, options.locStart(node)).match(/declare[ \t]*$/) || options.originalText.slice(node.range[0], node.range[1]).startsWith("declare ");
  22776. }
  22777. function shouldHugType(node) {
  22778. if (isSimpleFlowType(node) || isObjectType(node)) {
  22779. return true;
  22780. }
  22781. if (node.type === "UnionTypeAnnotation" || node.type === "TSUnionType") {
  22782. var voidCount = node.types.filter(function (n) {
  22783. return n.type === "VoidTypeAnnotation" || n.type === "TSVoidKeyword" || n.type === "NullLiteralTypeAnnotation" || n.type === "TSNullKeyword";
  22784. }).length;
  22785. var objectCount = node.types.filter(function (n) {
  22786. return n.type === "ObjectTypeAnnotation" || n.type === "TSTypeLiteral" || // This is a bit aggressive but captures Array<{x}>
  22787. n.type === "GenericTypeAnnotation" || n.type === "TSTypeReference";
  22788. }).length;
  22789. if (node.types.length - 1 === voidCount && objectCount > 0) {
  22790. return true;
  22791. }
  22792. }
  22793. return false;
  22794. }
  22795. function shouldHugArguments(fun) {
  22796. return fun && fun.params && fun.params.length === 1 && !fun.params[0].comments && (fun.params[0].type === "ObjectPattern" || fun.params[0].type === "ArrayPattern" || fun.params[0].type === "Identifier" && fun.params[0].typeAnnotation && (fun.params[0].typeAnnotation.type === "TypeAnnotation" || fun.params[0].typeAnnotation.type === "TSTypeAnnotation") && isObjectType(fun.params[0].typeAnnotation.typeAnnotation) || fun.params[0].type === "FunctionTypeParam" && isObjectType(fun.params[0].typeAnnotation) || fun.params[0].type === "AssignmentPattern" && (fun.params[0].left.type === "ObjectPattern" || fun.params[0].left.type === "ArrayPattern") && (fun.params[0].right.type === "Identifier" || fun.params[0].right.type === "ObjectExpression" && fun.params[0].right.properties.length === 0 || fun.params[0].right.type === "ArrayExpression" && fun.params[0].right.elements.length === 0)) && !fun.rest;
  22797. }
  22798. function templateLiteralHasNewLines(template) {
  22799. return template.quasis.some(function (quasi) {
  22800. return quasi.value.raw.includes("\n");
  22801. });
  22802. }
  22803. function isTemplateOnItsOwnLine(n, text, options) {
  22804. return (n.type === "TemplateLiteral" && templateLiteralHasNewLines(n) || n.type === "TaggedTemplateExpression" && templateLiteralHasNewLines(n.quasi)) && !hasNewline$2(text, options.locStart(n), {
  22805. backwards: true
  22806. });
  22807. }
  22808. function printArrayItems(path$$1, options, printPath, print) {
  22809. var printedElements = [];
  22810. var separatorParts = [];
  22811. path$$1.each(function (childPath) {
  22812. printedElements.push(concat$4(separatorParts));
  22813. printedElements.push(group$1(print(childPath)));
  22814. separatorParts = [",", line$3];
  22815. if (childPath.getValue() && isNextLineEmpty$2(options.originalText, childPath.getValue(), options)) {
  22816. separatorParts.push(softline$1);
  22817. }
  22818. }, printPath);
  22819. return concat$4(printedElements);
  22820. }
  22821. function hasDanglingComments(node) {
  22822. return node.comments && node.comments.some(function (comment) {
  22823. return !comment.leading && !comment.trailing;
  22824. });
  22825. }
  22826. function needsHardlineAfterDanglingComment(node) {
  22827. if (!node.comments) {
  22828. return false;
  22829. }
  22830. var lastDanglingComment = getLast$4(node.comments.filter(function (comment) {
  22831. return !comment.leading && !comment.trailing;
  22832. }));
  22833. return lastDanglingComment && !comments$3.isBlockComment(lastDanglingComment);
  22834. }
  22835. function isLiteral(node) {
  22836. return node.type === "BooleanLiteral" || node.type === "DirectiveLiteral" || node.type === "Literal" || node.type === "NullLiteral" || node.type === "NumericLiteral" || node.type === "RegExpLiteral" || node.type === "StringLiteral" || node.type === "TemplateLiteral" || node.type === "TSTypeLiteral" || node.type === "JSXText";
  22837. }
  22838. function isNumericLiteral(node) {
  22839. return node.type === "NumericLiteral" || node.type === "Literal" && typeof node.value === "number";
  22840. }
  22841. function isStringLiteral(node) {
  22842. return node.type === "StringLiteral" || node.type === "Literal" && typeof node.value === "string";
  22843. }
  22844. function isObjectType(n) {
  22845. return n.type === "ObjectTypeAnnotation" || n.type === "TSTypeLiteral";
  22846. }
  22847. var unitTestRe = /^(skip|[fx]?(it|describe|test))$/; // eg; `describe("some string", (done) => {})`
  22848. function isTestCall(n, parent) {
  22849. if (n.type !== "CallExpression") {
  22850. return false;
  22851. }
  22852. if (n.arguments.length === 1) {
  22853. if (isAngularTestWrapper(n) && parent && isTestCall(parent)) {
  22854. return isFunctionOrArrowExpression(n.arguments[0]);
  22855. }
  22856. if (isUnitTestSetUp(n)) {
  22857. return isAngularTestWrapper(n.arguments[0]);
  22858. }
  22859. } else if (n.arguments.length === 2 || n.arguments.length === 3) {
  22860. if ((n.callee.type === "Identifier" && unitTestRe.test(n.callee.name) || isSkipOrOnlyBlock(n)) && (isTemplateLiteral(n.arguments[0]) || isStringLiteral(n.arguments[0]))) {
  22861. // it("name", () => { ... }, 2500)
  22862. if (n.arguments[2] && !isNumericLiteral(n.arguments[2])) {
  22863. return false;
  22864. }
  22865. return (n.arguments.length === 2 ? isFunctionOrArrowExpression(n.arguments[1]) : isFunctionOrArrowExpressionWithBody(n.arguments[1]) && n.arguments[1].params.length <= 1) || isAngularTestWrapper(n.arguments[1]);
  22866. }
  22867. }
  22868. return false;
  22869. }
  22870. function isSkipOrOnlyBlock(node) {
  22871. return (node.callee.type === "MemberExpression" || node.callee.type === "OptionalMemberExpression") && node.callee.object.type === "Identifier" && node.callee.property.type === "Identifier" && unitTestRe.test(node.callee.object.name) && (node.callee.property.name === "only" || node.callee.property.name === "skip");
  22872. }
  22873. function isTemplateLiteral(node) {
  22874. return node.type === "TemplateLiteral";
  22875. } // `inject` is used in AngularJS 1.x, `async` in Angular 2+
  22876. // example: https://docs.angularjs.org/guide/unit-testing#using-beforeall-
  22877. function isAngularTestWrapper(node) {
  22878. return (node.type === "CallExpression" || node.type === "OptionalCallExpression") && node.callee.type === "Identifier" && (node.callee.name === "async" || node.callee.name === "inject" || node.callee.name === "fakeAsync");
  22879. }
  22880. function isFunctionOrArrowExpression(node) {
  22881. return node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression";
  22882. }
  22883. function isFunctionOrArrowExpressionWithBody(node) {
  22884. return node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression" && node.body.type === "BlockStatement";
  22885. }
  22886. function isUnitTestSetUp(n) {
  22887. var unitTestSetUpRe = /^(before|after)(Each|All)$/;
  22888. return n.callee.type === "Identifier" && unitTestSetUpRe.test(n.callee.name) && n.arguments.length === 1;
  22889. }
  22890. function isTheOnlyJSXElementInMarkdown(options, path$$1) {
  22891. if (options.parentParser !== "markdown" && options.parentParser !== "mdx") {
  22892. return false;
  22893. }
  22894. var node = path$$1.getNode();
  22895. if (!node.expression || !isJSXNode(node.expression)) {
  22896. return false;
  22897. }
  22898. var parent = path$$1.getParentNode();
  22899. return parent.type === "Program" && parent.body.length == 1;
  22900. }
  22901. function willPrintOwnComments(path$$1) {
  22902. var node = path$$1.getValue();
  22903. var parent = path$$1.getParentNode();
  22904. return (node && (isJSXNode(node) || hasFlowShorthandAnnotationComment(node) || parent && parent.type === "CallExpression" && (hasFlowAnnotationComment(node.leadingComments) || hasFlowAnnotationComment(node.trailingComments))) || parent && (parent.type === "JSXSpreadAttribute" || parent.type === "JSXSpreadChild" || parent.type === "UnionTypeAnnotation" || parent.type === "TSUnionType" || (parent.type === "ClassDeclaration" || parent.type === "ClassExpression") && parent.superClass === node)) && !hasIgnoreComment$1(path$$1);
  22905. }
  22906. function canAttachComment(node) {
  22907. return node.type && node.type !== "CommentBlock" && node.type !== "CommentLine" && node.type !== "Line" && node.type !== "Block" && node.type !== "EmptyStatement" && node.type !== "TemplateElement" && node.type !== "Import" && !(node.callee && node.callee.type === "Import");
  22908. }
  22909. function printComment$1(commentPath, options) {
  22910. var comment = commentPath.getValue();
  22911. switch (comment.type) {
  22912. case "CommentBlock":
  22913. case "Block":
  22914. {
  22915. if (isIndentableBlockComment(comment)) {
  22916. var printed = printIndentableBlockComment(comment); // We need to prevent an edge case of a previous trailing comment
  22917. // printed as a `lineSuffix` which causes the comments to be
  22918. // interleaved. See https://github.com/prettier/prettier/issues/4412
  22919. if (comment.trailing && !hasNewline$2(options.originalText, options.locStart(comment), {
  22920. backwards: true
  22921. })) {
  22922. return concat$4([hardline$3, printed]);
  22923. }
  22924. return printed;
  22925. }
  22926. var isInsideFlowComment = options.originalText.substr(options.locEnd(comment) - 3, 3) === "*-/";
  22927. return "/*" + comment.value + (isInsideFlowComment ? "*-/" : "*/");
  22928. }
  22929. case "CommentLine":
  22930. case "Line":
  22931. // Print shebangs with the proper comment characters
  22932. if (options.originalText.slice(options.locStart(comment)).startsWith("#!")) {
  22933. return "#!" + comment.value.trimRight();
  22934. }
  22935. return "//" + comment.value.trimRight();
  22936. default:
  22937. throw new Error("Not a comment: " + JSON.stringify(comment));
  22938. }
  22939. }
  22940. function isIndentableBlockComment(comment) {
  22941. // If the comment has multiple lines and every line starts with a star
  22942. // we can fix the indentation of each line. The stars in the `/*` and
  22943. // `*/` delimiters are not included in the comment value, so add them
  22944. // back first.
  22945. var lines = `*${comment.value}*`.split("\n");
  22946. return lines.length > 1 && lines.every(function (line) {
  22947. return line.trim()[0] === "*";
  22948. });
  22949. }
  22950. function printIndentableBlockComment(comment) {
  22951. var lines = comment.value.split("\n");
  22952. return concat$4(["/*", join$2(hardline$3, lines.map(function (line, index) {
  22953. return index === 0 ? line.trimRight() : " " + (index < lines.length - 1 ? line.trim() : line.trimLeft());
  22954. })), "*/"]);
  22955. }
  22956. function rawText(node) {
  22957. return node.extra ? node.extra.raw : node.raw;
  22958. }
  22959. function identity$1(x) {
  22960. return x;
  22961. }
  22962. var printerEstree = {
  22963. preprocess: preprocess_1,
  22964. print: genericPrint,
  22965. embed: embed_1,
  22966. insertPragma,
  22967. massageAstNode: clean_1,
  22968. hasPrettierIgnore,
  22969. willPrintOwnComments,
  22970. canAttachComment,
  22971. printComment: printComment$1,
  22972. isBlockComment: comments$3.isBlockComment,
  22973. handleComments: {
  22974. ownLine: comments$3.handleOwnLineComment,
  22975. endOfLine: comments$3.handleEndOfLineComment,
  22976. remaining: comments$3.handleRemainingComment
  22977. }
  22978. };
  22979. var _require$$0$builders$2 = doc.builders;
  22980. var concat$7 = _require$$0$builders$2.concat;
  22981. var hardline$5 = _require$$0$builders$2.hardline;
  22982. var indent$4 = _require$$0$builders$2.indent;
  22983. var join$5 = _require$$0$builders$2.join;
  22984. function genericPrint$1(path$$1, options, print) {
  22985. var node = path$$1.getValue();
  22986. switch (node.type) {
  22987. case "JsonRoot":
  22988. return concat$7([path$$1.call(print, "node"), hardline$5]);
  22989. case "ArrayExpression":
  22990. return node.elements.length === 0 ? "[]" : concat$7(["[", indent$4(concat$7([hardline$5, join$5(concat$7([",", hardline$5]), path$$1.map(print, "elements"))])), hardline$5, "]"]);
  22991. case "ObjectExpression":
  22992. return node.properties.length === 0 ? "{}" : concat$7(["{", indent$4(concat$7([hardline$5, join$5(concat$7([",", hardline$5]), path$$1.map(print, "properties"))])), hardline$5, "}"]);
  22993. case "ObjectProperty":
  22994. return concat$7([path$$1.call(print, "key"), ": ", path$$1.call(print, "value")]);
  22995. case "UnaryExpression":
  22996. return concat$7([node.operator === "+" ? "" : node.operator, path$$1.call(print, "argument")]);
  22997. case "NullLiteral":
  22998. return "null";
  22999. case "BooleanLiteral":
  23000. return node.value ? "true" : "false";
  23001. case "StringLiteral":
  23002. case "NumericLiteral":
  23003. return JSON.stringify(node.value);
  23004. case "Identifier":
  23005. return JSON.stringify(node.name);
  23006. default:
  23007. /* istanbul ignore next */
  23008. throw new Error("unknown type: " + JSON.stringify(node.type));
  23009. }
  23010. }
  23011. function clean$2(node, newNode
  23012. /*, parent*/
  23013. ) {
  23014. delete newNode.start;
  23015. delete newNode.end;
  23016. delete newNode.extra;
  23017. delete newNode.loc;
  23018. delete newNode.comments;
  23019. if (node.type === "Identifier") {
  23020. return {
  23021. type: "StringLiteral",
  23022. value: node.name
  23023. };
  23024. }
  23025. if (node.type === "UnaryExpression" && node.operator === "+") {
  23026. return newNode.argument;
  23027. }
  23028. }
  23029. var printerEstreeJson = {
  23030. preprocess: preprocess_1,
  23031. print: genericPrint$1,
  23032. massageAstNode: clean$2
  23033. };
  23034. var CATEGORY_COMMON = "Common"; // format based on https://github.com/prettier/prettier/blob/master/src/main/core-options.js
  23035. var commonOptions = {
  23036. bracketSpacing: {
  23037. since: "0.0.0",
  23038. category: CATEGORY_COMMON,
  23039. type: "boolean",
  23040. default: true,
  23041. description: "Print spaces between brackets.",
  23042. oppositeDescription: "Do not print spaces between brackets."
  23043. },
  23044. singleQuote: {
  23045. since: "0.0.0",
  23046. category: CATEGORY_COMMON,
  23047. type: "boolean",
  23048. default: false,
  23049. description: "Use single quotes instead of double quotes."
  23050. },
  23051. proseWrap: {
  23052. since: "1.8.2",
  23053. category: CATEGORY_COMMON,
  23054. type: "choice",
  23055. default: [{
  23056. since: "1.8.2",
  23057. value: true
  23058. }, {
  23059. since: "1.9.0",
  23060. value: "preserve"
  23061. }],
  23062. description: "How to wrap prose.",
  23063. choices: [{
  23064. since: "1.9.0",
  23065. value: "always",
  23066. description: "Wrap prose if it exceeds the print width."
  23067. }, {
  23068. since: "1.9.0",
  23069. value: "never",
  23070. description: "Do not wrap prose."
  23071. }, {
  23072. since: "1.9.0",
  23073. value: "preserve",
  23074. description: "Wrap prose as-is."
  23075. }, {
  23076. value: false,
  23077. deprecated: "1.9.0",
  23078. redirect: "never"
  23079. }, {
  23080. value: true,
  23081. deprecated: "1.9.0",
  23082. redirect: "always"
  23083. }]
  23084. }
  23085. };
  23086. var CATEGORY_JAVASCRIPT = "JavaScript"; // format based on https://github.com/prettier/prettier/blob/master/src/main/core-options.js
  23087. var options$4 = {
  23088. arrowParens: {
  23089. since: "1.9.0",
  23090. category: CATEGORY_JAVASCRIPT,
  23091. type: "choice",
  23092. default: "avoid",
  23093. description: "Include parentheses around a sole arrow function parameter.",
  23094. choices: [{
  23095. value: "avoid",
  23096. description: "Omit parens when possible. Example: `x => x`"
  23097. }, {
  23098. value: "always",
  23099. description: "Always include parens. Example: `(x) => x`"
  23100. }]
  23101. },
  23102. bracketSpacing: commonOptions.bracketSpacing,
  23103. jsxBracketSameLine: {
  23104. since: "0.17.0",
  23105. category: CATEGORY_JAVASCRIPT,
  23106. type: "boolean",
  23107. default: false,
  23108. description: "Put > on the last line instead of at a new line."
  23109. },
  23110. semi: {
  23111. since: "1.0.0",
  23112. category: CATEGORY_JAVASCRIPT,
  23113. type: "boolean",
  23114. default: true,
  23115. description: "Print semicolons.",
  23116. oppositeDescription: "Do not print semicolons, except at the beginning of lines which may need them."
  23117. },
  23118. singleQuote: commonOptions.singleQuote,
  23119. jsxSingleQuote: {
  23120. since: "1.15.0",
  23121. category: CATEGORY_JAVASCRIPT,
  23122. type: "boolean",
  23123. default: false,
  23124. description: "Use single quotes in JSX."
  23125. },
  23126. trailingComma: {
  23127. since: "0.0.0",
  23128. category: CATEGORY_JAVASCRIPT,
  23129. type: "choice",
  23130. default: [{
  23131. since: "0.0.0",
  23132. value: false
  23133. }, {
  23134. since: "0.19.0",
  23135. value: "none"
  23136. }],
  23137. description: "Print trailing commas wherever possible when multi-line.",
  23138. choices: [{
  23139. value: "none",
  23140. description: "No trailing commas."
  23141. }, {
  23142. value: "es5",
  23143. description: "Trailing commas where valid in ES5 (objects, arrays, etc.)"
  23144. }, {
  23145. value: "all",
  23146. description: "Trailing commas wherever possible (including function arguments)."
  23147. }, {
  23148. value: true,
  23149. deprecated: "0.19.0",
  23150. redirect: "es5"
  23151. }, {
  23152. value: false,
  23153. deprecated: "0.19.0",
  23154. redirect: "none"
  23155. }]
  23156. }
  23157. };
  23158. var createLanguage = function createLanguage(linguistData, _ref) {
  23159. var extend = _ref.extend,
  23160. override = _ref.override;
  23161. var language = {};
  23162. for (var key in linguistData) {
  23163. var newKey = key === "languageId" ? "linguistLanguageId" : key;
  23164. language[newKey] = linguistData[key];
  23165. }
  23166. if (extend) {
  23167. for (var _key in extend) {
  23168. language[_key] = (language[_key] || []).concat(extend[_key]);
  23169. }
  23170. }
  23171. for (var _key2 in override) {
  23172. language[_key2] = override[_key2];
  23173. }
  23174. return language;
  23175. };
  23176. var name$1 = "JavaScript";
  23177. var type = "programming";
  23178. var tmScope = "source.js";
  23179. var aceMode = "javascript";
  23180. var codemirrorMode = "javascript";
  23181. var codemirrorMimeType = "text/javascript";
  23182. var color = "#f1e05a";
  23183. var aliases = ["js", "node"];
  23184. var extensions = [".js", "._js", ".bones", ".es", ".es6", ".frag", ".gs", ".jake", ".jsb", ".jscad", ".jsfl", ".jsm", ".jss", ".mjs", ".njs", ".pac", ".sjs", ".ssjs", ".xsjs", ".xsjslib"];
  23185. var filenames = ["Jakefile"];
  23186. var interpreters = ["node"];
  23187. var languageId = 183;
  23188. var javascript = {
  23189. name: name$1,
  23190. type: type,
  23191. tmScope: tmScope,
  23192. aceMode: aceMode,
  23193. codemirrorMode: codemirrorMode,
  23194. codemirrorMimeType: codemirrorMimeType,
  23195. color: color,
  23196. aliases: aliases,
  23197. extensions: extensions,
  23198. filenames: filenames,
  23199. interpreters: interpreters,
  23200. languageId: languageId
  23201. };
  23202. var javascript$1 = Object.freeze({
  23203. name: name$1,
  23204. type: type,
  23205. tmScope: tmScope,
  23206. aceMode: aceMode,
  23207. codemirrorMode: codemirrorMode,
  23208. codemirrorMimeType: codemirrorMimeType,
  23209. color: color,
  23210. aliases: aliases,
  23211. extensions: extensions,
  23212. filenames: filenames,
  23213. interpreters: interpreters,
  23214. languageId: languageId,
  23215. default: javascript
  23216. });
  23217. var name$2 = "JSX";
  23218. var type$1 = "programming";
  23219. var group$3 = "JavaScript";
  23220. var extensions$1 = [".jsx"];
  23221. var tmScope$1 = "source.js.jsx";
  23222. var aceMode$1 = "javascript";
  23223. var codemirrorMode$1 = "jsx";
  23224. var codemirrorMimeType$1 = "text/jsx";
  23225. var languageId$1 = 178;
  23226. var jsx = {
  23227. name: name$2,
  23228. type: type$1,
  23229. group: group$3,
  23230. extensions: extensions$1,
  23231. tmScope: tmScope$1,
  23232. aceMode: aceMode$1,
  23233. codemirrorMode: codemirrorMode$1,
  23234. codemirrorMimeType: codemirrorMimeType$1,
  23235. languageId: languageId$1
  23236. };
  23237. var jsx$1 = Object.freeze({
  23238. name: name$2,
  23239. type: type$1,
  23240. group: group$3,
  23241. extensions: extensions$1,
  23242. tmScope: tmScope$1,
  23243. aceMode: aceMode$1,
  23244. codemirrorMode: codemirrorMode$1,
  23245. codemirrorMimeType: codemirrorMimeType$1,
  23246. languageId: languageId$1,
  23247. default: jsx
  23248. });
  23249. var name$3 = "TypeScript";
  23250. var type$2 = "programming";
  23251. var color$1 = "#2b7489";
  23252. var aliases$1 = ["ts"];
  23253. var extensions$2 = [".ts", ".tsx"];
  23254. var tmScope$2 = "source.ts";
  23255. var aceMode$2 = "typescript";
  23256. var codemirrorMode$2 = "javascript";
  23257. var codemirrorMimeType$2 = "application/typescript";
  23258. var languageId$2 = 378;
  23259. var typescript = {
  23260. name: name$3,
  23261. type: type$2,
  23262. color: color$1,
  23263. aliases: aliases$1,
  23264. extensions: extensions$2,
  23265. tmScope: tmScope$2,
  23266. aceMode: aceMode$2,
  23267. codemirrorMode: codemirrorMode$2,
  23268. codemirrorMimeType: codemirrorMimeType$2,
  23269. languageId: languageId$2
  23270. };
  23271. var typescript$1 = Object.freeze({
  23272. name: name$3,
  23273. type: type$2,
  23274. color: color$1,
  23275. aliases: aliases$1,
  23276. extensions: extensions$2,
  23277. tmScope: tmScope$2,
  23278. aceMode: aceMode$2,
  23279. codemirrorMode: codemirrorMode$2,
  23280. codemirrorMimeType: codemirrorMimeType$2,
  23281. languageId: languageId$2,
  23282. default: typescript
  23283. });
  23284. var name$4 = "JSON";
  23285. var type$3 = "data";
  23286. var tmScope$3 = "source.json";
  23287. var group$4 = "JavaScript";
  23288. var aceMode$3 = "json";
  23289. var codemirrorMode$3 = "javascript";
  23290. var codemirrorMimeType$3 = "application/json";
  23291. var searchable = false;
  23292. var extensions$3 = [".json", ".avsc", ".geojson", ".gltf", ".JSON-tmLanguage", ".jsonl", ".tfstate", ".tfstate.backup", ".topojson", ".webapp", ".webmanifest"];
  23293. var filenames$1 = [".arcconfig", ".htmlhintrc", ".tern-config", ".tern-project", "composer.lock", "mcmod.info"];
  23294. var languageId$3 = 174;
  23295. var json$2 = {
  23296. name: name$4,
  23297. type: type$3,
  23298. tmScope: tmScope$3,
  23299. group: group$4,
  23300. aceMode: aceMode$3,
  23301. codemirrorMode: codemirrorMode$3,
  23302. codemirrorMimeType: codemirrorMimeType$3,
  23303. searchable: searchable,
  23304. extensions: extensions$3,
  23305. filenames: filenames$1,
  23306. languageId: languageId$3
  23307. };
  23308. var json$3 = Object.freeze({
  23309. name: name$4,
  23310. type: type$3,
  23311. tmScope: tmScope$3,
  23312. group: group$4,
  23313. aceMode: aceMode$3,
  23314. codemirrorMode: codemirrorMode$3,
  23315. codemirrorMimeType: codemirrorMimeType$3,
  23316. searchable: searchable,
  23317. extensions: extensions$3,
  23318. filenames: filenames$1,
  23319. languageId: languageId$3,
  23320. default: json$2
  23321. });
  23322. var name$5 = "JSON with Comments";
  23323. var type$4 = "data";
  23324. var group$5 = "JSON";
  23325. var tmScope$4 = "source.js";
  23326. var aceMode$4 = "javascript";
  23327. var codemirrorMode$4 = "javascript";
  23328. var codemirrorMimeType$4 = "text/javascript";
  23329. var aliases$2 = ["jsonc"];
  23330. var extensions$4 = [".sublime-build", ".sublime-commands", ".sublime-completions", ".sublime-keymap", ".sublime-macro", ".sublime-menu", ".sublime-mousemap", ".sublime-project", ".sublime-settings", ".sublime-theme", ".sublime-workspace", ".sublime_metrics", ".sublime_session"];
  23331. var filenames$2 = [".babelrc", ".eslintrc.json", ".jscsrc", ".jshintrc", ".jslintrc", "tsconfig.json"];
  23332. var languageId$4 = 423;
  23333. var jsonWithComments = {
  23334. name: name$5,
  23335. type: type$4,
  23336. group: group$5,
  23337. tmScope: tmScope$4,
  23338. aceMode: aceMode$4,
  23339. codemirrorMode: codemirrorMode$4,
  23340. codemirrorMimeType: codemirrorMimeType$4,
  23341. aliases: aliases$2,
  23342. extensions: extensions$4,
  23343. filenames: filenames$2,
  23344. languageId: languageId$4
  23345. };
  23346. var jsonWithComments$1 = Object.freeze({
  23347. name: name$5,
  23348. type: type$4,
  23349. group: group$5,
  23350. tmScope: tmScope$4,
  23351. aceMode: aceMode$4,
  23352. codemirrorMode: codemirrorMode$4,
  23353. codemirrorMimeType: codemirrorMimeType$4,
  23354. aliases: aliases$2,
  23355. extensions: extensions$4,
  23356. filenames: filenames$2,
  23357. languageId: languageId$4,
  23358. default: jsonWithComments
  23359. });
  23360. var name$6 = "JSON5";
  23361. var type$5 = "data";
  23362. var extensions$5 = [".json5"];
  23363. var tmScope$5 = "source.js";
  23364. var aceMode$5 = "javascript";
  23365. var codemirrorMode$5 = "javascript";
  23366. var codemirrorMimeType$5 = "application/json";
  23367. var languageId$5 = 175;
  23368. var json5 = {
  23369. name: name$6,
  23370. type: type$5,
  23371. extensions: extensions$5,
  23372. tmScope: tmScope$5,
  23373. aceMode: aceMode$5,
  23374. codemirrorMode: codemirrorMode$5,
  23375. codemirrorMimeType: codemirrorMimeType$5,
  23376. languageId: languageId$5
  23377. };
  23378. var json5$1 = Object.freeze({
  23379. name: name$6,
  23380. type: type$5,
  23381. extensions: extensions$5,
  23382. tmScope: tmScope$5,
  23383. aceMode: aceMode$5,
  23384. codemirrorMode: codemirrorMode$5,
  23385. codemirrorMimeType: codemirrorMimeType$5,
  23386. languageId: languageId$5,
  23387. default: json5
  23388. });
  23389. var require$$0$21 = ( javascript$1 && javascript ) || javascript$1;
  23390. var require$$1$9 = ( jsx$1 && jsx ) || jsx$1;
  23391. var require$$2$10 = ( typescript$1 && typescript ) || typescript$1;
  23392. var require$$3$3 = ( json$3 && json$2 ) || json$3;
  23393. var require$$4$2 = ( jsonWithComments$1 && jsonWithComments ) || jsonWithComments$1;
  23394. var require$$5$1 = ( json5$1 && json5 ) || json5$1;
  23395. var languages = [createLanguage(require$$0$21, {
  23396. override: {
  23397. since: "0.0.0",
  23398. parsers: ["babel", "flow"],
  23399. vscodeLanguageIds: ["javascript"]
  23400. },
  23401. extend: {
  23402. interpreters: ["nodejs"]
  23403. }
  23404. }), createLanguage(require$$0$21, {
  23405. override: {
  23406. name: "Flow",
  23407. since: "0.0.0",
  23408. parsers: ["babel", "flow"],
  23409. vscodeLanguageIds: ["javascript"],
  23410. aliases: [],
  23411. filenames: [],
  23412. extensions: [".js.flow"]
  23413. }
  23414. }), createLanguage(require$$1$9, {
  23415. override: {
  23416. since: "0.0.0",
  23417. parsers: ["babel", "flow"],
  23418. vscodeLanguageIds: ["javascriptreact"]
  23419. }
  23420. }), createLanguage(require$$2$10, {
  23421. override: {
  23422. since: "1.4.0",
  23423. parsers: ["typescript"],
  23424. vscodeLanguageIds: ["typescript", "typescriptreact"]
  23425. }
  23426. }), createLanguage(require$$3$3, {
  23427. override: {
  23428. name: "JSON.stringify",
  23429. since: "1.13.0",
  23430. parsers: ["json-stringify"],
  23431. vscodeLanguageIds: ["json"],
  23432. extensions: [],
  23433. // .json file defaults to json instead of json-stringify
  23434. filenames: ["package.json", "package-lock.json", "composer.json"]
  23435. }
  23436. }), createLanguage(require$$3$3, {
  23437. override: {
  23438. since: "1.5.0",
  23439. parsers: ["json"],
  23440. vscodeLanguageIds: ["json"]
  23441. },
  23442. extend: {
  23443. filenames: [".prettierrc"]
  23444. }
  23445. }), createLanguage(require$$4$2, {
  23446. override: {
  23447. since: "1.5.0",
  23448. parsers: ["json"],
  23449. vscodeLanguageIds: ["jsonc"]
  23450. },
  23451. extend: {
  23452. filenames: [".eslintrc"]
  23453. }
  23454. }), createLanguage(require$$5$1, {
  23455. override: {
  23456. since: "1.13.0",
  23457. parsers: ["json5"],
  23458. vscodeLanguageIds: ["json5"]
  23459. }
  23460. })];
  23461. var printers = {
  23462. estree: printerEstree,
  23463. "estree-json": printerEstreeJson
  23464. };
  23465. var languageJs = {
  23466. languages,
  23467. options: options$4,
  23468. printers
  23469. };
  23470. var index$12 = ["a", "abbr", "acronym", "address", "applet", "area", "article", "aside", "audio", "b", "base", "basefont", "bdi", "bdo", "bgsound", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "command", "content", "data", "datalist", "dd", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "embed", "fieldset", "figcaption", "figure", "font", "footer", "form", "frame", "frameset", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "iframe", "image", "img", "input", "ins", "isindex", "kbd", "keygen", "label", "legend", "li", "link", "listing", "main", "map", "mark", "marquee", "math", "menu", "menuitem", "meta", "meter", "multicol", "nav", "nextid", "nobr", "noembed", "noframes", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "picture", "plaintext", "pre", "progress", "q", "rb", "rbc", "rp", "rt", "rtc", "ruby", "s", "samp", "script", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "svg", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "tt", "u", "ul", "var", "video", "wbr", "xmp"];
  23471. var htmlTagNames = Object.freeze({
  23472. default: index$12
  23473. });
  23474. var htmlTagNames$1 = ( htmlTagNames && index$12 ) || htmlTagNames;
  23475. function clean$3(ast, newObj, parent) {
  23476. ["raw", // front-matter
  23477. "raws", "sourceIndex", "source", "before", "after", "trailingComma"].forEach(function (name) {
  23478. delete newObj[name];
  23479. });
  23480. if (ast.type === "yaml") {
  23481. delete newObj.value;
  23482. } // --insert-pragma
  23483. if (ast.type === "css-comment" && parent.type === "css-root" && parent.nodes.length !== 0 && ( // first non-front-matter comment
  23484. parent.nodes[0] === ast || (parent.nodes[0].type === "yaml" || parent.nodes[0].type === "toml") && parent.nodes[1] === ast)) {
  23485. /**
  23486. * something
  23487. *
  23488. * @format
  23489. */
  23490. delete newObj.text; // standalone pragma
  23491. if (/^\*\s*@(format|prettier)\s*$/.test(ast.text)) {
  23492. return null;
  23493. }
  23494. }
  23495. if (ast.type === "media-query" || ast.type === "media-query-list" || ast.type === "media-feature-expression") {
  23496. delete newObj.value;
  23497. }
  23498. if (ast.type === "css-rule") {
  23499. delete newObj.params;
  23500. }
  23501. if (ast.type === "selector-combinator") {
  23502. newObj.value = newObj.value.replace(/\s+/g, " ");
  23503. }
  23504. if (ast.type === "media-feature") {
  23505. newObj.value = newObj.value.replace(/ /g, "");
  23506. }
  23507. if (ast.type === "value-word" && (ast.isColor && ast.isHex || ["initial", "inherit", "unset", "revert"].indexOf(newObj.value.replace().toLowerCase()) !== -1) || ast.type === "media-feature" || ast.type === "selector-root-invalid" || ast.type === "selector-pseudo") {
  23508. newObj.value = newObj.value.toLowerCase();
  23509. }
  23510. if (ast.type === "css-decl") {
  23511. newObj.prop = newObj.prop.toLowerCase();
  23512. }
  23513. if (ast.type === "css-atrule" || ast.type === "css-import") {
  23514. newObj.name = newObj.name.toLowerCase();
  23515. }
  23516. if (ast.type === "value-number") {
  23517. newObj.unit = newObj.unit.toLowerCase();
  23518. }
  23519. if ((ast.type === "media-feature" || ast.type === "media-keyword" || ast.type === "media-type" || ast.type === "media-unknown" || ast.type === "media-url" || ast.type === "media-value" || ast.type === "selector-attribute" || ast.type === "selector-string" || ast.type === "selector-class" || ast.type === "selector-combinator" || ast.type === "value-string") && newObj.value) {
  23520. newObj.value = cleanCSSStrings(newObj.value);
  23521. }
  23522. if (ast.type === "selector-attribute") {
  23523. newObj.attribute = newObj.attribute.trim();
  23524. if (newObj.namespace) {
  23525. if (typeof newObj.namespace === "string") {
  23526. newObj.namespace = newObj.namespace.trim();
  23527. if (newObj.namespace.length === 0) {
  23528. newObj.namespace = true;
  23529. }
  23530. }
  23531. }
  23532. if (newObj.value) {
  23533. newObj.value = newObj.value.trim().replace(/^['"]|['"]$/g, "");
  23534. delete newObj.quoted;
  23535. }
  23536. }
  23537. if ((ast.type === "media-value" || ast.type === "media-type" || ast.type === "value-number" || ast.type === "selector-root-invalid" || ast.type === "selector-class" || ast.type === "selector-combinator" || ast.type === "selector-tag") && newObj.value) {
  23538. newObj.value = newObj.value.replace(/([\d.eE+-]+)([a-zA-Z]*)/g, function (match, numStr, unit) {
  23539. var num = Number(numStr);
  23540. return isNaN(num) ? match : num + unit.toLowerCase();
  23541. });
  23542. }
  23543. if (ast.type === "selector-tag") {
  23544. var lowercasedValue = ast.value.toLowerCase();
  23545. if (htmlTagNames$1.indexOf(lowercasedValue) !== -1) {
  23546. newObj.value = lowercasedValue;
  23547. }
  23548. if (["from", "to"].indexOf(lowercasedValue) !== -1) {
  23549. newObj.value = lowercasedValue;
  23550. }
  23551. } // Workaround when `postcss-values-parser` parse `not`, `and` or `or` keywords as `value-func`
  23552. if (ast.type === "css-atrule" && ast.name.toLowerCase() === "supports") {
  23553. delete newObj.value;
  23554. } // Workaround for SCSS nested properties
  23555. if (ast.type === "selector-unknown") {
  23556. delete newObj.value;
  23557. }
  23558. }
  23559. function cleanCSSStrings(value) {
  23560. return value.replace(/'/g, '"').replace(/\\([^a-fA-F\d])/g, "$1");
  23561. }
  23562. var clean_1$2 = clean$3;
  23563. var _require$$0$builders$3 = doc.builders;
  23564. var hardline$7 = _require$$0$builders$3.hardline;
  23565. var literalline$3 = _require$$0$builders$3.literalline;
  23566. var concat$9 = _require$$0$builders$3.concat;
  23567. var markAsRoot$1 = _require$$0$builders$3.markAsRoot;
  23568. var mapDoc$4 = doc.utils.mapDoc;
  23569. function embed$2(path$$1, print, textToDoc
  23570. /*, options */
  23571. ) {
  23572. var node = path$$1.getValue();
  23573. if (node.type === "yaml") {
  23574. return markAsRoot$1(concat$9(["---", hardline$7, node.value.trim() ? replaceNewlinesWithLiterallines(textToDoc(node.value, {
  23575. parser: "yaml"
  23576. })) : "", "---", hardline$7]));
  23577. }
  23578. return null;
  23579. function replaceNewlinesWithLiterallines(doc$$2) {
  23580. return mapDoc$4(doc$$2, function (currentDoc) {
  23581. return typeof currentDoc === "string" && currentDoc.includes("\n") ? concat$9(currentDoc.split(/(\n)/g).map(function (v, i) {
  23582. return i % 2 === 0 ? v : literalline$3;
  23583. })) : currentDoc;
  23584. });
  23585. }
  23586. }
  23587. var embed_1$2 = embed$2;
  23588. var DELIMITER_MAP = {
  23589. "---": "yaml",
  23590. "+++": "toml"
  23591. };
  23592. function parse$5(text) {
  23593. var delimiterRegex = Object.keys(DELIMITER_MAP).map(escapeStringRegexp).join("|");
  23594. var match = text.match( // trailing spaces after delimiters are allowed
  23595. new RegExp(`^(${delimiterRegex})[^\\n\\S]*\\n(?:([\\s\\S]*?)\\n)?\\1[^\\n\\S]*(\\n|$)`));
  23596. if (match === null) {
  23597. return {
  23598. frontMatter: null,
  23599. content: text
  23600. };
  23601. }
  23602. var raw = match[0].replace(/\n$/, "");
  23603. var delimiter = match[1];
  23604. var value = match[2];
  23605. return {
  23606. frontMatter: {
  23607. type: DELIMITER_MAP[delimiter],
  23608. value,
  23609. raw
  23610. },
  23611. content: match[0].replace(/[^\n]/g, " ") + text.slice(match[0].length)
  23612. };
  23613. }
  23614. var frontMatter = parse$5;
  23615. function hasPragma$1(text) {
  23616. return pragma.hasPragma(frontMatter(text).content);
  23617. }
  23618. function insertPragma$3(text) {
  23619. var _parseFrontMatter = frontMatter(text),
  23620. frontMatter$$1 = _parseFrontMatter.frontMatter,
  23621. content = _parseFrontMatter.content;
  23622. return (frontMatter$$1 ? frontMatter$$1.raw + "\n\n" : "") + pragma.insertPragma(content);
  23623. }
  23624. var pragma$2 = {
  23625. hasPragma: hasPragma$1,
  23626. insertPragma: insertPragma$3
  23627. };
  23628. var colorAdjusterFunctions = ["red", "green", "blue", "alpha", "a", "rgb", "hue", "h", "saturation", "s", "lightness", "l", "whiteness", "w", "blackness", "b", "tint", "shade", "blend", "blenda", "contrast", "hsl", "hsla", "hwb", "hwba"];
  23629. function getAncestorCounter(path$$1, typeOrTypes) {
  23630. var types = [].concat(typeOrTypes);
  23631. var counter = -1;
  23632. var ancestorNode;
  23633. while (ancestorNode = path$$1.getParentNode(++counter)) {
  23634. if (types.indexOf(ancestorNode.type) !== -1) {
  23635. return counter;
  23636. }
  23637. }
  23638. return -1;
  23639. }
  23640. function getAncestorNode$1(path$$1, typeOrTypes) {
  23641. var counter = getAncestorCounter(path$$1, typeOrTypes);
  23642. return counter === -1 ? null : path$$1.getParentNode(counter);
  23643. }
  23644. function getPropOfDeclNode$1(path$$1) {
  23645. var declAncestorNode = getAncestorNode$1(path$$1, "css-decl");
  23646. return declAncestorNode && declAncestorNode.prop && declAncestorNode.prop.toLowerCase();
  23647. }
  23648. function isSCSS$1(parser, text) {
  23649. var hasExplicitParserChoice = parser === "less" || parser === "scss";
  23650. var IS_POSSIBLY_SCSS = /(\w\s*: [^}:]+|#){|@import[^\n]+(url|,)/;
  23651. return hasExplicitParserChoice ? parser === "scss" : IS_POSSIBLY_SCSS.test(text);
  23652. }
  23653. function isWideKeywords$1(value) {
  23654. return ["initial", "inherit", "unset", "revert"].indexOf(value.toLowerCase()) !== -1;
  23655. }
  23656. function isKeyframeAtRuleKeywords$1(path$$1, value) {
  23657. var atRuleAncestorNode = getAncestorNode$1(path$$1, "css-atrule");
  23658. return atRuleAncestorNode && atRuleAncestorNode.name && atRuleAncestorNode.name.toLowerCase().endsWith("keyframes") && ["from", "to"].indexOf(value.toLowerCase()) !== -1;
  23659. }
  23660. function maybeToLowerCase$1(value) {
  23661. return value.includes("$") || value.includes("@") || value.includes("#") || value.startsWith("%") || value.startsWith("--") || value.startsWith(":--") || value.includes("(") && value.includes(")") ? value : value.toLowerCase();
  23662. }
  23663. function insideValueFunctionNode$1(path$$1, functionName) {
  23664. var funcAncestorNode = getAncestorNode$1(path$$1, "value-func");
  23665. return funcAncestorNode && funcAncestorNode.value && funcAncestorNode.value.toLowerCase() === functionName;
  23666. }
  23667. function insideICSSRuleNode$1(path$$1) {
  23668. var ruleAncestorNode = getAncestorNode$1(path$$1, "css-rule");
  23669. return ruleAncestorNode && ruleAncestorNode.raws && ruleAncestorNode.raws.selector && (ruleAncestorNode.raws.selector.startsWith(":import") || ruleAncestorNode.raws.selector.startsWith(":export"));
  23670. }
  23671. function insideAtRuleNode$1(path$$1, atRuleNameOrAtRuleNames) {
  23672. var atRuleNames = [].concat(atRuleNameOrAtRuleNames);
  23673. var atRuleAncestorNode = getAncestorNode$1(path$$1, "css-atrule");
  23674. return atRuleAncestorNode && atRuleNames.indexOf(atRuleAncestorNode.name.toLowerCase()) !== -1;
  23675. }
  23676. function insideURLFunctionInImportAtRuleNode$1(path$$1) {
  23677. var node = path$$1.getValue();
  23678. var atRuleAncestorNode = getAncestorNode$1(path$$1, "css-atrule");
  23679. return atRuleAncestorNode && atRuleAncestorNode.name === "import" && node.groups[0].value === "url" && node.groups.length === 2;
  23680. }
  23681. function isURLFunctionNode$1(node) {
  23682. return node.type === "value-func" && node.value.toLowerCase() === "url";
  23683. }
  23684. function isLastNode$1(path$$1, node) {
  23685. var parentNode = path$$1.getParentNode();
  23686. if (!parentNode) {
  23687. return false;
  23688. }
  23689. var nodes = parentNode.nodes;
  23690. return nodes && nodes.indexOf(node) === nodes.length - 1;
  23691. }
  23692. function isHTMLTag$1(value) {
  23693. return htmlTagNames$1.indexOf(value.toLowerCase()) !== -1;
  23694. }
  23695. function isDetachedRulesetDeclarationNode$1(node) {
  23696. // If a Less file ends up being parsed with the SCSS parser, Less
  23697. // variable declarations will be parsed as atrules with names ending
  23698. // with a colon, so keep the original case then.
  23699. if (!node.selector) {
  23700. return false;
  23701. }
  23702. return typeof node.selector === "string" && /^@.+:.*$/.test(node.selector) || node.selector.value && /^@.+:.*$/.test(node.selector.value);
  23703. }
  23704. function isForKeywordNode$1(node) {
  23705. return node.type === "value-word" && ["from", "through", "end"].indexOf(node.value) !== -1;
  23706. }
  23707. function isIfElseKeywordNode$1(node) {
  23708. return node.type === "value-word" && ["and", "or", "not"].indexOf(node.value) !== -1;
  23709. }
  23710. function isEachKeywordNode$1(node) {
  23711. return node.type === "value-word" && node.value === "in";
  23712. }
  23713. function isMultiplicationNode$1(node) {
  23714. return node.type === "value-operator" && node.value === "*";
  23715. }
  23716. function isDivisionNode$1(node) {
  23717. return node.type === "value-operator" && node.value === "/";
  23718. }
  23719. function isAdditionNode$1(node) {
  23720. return node.type === "value-operator" && node.value === "+";
  23721. }
  23722. function isSubtractionNode$1(node) {
  23723. return node.type === "value-operator" && node.value === "-";
  23724. }
  23725. function isModuloNode(node) {
  23726. return node.type === "value-operator" && node.value === "%";
  23727. }
  23728. function isMathOperatorNode$1(node) {
  23729. return isMultiplicationNode$1(node) || isDivisionNode$1(node) || isAdditionNode$1(node) || isSubtractionNode$1(node) || isModuloNode(node);
  23730. }
  23731. function isEqualityOperatorNode$1(node) {
  23732. return node.type === "value-word" && ["==", "!="].indexOf(node.value) !== -1;
  23733. }
  23734. function isRelationalOperatorNode$1(node) {
  23735. return node.type === "value-word" && ["<", ">", "<=", ">="].indexOf(node.value) !== -1;
  23736. }
  23737. function isSCSSControlDirectiveNode$1(node) {
  23738. return node.type === "css-atrule" && ["if", "else", "for", "each", "while"].indexOf(node.name) !== -1;
  23739. }
  23740. function isSCSSNestedPropertyNode(node) {
  23741. if (!node.selector) {
  23742. return false;
  23743. }
  23744. return node.selector.replace(/\/\*.*?\*\//, "").replace(/\/\/.*?\n/, "").trim().endsWith(":");
  23745. }
  23746. function isDetachedRulesetCallNode$1(node) {
  23747. return node.raws && node.raws.params && /^\(\s*\)$/.test(node.raws.params);
  23748. }
  23749. function isTemplatePlaceholderNode$1(node) {
  23750. return node.name.startsWith("prettier-placeholder");
  23751. }
  23752. function isTemplatePropNode$1(node) {
  23753. return node.prop.startsWith("@prettier-placeholder");
  23754. }
  23755. function isPostcssSimpleVarNode$1(currentNode, nextNode) {
  23756. return currentNode.value === "$$" && currentNode.type === "value-func" && nextNode && nextNode.type === "value-word" && !nextNode.raws.before;
  23757. }
  23758. function hasComposesNode$1(node) {
  23759. return node.value && node.value.type === "value-root" && node.value.group && node.value.group.type === "value-value" && node.prop.toLowerCase() === "composes";
  23760. }
  23761. function hasParensAroundNode$1(node) {
  23762. return node.value && node.value.group && node.value.group.group && node.value.group.group.type === "value-paren_group" && node.value.group.group.open !== null && node.value.group.group.close !== null;
  23763. }
  23764. function hasEmptyRawBefore$1(node) {
  23765. return node.raws && node.raws.before === "";
  23766. }
  23767. function isKeyValuePairNode$1(node) {
  23768. return node.type === "value-comma_group" && node.groups && node.groups[1] && node.groups[1].type === "value-colon";
  23769. }
  23770. function isKeyValuePairInParenGroupNode(node) {
  23771. return node.type === "value-paren_group" && node.groups && node.groups[0] && isKeyValuePairNode$1(node.groups[0]);
  23772. }
  23773. function isSCSSMapItemNode$1(path$$1) {
  23774. var node = path$$1.getValue(); // Ignore empty item (i.e. `$key: ()`)
  23775. if (node.groups.length === 0) {
  23776. return false;
  23777. }
  23778. var parentParentNode = path$$1.getParentNode(1); // Check open parens contain key/value pair (i.e. `(key: value)` and `(key: (value, other-value)`)
  23779. if (!isKeyValuePairInParenGroupNode(node) && !(parentParentNode && isKeyValuePairInParenGroupNode(parentParentNode))) {
  23780. return false;
  23781. }
  23782. var declNode = getAncestorNode$1(path$$1, "css-decl"); // SCSS map declaration (i.e. `$map: (key: value, other-key: other-value)`)
  23783. if (declNode && declNode.prop && declNode.prop.startsWith("$")) {
  23784. return true;
  23785. } // List as value of key inside SCSS map (i.e. `$map: (key: (value other-value other-other-value))`)
  23786. if (isKeyValuePairInParenGroupNode(parentParentNode)) {
  23787. return true;
  23788. } // SCSS Map is argument of function (i.e. `func((key: value, other-key: other-value))`)
  23789. if (parentParentNode.type === "value-func") {
  23790. return true;
  23791. }
  23792. return false;
  23793. }
  23794. function isInlineValueCommentNode$1(node) {
  23795. return node.type === "value-comment" && node.inline;
  23796. }
  23797. function isHashNode$1(node) {
  23798. return node.type === "value-word" && node.value === "#";
  23799. }
  23800. function isLeftCurlyBraceNode$1(node) {
  23801. return node.type === "value-word" && node.value === "{";
  23802. }
  23803. function isRightCurlyBraceNode$1(node) {
  23804. return node.type === "value-word" && node.value === "}";
  23805. }
  23806. function isWordNode$1(node) {
  23807. return ["value-word", "value-atword"].indexOf(node.type) !== -1;
  23808. }
  23809. function isColonNode$1(node) {
  23810. return node.type === "value-colon";
  23811. }
  23812. function isMediaAndSupportsKeywords$1(node) {
  23813. return node.value && ["not", "and", "or"].indexOf(node.value.toLowerCase()) !== -1;
  23814. }
  23815. function isColorAdjusterFuncNode$1(node) {
  23816. if (node.type !== "value-func") {
  23817. return false;
  23818. }
  23819. return colorAdjusterFunctions.indexOf(node.value.toLowerCase()) !== -1;
  23820. }
  23821. var utils$6 = {
  23822. getAncestorCounter,
  23823. getAncestorNode: getAncestorNode$1,
  23824. getPropOfDeclNode: getPropOfDeclNode$1,
  23825. maybeToLowerCase: maybeToLowerCase$1,
  23826. insideValueFunctionNode: insideValueFunctionNode$1,
  23827. insideICSSRuleNode: insideICSSRuleNode$1,
  23828. insideAtRuleNode: insideAtRuleNode$1,
  23829. insideURLFunctionInImportAtRuleNode: insideURLFunctionInImportAtRuleNode$1,
  23830. isKeyframeAtRuleKeywords: isKeyframeAtRuleKeywords$1,
  23831. isHTMLTag: isHTMLTag$1,
  23832. isWideKeywords: isWideKeywords$1,
  23833. isSCSS: isSCSS$1,
  23834. isLastNode: isLastNode$1,
  23835. isSCSSControlDirectiveNode: isSCSSControlDirectiveNode$1,
  23836. isDetachedRulesetDeclarationNode: isDetachedRulesetDeclarationNode$1,
  23837. isRelationalOperatorNode: isRelationalOperatorNode$1,
  23838. isEqualityOperatorNode: isEqualityOperatorNode$1,
  23839. isMultiplicationNode: isMultiplicationNode$1,
  23840. isDivisionNode: isDivisionNode$1,
  23841. isAdditionNode: isAdditionNode$1,
  23842. isSubtractionNode: isSubtractionNode$1,
  23843. isModuloNode,
  23844. isMathOperatorNode: isMathOperatorNode$1,
  23845. isEachKeywordNode: isEachKeywordNode$1,
  23846. isForKeywordNode: isForKeywordNode$1,
  23847. isURLFunctionNode: isURLFunctionNode$1,
  23848. isIfElseKeywordNode: isIfElseKeywordNode$1,
  23849. hasComposesNode: hasComposesNode$1,
  23850. hasParensAroundNode: hasParensAroundNode$1,
  23851. hasEmptyRawBefore: hasEmptyRawBefore$1,
  23852. isSCSSNestedPropertyNode,
  23853. isDetachedRulesetCallNode: isDetachedRulesetCallNode$1,
  23854. isTemplatePlaceholderNode: isTemplatePlaceholderNode$1,
  23855. isTemplatePropNode: isTemplatePropNode$1,
  23856. isPostcssSimpleVarNode: isPostcssSimpleVarNode$1,
  23857. isKeyValuePairNode: isKeyValuePairNode$1,
  23858. isKeyValuePairInParenGroupNode,
  23859. isSCSSMapItemNode: isSCSSMapItemNode$1,
  23860. isInlineValueCommentNode: isInlineValueCommentNode$1,
  23861. isHashNode: isHashNode$1,
  23862. isLeftCurlyBraceNode: isLeftCurlyBraceNode$1,
  23863. isRightCurlyBraceNode: isRightCurlyBraceNode$1,
  23864. isWordNode: isWordNode$1,
  23865. isColonNode: isColonNode$1,
  23866. isMediaAndSupportsKeywords: isMediaAndSupportsKeywords$1,
  23867. isColorAdjusterFuncNode: isColorAdjusterFuncNode$1
  23868. };
  23869. var insertPragma$2 = pragma$2.insertPragma;
  23870. var printNumber$2 = util$1.printNumber;
  23871. var printString$2 = util$1.printString;
  23872. var hasIgnoreComment$2 = util$1.hasIgnoreComment;
  23873. var hasNewline$3 = util$1.hasNewline;
  23874. var isNextLineEmpty$3 = utilShared.isNextLineEmpty;
  23875. var _require$$3$builders = doc.builders;
  23876. var concat$8 = _require$$3$builders.concat;
  23877. var join$6 = _require$$3$builders.join;
  23878. var line$5 = _require$$3$builders.line;
  23879. var hardline$6 = _require$$3$builders.hardline;
  23880. var softline$3 = _require$$3$builders.softline;
  23881. var group$6 = _require$$3$builders.group;
  23882. var fill$3 = _require$$3$builders.fill;
  23883. var indent$5 = _require$$3$builders.indent;
  23884. var dedent$3 = _require$$3$builders.dedent;
  23885. var ifBreak$2 = _require$$3$builders.ifBreak;
  23886. var removeLines$2 = doc.utils.removeLines;
  23887. var getAncestorNode = utils$6.getAncestorNode;
  23888. var getPropOfDeclNode = utils$6.getPropOfDeclNode;
  23889. var maybeToLowerCase = utils$6.maybeToLowerCase;
  23890. var insideValueFunctionNode = utils$6.insideValueFunctionNode;
  23891. var insideICSSRuleNode = utils$6.insideICSSRuleNode;
  23892. var insideAtRuleNode = utils$6.insideAtRuleNode;
  23893. var insideURLFunctionInImportAtRuleNode = utils$6.insideURLFunctionInImportAtRuleNode;
  23894. var isKeyframeAtRuleKeywords = utils$6.isKeyframeAtRuleKeywords;
  23895. var isHTMLTag = utils$6.isHTMLTag;
  23896. var isWideKeywords = utils$6.isWideKeywords;
  23897. var isSCSS = utils$6.isSCSS;
  23898. var isLastNode = utils$6.isLastNode;
  23899. var isSCSSControlDirectiveNode = utils$6.isSCSSControlDirectiveNode;
  23900. var isDetachedRulesetDeclarationNode = utils$6.isDetachedRulesetDeclarationNode;
  23901. var isRelationalOperatorNode = utils$6.isRelationalOperatorNode;
  23902. var isEqualityOperatorNode = utils$6.isEqualityOperatorNode;
  23903. var isMultiplicationNode = utils$6.isMultiplicationNode;
  23904. var isDivisionNode = utils$6.isDivisionNode;
  23905. var isAdditionNode = utils$6.isAdditionNode;
  23906. var isSubtractionNode = utils$6.isSubtractionNode;
  23907. var isMathOperatorNode = utils$6.isMathOperatorNode;
  23908. var isEachKeywordNode = utils$6.isEachKeywordNode;
  23909. var isForKeywordNode = utils$6.isForKeywordNode;
  23910. var isURLFunctionNode = utils$6.isURLFunctionNode;
  23911. var isIfElseKeywordNode = utils$6.isIfElseKeywordNode;
  23912. var hasComposesNode = utils$6.hasComposesNode;
  23913. var hasParensAroundNode = utils$6.hasParensAroundNode;
  23914. var hasEmptyRawBefore = utils$6.hasEmptyRawBefore;
  23915. var isKeyValuePairNode = utils$6.isKeyValuePairNode;
  23916. var isDetachedRulesetCallNode = utils$6.isDetachedRulesetCallNode;
  23917. var isTemplatePlaceholderNode = utils$6.isTemplatePlaceholderNode;
  23918. var isTemplatePropNode = utils$6.isTemplatePropNode;
  23919. var isPostcssSimpleVarNode = utils$6.isPostcssSimpleVarNode;
  23920. var isSCSSMapItemNode = utils$6.isSCSSMapItemNode;
  23921. var isInlineValueCommentNode = utils$6.isInlineValueCommentNode;
  23922. var isHashNode = utils$6.isHashNode;
  23923. var isLeftCurlyBraceNode = utils$6.isLeftCurlyBraceNode;
  23924. var isRightCurlyBraceNode = utils$6.isRightCurlyBraceNode;
  23925. var isWordNode = utils$6.isWordNode;
  23926. var isColonNode = utils$6.isColonNode;
  23927. var isMediaAndSupportsKeywords = utils$6.isMediaAndSupportsKeywords;
  23928. var isColorAdjusterFuncNode = utils$6.isColorAdjusterFuncNode;
  23929. function shouldPrintComma$1(options) {
  23930. switch (options.trailingComma) {
  23931. case "all":
  23932. case "es5":
  23933. return true;
  23934. case "none":
  23935. default:
  23936. return false;
  23937. }
  23938. }
  23939. function genericPrint$2(path$$1, options, print) {
  23940. var node = path$$1.getValue();
  23941. /* istanbul ignore if */
  23942. if (!node) {
  23943. return "";
  23944. }
  23945. if (typeof node === "string") {
  23946. return node;
  23947. }
  23948. switch (node.type) {
  23949. case "yaml":
  23950. case "toml":
  23951. return concat$8([node.raw, hardline$6]);
  23952. case "css-root":
  23953. {
  23954. var nodes = printNodeSequence(path$$1, options, print);
  23955. if (nodes.parts.length) {
  23956. return concat$8([nodes, hardline$6]);
  23957. }
  23958. return nodes;
  23959. }
  23960. case "css-comment":
  23961. {
  23962. if (node.raws.content) {
  23963. return node.raws.content;
  23964. }
  23965. var text = options.originalText.slice(options.locStart(node), options.locEnd(node));
  23966. var rawText = node.raws.text || node.text; // Workaround a bug where the location is off.
  23967. // https://github.com/postcss/postcss-scss/issues/63
  23968. if (text.indexOf(rawText) === -1) {
  23969. if (node.raws.inline) {
  23970. return concat$8(["// ", rawText]);
  23971. }
  23972. return concat$8(["/* ", rawText, " */"]);
  23973. }
  23974. return text;
  23975. }
  23976. case "css-rule":
  23977. {
  23978. return concat$8([path$$1.call(print, "selector"), node.important ? " !important" : "", node.nodes ? concat$8([" {", node.nodes.length > 0 ? indent$5(concat$8([hardline$6, printNodeSequence(path$$1, options, print)])) : "", hardline$6, "}", isDetachedRulesetDeclarationNode(node) ? ";" : ""]) : ";"]);
  23979. }
  23980. case "css-decl":
  23981. {
  23982. var parentNode = path$$1.getParentNode();
  23983. return concat$8([node.raws.before.replace(/[\s;]/g, ""), insideICSSRuleNode(path$$1) ? node.prop : maybeToLowerCase(node.prop), node.raws.between.trim() === ":" ? ":" : node.raws.between.trim(), node.extend ? "" : " ", hasComposesNode(node) ? removeLines$2(path$$1.call(print, "value")) : path$$1.call(print, "value"), node.raws.important ? node.raws.important.replace(/\s*!\s*important/i, " !important") : node.important ? " !important" : "", node.raws.scssDefault ? node.raws.scssDefault.replace(/\s*!default/i, " !default") : node.scssDefault ? " !default" : "", node.raws.scssGlobal ? node.raws.scssGlobal.replace(/\s*!global/i, " !global") : node.scssGlobal ? " !global" : "", node.nodes ? concat$8([" {", indent$5(concat$8([softline$3, printNodeSequence(path$$1, options, print)])), softline$3, "}"]) : isTemplatePropNode(node) && !parentNode.raws.semicolon && options.originalText[options.locEnd(node) - 1] !== ";" ? "" : ";"]);
  23984. }
  23985. case "css-atrule":
  23986. {
  23987. var _parentNode = path$$1.getParentNode();
  23988. return concat$8(["@", // If a Less file ends up being parsed with the SCSS parser, Less
  23989. // variable declarations will be parsed as at-rules with names ending
  23990. // with a colon, so keep the original case then.
  23991. isDetachedRulesetCallNode(node) || node.name.endsWith(":") ? node.name : maybeToLowerCase(node.name), node.params ? concat$8([isDetachedRulesetCallNode(node) ? "" : isTemplatePlaceholderNode(node) && /^\s*\n/.test(node.raws.afterName) ? /^\s*\n\s*\n/.test(node.raws.afterName) ? concat$8([hardline$6, hardline$6]) : hardline$6 : " ", path$$1.call(print, "params")]) : "", node.selector ? indent$5(concat$8([" ", path$$1.call(print, "selector")])) : "", node.value ? group$6(concat$8([" ", path$$1.call(print, "value"), isSCSSControlDirectiveNode(node) ? hasParensAroundNode(node) ? " " : line$5 : ""])) : node.name === "else" ? " " : "", node.nodes ? concat$8([isSCSSControlDirectiveNode(node) ? "" : " ", "{", indent$5(concat$8([node.nodes.length > 0 ? softline$3 : "", printNodeSequence(path$$1, options, print)])), softline$3, "}"]) : isTemplatePlaceholderNode(node) && !_parentNode.raws.semicolon && options.originalText[options.locEnd(node) - 1] !== ";" ? "" : ";"]);
  23992. }
  23993. // postcss-media-query-parser
  23994. case "media-query-list":
  23995. {
  23996. var parts = [];
  23997. path$$1.each(function (childPath) {
  23998. var node = childPath.getValue();
  23999. if (node.type === "media-query" && node.value === "") {
  24000. return;
  24001. }
  24002. parts.push(childPath.call(print));
  24003. }, "nodes");
  24004. return group$6(indent$5(join$6(line$5, parts)));
  24005. }
  24006. case "media-query":
  24007. {
  24008. return concat$8([join$6(" ", path$$1.map(print, "nodes")), isLastNode(path$$1, node) ? "" : ","]);
  24009. }
  24010. case "media-type":
  24011. {
  24012. return adjustNumbers(adjustStrings(node.value, options));
  24013. }
  24014. case "media-feature-expression":
  24015. {
  24016. if (!node.nodes) {
  24017. return node.value;
  24018. }
  24019. return concat$8(["(", concat$8(path$$1.map(print, "nodes")), ")"]);
  24020. }
  24021. case "media-feature":
  24022. {
  24023. return maybeToLowerCase(adjustStrings(node.value.replace(/ +/g, " "), options));
  24024. }
  24025. case "media-colon":
  24026. {
  24027. return concat$8([node.value, " "]);
  24028. }
  24029. case "media-value":
  24030. {
  24031. return adjustNumbers(adjustStrings(node.value, options));
  24032. }
  24033. case "media-keyword":
  24034. {
  24035. return adjustStrings(node.value, options);
  24036. }
  24037. case "media-url":
  24038. {
  24039. return adjustStrings(node.value.replace(/^url\(\s+/gi, "url(").replace(/\s+\)$/gi, ")"), options);
  24040. }
  24041. case "media-unknown":
  24042. {
  24043. return node.value;
  24044. }
  24045. // postcss-selector-parser
  24046. case "selector-root":
  24047. {
  24048. return group$6(concat$8([insideAtRuleNode(path$$1, "custom-selector") ? concat$8([getAncestorNode(path$$1, "css-atrule").customSelector, line$5]) : "", join$6(concat$8([",", insideAtRuleNode(path$$1, ["extend", "custom-selector", "nest"]) ? line$5 : hardline$6]), path$$1.map(print, "nodes"))]));
  24049. }
  24050. case "selector-selector":
  24051. {
  24052. return group$6(indent$5(concat$8(path$$1.map(print, "nodes"))));
  24053. }
  24054. case "selector-comment":
  24055. {
  24056. return node.value;
  24057. }
  24058. case "selector-string":
  24059. {
  24060. return adjustStrings(node.value, options);
  24061. }
  24062. case "selector-tag":
  24063. {
  24064. var _parentNode2 = path$$1.getParentNode();
  24065. var index = _parentNode2 && _parentNode2.nodes.indexOf(node);
  24066. var prevNode = index && _parentNode2.nodes[index - 1];
  24067. return concat$8([node.namespace ? concat$8([node.namespace === true ? "" : node.namespace.trim(), "|"]) : "", prevNode.type === "selector-nesting" ? node.value : adjustNumbers(isHTMLTag(node.value) || isKeyframeAtRuleKeywords(path$$1, node.value) ? node.value.toLowerCase() : node.value)]);
  24068. }
  24069. case "selector-id":
  24070. {
  24071. return concat$8(["#", node.value]);
  24072. }
  24073. case "selector-class":
  24074. {
  24075. return concat$8([".", adjustNumbers(adjustStrings(node.value, options))]);
  24076. }
  24077. case "selector-attribute":
  24078. {
  24079. return concat$8(["[", node.namespace ? concat$8([node.namespace === true ? "" : node.namespace.trim(), "|"]) : "", node.attribute.trim(), node.operator ? node.operator : "", node.value ? quoteAttributeValue(adjustStrings(node.value.trim(), options), options) : "", node.insensitive ? " i" : "", "]"]);
  24080. }
  24081. case "selector-combinator":
  24082. {
  24083. if (node.value === "+" || node.value === ">" || node.value === "~" || node.value === ">>>") {
  24084. var _parentNode3 = path$$1.getParentNode();
  24085. var _leading = _parentNode3.type === "selector-selector" && _parentNode3.nodes[0] === node ? "" : line$5;
  24086. return concat$8([_leading, node.value, isLastNode(path$$1, node) ? "" : " "]);
  24087. }
  24088. var leading = node.value.trim().startsWith("(") ? line$5 : "";
  24089. var value = adjustNumbers(adjustStrings(node.value.trim(), options)) || line$5;
  24090. return concat$8([leading, value]);
  24091. }
  24092. case "selector-universal":
  24093. {
  24094. return concat$8([node.namespace ? concat$8([node.namespace === true ? "" : node.namespace.trim(), "|"]) : "", node.value]);
  24095. }
  24096. case "selector-pseudo":
  24097. {
  24098. return concat$8([maybeToLowerCase(node.value), node.nodes && node.nodes.length > 0 ? concat$8(["(", join$6(", ", path$$1.map(print, "nodes")), ")"]) : ""]);
  24099. }
  24100. case "selector-nesting":
  24101. {
  24102. return node.value;
  24103. }
  24104. case "selector-unknown":
  24105. {
  24106. var ruleAncestorNode = getAncestorNode(path$$1, "css-rule"); // Nested SCSS property
  24107. if (ruleAncestorNode && ruleAncestorNode.isSCSSNesterProperty) {
  24108. return adjustNumbers(adjustStrings(maybeToLowerCase(node.value), options));
  24109. }
  24110. return node.value;
  24111. }
  24112. // postcss-values-parser
  24113. case "value-value":
  24114. case "value-root":
  24115. {
  24116. return path$$1.call(print, "group");
  24117. }
  24118. case "value-comment":
  24119. {
  24120. return concat$8([node.inline ? "//" : "/*", node.value, node.inline ? "" : "*/"]);
  24121. }
  24122. case "value-comma_group":
  24123. {
  24124. var _parentNode4 = path$$1.getParentNode();
  24125. var parentParentNode = path$$1.getParentNode(1);
  24126. var declAncestorProp = getPropOfDeclNode(path$$1);
  24127. var isGridValue = declAncestorProp && _parentNode4.type === "value-value" && (declAncestorProp === "grid" || declAncestorProp.startsWith("grid-template"));
  24128. var atRuleAncestorNode = getAncestorNode(path$$1, "css-atrule");
  24129. var isControlDirective = atRuleAncestorNode && isSCSSControlDirectiveNode(atRuleAncestorNode);
  24130. var printed = path$$1.map(print, "groups");
  24131. var _parts = [];
  24132. var insideURLFunction = insideValueFunctionNode(path$$1, "url");
  24133. var insideSCSSInterpolationInString = false;
  24134. var didBreak = false;
  24135. for (var i = 0; i < node.groups.length; ++i) {
  24136. _parts.push(printed[i]); // Ignore value inside `url()`
  24137. if (insideURLFunction) {
  24138. continue;
  24139. }
  24140. var iPrevNode = node.groups[i - 1];
  24141. var iNode = node.groups[i];
  24142. var iNextNode = node.groups[i + 1];
  24143. var iNextNextNode = node.groups[i + 2]; // Ignore after latest node (i.e. before semicolon)
  24144. if (!iNextNode) {
  24145. continue;
  24146. } // Ignore spaces before/after string interpolation (i.e. `"#{my-fn("_")}"`)
  24147. var isStartSCSSinterpolationInString = iNode.type === "value-string" && iNode.value.startsWith("#{");
  24148. var isEndingSCSSinterpolationInString = insideSCSSInterpolationInString && iNextNode.type === "value-string" && iNextNode.value.endsWith("}");
  24149. if (isStartSCSSinterpolationInString || isEndingSCSSinterpolationInString) {
  24150. insideSCSSInterpolationInString = !insideSCSSInterpolationInString;
  24151. continue;
  24152. }
  24153. if (insideSCSSInterpolationInString) {
  24154. continue;
  24155. } // Ignore colon (i.e. `:`)
  24156. if (isColonNode(iNode) || isColonNode(iNextNode)) {
  24157. continue;
  24158. } // Ignore `@` in Less (i.e. `@@var;`)
  24159. if (iNode.type === "value-atword" && iNode.value === "") {
  24160. continue;
  24161. } // Ignore `~` in Less (i.e. `content: ~"^//* some horrible but needed css hack";`)
  24162. if (iNode.value === "~") {
  24163. continue;
  24164. } // Ignore escape `\`
  24165. if (iNode.value && iNode.value.indexOf("\\") !== -1 && iNextNode && iNextNode.type !== "value-comment") {
  24166. continue;
  24167. } // Ignore escaped `/`
  24168. if (iPrevNode && iPrevNode.value && iPrevNode.value.indexOf("\\") === iPrevNode.value.length - 1 && iNode.type === "value-operator" && iNode.value === "/") {
  24169. continue;
  24170. } // Ignore `\` (i.e. `$variable: \@small;`)
  24171. if (iNode.value === "\\") {
  24172. continue;
  24173. } // Ignore `$$` (i.e. `background-color: $$(style)Color;`)
  24174. if (isPostcssSimpleVarNode(iNode, iNextNode)) {
  24175. continue;
  24176. } // Ignore spaces after `#` and after `{` and before `}` in SCSS interpolation (i.e. `#{variable}`)
  24177. if (isHashNode(iNode) || isLeftCurlyBraceNode(iNode) || isRightCurlyBraceNode(iNextNode) || isLeftCurlyBraceNode(iNextNode) && hasEmptyRawBefore(iNextNode) || isRightCurlyBraceNode(iNode) && hasEmptyRawBefore(iNextNode)) {
  24178. continue;
  24179. } // Ignore css variables and interpolation in SCSS (i.e. `--#{$var}`)
  24180. if (iNode.value === "--" && isHashNode(iNextNode)) {
  24181. continue;
  24182. } // Formatting math operations
  24183. var isMathOperator = isMathOperatorNode(iNode);
  24184. var isNextMathOperator = isMathOperatorNode(iNextNode); // Print spaces before and after math operators beside SCSS interpolation as is
  24185. // (i.e. `#{$var}+5`, `#{$var} +5`, `#{$var}+ 5`, `#{$var} + 5`)
  24186. // (i.e. `5+#{$var}`, `5 +#{$var}`, `5+ #{$var}`, `5 + #{$var}`)
  24187. if ((isMathOperator && isHashNode(iNextNode) || isNextMathOperator && isRightCurlyBraceNode(iNode)) && hasEmptyRawBefore(iNextNode)) {
  24188. continue;
  24189. } // Print spaces before and after addition and subtraction math operators as is in `calc` function
  24190. // due to the fact that it is not valid syntax
  24191. // (i.e. `calc(1px+1px)`, `calc(1px+ 1px)`, `calc(1px +1px)`, `calc(1px + 1px)`)
  24192. if (insideValueFunctionNode(path$$1, "calc") && (isAdditionNode(iNode) || isAdditionNode(iNextNode) || isSubtractionNode(iNode) || isSubtractionNode(iNextNode)) && hasEmptyRawBefore(iNextNode)) {
  24193. continue;
  24194. } // Print spaces after `+` and `-` in color adjuster functions as is (e.g. `color(red l(+ 20%))`)
  24195. // Adjusters with signed numbers (e.g. `color(red l(+20%))`) output as-is.
  24196. var isColorAdjusterNode = (isAdditionNode(iNode) || isSubtractionNode(iNode)) && i === 0 && (iNextNode.type === "value-number" || iNextNode.isHex) && parentParentNode && isColorAdjusterFuncNode(parentParentNode) && !hasEmptyRawBefore(iNextNode);
  24197. var requireSpaceBeforeOperator = iNextNextNode && iNextNextNode.type === "value-func" || iNextNextNode && isWordNode(iNextNextNode) || iNode.type === "value-func" || isWordNode(iNode);
  24198. var requireSpaceAfterOperator = iNextNode.type === "value-func" || isWordNode(iNextNode) || iPrevNode && iPrevNode.type === "value-func" || iPrevNode && isWordNode(iPrevNode); // Formatting `/`, `+`, `-` sign
  24199. if (!(isMultiplicationNode(iNextNode) || isMultiplicationNode(iNode)) && !insideValueFunctionNode(path$$1, "calc") && !isColorAdjusterNode && (isDivisionNode(iNextNode) && !requireSpaceBeforeOperator || isDivisionNode(iNode) && !requireSpaceAfterOperator || isAdditionNode(iNextNode) && !requireSpaceBeforeOperator || isAdditionNode(iNode) && !requireSpaceAfterOperator || isSubtractionNode(iNextNode) || isSubtractionNode(iNode)) && (hasEmptyRawBefore(iNextNode) || isMathOperator && (!iPrevNode || iPrevNode && isMathOperatorNode(iPrevNode)))) {
  24200. continue;
  24201. } // Add `hardline` after inline comment (i.e. `// comment\n foo: bar;`)
  24202. if (isInlineValueCommentNode(iNode)) {
  24203. _parts.push(hardline$6);
  24204. continue;
  24205. } // Handle keywords in SCSS control directive
  24206. if (isControlDirective && (isEqualityOperatorNode(iNextNode) || isRelationalOperatorNode(iNextNode) || isIfElseKeywordNode(iNextNode) || isEachKeywordNode(iNode) || isForKeywordNode(iNode))) {
  24207. _parts.push(" ");
  24208. continue;
  24209. } // At-rule `namespace` should be in one line
  24210. if (atRuleAncestorNode && atRuleAncestorNode.name.toLowerCase() === "namespace") {
  24211. _parts.push(" ");
  24212. continue;
  24213. } // Formatting `grid` property
  24214. if (isGridValue) {
  24215. if (iNode.source && iNextNode.source && iNode.source.start.line !== iNextNode.source.start.line) {
  24216. _parts.push(hardline$6);
  24217. didBreak = true;
  24218. } else {
  24219. _parts.push(" ");
  24220. }
  24221. continue;
  24222. } // Add `space` before next math operation
  24223. // Note: `grip` property have `/` delimiter and it is not math operation, so
  24224. // `grid` property handles above
  24225. if (isNextMathOperator) {
  24226. _parts.push(" ");
  24227. continue;
  24228. } // Be default all values go through `line`
  24229. _parts.push(line$5);
  24230. }
  24231. if (didBreak) {
  24232. _parts.unshift(hardline$6);
  24233. }
  24234. if (isControlDirective) {
  24235. return group$6(indent$5(concat$8(_parts)));
  24236. } // Indent is not needed for import url when url is very long
  24237. // and node has two groups
  24238. // when type is value-comma_group
  24239. // example @import url("verylongurl") projection,tv
  24240. if (insideURLFunctionInImportAtRuleNode(path$$1)) {
  24241. return group$6(fill$3(_parts));
  24242. }
  24243. return group$6(indent$5(fill$3(_parts)));
  24244. }
  24245. case "value-paren_group":
  24246. {
  24247. var _parentNode5 = path$$1.getParentNode();
  24248. if (_parentNode5 && isURLFunctionNode(_parentNode5) && (node.groups.length === 1 || node.groups.length > 0 && node.groups[0].type === "value-comma_group" && node.groups[0].groups.length > 0 && node.groups[0].groups[0].type === "value-word" && node.groups[0].groups[0].value.startsWith("data:"))) {
  24249. return concat$8([node.open ? path$$1.call(print, "open") : "", join$6(",", path$$1.map(print, "groups")), node.close ? path$$1.call(print, "close") : ""]);
  24250. }
  24251. if (!node.open) {
  24252. var _printed = path$$1.map(print, "groups");
  24253. var res = [];
  24254. for (var _i = 0; _i < _printed.length; _i++) {
  24255. if (_i !== 0) {
  24256. res.push(concat$8([",", line$5]));
  24257. }
  24258. res.push(_printed[_i]);
  24259. }
  24260. return group$6(indent$5(fill$3(res)));
  24261. }
  24262. var isSCSSMapItem = isSCSSMapItemNode(path$$1);
  24263. return group$6(concat$8([node.open ? path$$1.call(print, "open") : "", indent$5(concat$8([softline$3, join$6(concat$8([",", line$5]), path$$1.map(function (childPath) {
  24264. var node = childPath.getValue();
  24265. var printed = print(childPath); // Key/Value pair in open paren already indented
  24266. if (isKeyValuePairNode(node) && node.type === "value-comma_group" && node.groups && node.groups[2] && node.groups[2].type === "value-paren_group") {
  24267. printed.contents.contents.parts[1] = group$6(printed.contents.contents.parts[1]);
  24268. return group$6(dedent$3(printed));
  24269. }
  24270. return printed;
  24271. }, "groups"))])), ifBreak$2(isSCSS(options.parser, options.originalText) && isSCSSMapItem && shouldPrintComma$1(options) ? "," : ""), softline$3, node.close ? path$$1.call(print, "close") : ""]), {
  24272. shouldBreak: isSCSSMapItem
  24273. });
  24274. }
  24275. case "value-func":
  24276. {
  24277. return concat$8([node.value, insideAtRuleNode(path$$1, "supports") && isMediaAndSupportsKeywords(node) ? " " : "", path$$1.call(print, "group")]);
  24278. }
  24279. case "value-paren":
  24280. {
  24281. return node.value;
  24282. }
  24283. case "value-number":
  24284. {
  24285. return concat$8([printCssNumber(node.value), maybeToLowerCase(node.unit)]);
  24286. }
  24287. case "value-operator":
  24288. {
  24289. return node.value;
  24290. }
  24291. case "value-word":
  24292. {
  24293. if (node.isColor && node.isHex || isWideKeywords(node.value)) {
  24294. return node.value.toLowerCase();
  24295. }
  24296. return node.value;
  24297. }
  24298. case "value-colon":
  24299. {
  24300. return concat$8([node.value, // Don't add spaces on `:` in `url` function (i.e. `url(fbglyph: cross-outline, fig-white)`)
  24301. insideValueFunctionNode(path$$1, "url") ? "" : line$5]);
  24302. }
  24303. case "value-comma":
  24304. {
  24305. return concat$8([node.value, " "]);
  24306. }
  24307. case "value-string":
  24308. {
  24309. return printString$2(node.raws.quote + node.value + node.raws.quote, options);
  24310. }
  24311. case "value-atword":
  24312. {
  24313. return concat$8(["@", node.value]);
  24314. }
  24315. case "value-unicode-range":
  24316. {
  24317. return node.value;
  24318. }
  24319. case "value-unknown":
  24320. {
  24321. return node.value;
  24322. }
  24323. default:
  24324. /* istanbul ignore next */
  24325. throw new Error(`Unknown postcss type ${JSON.stringify(node.type)}`);
  24326. }
  24327. }
  24328. function printNodeSequence(path$$1, options, print) {
  24329. var node = path$$1.getValue();
  24330. var parts = [];
  24331. var i = 0;
  24332. path$$1.map(function (pathChild) {
  24333. var prevNode = node.nodes[i - 1];
  24334. if (prevNode && prevNode.type === "css-comment" && prevNode.text.trim() === "prettier-ignore") {
  24335. var childNode = pathChild.getValue();
  24336. parts.push(options.originalText.slice(options.locStart(childNode), options.locEnd(childNode)));
  24337. } else {
  24338. parts.push(pathChild.call(print));
  24339. }
  24340. if (i !== node.nodes.length - 1) {
  24341. if (node.nodes[i + 1].type === "css-comment" && !hasNewline$3(options.originalText, options.locStart(node.nodes[i + 1]), {
  24342. backwards: true
  24343. }) && node.nodes[i].type !== "yaml" && node.nodes[i].type !== "toml" || node.nodes[i + 1].type === "css-atrule" && node.nodes[i + 1].name === "else" && node.nodes[i].type !== "css-comment") {
  24344. parts.push(" ");
  24345. } else {
  24346. parts.push(hardline$6);
  24347. if (isNextLineEmpty$3(options.originalText, pathChild.getValue(), options) && node.nodes[i].type !== "yaml" && node.nodes[i].type !== "toml") {
  24348. parts.push(hardline$6);
  24349. }
  24350. }
  24351. }
  24352. i++;
  24353. }, "nodes");
  24354. return concat$8(parts);
  24355. }
  24356. var STRING_REGEX = /(['"])(?:(?!\1)[^\\]|\\[\s\S])*\1/g;
  24357. var NUMBER_REGEX = /(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/g;
  24358. var STANDARD_UNIT_REGEX = /[a-zA-Z]+/g;
  24359. var WORD_PART_REGEX = /[$@]?[a-zA-Z_\u0080-\uFFFF][\w\-\u0080-\uFFFF]*/g;
  24360. var ADJUST_NUMBERS_REGEX = RegExp(STRING_REGEX.source + `|` + `(${WORD_PART_REGEX.source})?` + `(${NUMBER_REGEX.source})` + `(${STANDARD_UNIT_REGEX.source})?`, "g");
  24361. function adjustStrings(value, options) {
  24362. return value.replace(STRING_REGEX, function (match) {
  24363. return printString$2(match, options);
  24364. });
  24365. }
  24366. function quoteAttributeValue(value, options) {
  24367. var quote = options.singleQuote ? "'" : '"';
  24368. return value.includes('"') || value.includes("'") ? value : quote + value + quote;
  24369. }
  24370. function adjustNumbers(value) {
  24371. return value.replace(ADJUST_NUMBERS_REGEX, function (match, quote, wordPart, number, unit) {
  24372. return !wordPart && number ? (wordPart || "") + printCssNumber(number) + maybeToLowerCase(unit || "") : match;
  24373. });
  24374. }
  24375. function printCssNumber(rawNumber) {
  24376. return printNumber$2(rawNumber) // Remove trailing `.0`.
  24377. .replace(/\.0(?=$|e)/, "");
  24378. }
  24379. var printerPostcss = {
  24380. print: genericPrint$2,
  24381. embed: embed_1$2,
  24382. insertPragma: insertPragma$2,
  24383. hasPrettierIgnore: hasIgnoreComment$2,
  24384. massageAstNode: clean_1$2
  24385. };
  24386. var options$7 = {
  24387. singleQuote: commonOptions.singleQuote
  24388. };
  24389. var name$7 = "CSS";
  24390. var type$6 = "markup";
  24391. var tmScope$6 = "source.css";
  24392. var aceMode$6 = "css";
  24393. var codemirrorMode$6 = "css";
  24394. var codemirrorMimeType$6 = "text/css";
  24395. var color$2 = "#563d7c";
  24396. var extensions$6 = [".css"];
  24397. var languageId$6 = 50;
  24398. var css$2 = {
  24399. name: name$7,
  24400. type: type$6,
  24401. tmScope: tmScope$6,
  24402. aceMode: aceMode$6,
  24403. codemirrorMode: codemirrorMode$6,
  24404. codemirrorMimeType: codemirrorMimeType$6,
  24405. color: color$2,
  24406. extensions: extensions$6,
  24407. languageId: languageId$6
  24408. };
  24409. var css$3 = Object.freeze({
  24410. name: name$7,
  24411. type: type$6,
  24412. tmScope: tmScope$6,
  24413. aceMode: aceMode$6,
  24414. codemirrorMode: codemirrorMode$6,
  24415. codemirrorMimeType: codemirrorMimeType$6,
  24416. color: color$2,
  24417. extensions: extensions$6,
  24418. languageId: languageId$6,
  24419. default: css$2
  24420. });
  24421. var name$8 = "PostCSS";
  24422. var type$7 = "markup";
  24423. var tmScope$7 = "source.postcss";
  24424. var group$7 = "CSS";
  24425. var extensions$7 = [".pcss"];
  24426. var aceMode$7 = "text";
  24427. var languageId$7 = 262764437;
  24428. var postcss = {
  24429. name: name$8,
  24430. type: type$7,
  24431. tmScope: tmScope$7,
  24432. group: group$7,
  24433. extensions: extensions$7,
  24434. aceMode: aceMode$7,
  24435. languageId: languageId$7
  24436. };
  24437. var postcss$1 = Object.freeze({
  24438. name: name$8,
  24439. type: type$7,
  24440. tmScope: tmScope$7,
  24441. group: group$7,
  24442. extensions: extensions$7,
  24443. aceMode: aceMode$7,
  24444. languageId: languageId$7,
  24445. default: postcss
  24446. });
  24447. var name$9 = "Less";
  24448. var type$8 = "markup";
  24449. var group$8 = "CSS";
  24450. var extensions$8 = [".less"];
  24451. var tmScope$8 = "source.css.less";
  24452. var aceMode$8 = "less";
  24453. var codemirrorMode$7 = "css";
  24454. var codemirrorMimeType$7 = "text/css";
  24455. var languageId$8 = 198;
  24456. var less = {
  24457. name: name$9,
  24458. type: type$8,
  24459. group: group$8,
  24460. extensions: extensions$8,
  24461. tmScope: tmScope$8,
  24462. aceMode: aceMode$8,
  24463. codemirrorMode: codemirrorMode$7,
  24464. codemirrorMimeType: codemirrorMimeType$7,
  24465. languageId: languageId$8
  24466. };
  24467. var less$1 = Object.freeze({
  24468. name: name$9,
  24469. type: type$8,
  24470. group: group$8,
  24471. extensions: extensions$8,
  24472. tmScope: tmScope$8,
  24473. aceMode: aceMode$8,
  24474. codemirrorMode: codemirrorMode$7,
  24475. codemirrorMimeType: codemirrorMimeType$7,
  24476. languageId: languageId$8,
  24477. default: less
  24478. });
  24479. var name$10 = "SCSS";
  24480. var type$9 = "markup";
  24481. var tmScope$9 = "source.scss";
  24482. var group$9 = "CSS";
  24483. var aceMode$9 = "scss";
  24484. var codemirrorMode$8 = "css";
  24485. var codemirrorMimeType$8 = "text/x-scss";
  24486. var extensions$9 = [".scss"];
  24487. var languageId$9 = 329;
  24488. var scss = {
  24489. name: name$10,
  24490. type: type$9,
  24491. tmScope: tmScope$9,
  24492. group: group$9,
  24493. aceMode: aceMode$9,
  24494. codemirrorMode: codemirrorMode$8,
  24495. codemirrorMimeType: codemirrorMimeType$8,
  24496. extensions: extensions$9,
  24497. languageId: languageId$9
  24498. };
  24499. var scss$1 = Object.freeze({
  24500. name: name$10,
  24501. type: type$9,
  24502. tmScope: tmScope$9,
  24503. group: group$9,
  24504. aceMode: aceMode$9,
  24505. codemirrorMode: codemirrorMode$8,
  24506. codemirrorMimeType: codemirrorMimeType$8,
  24507. extensions: extensions$9,
  24508. languageId: languageId$9,
  24509. default: scss
  24510. });
  24511. var require$$0$23 = ( css$3 && css$2 ) || css$3;
  24512. var require$$1$10 = ( postcss$1 && postcss ) || postcss$1;
  24513. var require$$2$11 = ( less$1 && less ) || less$1;
  24514. var require$$3$4 = ( scss$1 && scss ) || scss$1;
  24515. var languages$1 = [createLanguage(require$$0$23, {
  24516. override: {
  24517. since: "1.4.0",
  24518. parsers: ["css"],
  24519. vscodeLanguageIds: ["css"]
  24520. }
  24521. }), createLanguage(require$$1$10, {
  24522. override: {
  24523. since: "1.4.0",
  24524. parsers: ["css"],
  24525. vscodeLanguageIds: ["postcss"]
  24526. },
  24527. extend: {
  24528. extensions: [".postcss"]
  24529. }
  24530. }), createLanguage(require$$2$11, {
  24531. override: {
  24532. since: "1.4.0",
  24533. parsers: ["less"],
  24534. vscodeLanguageIds: ["less"]
  24535. }
  24536. }), createLanguage(require$$3$4, {
  24537. override: {
  24538. since: "1.4.0",
  24539. parsers: ["scss"],
  24540. vscodeLanguageIds: ["scss"]
  24541. }
  24542. })];
  24543. var printers$1 = {
  24544. postcss: printerPostcss
  24545. };
  24546. var languageCss = {
  24547. languages: languages$1,
  24548. options: options$7,
  24549. printers: printers$1
  24550. };
  24551. var _require$$0$builders$4 = doc.builders;
  24552. var concat$10 = _require$$0$builders$4.concat;
  24553. var join$7 = _require$$0$builders$4.join;
  24554. var softline$4 = _require$$0$builders$4.softline;
  24555. var hardline$8 = _require$$0$builders$4.hardline;
  24556. var line$6 = _require$$0$builders$4.line;
  24557. var group$10 = _require$$0$builders$4.group;
  24558. var indent$6 = _require$$0$builders$4.indent;
  24559. var ifBreak$3 = _require$$0$builders$4.ifBreak; // http://w3c.github.io/html/single-page.html#void-elements
  24560. var voidTags = ["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]; // Formatter based on @glimmerjs/syntax's built-in test formatter:
  24561. // https://github.com/glimmerjs/glimmer-vm/blob/master/packages/%40glimmer/syntax/lib/generation/print.ts
  24562. function print(path$$1, options, print) {
  24563. var n = path$$1.getValue();
  24564. /* istanbul ignore if*/
  24565. if (!n) {
  24566. return "";
  24567. }
  24568. switch (n.type) {
  24569. case "Program":
  24570. {
  24571. return group$10(join$7(softline$4, path$$1.map(print, "body").filter(function (text) {
  24572. return text !== "";
  24573. })));
  24574. }
  24575. case "ElementNode":
  24576. {
  24577. var tagFirstChar = n.tag[0];
  24578. var isLocal = n.tag.indexOf(".") !== -1;
  24579. var isGlimmerComponent = tagFirstChar.toUpperCase() === tagFirstChar || isLocal;
  24580. var hasChildren = n.children.length > 0;
  24581. var isVoid = isGlimmerComponent && !hasChildren || voidTags.indexOf(n.tag) !== -1;
  24582. var closeTag = isVoid ? concat$10([" />", softline$4]) : ">";
  24583. var _getParams = function _getParams(path$$1, print) {
  24584. return indent$6(concat$10([n.attributes.length ? line$6 : "", join$7(line$6, path$$1.map(print, "attributes")), n.modifiers.length ? line$6 : "", join$7(line$6, path$$1.map(print, "modifiers")), n.comments.length ? line$6 : "", join$7(line$6, path$$1.map(print, "comments"))]));
  24585. }; // The problem here is that I want to not break at all if the children
  24586. // would not break but I need to force an indent, so I use a hardline.
  24587. /**
  24588. * What happens now:
  24589. * <div>
  24590. * Hello
  24591. * </div>
  24592. * ==>
  24593. * <div>Hello</div>
  24594. * This is due to me using hasChildren to decide to put the hardline in.
  24595. * I would rather use a {DOES THE WHOLE THING NEED TO BREAK}
  24596. */
  24597. return concat$10([group$10(concat$10(["<", n.tag, _getParams(path$$1, print), n.blockParams.length ? ` as |${n.blockParams.join(" ")}|` : "", ifBreak$3(softline$4, ""), closeTag])), group$10(concat$10([indent$6(join$7(softline$4, [""].concat(path$$1.map(print, "children")))), ifBreak$3(hasChildren ? hardline$8 : "", ""), !isVoid ? concat$10(["</", n.tag, ">"]) : ""]))]);
  24598. }
  24599. case "BlockStatement":
  24600. {
  24601. var pp = path$$1.getParentNode(1);
  24602. var isElseIf = pp && pp.inverse && pp.inverse.body[0] === n && pp.inverse.body[0].path.parts[0] === "if";
  24603. var hasElseIf = n.inverse && n.inverse.body[0] && n.inverse.body[0].type === "BlockStatement" && n.inverse.body[0].path.parts[0] === "if";
  24604. var indentElse = hasElseIf ? function (a) {
  24605. return a;
  24606. } : indent$6;
  24607. if (n.inverse) {
  24608. return concat$10([isElseIf ? concat$10(["{{else ", printPathParams(path$$1, print), "}}"]) : printOpenBlock(path$$1, print), indent$6(concat$10([hardline$8, path$$1.call(print, "program")])), n.inverse && !hasElseIf ? concat$10([hardline$8, "{{else}}"]) : "", n.inverse ? indentElse(concat$10([hardline$8, path$$1.call(print, "inverse")])) : "", isElseIf ? "" : concat$10([hardline$8, printCloseBlock(path$$1, print)])]);
  24609. } else if (isElseIf) {
  24610. return concat$10([concat$10(["{{else ", printPathParams(path$$1, print), "}}"]), indent$6(concat$10([hardline$8, path$$1.call(print, "program")]))]);
  24611. }
  24612. /**
  24613. * I want this boolean to be: if params are going to cause a break,
  24614. * not that it has params.
  24615. */
  24616. var hasParams = n.params.length > 0 || n.hash.pairs.length > 0;
  24617. var _hasChildren = n.program.body.length > 0;
  24618. return concat$10([printOpenBlock(path$$1, print), group$10(concat$10([indent$6(concat$10([softline$4, path$$1.call(print, "program")])), hasParams && _hasChildren ? hardline$8 : softline$4, printCloseBlock(path$$1, print)]))]);
  24619. }
  24620. case "ElementModifierStatement":
  24621. case "MustacheStatement":
  24622. {
  24623. var _pp = path$$1.getParentNode(1);
  24624. var isConcat = _pp && _pp.type === "ConcatStatement";
  24625. return group$10(concat$10([n.escaped === false ? "{{{" : "{{", printPathParams(path$$1, print), isConcat ? "" : softline$4, n.escaped === false ? "}}}" : "}}"]));
  24626. }
  24627. case "SubExpression":
  24628. {
  24629. var params = getParams(path$$1, print);
  24630. var printedParams = params.length > 0 ? indent$6(concat$10([line$6, group$10(join$7(line$6, params))])) : "";
  24631. return group$10(concat$10(["(", printPath(path$$1, print), printedParams, softline$4, ")"]));
  24632. }
  24633. case "AttrNode":
  24634. {
  24635. var isText = n.value.type === "TextNode";
  24636. if (isText && n.value.loc.start.column === n.value.loc.end.column) {
  24637. return concat$10([n.name]);
  24638. }
  24639. var quote = isText ? '"' : "";
  24640. return concat$10([n.name, "=", quote, path$$1.call(print, "value"), quote]);
  24641. }
  24642. case "ConcatStatement":
  24643. {
  24644. return concat$10(['"', group$10(indent$6(join$7(softline$4, path$$1.map(function (partPath) {
  24645. return print(partPath);
  24646. }, "parts").filter(function (a) {
  24647. return a !== "";
  24648. })))), '"']);
  24649. }
  24650. case "Hash":
  24651. {
  24652. return concat$10([join$7(line$6, path$$1.map(print, "pairs"))]);
  24653. }
  24654. case "HashPair":
  24655. {
  24656. return concat$10([n.key, "=", path$$1.call(print, "value")]);
  24657. }
  24658. case "TextNode":
  24659. {
  24660. var leadingSpace = "";
  24661. var trailingSpace = ""; // preserve a space inside of an attribute node where whitespace present, when next to mustache statement.
  24662. var inAttrNode = path$$1.stack.indexOf("attributes") >= 0;
  24663. if (inAttrNode) {
  24664. var parentNode = path$$1.getParentNode(0);
  24665. var _isConcat = parentNode.type === "ConcatStatement";
  24666. if (_isConcat) {
  24667. var parts = parentNode.parts;
  24668. var partIndex = parts.indexOf(n);
  24669. if (partIndex > 0) {
  24670. var partType = parts[partIndex - 1].type;
  24671. var isMustache = partType === "MustacheStatement";
  24672. if (isMustache) {
  24673. leadingSpace = " ";
  24674. }
  24675. }
  24676. if (partIndex < parts.length - 1) {
  24677. var _partType = parts[partIndex + 1].type;
  24678. var _isMustache = _partType === "MustacheStatement";
  24679. if (_isMustache) {
  24680. trailingSpace = " ";
  24681. }
  24682. }
  24683. }
  24684. }
  24685. return n.chars.replace(/^\s+/, leadingSpace).replace(/\s+$/, trailingSpace);
  24686. }
  24687. case "MustacheCommentStatement":
  24688. {
  24689. var dashes = n.value.indexOf("}}") > -1 ? "--" : "";
  24690. return concat$10(["{{!", dashes, n.value, dashes, "}}"]);
  24691. }
  24692. case "PathExpression":
  24693. {
  24694. return n.original;
  24695. }
  24696. case "BooleanLiteral":
  24697. {
  24698. return String(n.value);
  24699. }
  24700. case "CommentStatement":
  24701. {
  24702. return concat$10(["<!--", n.value, "-->"]);
  24703. }
  24704. case "StringLiteral":
  24705. {
  24706. return printStringLiteral(n.value, options);
  24707. }
  24708. case "NumberLiteral":
  24709. {
  24710. return String(n.value);
  24711. }
  24712. case "UndefinedLiteral":
  24713. {
  24714. return "undefined";
  24715. }
  24716. case "NullLiteral":
  24717. {
  24718. return "null";
  24719. }
  24720. /* istanbul ignore next */
  24721. default:
  24722. throw new Error("unknown glimmer type: " + JSON.stringify(n.type));
  24723. }
  24724. }
  24725. /**
  24726. * Prints a string literal with the correct surrounding quotes based on
  24727. * `options.singleQuote` and the number of escaped quotes contained in
  24728. * the string literal. This function is the glimmer equivalent of `printString`
  24729. * in `common/util`, but has differences because of the way escaped characters
  24730. * are treated in hbs string literals.
  24731. * @param {string} stringLiteral - the string literal value
  24732. * @param {object} options - the prettier options object
  24733. */
  24734. function printStringLiteral(stringLiteral, options) {
  24735. var double = {
  24736. quote: '"',
  24737. regex: /"/g
  24738. };
  24739. var single = {
  24740. quote: "'",
  24741. regex: /'/g
  24742. };
  24743. var preferred = options.singleQuote ? single : double;
  24744. var alternate = preferred === single ? double : single;
  24745. var shouldUseAlternateQuote = false; // If `stringLiteral` contains at least one of the quote preferred for
  24746. // enclosing the string, we might want to enclose with the alternate quote
  24747. // instead, to minimize the number of escaped quotes.
  24748. if (stringLiteral.includes(preferred.quote) || stringLiteral.includes(alternate.quote)) {
  24749. var numPreferredQuotes = (stringLiteral.match(preferred.regex) || []).length;
  24750. var numAlternateQuotes = (stringLiteral.match(alternate.regex) || []).length;
  24751. shouldUseAlternateQuote = numPreferredQuotes > numAlternateQuotes;
  24752. }
  24753. var enclosingQuote = shouldUseAlternateQuote ? alternate : preferred;
  24754. var escapedStringLiteral = stringLiteral.replace(enclosingQuote.regex, `\\${enclosingQuote.quote}`);
  24755. return `${enclosingQuote.quote}${escapedStringLiteral}${enclosingQuote.quote}`;
  24756. }
  24757. function printPath(path$$1, print) {
  24758. return path$$1.call(print, "path");
  24759. }
  24760. function getParams(path$$1, print) {
  24761. var node = path$$1.getValue();
  24762. var parts = [];
  24763. if (node.params.length > 0) {
  24764. parts = parts.concat(path$$1.map(print, "params"));
  24765. }
  24766. if (node.hash && node.hash.pairs.length > 0) {
  24767. parts.push(path$$1.call(print, "hash"));
  24768. }
  24769. return parts;
  24770. }
  24771. function printPathParams(path$$1, print) {
  24772. var parts = [];
  24773. parts.push(printPath(path$$1, print));
  24774. parts = parts.concat(getParams(path$$1, print));
  24775. return indent$6(group$10(join$7(line$6, parts)));
  24776. }
  24777. function printBlockParams(path$$1) {
  24778. var block = path$$1.getValue();
  24779. if (!block.program || !block.program.blockParams.length) {
  24780. return "";
  24781. }
  24782. return concat$10([" as |", block.program.blockParams.join(" "), "|"]);
  24783. }
  24784. function printOpenBlock(path$$1, print) {
  24785. return group$10(concat$10(["{{#", printPathParams(path$$1, print), printBlockParams(path$$1), softline$4, "}}"]));
  24786. }
  24787. function printCloseBlock(path$$1, print) {
  24788. return concat$10(["{{/", path$$1.call(print, "path"), "}}"]);
  24789. }
  24790. function clean$5(ast, newObj) {
  24791. delete newObj.loc; // (Glimmer/HTML) ignore TextNode whitespace
  24792. if (ast.type === "TextNode") {
  24793. if (ast.chars.replace(/\s+/, "") === "") {
  24794. return null;
  24795. }
  24796. newObj.chars = ast.chars.replace(/^\s+/, "").replace(/\s+$/, "");
  24797. }
  24798. }
  24799. var printerGlimmer = {
  24800. print,
  24801. massageAstNode: clean$5
  24802. };
  24803. var name$11 = "Handlebars";
  24804. var type$10 = "markup";
  24805. var group$11 = "HTML";
  24806. var aliases$3 = ["hbs", "htmlbars"];
  24807. var extensions$10 = [".handlebars", ".hbs"];
  24808. var tmScope$10 = "text.html.handlebars";
  24809. var aceMode$10 = "handlebars";
  24810. var languageId$10 = 155;
  24811. var handlebars = {
  24812. name: name$11,
  24813. type: type$10,
  24814. group: group$11,
  24815. aliases: aliases$3,
  24816. extensions: extensions$10,
  24817. tmScope: tmScope$10,
  24818. aceMode: aceMode$10,
  24819. languageId: languageId$10
  24820. };
  24821. var handlebars$1 = Object.freeze({
  24822. name: name$11,
  24823. type: type$10,
  24824. group: group$11,
  24825. aliases: aliases$3,
  24826. extensions: extensions$10,
  24827. tmScope: tmScope$10,
  24828. aceMode: aceMode$10,
  24829. languageId: languageId$10,
  24830. default: handlebars
  24831. });
  24832. var require$$0$24 = ( handlebars$1 && handlebars ) || handlebars$1;
  24833. var languages$2 = [createLanguage(require$$0$24, {
  24834. override: {
  24835. since: null,
  24836. // unreleased
  24837. parsers: ["glimmer"],
  24838. vscodeLanguageIds: ["handlebars"]
  24839. }
  24840. })];
  24841. var printers$2 = {
  24842. glimmer: printerGlimmer
  24843. };
  24844. var languageHandlebars = {
  24845. languages: languages$2,
  24846. printers: printers$2
  24847. };
  24848. function hasPragma$2(text) {
  24849. return /^\s*#[^\n\S]*@(format|prettier)\s*(\n|$)/.test(text);
  24850. }
  24851. function insertPragma$5(text) {
  24852. return "# @format\n\n" + text;
  24853. }
  24854. var pragma$4 = {
  24855. hasPragma: hasPragma$2,
  24856. insertPragma: insertPragma$5
  24857. };
  24858. var _require$$0$builders$5 = doc.builders;
  24859. var concat$11 = _require$$0$builders$5.concat;
  24860. var join$8 = _require$$0$builders$5.join;
  24861. var hardline$9 = _require$$0$builders$5.hardline;
  24862. var line$7 = _require$$0$builders$5.line;
  24863. var softline$5 = _require$$0$builders$5.softline;
  24864. var group$12 = _require$$0$builders$5.group;
  24865. var indent$7 = _require$$0$builders$5.indent;
  24866. var ifBreak$4 = _require$$0$builders$5.ifBreak;
  24867. var hasIgnoreComment$3 = util$1.hasIgnoreComment;
  24868. var isNextLineEmpty$4 = utilShared.isNextLineEmpty;
  24869. var insertPragma$4 = pragma$4.insertPragma;
  24870. function genericPrint$3(path$$1, options, print) {
  24871. var n = path$$1.getValue();
  24872. if (!n) {
  24873. return "";
  24874. }
  24875. if (typeof n === "string") {
  24876. return n;
  24877. }
  24878. switch (n.kind) {
  24879. case "Document":
  24880. {
  24881. var parts = [];
  24882. path$$1.map(function (pathChild, index) {
  24883. parts.push(concat$11([pathChild.call(print)]));
  24884. if (index !== n.definitions.length - 1) {
  24885. parts.push(hardline$9);
  24886. if (isNextLineEmpty$4(options.originalText, pathChild.getValue(), options)) {
  24887. parts.push(hardline$9);
  24888. }
  24889. }
  24890. }, "definitions");
  24891. return concat$11([concat$11(parts), hardline$9]);
  24892. }
  24893. case "OperationDefinition":
  24894. {
  24895. var hasOperation = options.originalText[options.locStart(n)] !== "{";
  24896. var hasName = !!n.name;
  24897. return concat$11([hasOperation ? n.operation : "", hasOperation && hasName ? concat$11([" ", path$$1.call(print, "name")]) : "", n.variableDefinitions && n.variableDefinitions.length ? group$12(concat$11(["(", indent$7(concat$11([softline$5, join$8(concat$11([ifBreak$4("", ", "), softline$5]), path$$1.map(print, "variableDefinitions"))])), softline$5, ")"])) : "", printDirectives(path$$1, print, n), n.selectionSet ? !hasOperation && !hasName ? "" : " " : "", path$$1.call(print, "selectionSet")]);
  24898. }
  24899. case "FragmentDefinition":
  24900. {
  24901. return concat$11(["fragment ", path$$1.call(print, "name"), " on ", path$$1.call(print, "typeCondition"), printDirectives(path$$1, print, n), " ", path$$1.call(print, "selectionSet")]);
  24902. }
  24903. case "SelectionSet":
  24904. {
  24905. return concat$11(["{", indent$7(concat$11([hardline$9, join$8(hardline$9, path$$1.call(function (selectionsPath) {
  24906. return printSequence(selectionsPath, options, print);
  24907. }, "selections"))])), hardline$9, "}"]);
  24908. }
  24909. case "Field":
  24910. {
  24911. return group$12(concat$11([n.alias ? concat$11([path$$1.call(print, "alias"), ": "]) : "", path$$1.call(print, "name"), n.arguments.length > 0 ? group$12(concat$11(["(", indent$7(concat$11([softline$5, join$8(concat$11([ifBreak$4("", ", "), softline$5]), path$$1.call(function (argsPath) {
  24912. return printSequence(argsPath, options, print);
  24913. }, "arguments"))])), softline$5, ")"])) : "", printDirectives(path$$1, print, n), n.selectionSet ? " " : "", path$$1.call(print, "selectionSet")]));
  24914. }
  24915. case "Name":
  24916. {
  24917. return n.value;
  24918. }
  24919. case "StringValue":
  24920. {
  24921. if (n.block) {
  24922. return concat$11(['"""', hardline$9, join$8(hardline$9, n.value.replace(/"""/g, "\\$&").split("\n")), hardline$9, '"""']);
  24923. }
  24924. return concat$11(['"', n.value.replace(/["\\]/g, "\\$&").replace(/\n/g, "\\n"), '"']);
  24925. }
  24926. case "IntValue":
  24927. case "FloatValue":
  24928. case "EnumValue":
  24929. {
  24930. return n.value;
  24931. }
  24932. case "BooleanValue":
  24933. {
  24934. return n.value ? "true" : "false";
  24935. }
  24936. case "NullValue":
  24937. {
  24938. return "null";
  24939. }
  24940. case "Variable":
  24941. {
  24942. return concat$11(["$", path$$1.call(print, "name")]);
  24943. }
  24944. case "ListValue":
  24945. {
  24946. return group$12(concat$11(["[", indent$7(concat$11([softline$5, join$8(concat$11([ifBreak$4("", ", "), softline$5]), path$$1.map(print, "values"))])), softline$5, "]"]));
  24947. }
  24948. case "ObjectValue":
  24949. {
  24950. return group$12(concat$11(["{", options.bracketSpacing && n.fields.length > 0 ? " " : "", indent$7(concat$11([softline$5, join$8(concat$11([ifBreak$4("", ", "), softline$5]), path$$1.map(print, "fields"))])), softline$5, ifBreak$4("", options.bracketSpacing && n.fields.length > 0 ? " " : ""), "}"]));
  24951. }
  24952. case "ObjectField":
  24953. case "Argument":
  24954. {
  24955. return concat$11([path$$1.call(print, "name"), ": ", path$$1.call(print, "value")]);
  24956. }
  24957. case "Directive":
  24958. {
  24959. return concat$11(["@", path$$1.call(print, "name"), n.arguments.length > 0 ? group$12(concat$11(["(", indent$7(concat$11([softline$5, join$8(concat$11([ifBreak$4("", ", "), softline$5]), path$$1.call(function (argsPath) {
  24960. return printSequence(argsPath, options, print);
  24961. }, "arguments"))])), softline$5, ")"])) : ""]);
  24962. }
  24963. case "NamedType":
  24964. {
  24965. return path$$1.call(print, "name");
  24966. }
  24967. case "VariableDefinition":
  24968. {
  24969. return concat$11([path$$1.call(print, "variable"), ": ", path$$1.call(print, "type"), n.defaultValue ? concat$11([" = ", path$$1.call(print, "defaultValue")]) : ""]);
  24970. }
  24971. case "TypeExtensionDefinition":
  24972. {
  24973. return concat$11(["extend ", path$$1.call(print, "definition")]);
  24974. }
  24975. case "ObjectTypeExtension":
  24976. case "ObjectTypeDefinition":
  24977. {
  24978. return concat$11([path$$1.call(print, "description"), n.description ? hardline$9 : "", n.kind === "ObjectTypeExtension" ? "extend " : "", "type ", path$$1.call(print, "name"), n.interfaces.length > 0 ? concat$11([" implements ", join$8(determineInterfaceSeparator(options.originalText.substr(options.locStart(n), options.locEnd(n))), path$$1.map(print, "interfaces"))]) : "", printDirectives(path$$1, print, n), n.fields.length > 0 ? concat$11([" {", indent$7(concat$11([hardline$9, join$8(hardline$9, path$$1.call(function (fieldsPath) {
  24979. return printSequence(fieldsPath, options, print);
  24980. }, "fields"))])), hardline$9, "}"]) : ""]);
  24981. }
  24982. case "FieldDefinition":
  24983. {
  24984. return concat$11([path$$1.call(print, "description"), n.description ? hardline$9 : "", path$$1.call(print, "name"), n.arguments.length > 0 ? group$12(concat$11(["(", indent$7(concat$11([softline$5, join$8(concat$11([ifBreak$4("", ", "), softline$5]), path$$1.call(function (argsPath) {
  24985. return printSequence(argsPath, options, print);
  24986. }, "arguments"))])), softline$5, ")"])) : "", ": ", path$$1.call(print, "type"), printDirectives(path$$1, print, n)]);
  24987. }
  24988. case "DirectiveDefinition":
  24989. {
  24990. return concat$11([path$$1.call(print, "description"), n.description ? hardline$9 : "", "directive ", "@", path$$1.call(print, "name"), n.arguments.length > 0 ? group$12(concat$11(["(", indent$7(concat$11([softline$5, join$8(concat$11([ifBreak$4("", ", "), softline$5]), path$$1.call(function (argsPath) {
  24991. return printSequence(argsPath, options, print);
  24992. }, "arguments"))])), softline$5, ")"])) : "", concat$11([" on ", join$8(" | ", path$$1.map(print, "locations"))])]);
  24993. }
  24994. case "EnumTypeExtension":
  24995. case "EnumTypeDefinition":
  24996. {
  24997. return concat$11([path$$1.call(print, "description"), n.description ? hardline$9 : "", n.kind === "EnumTypeExtension" ? "extend " : "", "enum ", path$$1.call(print, "name"), printDirectives(path$$1, print, n), n.values.length > 0 ? concat$11([" {", indent$7(concat$11([hardline$9, join$8(hardline$9, path$$1.call(function (valuesPath) {
  24998. return printSequence(valuesPath, options, print);
  24999. }, "values"))])), hardline$9, "}"]) : ""]);
  25000. }
  25001. case "EnumValueDefinition":
  25002. {
  25003. return concat$11([path$$1.call(print, "description"), n.description ? hardline$9 : "", path$$1.call(print, "name"), printDirectives(path$$1, print, n)]);
  25004. }
  25005. case "InputValueDefinition":
  25006. {
  25007. return concat$11([path$$1.call(print, "description"), n.description ? n.description.block ? hardline$9 : line$7 : "", path$$1.call(print, "name"), ": ", path$$1.call(print, "type"), n.defaultValue ? concat$11([" = ", path$$1.call(print, "defaultValue")]) : "", printDirectives(path$$1, print, n)]);
  25008. }
  25009. case "InputObjectTypeExtension":
  25010. case "InputObjectTypeDefinition":
  25011. {
  25012. return concat$11([path$$1.call(print, "description"), n.description ? hardline$9 : "", n.kind === "InputObjectTypeExtension" ? "extend " : "", "input ", path$$1.call(print, "name"), printDirectives(path$$1, print, n), n.fields.length > 0 ? concat$11([" {", indent$7(concat$11([hardline$9, join$8(hardline$9, path$$1.call(function (fieldsPath) {
  25013. return printSequence(fieldsPath, options, print);
  25014. }, "fields"))])), hardline$9, "}"]) : ""]);
  25015. }
  25016. case "SchemaDefinition":
  25017. {
  25018. return concat$11(["schema", printDirectives(path$$1, print, n), " {", n.operationTypes.length > 0 ? indent$7(concat$11([hardline$9, join$8(hardline$9, path$$1.call(function (opsPath) {
  25019. return printSequence(opsPath, options, print);
  25020. }, "operationTypes"))])) : "", hardline$9, "}"]);
  25021. }
  25022. case "OperationTypeDefinition":
  25023. {
  25024. return concat$11([path$$1.call(print, "operation"), ": ", path$$1.call(print, "type")]);
  25025. }
  25026. case "InterfaceTypeExtension":
  25027. case "InterfaceTypeDefinition":
  25028. {
  25029. return concat$11([path$$1.call(print, "description"), n.description ? hardline$9 : "", n.kind === "InterfaceTypeExtension" ? "extend " : "", "interface ", path$$1.call(print, "name"), printDirectives(path$$1, print, n), n.fields.length > 0 ? concat$11([" {", indent$7(concat$11([hardline$9, join$8(hardline$9, path$$1.call(function (fieldsPath) {
  25030. return printSequence(fieldsPath, options, print);
  25031. }, "fields"))])), hardline$9, "}"]) : ""]);
  25032. }
  25033. case "FragmentSpread":
  25034. {
  25035. return concat$11(["...", path$$1.call(print, "name"), printDirectives(path$$1, print, n)]);
  25036. }
  25037. case "InlineFragment":
  25038. {
  25039. return concat$11(["...", n.typeCondition ? concat$11([" on ", path$$1.call(print, "typeCondition")]) : "", printDirectives(path$$1, print, n), " ", path$$1.call(print, "selectionSet")]);
  25040. }
  25041. case "UnionTypeExtension":
  25042. case "UnionTypeDefinition":
  25043. {
  25044. return group$12(concat$11([path$$1.call(print, "description"), n.description ? hardline$9 : "", group$12(concat$11([n.kind === "UnionTypeExtension" ? "extend " : "", "union ", path$$1.call(print, "name"), printDirectives(path$$1, print, n), n.types.length > 0 ? concat$11([" =", ifBreak$4("", " "), indent$7(concat$11([ifBreak$4(concat$11([line$7, " "])), join$8(concat$11([line$7, "| "]), path$$1.map(print, "types"))]))]) : ""]))]));
  25045. }
  25046. case "ScalarTypeExtension":
  25047. case "ScalarTypeDefinition":
  25048. {
  25049. return concat$11([path$$1.call(print, "description"), n.description ? hardline$9 : "", n.kind === "ScalarTypeExtension" ? "extend " : "", "scalar ", path$$1.call(print, "name"), printDirectives(path$$1, print, n)]);
  25050. }
  25051. case "NonNullType":
  25052. {
  25053. return concat$11([path$$1.call(print, "type"), "!"]);
  25054. }
  25055. case "ListType":
  25056. {
  25057. return concat$11(["[", path$$1.call(print, "type"), "]"]);
  25058. }
  25059. default:
  25060. /* istanbul ignore next */
  25061. throw new Error("unknown graphql type: " + JSON.stringify(n.kind));
  25062. }
  25063. }
  25064. function printDirectives(path$$1, print, n) {
  25065. if (n.directives.length === 0) {
  25066. return "";
  25067. }
  25068. return concat$11([" ", group$12(indent$7(concat$11([softline$5, join$8(concat$11([ifBreak$4("", " "), softline$5]), path$$1.map(print, "directives"))])))]);
  25069. }
  25070. function printSequence(sequencePath, options, print) {
  25071. var count = sequencePath.getValue().length;
  25072. return sequencePath.map(function (path$$1, i) {
  25073. var printed = print(path$$1);
  25074. if (isNextLineEmpty$4(options.originalText, path$$1.getValue(), options) && i < count - 1) {
  25075. return concat$11([printed, hardline$9]);
  25076. }
  25077. return printed;
  25078. });
  25079. }
  25080. function canAttachComment$1(node) {
  25081. return node.kind && node.kind !== "Comment";
  25082. }
  25083. function printComment$2(commentPath) {
  25084. var comment = commentPath.getValue();
  25085. if (comment.kind === "Comment") {
  25086. return "#" + comment.value.trimRight();
  25087. }
  25088. throw new Error("Not a comment: " + JSON.stringify(comment));
  25089. }
  25090. function determineInterfaceSeparator(originalSource) {
  25091. var start = originalSource.indexOf("implements");
  25092. if (start === -1) {
  25093. throw new Error("Must implement interfaces: " + originalSource);
  25094. }
  25095. var end = originalSource.indexOf("{");
  25096. if (end === -1) {
  25097. end = originalSource.length;
  25098. }
  25099. return originalSource.substr(start, end).includes("&") ? " & " : ", ";
  25100. }
  25101. function clean$6(node, newNode
  25102. /*, parent*/
  25103. ) {
  25104. delete newNode.loc;
  25105. delete newNode.comments;
  25106. }
  25107. var printerGraphql = {
  25108. print: genericPrint$3,
  25109. massageAstNode: clean$6,
  25110. hasPrettierIgnore: hasIgnoreComment$3,
  25111. insertPragma: insertPragma$4,
  25112. printComment: printComment$2,
  25113. canAttachComment: canAttachComment$1
  25114. };
  25115. var options$10 = {
  25116. bracketSpacing: commonOptions.bracketSpacing
  25117. };
  25118. var name$12 = "GraphQL";
  25119. var type$11 = "data";
  25120. var extensions$11 = [".graphql", ".gql"];
  25121. var tmScope$11 = "source.graphql";
  25122. var aceMode$11 = "text";
  25123. var languageId$11 = 139;
  25124. var graphql = {
  25125. name: name$12,
  25126. type: type$11,
  25127. extensions: extensions$11,
  25128. tmScope: tmScope$11,
  25129. aceMode: aceMode$11,
  25130. languageId: languageId$11
  25131. };
  25132. var graphql$1 = Object.freeze({
  25133. name: name$12,
  25134. type: type$11,
  25135. extensions: extensions$11,
  25136. tmScope: tmScope$11,
  25137. aceMode: aceMode$11,
  25138. languageId: languageId$11,
  25139. default: graphql
  25140. });
  25141. var require$$0$25 = ( graphql$1 && graphql ) || graphql$1;
  25142. var languages$3 = [createLanguage(require$$0$25, {
  25143. override: {
  25144. since: "1.5.0",
  25145. parsers: ["graphql"],
  25146. vscodeLanguageIds: ["graphql"]
  25147. }
  25148. })];
  25149. var printers$3 = {
  25150. graphql: printerGraphql
  25151. };
  25152. var languageGraphql = {
  25153. languages: languages$3,
  25154. options: options$10,
  25155. printers: printers$3
  25156. };
  25157. var json$6 = {"cjkPattern":"[\\u02ea-\\u02eb\\u1100-\\u11ff\\u2e80-\\u2e99\\u2e9b-\\u2ef3\\u2f00-\\u2fd5\\u3000-\\u303f\\u3041-\\u3096\\u3099-\\u309f\\u30a1-\\u30fa\\u30fc-\\u30ff\\u3105-\\u312e\\u3131-\\u318e\\u3190-\\u3191\\u3196-\\u31ba\\u31c0-\\u31e3\\u31f0-\\u321e\\u322a-\\u3247\\u3260-\\u327e\\u328a-\\u32b0\\u32c0-\\u32cb\\u32d0-\\u32fe\\u3300-\\u3370\\u337b-\\u337f\\u33e0-\\u33fe\\u3400-\\u4db5\\u4e00-\\u9fea\\ua960-\\ua97c\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\uf900-\\ufa6d\\ufa70-\\ufad9\\ufe10-\\ufe1f\\ufe30-\\ufe6f\\uff00-\\uffef]|[\\ud840-\\ud868\\ud86a-\\ud86c\\ud86f-\\ud872\\ud874-\\ud879][\\udc00-\\udfff]|\\ud82c[\\udc00-\\udd1e]|\\ud83c[\\ude00\\ude50-\\ude51]|\\ud869[\\udc00-\\uded6\\udf00-\\udfff]|\\ud86d[\\udc00-\\udf34\\udf40-\\udfff]|\\ud86e[\\udc00-\\udc1d\\udc20-\\udfff]|\\ud873[\\udc00-\\udea1\\udeb0-\\udfff]|\\ud87a[\\udc00-\\udfe0]|\\ud87e[\\udc00-\\ude1d]","kPattern":"[\\u1100-\\u11ff\\u3001-\\u3003\\u3008-\\u3011\\u3013-\\u301f\\u302e-\\u3030\\u3037\\u30fb\\u3131-\\u318e\\u3200-\\u321e\\u3260-\\u327e\\ua960-\\ua97c\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\ufe45-\\ufe46\\uff61-\\uff65\\uffa0-\\uffbe\\uffc2-\\uffc7\\uffca-\\uffcf\\uffd2-\\uffd7\\uffda-\\uffdc]","punctuationPattern":"[\\u0021-\\u002f\\u003a-\\u0040\\u005b-\\u0060\\u007b-\\u007e\\u00a1\\u00a7\\u00ab\\u00b6-\\u00b7\\u00bb\\u00bf\\u037e\\u0387\\u055a-\\u055f\\u0589-\\u058a\\u05be\\u05c0\\u05c3\\u05c6\\u05f3-\\u05f4\\u0609-\\u060a\\u060c-\\u060d\\u061b\\u061e-\\u061f\\u066a-\\u066d\\u06d4\\u0700-\\u070d\\u07f7-\\u07f9\\u0830-\\u083e\\u085e\\u0964-\\u0965\\u0970\\u09fd\\u0af0\\u0df4\\u0e4f\\u0e5a-\\u0e5b\\u0f04-\\u0f12\\u0f14\\u0f3a-\\u0f3d\\u0f85\\u0fd0-\\u0fd4\\u0fd9-\\u0fda\\u104a-\\u104f\\u10fb\\u1360-\\u1368\\u1400\\u166d-\\u166e\\u169b-\\u169c\\u16eb-\\u16ed\\u1735-\\u1736\\u17d4-\\u17d6\\u17d8-\\u17da\\u1800-\\u180a\\u1944-\\u1945\\u1a1e-\\u1a1f\\u1aa0-\\u1aa6\\u1aa8-\\u1aad\\u1b5a-\\u1b60\\u1bfc-\\u1bff\\u1c3b-\\u1c3f\\u1c7e-\\u1c7f\\u1cc0-\\u1cc7\\u1cd3\\u2010-\\u2027\\u2030-\\u2043\\u2045-\\u2051\\u2053-\\u205e\\u207d-\\u207e\\u208d-\\u208e\\u2308-\\u230b\\u2329-\\u232a\\u2768-\\u2775\\u27c5-\\u27c6\\u27e6-\\u27ef\\u2983-\\u2998\\u29d8-\\u29db\\u29fc-\\u29fd\\u2cf9-\\u2cfc\\u2cfe-\\u2cff\\u2d70\\u2e00-\\u2e2e\\u2e30-\\u2e49\\u3001-\\u3003\\u3008-\\u3011\\u3014-\\u301f\\u3030\\u303d\\u30a0\\u30fb\\ua4fe-\\ua4ff\\ua60d-\\ua60f\\ua673\\ua67e\\ua6f2-\\ua6f7\\ua874-\\ua877\\ua8ce-\\ua8cf\\ua8f8-\\ua8fa\\ua8fc\\ua92e-\\ua92f\\ua95f\\ua9c1-\\ua9cd\\ua9de-\\ua9df\\uaa5c-\\uaa5f\\uaade-\\uaadf\\uaaf0-\\uaaf1\\uabeb\\ufd3e-\\ufd3f\\ufe10-\\ufe19\\ufe30-\\ufe52\\ufe54-\\ufe61\\ufe63\\ufe68\\ufe6a-\\ufe6b\\uff01-\\uff03\\uff05-\\uff0a\\uff0c-\\uff0f\\uff1a-\\uff1b\\uff1f-\\uff20\\uff3b-\\uff3d\\uff3f\\uff5b\\uff5d\\uff5f-\\uff65]|\\ud800[\\udd00-\\udd02\\udf9f\\udfd0]|\\ud801[\\udd6f]|\\ud802[\\udc57\\udd1f\\udd3f\\ude50-\\ude58\\ude7f\\udef0-\\udef6\\udf39-\\udf3f\\udf99-\\udf9c]|\\ud804[\\udc47-\\udc4d\\udcbb-\\udcbc\\udcbe-\\udcc1\\udd40-\\udd43\\udd74-\\udd75\\uddc5-\\uddc9\\uddcd\\udddb\\udddd-\\udddf\\ude38-\\ude3d\\udea9]|\\ud805[\\udc4b-\\udc4f\\udc5b\\udc5d\\udcc6\\uddc1-\\uddd7\\ude41-\\ude43\\ude60-\\ude6c\\udf3c-\\udf3e]|\\ud806[\\ude3f-\\ude46\\ude9a-\\ude9c\\ude9e-\\udea2]|\\ud807[\\udc41-\\udc45\\udc70-\\udc71]|\\ud809[\\udc70-\\udc74]|\\ud81a[\\ude6e-\\ude6f\\udef5\\udf37-\\udf3b\\udf44]|\\ud82f[\\udc9f]|\\ud836[\\ude87-\\ude8b]|\\ud83a[\\udd5e-\\udd5f]"};
  25158. var cjkPattern = json$6.cjkPattern;
  25159. var kPattern = json$6.kPattern;
  25160. var punctuationPattern$1 = json$6.punctuationPattern;
  25161. var getLast$5 = util$1.getLast;
  25162. var INLINE_NODE_TYPES$1 = ["liquidNode", "inlineCode", "emphasis", "strong", "delete", "link", "linkReference", "image", "imageReference", "footnote", "footnoteReference", "sentence", "whitespace", "word", "break", "inlineMath"];
  25163. var INLINE_NODE_WRAPPER_TYPES$1 = INLINE_NODE_TYPES$1.concat(["tableCell", "paragraph", "heading"]);
  25164. var kRegex = new RegExp(kPattern);
  25165. var punctuationRegex = new RegExp(punctuationPattern$1);
  25166. /**
  25167. * split text into whitespaces and words
  25168. * @param {string} text
  25169. * @return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>}
  25170. */
  25171. function splitText$1(text, options) {
  25172. var KIND_NON_CJK = "non-cjk";
  25173. var KIND_CJ_LETTER = "cj-letter";
  25174. var KIND_K_LETTER = "k-letter";
  25175. var KIND_CJK_PUNCTUATION = "cjk-punctuation";
  25176. var nodes = [];
  25177. (options.proseWrap === "preserve" ? text : text.replace(new RegExp(`(${cjkPattern})\n(${cjkPattern})`, "g"), "$1$2")).split(/([ \t\n]+)/).forEach(function (token, index, tokens) {
  25178. // whitespace
  25179. if (index % 2 === 1) {
  25180. nodes.push({
  25181. type: "whitespace",
  25182. value: /\n/.test(token) ? "\n" : " "
  25183. });
  25184. return;
  25185. } // word separated by whitespace
  25186. if ((index === 0 || index === tokens.length - 1) && token === "") {
  25187. return;
  25188. }
  25189. token.split(new RegExp(`(${cjkPattern})`)).forEach(function (innerToken, innerIndex, innerTokens) {
  25190. if ((innerIndex === 0 || innerIndex === innerTokens.length - 1) && innerToken === "") {
  25191. return;
  25192. } // non-CJK word
  25193. if (innerIndex % 2 === 0) {
  25194. if (innerToken !== "") {
  25195. appendNode({
  25196. type: "word",
  25197. value: innerToken,
  25198. kind: KIND_NON_CJK,
  25199. hasLeadingPunctuation: punctuationRegex.test(innerToken[0]),
  25200. hasTrailingPunctuation: punctuationRegex.test(getLast$5(innerToken))
  25201. });
  25202. }
  25203. return;
  25204. } // CJK character
  25205. appendNode(punctuationRegex.test(innerToken) ? {
  25206. type: "word",
  25207. value: innerToken,
  25208. kind: KIND_CJK_PUNCTUATION,
  25209. hasLeadingPunctuation: true,
  25210. hasTrailingPunctuation: true
  25211. } : {
  25212. type: "word",
  25213. value: innerToken,
  25214. kind: kRegex.test(innerToken) ? KIND_K_LETTER : KIND_CJ_LETTER,
  25215. hasLeadingPunctuation: false,
  25216. hasTrailingPunctuation: false
  25217. });
  25218. });
  25219. });
  25220. return nodes;
  25221. function appendNode(node) {
  25222. var lastNode = getLast$5(nodes);
  25223. if (lastNode && lastNode.type === "word") {
  25224. if (lastNode.kind === KIND_NON_CJK && node.kind === KIND_CJ_LETTER && !lastNode.hasTrailingPunctuation || lastNode.kind === KIND_CJ_LETTER && node.kind === KIND_NON_CJK && !node.hasLeadingPunctuation) {
  25225. nodes.push({
  25226. type: "whitespace",
  25227. value: " "
  25228. });
  25229. } else if (!isBetween(KIND_NON_CJK, KIND_CJK_PUNCTUATION) && // disallow leading/trailing full-width whitespace
  25230. ![lastNode.value, node.value].some(function (value) {
  25231. return /\u3000/.test(value);
  25232. })) {
  25233. nodes.push({
  25234. type: "whitespace",
  25235. value: ""
  25236. });
  25237. }
  25238. }
  25239. nodes.push(node);
  25240. function isBetween(kind1, kind2) {
  25241. return lastNode.kind === kind1 && node.kind === kind2 || lastNode.kind === kind2 && node.kind === kind1;
  25242. }
  25243. }
  25244. }
  25245. function getOrderedListItemInfo$1(orderListItem, originalText) {
  25246. var _originalText$slice$m = originalText.slice(orderListItem.position.start.offset, orderListItem.position.end.offset).match(/^\s*(\d+)(\.|\))(\s*)/),
  25247. _originalText$slice$m2 = _slicedToArray(_originalText$slice$m, 4),
  25248. numberText = _originalText$slice$m2[1],
  25249. marker = _originalText$slice$m2[2],
  25250. leadingSpaces = _originalText$slice$m2[3];
  25251. return {
  25252. numberText,
  25253. marker,
  25254. leadingSpaces
  25255. };
  25256. } // workaround for https://github.com/remarkjs/remark/issues/351
  25257. // leading and trailing newlines are stripped by remark
  25258. function getFencedCodeBlockValue$2(node, originalText) {
  25259. var text = originalText.slice(node.position.start.offset, node.position.end.offset);
  25260. var leadingSpaceCount = text.match(/^\s*/)[0].length;
  25261. var replaceRegex = new RegExp(`^\\s{0,${leadingSpaceCount}}`);
  25262. var lineContents = text.split("\n");
  25263. var markerStyle = text[leadingSpaceCount]; // ` or ~
  25264. var marker = text.slice(leadingSpaceCount).match(new RegExp(`^[${markerStyle}]+`))[0]; // https://spec.commonmark.org/0.28/#example-104: Closing fences may be indented by 0-3 spaces
  25265. // https://spec.commonmark.org/0.28/#example-93: The closing code fence must be at least as long as the opening fence
  25266. var hasEndMarker = new RegExp(`^\\s{0,3}${marker}`).test(lineContents[lineContents.length - 1].slice(getIndent(lineContents.length - 1)));
  25267. return lineContents.slice(1, hasEndMarker ? -1 : undefined).map(function (x, i) {
  25268. return x.slice(getIndent(i + 1)).replace(replaceRegex, "");
  25269. }).join("\n");
  25270. function getIndent(lineIndex) {
  25271. return node.position.indent[lineIndex - 1] - 1;
  25272. }
  25273. }
  25274. function mapAst(ast, handler) {
  25275. return function preorder(node, index, parentStack) {
  25276. parentStack = parentStack || [];
  25277. var newNode = Object.assign({}, handler(node, index, parentStack));
  25278. if (newNode.children) {
  25279. newNode.children = newNode.children.map(function (child, index) {
  25280. return preorder(child, index, [newNode].concat(parentStack));
  25281. });
  25282. }
  25283. return newNode;
  25284. }(ast, null, null);
  25285. }
  25286. var utils$8 = {
  25287. mapAst,
  25288. splitText: splitText$1,
  25289. punctuationPattern: punctuationPattern$1,
  25290. getFencedCodeBlockValue: getFencedCodeBlockValue$2,
  25291. getOrderedListItemInfo: getOrderedListItemInfo$1,
  25292. INLINE_NODE_TYPES: INLINE_NODE_TYPES$1,
  25293. INLINE_NODE_WRAPPER_TYPES: INLINE_NODE_WRAPPER_TYPES$1
  25294. };
  25295. var _require$$0$builders$7 = doc.builders;
  25296. var hardline$11 = _require$$0$builders$7.hardline;
  25297. var literalline$5 = _require$$0$builders$7.literalline;
  25298. var concat$13 = _require$$0$builders$7.concat;
  25299. var markAsRoot$3 = _require$$0$builders$7.markAsRoot;
  25300. var mapDoc$6 = doc.utils.mapDoc;
  25301. var getFencedCodeBlockValue$1 = utils$8.getFencedCodeBlockValue;
  25302. function embed$4(path$$1, print, textToDoc, options) {
  25303. var node = path$$1.getValue();
  25304. if (node.type === "code" && node.lang !== null) {
  25305. // only look for the first string so as to support [markdown-preview-enhanced](https://shd101wyy.github.io/markdown-preview-enhanced/#/code-chunk)
  25306. var langMatch = node.lang.match(/^[A-Za-z0-9_-]+/);
  25307. var lang = langMatch ? langMatch[0] : "";
  25308. var parser = getParserName(lang);
  25309. if (parser) {
  25310. var styleUnit = options.__inJsTemplate ? "~" : "`";
  25311. var style = styleUnit.repeat(Math.max(3, util$1.getMaxContinuousCount(node.value, styleUnit) + 1));
  25312. var doc$$2 = textToDoc(getFencedCodeBlockValue$1(node, options.originalText), {
  25313. parser
  25314. });
  25315. return markAsRoot$3(concat$13([style, node.lang, hardline$11, replaceNewlinesWithLiterallines(doc$$2), style]));
  25316. }
  25317. }
  25318. if (node.type === "yaml") {
  25319. return markAsRoot$3(concat$13(["---", hardline$11, node.value && node.value.trim() ? replaceNewlinesWithLiterallines(textToDoc(node.value, {
  25320. parser: "yaml"
  25321. })) : "", "---"]));
  25322. } // MDX
  25323. switch (node.type) {
  25324. case "importExport":
  25325. return textToDoc(node.value, {
  25326. parser: "babel"
  25327. });
  25328. case "jsx":
  25329. return textToDoc(node.value, {
  25330. parser: "__js_expression"
  25331. });
  25332. }
  25333. return null;
  25334. function getParserName(lang) {
  25335. var supportInfo = support.getSupportInfo(null, {
  25336. plugins: options.plugins
  25337. });
  25338. var language = supportInfo.languages.find(function (language) {
  25339. return language.name.toLowerCase() === lang || language.aliases && language.aliases.indexOf(lang) !== -1 || language.extensions && language.extensions.find(function (ext) {
  25340. return ext.substring(1) === lang;
  25341. });
  25342. });
  25343. if (language) {
  25344. return language.parsers[0];
  25345. }
  25346. return null;
  25347. }
  25348. function replaceNewlinesWithLiterallines(doc$$2) {
  25349. return mapDoc$6(doc$$2, function (currentDoc) {
  25350. return typeof currentDoc === "string" && currentDoc.includes("\n") ? concat$13(currentDoc.split(/(\n)/g).map(function (v, i) {
  25351. return i % 2 === 0 ? v : literalline$5;
  25352. })) : currentDoc;
  25353. });
  25354. }
  25355. }
  25356. var embed_1$4 = embed$4;
  25357. var pragma$6 = createCommonjsModule(function (module) {
  25358. "use strict";
  25359. var pragmas = ["format", "prettier"];
  25360. function startWithPragma(text) {
  25361. var pragma = `@(${pragmas.join("|")})`;
  25362. var regex = new RegExp([`<!--\\s*${pragma}\\s*-->`, `<!--.*\r?\n[\\s\\S]*(^|\n)[^\\S\n]*${pragma}[^\\S\n]*($|\n)[\\s\\S]*\n.*-->`].join("|"), "m");
  25363. var matched = text.match(regex);
  25364. return matched && matched.index === 0;
  25365. }
  25366. module.exports = {
  25367. startWithPragma,
  25368. hasPragma: function hasPragma(text) {
  25369. return startWithPragma(frontMatter(text).content.trimLeft());
  25370. },
  25371. insertPragma: function insertPragma(text) {
  25372. var extracted = frontMatter(text);
  25373. var pragma = `<!-- @${pragmas[0]} -->`;
  25374. return extracted.frontMatter ? `${extracted.frontMatter.raw}\n\n${pragma}\n\n${extracted.content}` : `${pragma}\n\n${extracted.content}`;
  25375. }
  25376. };
  25377. });
  25378. var getOrderedListItemInfo$2 = utils$8.getOrderedListItemInfo;
  25379. var mapAst$1 = utils$8.mapAst;
  25380. var splitText$2 = utils$8.splitText; // 0x0 ~ 0x10ffff
  25381. var isSingleCharRegex = /^([\u0000-\uffff]|[\ud800-\udbff][\udc00-\udfff])$/;
  25382. function preprocess$2(ast, options) {
  25383. ast = restoreUnescapedCharacter(ast, options);
  25384. ast = mergeContinuousTexts(ast);
  25385. ast = transformInlineCode(ast);
  25386. ast = transformIndentedCodeblockAndMarkItsParentList(ast, options);
  25387. ast = markAlignedList(ast, options);
  25388. ast = splitTextIntoSentences(ast, options);
  25389. ast = transformImportExport(ast);
  25390. ast = mergeContinuousImportExport(ast);
  25391. return ast;
  25392. }
  25393. function transformImportExport(ast) {
  25394. return mapAst$1(ast, function (node) {
  25395. if (node.type !== "import" && node.type !== "export") {
  25396. return node;
  25397. }
  25398. return Object.assign({}, node, {
  25399. type: "importExport"
  25400. });
  25401. });
  25402. }
  25403. function transformInlineCode(ast) {
  25404. return mapAst$1(ast, function (node) {
  25405. if (node.type !== "inlineCode") {
  25406. return node;
  25407. }
  25408. return Object.assign({}, node, {
  25409. value: node.value.replace(/\s+/g, " ")
  25410. });
  25411. });
  25412. }
  25413. function restoreUnescapedCharacter(ast, options) {
  25414. return mapAst$1(ast, function (node) {
  25415. return node.type !== "text" ? node : Object.assign({}, node, {
  25416. value: node.value !== "*" && node.value !== "_" && node.value !== "$" && // handle these cases in printer
  25417. isSingleCharRegex.test(node.value) && node.position.end.offset - node.position.start.offset !== node.value.length ? options.originalText.slice(node.position.start.offset, node.position.end.offset) : node.value
  25418. });
  25419. });
  25420. }
  25421. function mergeContinuousImportExport(ast) {
  25422. return mergeChildren(ast, function (prevNode, node) {
  25423. return prevNode.type === "importExport" && node.type === "importExport";
  25424. }, function (prevNode, node) {
  25425. return {
  25426. type: "importExport",
  25427. value: prevNode.value + "\n\n" + node.value,
  25428. position: {
  25429. start: prevNode.position.start,
  25430. end: node.position.end
  25431. }
  25432. };
  25433. });
  25434. }
  25435. function mergeChildren(ast, shouldMerge, mergeNode) {
  25436. return mapAst$1(ast, function (node) {
  25437. if (!node.children) {
  25438. return node;
  25439. }
  25440. var children = node.children.reduce(function (current, child) {
  25441. var lastChild = current[current.length - 1];
  25442. if (lastChild && shouldMerge(lastChild, child)) {
  25443. current.splice(-1, 1, mergeNode(lastChild, child));
  25444. } else {
  25445. current.push(child);
  25446. }
  25447. return current;
  25448. }, []);
  25449. return Object.assign({}, node, {
  25450. children
  25451. });
  25452. });
  25453. }
  25454. function mergeContinuousTexts(ast) {
  25455. return mergeChildren(ast, function (prevNode, node) {
  25456. return prevNode.type === "text" && node.type === "text";
  25457. }, function (prevNode, node) {
  25458. return {
  25459. type: "text",
  25460. value: prevNode.value + node.value,
  25461. position: {
  25462. start: prevNode.position.start,
  25463. end: node.position.end
  25464. }
  25465. };
  25466. });
  25467. }
  25468. function splitTextIntoSentences(ast, options) {
  25469. return mapAst$1(ast, function (node, index, _ref) {
  25470. var _ref2 = _slicedToArray(_ref, 1),
  25471. parentNode = _ref2[0];
  25472. if (node.type !== "text") {
  25473. return node;
  25474. }
  25475. var value = node.value;
  25476. if (parentNode.type === "paragraph") {
  25477. if (index === 0) {
  25478. value = value.trimLeft();
  25479. }
  25480. if (index === parentNode.children.length - 1) {
  25481. value = value.trimRight();
  25482. }
  25483. }
  25484. return {
  25485. type: "sentence",
  25486. position: node.position,
  25487. children: splitText$2(value, options)
  25488. };
  25489. });
  25490. }
  25491. function transformIndentedCodeblockAndMarkItsParentList(ast, options) {
  25492. return mapAst$1(ast, function (node, index, parentStack) {
  25493. if (node.type === "code") {
  25494. // the first char may point to `\n`, e.g. `\n\t\tbar`, just ignore it
  25495. var isIndented = /^\n?( {4,}|\t)/.test(options.originalText.slice(node.position.start.offset, node.position.end.offset));
  25496. node.isIndented = isIndented;
  25497. if (isIndented) {
  25498. for (var i = 0; i < parentStack.length; i++) {
  25499. var parent = parentStack[i]; // no need to check checked items
  25500. if (parent.hasIndentedCodeblock) {
  25501. break;
  25502. }
  25503. if (parent.type === "list") {
  25504. parent.hasIndentedCodeblock = true;
  25505. }
  25506. }
  25507. }
  25508. }
  25509. return node;
  25510. });
  25511. }
  25512. function markAlignedList(ast, options) {
  25513. return mapAst$1(ast, function (node, index, parentStack) {
  25514. if (node.type === "list" && node.children.length !== 0) {
  25515. // if one of its parents is not aligned, it's not possible to be aligned in sub-lists
  25516. for (var i = 0; i < parentStack.length; i++) {
  25517. var parent = parentStack[i];
  25518. if (parent.type === "list" && !parent.isAligned) {
  25519. node.isAligned = false;
  25520. return node;
  25521. }
  25522. }
  25523. node.isAligned = isAligned(node);
  25524. }
  25525. return node;
  25526. });
  25527. function getListItemStart(listItem) {
  25528. return listItem.children.length === 0 ? -1 : listItem.children[0].position.start.column - 1;
  25529. }
  25530. function isAligned(list) {
  25531. if (!list.ordered) {
  25532. /**
  25533. * - 123
  25534. * - 123
  25535. */
  25536. return true;
  25537. }
  25538. var _list$children = _slicedToArray(list.children, 2),
  25539. firstItem = _list$children[0],
  25540. secondItem = _list$children[1];
  25541. var firstInfo = getOrderedListItemInfo$2(firstItem, options.originalText);
  25542. if (firstInfo.leadingSpaces.length > 1) {
  25543. /**
  25544. * 1. 123
  25545. *
  25546. * 1. 123
  25547. * 1. 123
  25548. */
  25549. return true;
  25550. }
  25551. var firstStart = getListItemStart(firstItem);
  25552. if (firstStart === -1) {
  25553. /**
  25554. * 1.
  25555. *
  25556. * 1.
  25557. * 1.
  25558. */
  25559. return false;
  25560. }
  25561. if (list.children.length === 1) {
  25562. /**
  25563. * aligned:
  25564. *
  25565. * 11. 123
  25566. *
  25567. * not aligned:
  25568. *
  25569. * 1. 123
  25570. */
  25571. return firstStart % options.tabWidth === 0;
  25572. }
  25573. var secondStart = getListItemStart(secondItem);
  25574. if (firstStart !== secondStart) {
  25575. /**
  25576. * 11. 123
  25577. * 1. 123
  25578. *
  25579. * 1. 123
  25580. * 11. 123
  25581. */
  25582. return false;
  25583. }
  25584. if (firstStart % options.tabWidth === 0) {
  25585. /**
  25586. * 11. 123
  25587. * 12. 123
  25588. */
  25589. return true;
  25590. }
  25591. /**
  25592. * aligned:
  25593. *
  25594. * 11. 123
  25595. * 1. 123
  25596. *
  25597. * not aligned:
  25598. *
  25599. * 1. 123
  25600. * 2. 123
  25601. */
  25602. var secondInfo = getOrderedListItemInfo$2(secondItem, options.originalText);
  25603. return secondInfo.leadingSpaces.length > 1;
  25604. }
  25605. }
  25606. var preprocess_1$2 = preprocess$2;
  25607. var _require$$0$builders$6 = doc.builders;
  25608. var concat$12 = _require$$0$builders$6.concat;
  25609. var join$9 = _require$$0$builders$6.join;
  25610. var line$8 = _require$$0$builders$6.line;
  25611. var literalline$4 = _require$$0$builders$6.literalline;
  25612. var markAsRoot$2 = _require$$0$builders$6.markAsRoot;
  25613. var hardline$10 = _require$$0$builders$6.hardline;
  25614. var softline$6 = _require$$0$builders$6.softline;
  25615. var fill$4 = _require$$0$builders$6.fill;
  25616. var align$2 = _require$$0$builders$6.align;
  25617. var indent$8 = _require$$0$builders$6.indent;
  25618. var group$13 = _require$$0$builders$6.group;
  25619. var mapDoc$5 = doc.utils.mapDoc;
  25620. var printDocToString$3 = doc.printer.printDocToString;
  25621. var getFencedCodeBlockValue = utils$8.getFencedCodeBlockValue;
  25622. var getOrderedListItemInfo = utils$8.getOrderedListItemInfo;
  25623. var splitText = utils$8.splitText;
  25624. var punctuationPattern = utils$8.punctuationPattern;
  25625. var INLINE_NODE_TYPES = utils$8.INLINE_NODE_TYPES;
  25626. var INLINE_NODE_WRAPPER_TYPES = utils$8.INLINE_NODE_WRAPPER_TYPES;
  25627. var replaceEndOfLineWith$1 = util$1.replaceEndOfLineWith;
  25628. var TRAILING_HARDLINE_NODES = ["importExport"];
  25629. var SINGLE_LINE_NODE_TYPES = ["heading", "tableCell", "link"];
  25630. var SIBLING_NODE_TYPES = ["listItem", "definition", "footnoteDefinition"];
  25631. function genericPrint$4(path$$1, options, print) {
  25632. var node = path$$1.getValue();
  25633. if (shouldRemainTheSameContent(path$$1)) {
  25634. return concat$12(splitText(options.originalText.slice(node.position.start.offset, node.position.end.offset), options).map(function (node) {
  25635. return node.type === "word" ? node.value : node.value === "" ? "" : printLine(path$$1, node.value, options);
  25636. }));
  25637. }
  25638. switch (node.type) {
  25639. case "root":
  25640. if (node.children.length === 0) {
  25641. return "";
  25642. }
  25643. return concat$12([normalizeDoc(printRoot(path$$1, options, print)), TRAILING_HARDLINE_NODES.indexOf(getLastDescendantNode(node).type) === -1 ? hardline$10 : ""]);
  25644. case "paragraph":
  25645. return printChildren(path$$1, options, print, {
  25646. postprocessor: fill$4
  25647. });
  25648. case "sentence":
  25649. return printChildren(path$$1, options, print);
  25650. case "word":
  25651. return node.value.replace(/[*$]/g, "\\$&") // escape all `*` and `$` (math)
  25652. .replace(new RegExp([`(^|${punctuationPattern})(_+)`, `(_+)(${punctuationPattern}|$)`].join("|"), "g"), function (_, text1, underscore1, underscore2, text2) {
  25653. return (underscore1 ? `${text1}${underscore1}` : `${underscore2}${text2}`).replace(/_/g, "\\_");
  25654. });
  25655. // escape all `_` except concating with non-punctuation, e.g. `1_2_3` is not considered emphasis
  25656. case "whitespace":
  25657. {
  25658. var parentNode = path$$1.getParentNode();
  25659. var index = parentNode.children.indexOf(node);
  25660. var nextNode = parentNode.children[index + 1];
  25661. var proseWrap = // leading char that may cause different syntax
  25662. nextNode && /^>|^([-+*]|#{1,6}|[0-9]+[.)])$/.test(nextNode.value) ? "never" : options.proseWrap;
  25663. return printLine(path$$1, node.value, {
  25664. proseWrap
  25665. });
  25666. }
  25667. case "emphasis":
  25668. {
  25669. var _parentNode = path$$1.getParentNode();
  25670. var _index = _parentNode.children.indexOf(node);
  25671. var prevNode = _parentNode.children[_index - 1];
  25672. var _nextNode = _parentNode.children[_index + 1];
  25673. var hasPrevOrNextWord = // `1*2*3` is considered emphais but `1_2_3` is not
  25674. prevNode && prevNode.type === "sentence" && prevNode.children.length > 0 && util$1.getLast(prevNode.children).type === "word" && !util$1.getLast(prevNode.children).hasTrailingPunctuation || _nextNode && _nextNode.type === "sentence" && _nextNode.children.length > 0 && _nextNode.children[0].type === "word" && !_nextNode.children[0].hasLeadingPunctuation;
  25675. var style = hasPrevOrNextWord || getAncestorNode$2(path$$1, "emphasis") ? "*" : "_";
  25676. return concat$12([style, printChildren(path$$1, options, print), style]);
  25677. }
  25678. case "strong":
  25679. return concat$12(["**", printChildren(path$$1, options, print), "**"]);
  25680. case "delete":
  25681. return concat$12(["~~", printChildren(path$$1, options, print), "~~"]);
  25682. case "inlineCode":
  25683. {
  25684. var backtickCount = util$1.getMaxContinuousCount(node.value, "`");
  25685. var _style = backtickCount === 1 ? "``" : "`";
  25686. var gap = backtickCount ? " " : "";
  25687. return concat$12([_style, gap, node.value, gap, _style]);
  25688. }
  25689. case "link":
  25690. switch (options.originalText[node.position.start.offset]) {
  25691. case "<":
  25692. {
  25693. var mailto = "mailto:";
  25694. var url = // <hello@example.com> is parsed as { url: "mailto:hello@example.com" }
  25695. node.url.startsWith(mailto) && options.originalText.slice(node.position.start.offset + 1, node.position.start.offset + 1 + mailto.length) !== mailto ? node.url.slice(mailto.length) : node.url;
  25696. return concat$12(["<", url, ">"]);
  25697. }
  25698. case "[":
  25699. return concat$12(["[", printChildren(path$$1, options, print), "](", printUrl(node.url, ")"), printTitle(node.title, options), ")"]);
  25700. default:
  25701. return options.originalText.slice(node.position.start.offset, node.position.end.offset);
  25702. }
  25703. case "image":
  25704. return concat$12(["![", node.alt || "", "](", printUrl(node.url, ")"), printTitle(node.title, options), ")"]);
  25705. case "blockquote":
  25706. return concat$12(["> ", align$2("> ", printChildren(path$$1, options, print))]);
  25707. case "heading":
  25708. return concat$12(["#".repeat(node.depth) + " ", printChildren(path$$1, options, print)]);
  25709. case "code":
  25710. {
  25711. if (node.isIndented) {
  25712. // indented code block
  25713. var alignment = " ".repeat(4);
  25714. return align$2(alignment, concat$12([alignment, concat$12(replaceEndOfLineWith$1(node.value, hardline$10))]));
  25715. } // fenced code block
  25716. var styleUnit = options.__inJsTemplate ? "~" : "`";
  25717. var _style2 = styleUnit.repeat(Math.max(3, util$1.getMaxContinuousCount(node.value, styleUnit) + 1));
  25718. return concat$12([_style2, node.lang || "", hardline$10, concat$12(replaceEndOfLineWith$1(getFencedCodeBlockValue(node, options.originalText), hardline$10)), hardline$10, _style2]);
  25719. }
  25720. case "yaml":
  25721. case "toml":
  25722. return options.originalText.slice(node.position.start.offset, node.position.end.offset);
  25723. case "html":
  25724. {
  25725. var _parentNode2 = path$$1.getParentNode();
  25726. var value = _parentNode2.type === "root" && util$1.getLast(_parentNode2.children) === node ? node.value.trimRight() : node.value;
  25727. var isHtmlComment = /^<!--[\s\S]*-->$/.test(value);
  25728. return concat$12(replaceEndOfLineWith$1(value, isHtmlComment ? hardline$10 : markAsRoot$2(literalline$4)));
  25729. }
  25730. case "list":
  25731. {
  25732. var nthSiblingIndex = getNthListSiblingIndex(node, path$$1.getParentNode());
  25733. var isGitDiffFriendlyOrderedList = node.ordered && node.children.length > 1 && +getOrderedListItemInfo(node.children[1], options.originalText).numberText === 1;
  25734. return printChildren(path$$1, options, print, {
  25735. processor: function processor(childPath, index) {
  25736. var prefix = getPrefix();
  25737. return concat$12([prefix, align$2(" ".repeat(prefix.length), printListItem(childPath, options, print, prefix))]);
  25738. function getPrefix() {
  25739. var rawPrefix = node.ordered ? (index === 0 ? node.start : isGitDiffFriendlyOrderedList ? 1 : node.start + index) + (nthSiblingIndex % 2 === 0 ? ". " : ") ") : nthSiblingIndex % 2 === 0 ? "- " : "* ";
  25740. return node.isAligned ||
  25741. /* workaround for https://github.com/remarkjs/remark/issues/315 */
  25742. node.hasIndentedCodeblock ? alignListPrefix(rawPrefix, options) : rawPrefix;
  25743. }
  25744. }
  25745. });
  25746. }
  25747. case "thematicBreak":
  25748. {
  25749. var counter = getAncestorCounter$1(path$$1, "list");
  25750. if (counter === -1) {
  25751. return "---";
  25752. }
  25753. var _nthSiblingIndex = getNthListSiblingIndex(path$$1.getParentNode(counter), path$$1.getParentNode(counter + 1));
  25754. return _nthSiblingIndex % 2 === 0 ? "***" : "---";
  25755. }
  25756. case "linkReference":
  25757. return concat$12(["[", printChildren(path$$1, options, print), "]", node.referenceType === "full" ? concat$12(["[", node.identifier, "]"]) : node.referenceType === "collapsed" ? "[]" : ""]);
  25758. case "imageReference":
  25759. switch (node.referenceType) {
  25760. case "full":
  25761. return concat$12(["![", node.alt || "", "][", node.identifier, "]"]);
  25762. default:
  25763. return concat$12(["![", node.alt, "]", node.referenceType === "collapsed" ? "[]" : ""]);
  25764. }
  25765. case "definition":
  25766. {
  25767. var lineOrSpace = options.proseWrap === "always" ? line$8 : " ";
  25768. return group$13(concat$12([concat$12(["[", node.identifier, "]:"]), indent$8(concat$12([lineOrSpace, printUrl(node.url), node.title === null ? "" : concat$12([lineOrSpace, printTitle(node.title, options, false)])]))]));
  25769. }
  25770. case "footnote":
  25771. return concat$12(["[^", printChildren(path$$1, options, print), "]"]);
  25772. case "footnoteReference":
  25773. return concat$12(["[^", node.identifier, "]"]);
  25774. case "footnoteDefinition":
  25775. {
  25776. var _nextNode2 = path$$1.getParentNode().children[path$$1.getName() + 1];
  25777. var shouldInlineFootnote = node.children.length === 1 && node.children[0].type === "paragraph" && (options.proseWrap === "never" || options.proseWrap === "preserve" && node.children[0].position.start.line === node.children[0].position.end.line);
  25778. return concat$12(["[^", node.identifier, "]: ", shouldInlineFootnote ? printChildren(path$$1, options, print) : group$13(concat$12([align$2(" ".repeat(options.tabWidth), printChildren(path$$1, options, print, {
  25779. processor: function processor(childPath, index) {
  25780. return index === 0 ? group$13(concat$12([softline$6, softline$6, childPath.call(print)])) : childPath.call(print);
  25781. }
  25782. })), _nextNode2 && _nextNode2.type === "footnoteDefinition" ? softline$6 : ""]))]);
  25783. }
  25784. case "table":
  25785. return printTable(path$$1, options, print);
  25786. case "tableCell":
  25787. return printChildren(path$$1, options, print);
  25788. case "break":
  25789. return /\s/.test(options.originalText[node.position.start.offset]) ? concat$12([" ", markAsRoot$2(literalline$4)]) : concat$12(["\\", hardline$10]);
  25790. case "liquidNode":
  25791. return concat$12(replaceEndOfLineWith$1(node.value, hardline$10));
  25792. // MDX
  25793. case "importExport":
  25794. case "jsx":
  25795. return node.value;
  25796. // fallback to the original text if multiparser failed
  25797. case "math":
  25798. return concat$12(["$$", hardline$10, node.value ? concat$12([concat$12(replaceEndOfLineWith$1(node.value, hardline$10)), hardline$10]) : "", "$$"]);
  25799. case "inlineMath":
  25800. {
  25801. // remark-math trims content but we don't want to remove whitespaces
  25802. // since it's very possible that it's recognized as math accidentally
  25803. return options.originalText.slice(options.locStart(node), options.locEnd(node));
  25804. }
  25805. case "tableRow": // handled in "table"
  25806. case "listItem": // handled in "list"
  25807. default:
  25808. throw new Error(`Unknown markdown type ${JSON.stringify(node.type)}`);
  25809. }
  25810. }
  25811. function printListItem(path$$1, options, print, listPrefix) {
  25812. var node = path$$1.getValue();
  25813. var prefix = node.checked === null ? "" : node.checked ? "[x] " : "[ ] ";
  25814. return concat$12([prefix, printChildren(path$$1, options, print, {
  25815. processor: function processor(childPath, index) {
  25816. if (index === 0 && childPath.getValue().type !== "list") {
  25817. return align$2(" ".repeat(prefix.length), childPath.call(print));
  25818. }
  25819. var alignment = " ".repeat(clamp(options.tabWidth - listPrefix.length, 0, 3) // 4+ will cause indented code block
  25820. );
  25821. return concat$12([alignment, align$2(alignment, childPath.call(print))]);
  25822. }
  25823. })]);
  25824. }
  25825. function alignListPrefix(prefix, options) {
  25826. var additionalSpaces = getAdditionalSpaces();
  25827. return prefix + " ".repeat(additionalSpaces >= 4 ? 0 : additionalSpaces // 4+ will cause indented code block
  25828. );
  25829. function getAdditionalSpaces() {
  25830. var restSpaces = prefix.length % options.tabWidth;
  25831. return restSpaces === 0 ? 0 : options.tabWidth - restSpaces;
  25832. }
  25833. }
  25834. function getNthListSiblingIndex(node, parentNode) {
  25835. return getNthSiblingIndex(node, parentNode, function (siblingNode) {
  25836. return siblingNode.ordered === node.ordered;
  25837. });
  25838. }
  25839. function getNthSiblingIndex(node, parentNode, condition) {
  25840. condition = condition || function () {
  25841. return true;
  25842. };
  25843. var index = -1;
  25844. var _iteratorNormalCompletion = true;
  25845. var _didIteratorError = false;
  25846. var _iteratorError = undefined;
  25847. try {
  25848. for (var _iterator = parentNode.children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  25849. var childNode = _step.value;
  25850. if (childNode.type === node.type && condition(childNode)) {
  25851. index++;
  25852. } else {
  25853. index = -1;
  25854. }
  25855. if (childNode === node) {
  25856. return index;
  25857. }
  25858. }
  25859. } catch (err) {
  25860. _didIteratorError = true;
  25861. _iteratorError = err;
  25862. } finally {
  25863. try {
  25864. if (!_iteratorNormalCompletion && _iterator.return != null) {
  25865. _iterator.return();
  25866. }
  25867. } finally {
  25868. if (_didIteratorError) {
  25869. throw _iteratorError;
  25870. }
  25871. }
  25872. }
  25873. }
  25874. function getAncestorCounter$1(path$$1, typeOrTypes) {
  25875. var types = [].concat(typeOrTypes);
  25876. var counter = -1;
  25877. var ancestorNode;
  25878. while (ancestorNode = path$$1.getParentNode(++counter)) {
  25879. if (types.indexOf(ancestorNode.type) !== -1) {
  25880. return counter;
  25881. }
  25882. }
  25883. return -1;
  25884. }
  25885. function getAncestorNode$2(path$$1, typeOrTypes) {
  25886. var counter = getAncestorCounter$1(path$$1, typeOrTypes);
  25887. return counter === -1 ? null : path$$1.getParentNode(counter);
  25888. }
  25889. function printLine(path$$1, value, options) {
  25890. if (options.proseWrap === "preserve" && value === "\n") {
  25891. return hardline$10;
  25892. }
  25893. var isBreakable = options.proseWrap === "always" && !getAncestorNode$2(path$$1, SINGLE_LINE_NODE_TYPES);
  25894. return value !== "" ? isBreakable ? line$8 : " " : isBreakable ? softline$6 : "";
  25895. }
  25896. function printTable(path$$1, options, print) {
  25897. var node = path$$1.getValue();
  25898. var contents = []; // { [rowIndex: number]: { [columnIndex: number]: string } }
  25899. path$$1.map(function (rowPath) {
  25900. var rowContents = [];
  25901. rowPath.map(function (cellPath) {
  25902. rowContents.push(printDocToString$3(cellPath.call(print), options).formatted);
  25903. }, "children");
  25904. contents.push(rowContents);
  25905. }, "children");
  25906. var columnMaxWidths = contents.reduce(function (currentWidths, rowContents) {
  25907. return currentWidths.map(function (width, columnIndex) {
  25908. return Math.max(width, util$1.getStringWidth(rowContents[columnIndex]));
  25909. });
  25910. }, contents[0].map(function () {
  25911. return 3;
  25912. }) // minimum width = 3 (---, :--, :-:, --:)
  25913. );
  25914. return join$9(hardline$10, [printRow(contents[0]), printSeparator(), join$9(hardline$10, contents.slice(1).map(printRow))]);
  25915. function printSeparator() {
  25916. return concat$12(["| ", join$9(" | ", columnMaxWidths.map(function (width, index) {
  25917. switch (node.align[index]) {
  25918. case "left":
  25919. return ":" + "-".repeat(width - 1);
  25920. case "right":
  25921. return "-".repeat(width - 1) + ":";
  25922. case "center":
  25923. return ":" + "-".repeat(width - 2) + ":";
  25924. default:
  25925. return "-".repeat(width);
  25926. }
  25927. })), " |"]);
  25928. }
  25929. function printRow(rowContents) {
  25930. return concat$12(["| ", join$9(" | ", rowContents.map(function (rowContent, columnIndex) {
  25931. switch (node.align[columnIndex]) {
  25932. case "right":
  25933. return alignRight(rowContent, columnMaxWidths[columnIndex]);
  25934. case "center":
  25935. return alignCenter(rowContent, columnMaxWidths[columnIndex]);
  25936. default:
  25937. return alignLeft(rowContent, columnMaxWidths[columnIndex]);
  25938. }
  25939. })), " |"]);
  25940. }
  25941. function alignLeft(text, width) {
  25942. return concat$12([text, " ".repeat(width - util$1.getStringWidth(text))]);
  25943. }
  25944. function alignRight(text, width) {
  25945. return concat$12([" ".repeat(width - util$1.getStringWidth(text)), text]);
  25946. }
  25947. function alignCenter(text, width) {
  25948. var spaces = width - util$1.getStringWidth(text);
  25949. var left = Math.floor(spaces / 2);
  25950. var right = spaces - left;
  25951. return concat$12([" ".repeat(left), text, " ".repeat(right)]);
  25952. }
  25953. }
  25954. function printRoot(path$$1, options, print) {
  25955. /** @typedef {{ index: number, offset: number }} IgnorePosition */
  25956. /** @type {Array<{start: IgnorePosition, end: IgnorePosition}>} */
  25957. var ignoreRanges = [];
  25958. /** @type {IgnorePosition | null} */
  25959. var ignoreStart = null;
  25960. var children = path$$1.getValue().children;
  25961. children.forEach(function (childNode, index) {
  25962. switch (isPrettierIgnore(childNode)) {
  25963. case "start":
  25964. if (ignoreStart === null) {
  25965. ignoreStart = {
  25966. index,
  25967. offset: childNode.position.end.offset
  25968. };
  25969. }
  25970. break;
  25971. case "end":
  25972. if (ignoreStart !== null) {
  25973. ignoreRanges.push({
  25974. start: ignoreStart,
  25975. end: {
  25976. index,
  25977. offset: childNode.position.start.offset
  25978. }
  25979. });
  25980. ignoreStart = null;
  25981. }
  25982. break;
  25983. default:
  25984. // do nothing
  25985. break;
  25986. }
  25987. });
  25988. return printChildren(path$$1, options, print, {
  25989. processor: function processor(childPath, index) {
  25990. if (ignoreRanges.length !== 0) {
  25991. var ignoreRange = ignoreRanges[0];
  25992. if (index === ignoreRange.start.index) {
  25993. return concat$12([children[ignoreRange.start.index].value, options.originalText.slice(ignoreRange.start.offset, ignoreRange.end.offset), children[ignoreRange.end.index].value]);
  25994. }
  25995. if (ignoreRange.start.index < index && index < ignoreRange.end.index) {
  25996. return false;
  25997. }
  25998. if (index === ignoreRange.end.index) {
  25999. ignoreRanges.shift();
  26000. return false;
  26001. }
  26002. }
  26003. return childPath.call(print);
  26004. }
  26005. });
  26006. }
  26007. function printChildren(path$$1, options, print, events$$1) {
  26008. events$$1 = events$$1 || {};
  26009. var postprocessor = events$$1.postprocessor || concat$12;
  26010. var processor = events$$1.processor || function (childPath) {
  26011. return childPath.call(print);
  26012. };
  26013. var node = path$$1.getValue();
  26014. var parts = [];
  26015. var lastChildNode;
  26016. path$$1.map(function (childPath, index) {
  26017. var childNode = childPath.getValue();
  26018. var result = processor(childPath, index);
  26019. if (result !== false) {
  26020. var data = {
  26021. parts,
  26022. prevNode: lastChildNode,
  26023. parentNode: node,
  26024. options
  26025. };
  26026. if (!shouldNotPrePrintHardline(childNode, data)) {
  26027. parts.push(hardline$10);
  26028. if (lastChildNode && TRAILING_HARDLINE_NODES.indexOf(lastChildNode.type) !== -1) {
  26029. if (shouldPrePrintTripleHardline(childNode, data)) {
  26030. parts.push(hardline$10);
  26031. }
  26032. } else {
  26033. if (shouldPrePrintDoubleHardline(childNode, data) || shouldPrePrintTripleHardline(childNode, data)) {
  26034. parts.push(hardline$10);
  26035. }
  26036. if (shouldPrePrintTripleHardline(childNode, data)) {
  26037. parts.push(hardline$10);
  26038. }
  26039. }
  26040. }
  26041. parts.push(result);
  26042. lastChildNode = childNode;
  26043. }
  26044. }, "children");
  26045. return postprocessor(parts);
  26046. }
  26047. function getLastDescendantNode(node) {
  26048. var current = node;
  26049. while (current.children && current.children.length !== 0) {
  26050. current = current.children[current.children.length - 1];
  26051. }
  26052. return current;
  26053. }
  26054. /** @return {false | 'next' | 'start' | 'end'} */
  26055. function isPrettierIgnore(node) {
  26056. if (node.type !== "html") {
  26057. return false;
  26058. }
  26059. var match = node.value.match(/^<!--\s*prettier-ignore(?:-(start|end))?\s*-->$/);
  26060. return match === null ? false : match[1] ? match[1] : "next";
  26061. }
  26062. function shouldNotPrePrintHardline(node, data) {
  26063. var isFirstNode = data.parts.length === 0;
  26064. var isInlineNode = INLINE_NODE_TYPES.indexOf(node.type) !== -1;
  26065. var isInlineHTML = node.type === "html" && INLINE_NODE_WRAPPER_TYPES.indexOf(data.parentNode.type) !== -1;
  26066. return isFirstNode || isInlineNode || isInlineHTML;
  26067. }
  26068. function shouldPrePrintDoubleHardline(node, data) {
  26069. var isSequence = (data.prevNode && data.prevNode.type) === node.type;
  26070. var isSiblingNode = isSequence && SIBLING_NODE_TYPES.indexOf(node.type) !== -1;
  26071. var isInTightListItem = data.parentNode.type === "listItem" && !data.parentNode.loose;
  26072. var isPrevNodeLooseListItem = data.prevNode && data.prevNode.type === "listItem" && data.prevNode.loose;
  26073. var isPrevNodePrettierIgnore = isPrettierIgnore(data.prevNode) === "next";
  26074. var isBlockHtmlWithoutBlankLineBetweenPrevHtml = node.type === "html" && data.prevNode && data.prevNode.type === "html" && data.prevNode.position.end.line + 1 === node.position.start.line;
  26075. return isPrevNodeLooseListItem || !(isSiblingNode || isInTightListItem || isPrevNodePrettierIgnore || isBlockHtmlWithoutBlankLineBetweenPrevHtml);
  26076. }
  26077. function shouldPrePrintTripleHardline(node, data) {
  26078. var isPrevNodeList = data.prevNode && data.prevNode.type === "list";
  26079. var isIndentedCode = node.type === "code" && node.isIndented;
  26080. return isPrevNodeList && isIndentedCode;
  26081. }
  26082. function shouldRemainTheSameContent(path$$1) {
  26083. var ancestorNode = getAncestorNode$2(path$$1, ["linkReference", "imageReference"]);
  26084. return ancestorNode && (ancestorNode.type !== "linkReference" || ancestorNode.referenceType !== "full");
  26085. }
  26086. function normalizeDoc(doc$$2) {
  26087. return mapDoc$5(doc$$2, function (currentDoc) {
  26088. if (!currentDoc.parts) {
  26089. return currentDoc;
  26090. }
  26091. if (currentDoc.type === "concat" && currentDoc.parts.length === 1) {
  26092. return currentDoc.parts[0];
  26093. }
  26094. var parts = [];
  26095. currentDoc.parts.forEach(function (part) {
  26096. if (part.type === "concat") {
  26097. parts.push.apply(parts, part.parts);
  26098. } else if (part !== "") {
  26099. parts.push(part);
  26100. }
  26101. });
  26102. return Object.assign({}, currentDoc, {
  26103. parts: normalizeParts(parts)
  26104. });
  26105. });
  26106. }
  26107. function printUrl(url, dangerousCharOrChars) {
  26108. var dangerousChars = [" "].concat(dangerousCharOrChars || []);
  26109. return new RegExp(dangerousChars.map(function (x) {
  26110. return `\\${x}`;
  26111. }).join("|")).test(url) ? `<${url}>` : url;
  26112. }
  26113. function printTitle(title, options, printSpace) {
  26114. if (printSpace == null) {
  26115. printSpace = true;
  26116. }
  26117. if (!title) {
  26118. return "";
  26119. }
  26120. if (printSpace) {
  26121. return " " + printTitle(title, options, false);
  26122. }
  26123. if (title.includes('"') && title.includes("'") && !title.includes(")")) {
  26124. return `(${title})`; // avoid escaped quotes
  26125. } // faster than using RegExps: https://jsperf.com/performance-of-match-vs-split
  26126. var singleCount = title.split("'").length - 1;
  26127. var doubleCount = title.split('"').length - 1;
  26128. var quote = singleCount > doubleCount ? '"' : doubleCount > singleCount ? "'" : options.singleQuote ? "'" : '"';
  26129. title = title.replace(new RegExp(`(${quote})`, "g"), "\\$1");
  26130. return `${quote}${title}${quote}`;
  26131. }
  26132. function normalizeParts(parts) {
  26133. return parts.reduce(function (current, part) {
  26134. var lastPart = util$1.getLast(current);
  26135. if (typeof lastPart === "string" && typeof part === "string") {
  26136. current.splice(-1, 1, lastPart + part);
  26137. } else {
  26138. current.push(part);
  26139. }
  26140. return current;
  26141. }, []);
  26142. }
  26143. function clamp(value, min, max) {
  26144. return value < min ? min : value > max ? max : value;
  26145. }
  26146. function clean$7(ast, newObj, parent) {
  26147. delete newObj.position;
  26148. delete newObj.raw; // front-matter
  26149. // for codeblock
  26150. if (ast.type === "code" || ast.type === "yaml" || ast.type === "import" || ast.type === "export" || ast.type === "jsx") {
  26151. delete newObj.value;
  26152. }
  26153. if (ast.type === "list") {
  26154. delete newObj.isAligned;
  26155. } // texts can be splitted or merged
  26156. if (ast.type === "text") {
  26157. return null;
  26158. }
  26159. if (ast.type === "inlineCode") {
  26160. newObj.value = ast.value.replace(/[ \t\n]+/g, " ");
  26161. } // for insert pragma
  26162. if (parent && parent.type === "root" && parent.children.length > 0 && (parent.children[0] === ast || (parent.children[0].type === "yaml" || parent.children[0].type === "toml") && parent.children[1] === ast) && ast.type === "html" && pragma$6.startWithPragma(ast.value)) {
  26163. return null;
  26164. }
  26165. }
  26166. function hasPrettierIgnore$1(path$$1) {
  26167. var index = +path$$1.getName();
  26168. if (index === 0) {
  26169. return false;
  26170. }
  26171. var prevNode = path$$1.getParentNode().children[index - 1];
  26172. return isPrettierIgnore(prevNode) === "next";
  26173. }
  26174. var printerMarkdown = {
  26175. preprocess: preprocess_1$2,
  26176. print: genericPrint$4,
  26177. embed: embed_1$4,
  26178. massageAstNode: clean$7,
  26179. hasPrettierIgnore: hasPrettierIgnore$1,
  26180. insertPragma: pragma$6.insertPragma
  26181. };
  26182. var options$13 = {
  26183. proseWrap: commonOptions.proseWrap,
  26184. singleQuote: commonOptions.singleQuote
  26185. };
  26186. var name$13 = "Markdown";
  26187. var type$12 = "prose";
  26188. var aliases$4 = ["pandoc"];
  26189. var aceMode$12 = "markdown";
  26190. var codemirrorMode$9 = "gfm";
  26191. var codemirrorMimeType$9 = "text/x-gfm";
  26192. var wrap = true;
  26193. var extensions$12 = [".md", ".markdown", ".mdown", ".mdwn", ".mkd", ".mkdn", ".mkdown", ".ronn", ".workbook"];
  26194. var tmScope$12 = "source.gfm";
  26195. var languageId$12 = 222;
  26196. var markdown = {
  26197. name: name$13,
  26198. type: type$12,
  26199. aliases: aliases$4,
  26200. aceMode: aceMode$12,
  26201. codemirrorMode: codemirrorMode$9,
  26202. codemirrorMimeType: codemirrorMimeType$9,
  26203. wrap: wrap,
  26204. extensions: extensions$12,
  26205. tmScope: tmScope$12,
  26206. languageId: languageId$12
  26207. };
  26208. var markdown$1 = Object.freeze({
  26209. name: name$13,
  26210. type: type$12,
  26211. aliases: aliases$4,
  26212. aceMode: aceMode$12,
  26213. codemirrorMode: codemirrorMode$9,
  26214. codemirrorMimeType: codemirrorMimeType$9,
  26215. wrap: wrap,
  26216. extensions: extensions$12,
  26217. tmScope: tmScope$12,
  26218. languageId: languageId$12,
  26219. default: markdown
  26220. });
  26221. var require$$0$28 = ( markdown$1 && markdown ) || markdown$1;
  26222. var languages$4 = [createLanguage(require$$0$28, {
  26223. override: {
  26224. since: "1.8.0",
  26225. parsers: ["remark"],
  26226. vscodeLanguageIds: ["markdown"]
  26227. },
  26228. extend: {
  26229. filenames: ["README"]
  26230. }
  26231. }), createLanguage({
  26232. name: "MDX",
  26233. extensions: [".mdx"]
  26234. }, // TODO: use linguist data
  26235. {
  26236. override: {
  26237. since: "1.15.0",
  26238. parsers: ["mdx"],
  26239. vscodeLanguageIds: ["mdx"]
  26240. }
  26241. })];
  26242. var printers$4 = {
  26243. mdast: printerMarkdown
  26244. };
  26245. var languageMarkdown = {
  26246. languages: languages$4,
  26247. options: options$13,
  26248. printers: printers$4
  26249. };
  26250. var clean$8 = function clean(ast, newNode) {
  26251. delete newNode.sourceSpan;
  26252. delete newNode.startSourceSpan;
  26253. delete newNode.endSourceSpan;
  26254. delete newNode.nameSpan;
  26255. delete newNode.valueSpan;
  26256. if (ast.type === "text" || ast.type === "comment") {
  26257. return null;
  26258. } // may be formatted by multiparser
  26259. if (ast.type === "yaml" || ast.type === "toml") {
  26260. return null;
  26261. }
  26262. if (ast.type === "attribute") {
  26263. delete newNode.value;
  26264. }
  26265. if (ast.type === "docType") {
  26266. delete newNode.value;
  26267. }
  26268. };
  26269. var a = ["accesskey", "charset", "coords", "download", "href", "hreflang", "name", "ping", "referrerpolicy", "rel", "rev", "shape", "tabindex", "target", "type"];
  26270. var abbr = ["title"];
  26271. var applet = ["align", "alt", "archive", "code", "codebase", "height", "hspace", "name", "object", "vspace", "width"];
  26272. var area = ["accesskey", "alt", "coords", "download", "href", "hreflang", "nohref", "ping", "referrerpolicy", "rel", "shape", "tabindex", "target", "type"];
  26273. var audio = ["autoplay", "controls", "crossorigin", "loop", "muted", "preload", "src"];
  26274. var base$2 = ["href", "target"];
  26275. var basefont = ["color", "face", "size"];
  26276. var bdo = ["dir"];
  26277. var blockquote = ["cite"];
  26278. var body = ["alink", "background", "bgcolor", "link", "text", "vlink"];
  26279. var br = ["clear"];
  26280. var button = ["accesskey", "autofocus", "disabled", "form", "formaction", "formenctype", "formmethod", "formnovalidate", "formtarget", "name", "tabindex", "type", "value"];
  26281. var canvas = ["height", "width"];
  26282. var caption = ["align"];
  26283. var col = ["align", "char", "charoff", "span", "valign", "width"];
  26284. var colgroup = ["align", "char", "charoff", "span", "valign", "width"];
  26285. var data$1 = ["value"];
  26286. var del = ["cite", "datetime"];
  26287. var details = ["open"];
  26288. var dfn = ["title"];
  26289. var dialog = ["open"];
  26290. var dir = ["compact"];
  26291. var div = ["align"];
  26292. var dl = ["compact"];
  26293. var embed$7 = ["height", "src", "type", "width"];
  26294. var fieldset = ["disabled", "form", "name"];
  26295. var font = ["color", "face", "size"];
  26296. var form = ["accept", "accept-charset", "action", "autocomplete", "enctype", "method", "name", "novalidate", "target"];
  26297. var frame = ["frameborder", "longdesc", "marginheight", "marginwidth", "name", "noresize", "scrolling", "src"];
  26298. var frameset = ["cols", "rows"];
  26299. var h1 = ["align"];
  26300. var h2 = ["align"];
  26301. var h3 = ["align"];
  26302. var h4 = ["align"];
  26303. var h5 = ["align"];
  26304. var h6 = ["align"];
  26305. var head = ["profile"];
  26306. var hr = ["align", "noshade", "size", "width"];
  26307. var html = ["manifest", "version"];
  26308. var iframe = ["align", "allowfullscreen", "allowpaymentrequest", "allowusermedia", "frameborder", "height", "longdesc", "marginheight", "marginwidth", "name", "referrerpolicy", "sandbox", "scrolling", "src", "srcdoc", "width"];
  26309. var img = ["align", "alt", "border", "crossorigin", "decoding", "height", "hspace", "ismap", "longdesc", "name", "referrerpolicy", "sizes", "src", "srcset", "usemap", "vspace", "width"];
  26310. var input = ["accept", "accesskey", "align", "alt", "autocomplete", "autofocus", "checked", "dirname", "disabled", "form", "formaction", "formenctype", "formmethod", "formnovalidate", "formtarget", "height", "ismap", "list", "max", "maxlength", "min", "minlength", "multiple", "name", "pattern", "placeholder", "readonly", "required", "size", "src", "step", "tabindex", "title", "type", "usemap", "value", "width"];
  26311. var ins = ["cite", "datetime"];
  26312. var isindex = ["prompt"];
  26313. var label = ["accesskey", "for", "form"];
  26314. var legend = ["accesskey", "align"];
  26315. var li = ["type", "value"];
  26316. var link$1 = ["as", "charset", "color", "crossorigin", "href", "hreflang", "integrity", "media", "nonce", "referrerpolicy", "rel", "rev", "sizes", "target", "title", "type"];
  26317. var map = ["name"];
  26318. var menu = ["compact"];
  26319. var meta = ["charset", "content", "http-equiv", "name", "scheme"];
  26320. var meter = ["high", "low", "max", "min", "optimum", "value"];
  26321. var object = ["align", "archive", "border", "classid", "codebase", "codetype", "data", "declare", "form", "height", "hspace", "name", "standby", "tabindex", "type", "typemustmatch", "usemap", "vspace", "width"];
  26322. var ol = ["compact", "reversed", "start", "type"];
  26323. var optgroup = ["disabled", "label"];
  26324. var option = ["disabled", "label", "selected", "value"];
  26325. var output = ["for", "form", "name"];
  26326. var p = ["align"];
  26327. var param = ["name", "type", "value", "valuetype"];
  26328. var pre = ["width"];
  26329. var progress = ["max", "value"];
  26330. var q = ["cite"];
  26331. var script = ["async", "charset", "crossorigin", "defer", "integrity", "language", "nomodule", "nonce", "referrerpolicy", "src", "type"];
  26332. var select = ["autocomplete", "autofocus", "disabled", "form", "multiple", "name", "required", "size", "tabindex"];
  26333. var slot = ["name"];
  26334. var source = ["media", "sizes", "src", "srcset", "type"];
  26335. var style = ["media", "nonce", "title", "type"];
  26336. var table = ["align", "bgcolor", "border", "cellpadding", "cellspacing", "frame", "rules", "summary", "width"];
  26337. var tbody = ["align", "char", "charoff", "valign"];
  26338. var td = ["abbr", "align", "axis", "bgcolor", "char", "charoff", "colspan", "headers", "height", "nowrap", "rowspan", "scope", "valign", "width"];
  26339. var textarea = ["accesskey", "autocomplete", "autofocus", "cols", "dirname", "disabled", "form", "maxlength", "minlength", "name", "placeholder", "readonly", "required", "rows", "tabindex", "wrap"];
  26340. var tfoot = ["align", "char", "charoff", "valign"];
  26341. var th = ["abbr", "align", "axis", "bgcolor", "char", "charoff", "colspan", "headers", "height", "nowrap", "rowspan", "scope", "valign", "width"];
  26342. var thead = ["align", "char", "charoff", "valign"];
  26343. var time = ["datetime"];
  26344. var tr = ["align", "bgcolor", "char", "charoff", "valign"];
  26345. var track = ["default", "kind", "label", "src", "srclang"];
  26346. var ul = ["compact", "type"];
  26347. var video = ["autoplay", "controls", "crossorigin", "height", "loop", "muted", "playsinline", "poster", "preload", "src", "width"];
  26348. var index$13 = {
  26349. a: a,
  26350. abbr: abbr,
  26351. applet: applet,
  26352. area: area,
  26353. audio: audio,
  26354. base: base$2,
  26355. basefont: basefont,
  26356. bdo: bdo,
  26357. blockquote: blockquote,
  26358. body: body,
  26359. br: br,
  26360. button: button,
  26361. canvas: canvas,
  26362. caption: caption,
  26363. col: col,
  26364. colgroup: colgroup,
  26365. data: data$1,
  26366. del: del,
  26367. details: details,
  26368. dfn: dfn,
  26369. dialog: dialog,
  26370. dir: dir,
  26371. div: div,
  26372. dl: dl,
  26373. embed: embed$7,
  26374. fieldset: fieldset,
  26375. font: font,
  26376. form: form,
  26377. frame: frame,
  26378. frameset: frameset,
  26379. h1: h1,
  26380. h2: h2,
  26381. h3: h3,
  26382. h4: h4,
  26383. h5: h5,
  26384. h6: h6,
  26385. head: head,
  26386. hr: hr,
  26387. html: html,
  26388. iframe: iframe,
  26389. img: img,
  26390. input: input,
  26391. ins: ins,
  26392. isindex: isindex,
  26393. label: label,
  26394. legend: legend,
  26395. li: li,
  26396. link: link$1,
  26397. map: map,
  26398. menu: menu,
  26399. meta: meta,
  26400. meter: meter,
  26401. object: object,
  26402. ol: ol,
  26403. optgroup: optgroup,
  26404. option: option,
  26405. output: output,
  26406. p: p,
  26407. param: param,
  26408. pre: pre,
  26409. progress: progress,
  26410. q: q,
  26411. script: script,
  26412. select: select,
  26413. slot: slot,
  26414. source: source,
  26415. style: style,
  26416. table: table,
  26417. tbody: tbody,
  26418. td: td,
  26419. textarea: textarea,
  26420. tfoot: tfoot,
  26421. th: th,
  26422. thead: thead,
  26423. time: time,
  26424. tr: tr,
  26425. track: track,
  26426. ul: ul,
  26427. video: video,
  26428. "*": ["accesskey", "autocapitalize", "class", "contenteditable", "dir", "draggable", "hidden", "id", "inputmode", "is", "itemid", "itemprop", "itemref", "itemscope", "itemtype", "lang", "nonce", "slot", "spellcheck", "style", "tabindex", "title", "translate"]
  26429. };
  26430. var htmlElementAttributes = Object.freeze({
  26431. a: a,
  26432. abbr: abbr,
  26433. applet: applet,
  26434. area: area,
  26435. audio: audio,
  26436. base: base$2,
  26437. basefont: basefont,
  26438. bdo: bdo,
  26439. blockquote: blockquote,
  26440. body: body,
  26441. br: br,
  26442. button: button,
  26443. canvas: canvas,
  26444. caption: caption,
  26445. col: col,
  26446. colgroup: colgroup,
  26447. data: data$1,
  26448. del: del,
  26449. details: details,
  26450. dfn: dfn,
  26451. dialog: dialog,
  26452. dir: dir,
  26453. div: div,
  26454. dl: dl,
  26455. embed: embed$7,
  26456. fieldset: fieldset,
  26457. font: font,
  26458. form: form,
  26459. frame: frame,
  26460. frameset: frameset,
  26461. h1: h1,
  26462. h2: h2,
  26463. h3: h3,
  26464. h4: h4,
  26465. h5: h5,
  26466. h6: h6,
  26467. head: head,
  26468. hr: hr,
  26469. html: html,
  26470. iframe: iframe,
  26471. img: img,
  26472. input: input,
  26473. ins: ins,
  26474. isindex: isindex,
  26475. label: label,
  26476. legend: legend,
  26477. li: li,
  26478. link: link$1,
  26479. map: map,
  26480. menu: menu,
  26481. meta: meta,
  26482. meter: meter,
  26483. object: object,
  26484. ol: ol,
  26485. optgroup: optgroup,
  26486. option: option,
  26487. output: output,
  26488. p: p,
  26489. param: param,
  26490. pre: pre,
  26491. progress: progress,
  26492. q: q,
  26493. script: script,
  26494. select: select,
  26495. slot: slot,
  26496. source: source,
  26497. style: style,
  26498. table: table,
  26499. tbody: tbody,
  26500. td: td,
  26501. textarea: textarea,
  26502. tfoot: tfoot,
  26503. th: th,
  26504. thead: thead,
  26505. time: time,
  26506. tr: tr,
  26507. track: track,
  26508. ul: ul,
  26509. video: video,
  26510. default: index$13
  26511. });
  26512. var json$9 = {"CSS_DISPLAY_TAGS":{"area":"none","base":"none","basefont":"none","datalist":"none","head":"none","link":"none","meta":"none","noembed":"none","noframes":"none","param":"none","rp":"none","script":"none","source":"block","style":"none","template":"inline","track":"block","title":"none","html":"block","body":"block","address":"block","blockquote":"block","center":"block","div":"block","figure":"block","figcaption":"block","footer":"block","form":"block","header":"block","hr":"block","legend":"block","listing":"block","main":"block","p":"block","plaintext":"block","pre":"block","xmp":"block","slot":"contents","ruby":"ruby","rt":"ruby-text","article":"block","aside":"block","h1":"block","h2":"block","h3":"block","h4":"block","h5":"block","h6":"block","hgroup":"block","nav":"block","section":"block","dir":"block","dd":"block","dl":"block","dt":"block","ol":"block","ul":"block","li":"list-item","table":"table","caption":"table-caption","colgroup":"table-column-group","col":"table-column","thead":"table-header-group","tbody":"table-row-group","tfoot":"table-footer-group","tr":"table-row","td":"table-cell","th":"table-cell","fieldset":"block","button":"inline-block","video":"inline-block","audio":"inline-block"},"CSS_DISPLAY_DEFAULT":"inline","CSS_WHITE_SPACE_TAGS":{"listing":"pre","plaintext":"pre","pre":"pre","xmp":"pre","nobr":"nowrap","table":"initial","textarea":"pre-wrap"},"CSS_WHITE_SPACE_DEFAULT":"normal"};
  26513. var htmlElementAttributes$1 = ( htmlElementAttributes && index$13 ) || htmlElementAttributes;
  26514. var CSS_DISPLAY_TAGS = json$9.CSS_DISPLAY_TAGS;
  26515. var CSS_DISPLAY_DEFAULT = json$9.CSS_DISPLAY_DEFAULT;
  26516. var CSS_WHITE_SPACE_TAGS = json$9.CSS_WHITE_SPACE_TAGS;
  26517. var CSS_WHITE_SPACE_DEFAULT = json$9.CSS_WHITE_SPACE_DEFAULT;
  26518. var HTML_TAGS = arrayToMap(htmlTagNames$1);
  26519. var HTML_ELEMENT_ATTRIBUTES = mapObject(htmlElementAttributes$1, arrayToMap);
  26520. function arrayToMap(array) {
  26521. var map = Object.create(null);
  26522. var _iteratorNormalCompletion = true;
  26523. var _didIteratorError = false;
  26524. var _iteratorError = undefined;
  26525. try {
  26526. for (var _iterator = array[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  26527. var value = _step.value;
  26528. map[value] = true;
  26529. }
  26530. } catch (err) {
  26531. _didIteratorError = true;
  26532. _iteratorError = err;
  26533. } finally {
  26534. try {
  26535. if (!_iteratorNormalCompletion && _iterator.return != null) {
  26536. _iterator.return();
  26537. }
  26538. } finally {
  26539. if (_didIteratorError) {
  26540. throw _iteratorError;
  26541. }
  26542. }
  26543. }
  26544. return map;
  26545. }
  26546. function mapObject(object, fn) {
  26547. var newObject = Object.create(null);
  26548. var _arr = Object.keys(object);
  26549. for (var _i = 0; _i < _arr.length; _i++) {
  26550. var key = _arr[_i];
  26551. newObject[key] = fn(object[key], key);
  26552. }
  26553. return newObject;
  26554. }
  26555. function shouldPreserveContent$1(node, options) {
  26556. if (node.type === "element" && node.fullName === "template" && node.attrMap.lang && node.attrMap.lang !== "html") {
  26557. return true;
  26558. } // unterminated node in ie conditional comment
  26559. // e.g. <!--[if lt IE 9]><html><![endif]-->
  26560. if (node.type === "ieConditionalComment" && node.lastChild && !node.lastChild.isSelfClosing && !node.lastChild.endSourceSpan) {
  26561. return true;
  26562. } // incomplete html in ie conditional comment
  26563. // e.g. <!--[if lt IE 9]></div><![endif]-->
  26564. if (node.type === "ieConditionalComment" && !node.complete) {
  26565. return true;
  26566. } // top-level elements (excluding <template>, <style> and <script>) in Vue SFC are considered custom block
  26567. // custom blocks can be written in other languages so we should preserve them to not break the code
  26568. if (options.parser === "vue" && node.type === "element" && node.parent.type === "root" && ["template", "style", "script", // vue parser can be used for vue dom template as well, so we should still format top-level <html>
  26569. "html"].indexOf(node.fullName) === -1) {
  26570. return true;
  26571. } // TODO: handle non-text children in <pre>
  26572. if (isPreLikeNode(node) && node.children.some(function (child) {
  26573. return child.type !== "text" && child.type !== "interpolation";
  26574. })) {
  26575. return true;
  26576. }
  26577. return false;
  26578. }
  26579. function hasPrettierIgnore$3(node) {
  26580. if (node.type === "attribute" || isTextLikeNode$1(node)) {
  26581. return false;
  26582. }
  26583. if (!node.parent) {
  26584. return false;
  26585. }
  26586. if (typeof node.index !== "number" || node.index === 0) {
  26587. return false;
  26588. }
  26589. var prevNode = node.parent.children[node.index - 1];
  26590. return isPrettierIgnore$1(prevNode);
  26591. }
  26592. function isPrettierIgnore$1(node) {
  26593. return node.type === "comment" && node.value.trim() === "prettier-ignore";
  26594. }
  26595. function getPrettierIgnoreAttributeCommentData$1(value) {
  26596. var match = value.trim().match(/^prettier-ignore-attribute(?:\s+([^]+))?$/);
  26597. if (!match) {
  26598. return false;
  26599. }
  26600. if (!match[1]) {
  26601. return true;
  26602. }
  26603. return match[1].split(/\s+/);
  26604. }
  26605. /** there's no opening/closing tag or it's considered not breakable */
  26606. function isTextLikeNode$1(node) {
  26607. return node.type === "text" || node.type === "comment";
  26608. }
  26609. function isScriptLikeTag$1(node) {
  26610. return node.type === "element" && (node.fullName === "script" || node.fullName === "style" || node.fullName === "svg:style");
  26611. }
  26612. function isFrontMatterNode(node) {
  26613. return node.type === "yaml" || node.type === "toml";
  26614. }
  26615. function canHaveInterpolation(node) {
  26616. return node.children && !isScriptLikeTag$1(node);
  26617. }
  26618. function isWhitespaceSensitiveNode(node) {
  26619. return isScriptLikeTag$1(node) || node.type === "interpolation" || isIndentationSensitiveNode(node);
  26620. }
  26621. function isIndentationSensitiveNode(node) {
  26622. return getNodeCssStyleWhiteSpace(node).startsWith("pre");
  26623. }
  26624. function isLeadingSpaceSensitiveNode(node) {
  26625. var isLeadingSpaceSensitive = _isLeadingSpaceSensitiveNode();
  26626. if (isLeadingSpaceSensitive && !node.prev && node.parent && node.parent.tagDefinition && node.parent.tagDefinition.ignoreFirstLf) {
  26627. return node.type === "interpolation";
  26628. }
  26629. return isLeadingSpaceSensitive;
  26630. function _isLeadingSpaceSensitiveNode() {
  26631. if (isFrontMatterNode(node)) {
  26632. return false;
  26633. }
  26634. if ((node.type === "text" || node.type === "interpolation") && node.prev && (node.prev.type === "text" || node.prev.type === "interpolation")) {
  26635. return true;
  26636. }
  26637. if (!node.parent || node.parent.cssDisplay === "none") {
  26638. return false;
  26639. }
  26640. if (isPreLikeNode(node.parent)) {
  26641. return true;
  26642. }
  26643. if (!node.prev && (node.parent.type === "root" || isScriptLikeTag$1(node.parent) || !isFirstChildLeadingSpaceSensitiveCssDisplay(node.parent.cssDisplay))) {
  26644. return false;
  26645. }
  26646. if (node.prev && !isNextLeadingSpaceSensitiveCssDisplay(node.prev.cssDisplay)) {
  26647. return false;
  26648. }
  26649. return true;
  26650. }
  26651. }
  26652. function isTrailingSpaceSensitiveNode(node) {
  26653. if (isFrontMatterNode(node)) {
  26654. return false;
  26655. }
  26656. if ((node.type === "text" || node.type === "interpolation") && node.next && (node.next.type === "text" || node.next.type === "interpolation")) {
  26657. return true;
  26658. }
  26659. if (!node.parent || node.parent.cssDisplay === "none") {
  26660. return false;
  26661. }
  26662. if (isPreLikeNode(node.parent)) {
  26663. return true;
  26664. }
  26665. if (!node.next && (node.parent.type === "root" || isScriptLikeTag$1(node.parent) || !isLastChildTrailingSpaceSensitiveCssDisplay(node.parent.cssDisplay))) {
  26666. return false;
  26667. }
  26668. if (node.next && !isPrevTrailingSpaceSensitiveCssDisplay(node.next.cssDisplay)) {
  26669. return false;
  26670. }
  26671. return true;
  26672. }
  26673. function isDanglingSpaceSensitiveNode(node) {
  26674. return isDanglingSpaceSensitiveCssDisplay(node.cssDisplay) && !isScriptLikeTag$1(node);
  26675. }
  26676. function forceNextEmptyLine$1(node) {
  26677. return isFrontMatterNode(node) || node.next && node.sourceSpan.end.line + 1 < node.next.sourceSpan.start.line;
  26678. }
  26679. /** firstChild leadingSpaces and lastChild trailingSpaces */
  26680. function forceBreakContent$1(node) {
  26681. return forceBreakChildren$1(node) || node.type === "element" && node.children.length !== 0 && (["body", "template", "script", "style"].indexOf(node.name) !== -1 || node.children.some(function (child) {
  26682. return hasNonTextChild(child);
  26683. })) || node.firstChild && node.firstChild === node.lastChild && hasLeadingLineBreak(node.firstChild) && (!node.lastChild.isTrailingSpaceSensitive || hasTrailingLineBreak(node.lastChild));
  26684. }
  26685. /** spaces between children */
  26686. function forceBreakChildren$1(node) {
  26687. return node.type === "element" && node.children.length !== 0 && (["html", "head", "ul", "ol", "select"].indexOf(node.name) !== -1 || node.cssDisplay.startsWith("table") && node.cssDisplay !== "table-cell");
  26688. }
  26689. function preferHardlineAsLeadingSpaces$1(node) {
  26690. return preferHardlineAsSurroundingSpaces(node) || node.prev && preferHardlineAsTrailingSpaces(node.prev) || hasSurroundingLineBreak(node);
  26691. }
  26692. function preferHardlineAsTrailingSpaces(node) {
  26693. return preferHardlineAsSurroundingSpaces(node) || node.type === "element" && node.fullName === "br" || hasSurroundingLineBreak(node);
  26694. }
  26695. function hasSurroundingLineBreak(node) {
  26696. return hasLeadingLineBreak(node) && hasTrailingLineBreak(node);
  26697. }
  26698. function hasLeadingLineBreak(node) {
  26699. return node.hasLeadingSpaces && (node.prev ? node.prev.sourceSpan.end.line < node.sourceSpan.start.line : node.parent.type === "root" || node.parent.startSourceSpan.end.line < node.sourceSpan.start.line);
  26700. }
  26701. function hasTrailingLineBreak(node) {
  26702. return node.hasTrailingSpaces && (node.next ? node.next.sourceSpan.start.line > node.sourceSpan.end.line : node.parent.type === "root" || node.parent.endSourceSpan.start.line > node.sourceSpan.end.line);
  26703. }
  26704. function preferHardlineAsSurroundingSpaces(node) {
  26705. switch (node.type) {
  26706. case "ieConditionalComment":
  26707. case "comment":
  26708. case "directive":
  26709. return true;
  26710. case "element":
  26711. return ["script", "select"].indexOf(node.name) !== -1;
  26712. }
  26713. return false;
  26714. }
  26715. function getLastDescendant$1(node) {
  26716. return node.lastChild ? getLastDescendant$1(node.lastChild) : node;
  26717. }
  26718. function hasNonTextChild(node) {
  26719. return node.children && node.children.some(function (child) {
  26720. return child.type !== "text";
  26721. });
  26722. }
  26723. function inferScriptParser$1(node) {
  26724. if (node.name === "script" && !node.attrMap.src) {
  26725. if (!node.attrMap.lang && !node.attrMap.type || node.attrMap.type === "module" || node.attrMap.type === "text/javascript" || node.attrMap.type === "text/babel" || node.attrMap.type === "application/javascript") {
  26726. return "babel";
  26727. }
  26728. if (node.attrMap.type === "application/x-typescript" || node.attrMap.lang === "ts" || node.attrMap.lang === "tsx") {
  26729. return "typescript";
  26730. }
  26731. if (node.attrMap.type === "text/markdown") {
  26732. return "markdown";
  26733. }
  26734. if (node.attrMap.type === "application/ld+json") {
  26735. return "json";
  26736. }
  26737. }
  26738. if (node.name === "style") {
  26739. if (!node.attrMap.lang || node.attrMap.lang === "postcss") {
  26740. return "css";
  26741. }
  26742. if (node.attrMap.lang === "scss") {
  26743. return "scss";
  26744. }
  26745. if (node.attrMap.lang === "less") {
  26746. return "less";
  26747. }
  26748. }
  26749. return null;
  26750. }
  26751. function isBlockLikeCssDisplay(cssDisplay) {
  26752. return cssDisplay === "block" || cssDisplay === "list-item" || cssDisplay.startsWith("table");
  26753. }
  26754. function isFirstChildLeadingSpaceSensitiveCssDisplay(cssDisplay) {
  26755. return !isBlockLikeCssDisplay(cssDisplay) && cssDisplay !== "inline-block";
  26756. }
  26757. function isLastChildTrailingSpaceSensitiveCssDisplay(cssDisplay) {
  26758. return !isBlockLikeCssDisplay(cssDisplay) && cssDisplay !== "inline-block";
  26759. }
  26760. function isPrevTrailingSpaceSensitiveCssDisplay(cssDisplay) {
  26761. return !isBlockLikeCssDisplay(cssDisplay);
  26762. }
  26763. function isNextLeadingSpaceSensitiveCssDisplay(cssDisplay) {
  26764. return !isBlockLikeCssDisplay(cssDisplay);
  26765. }
  26766. function isDanglingSpaceSensitiveCssDisplay(cssDisplay) {
  26767. return !isBlockLikeCssDisplay(cssDisplay) && cssDisplay !== "inline-block";
  26768. }
  26769. function isPreLikeNode(node) {
  26770. return getNodeCssStyleWhiteSpace(node).startsWith("pre");
  26771. }
  26772. function countParents$1(path$$1) {
  26773. var predicate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {
  26774. return true;
  26775. };
  26776. var counter = 0;
  26777. for (var i = path$$1.stack.length - 1; i >= 0; i--) {
  26778. var value = path$$1.stack[i];
  26779. if (value && typeof value === "object" && !Array.isArray(value) && predicate(value)) {
  26780. counter++;
  26781. }
  26782. }
  26783. return counter;
  26784. }
  26785. function hasParent(node, fn) {
  26786. var current = node;
  26787. while (current) {
  26788. if (fn(current)) {
  26789. return true;
  26790. }
  26791. current = current.parent;
  26792. }
  26793. return false;
  26794. }
  26795. function getNodeCssStyleDisplay(node, options) {
  26796. if (node.prev && node.prev.type === "comment") {
  26797. // <!-- display: block -->
  26798. var match = node.prev.value.match(/^\s*display:\s*([a-z]+)\s*$/);
  26799. if (match) {
  26800. return match[1];
  26801. }
  26802. }
  26803. var isInSvgForeignObject = false;
  26804. if (node.type === "element" && node.namespace === "svg") {
  26805. if (hasParent(node, function (parent) {
  26806. return parent.fullName === "svg:foreignObject";
  26807. })) {
  26808. isInSvgForeignObject = true;
  26809. } else {
  26810. return node.name === "svg" ? "inline-block" : "block";
  26811. }
  26812. }
  26813. switch (options.htmlWhitespaceSensitivity) {
  26814. case "strict":
  26815. return "inline";
  26816. case "ignore":
  26817. return "block";
  26818. default:
  26819. return node.type === "element" && (!node.namespace || isInSvgForeignObject) && CSS_DISPLAY_TAGS[node.name] || CSS_DISPLAY_DEFAULT;
  26820. }
  26821. }
  26822. function getNodeCssStyleWhiteSpace(node) {
  26823. return node.type === "element" && !node.namespace && CSS_WHITE_SPACE_TAGS[node.name] || CSS_WHITE_SPACE_DEFAULT;
  26824. }
  26825. function getMinIndentation(text) {
  26826. var minIndentation = Infinity;
  26827. var _iteratorNormalCompletion2 = true;
  26828. var _didIteratorError2 = false;
  26829. var _iteratorError2 = undefined;
  26830. try {
  26831. for (var _iterator2 = text.split("\n")[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  26832. var lineText = _step2.value;
  26833. if (lineText.length === 0) {
  26834. continue;
  26835. }
  26836. if (/\S/.test(lineText[0])) {
  26837. return 0;
  26838. }
  26839. var indentation = lineText.match(/^\s*/)[0].length;
  26840. if (lineText.length === indentation) {
  26841. continue;
  26842. }
  26843. if (indentation < minIndentation) {
  26844. minIndentation = indentation;
  26845. }
  26846. }
  26847. } catch (err) {
  26848. _didIteratorError2 = true;
  26849. _iteratorError2 = err;
  26850. } finally {
  26851. try {
  26852. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  26853. _iterator2.return();
  26854. }
  26855. } finally {
  26856. if (_didIteratorError2) {
  26857. throw _iteratorError2;
  26858. }
  26859. }
  26860. }
  26861. return minIndentation === Infinity ? 0 : minIndentation;
  26862. }
  26863. function dedentString$1(text) {
  26864. var minIndent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getMinIndentation(text);
  26865. return minIndent === 0 ? text : text.split("\n").map(function (lineText) {
  26866. return lineText.slice(minIndent);
  26867. }).join("\n");
  26868. }
  26869. function normalizeParts$2(parts) {
  26870. var newParts = [];
  26871. var restParts = parts.slice();
  26872. while (restParts.length !== 0) {
  26873. var part = restParts.shift();
  26874. if (!part) {
  26875. continue;
  26876. }
  26877. if (part.type === "concat") {
  26878. Array.prototype.unshift.apply(restParts, part.parts);
  26879. continue;
  26880. }
  26881. if (newParts.length !== 0 && typeof newParts[newParts.length - 1] === "string" && typeof part === "string") {
  26882. newParts.push(newParts.pop() + part);
  26883. continue;
  26884. }
  26885. newParts.push(part);
  26886. }
  26887. return newParts;
  26888. }
  26889. function identity$2(x) {
  26890. return x;
  26891. }
  26892. function shouldNotPrintClosingTag$1(node, options) {
  26893. return !node.isSelfClosing && !node.endSourceSpan && (hasPrettierIgnore$3(node) || shouldPreserveContent$1(node.parent, options));
  26894. }
  26895. function countChars$1(text, char) {
  26896. var counter = 0;
  26897. for (var i = 0; i < text.length; i++) {
  26898. if (text[i] === char) {
  26899. counter++;
  26900. }
  26901. }
  26902. return counter;
  26903. }
  26904. function unescapeQuoteEntities$1(text) {
  26905. return text.replace(/&apos;/g, "'").replace(/&quot;/g, '"');
  26906. }
  26907. var utils$10 = {
  26908. HTML_ELEMENT_ATTRIBUTES,
  26909. HTML_TAGS,
  26910. canHaveInterpolation,
  26911. countChars: countChars$1,
  26912. countParents: countParents$1,
  26913. dedentString: dedentString$1,
  26914. forceBreakChildren: forceBreakChildren$1,
  26915. forceBreakContent: forceBreakContent$1,
  26916. forceNextEmptyLine: forceNextEmptyLine$1,
  26917. getLastDescendant: getLastDescendant$1,
  26918. getNodeCssStyleDisplay,
  26919. getNodeCssStyleWhiteSpace,
  26920. getPrettierIgnoreAttributeCommentData: getPrettierIgnoreAttributeCommentData$1,
  26921. hasPrettierIgnore: hasPrettierIgnore$3,
  26922. identity: identity$2,
  26923. inferScriptParser: inferScriptParser$1,
  26924. isDanglingSpaceSensitiveNode,
  26925. isFrontMatterNode,
  26926. isIndentationSensitiveNode,
  26927. isLeadingSpaceSensitiveNode,
  26928. isPreLikeNode,
  26929. isScriptLikeTag: isScriptLikeTag$1,
  26930. isTextLikeNode: isTextLikeNode$1,
  26931. isTrailingSpaceSensitiveNode,
  26932. isWhitespaceSensitiveNode,
  26933. normalizeParts: normalizeParts$2,
  26934. preferHardlineAsLeadingSpaces: preferHardlineAsLeadingSpaces$1,
  26935. preferHardlineAsTrailingSpaces,
  26936. shouldNotPrintClosingTag: shouldNotPrintClosingTag$1,
  26937. shouldPreserveContent: shouldPreserveContent$1,
  26938. unescapeQuoteEntities: unescapeQuoteEntities$1
  26939. };
  26940. var canHaveInterpolation$1 = utils$10.canHaveInterpolation;
  26941. var getNodeCssStyleDisplay$1 = utils$10.getNodeCssStyleDisplay;
  26942. var isDanglingSpaceSensitiveNode$1 = utils$10.isDanglingSpaceSensitiveNode;
  26943. var isIndentationSensitiveNode$1 = utils$10.isIndentationSensitiveNode;
  26944. var isLeadingSpaceSensitiveNode$1 = utils$10.isLeadingSpaceSensitiveNode;
  26945. var isTrailingSpaceSensitiveNode$1 = utils$10.isTrailingSpaceSensitiveNode;
  26946. var isWhitespaceSensitiveNode$1 = utils$10.isWhitespaceSensitiveNode;
  26947. var PREPROCESS_PIPELINE = [removeIgnorableFirstLf, mergeIeConditonalStartEndCommentIntoElementOpeningTag, mergeCdataIntoText, extractInterpolation, extractWhitespaces, addCssDisplay, addIsSelfClosing, addHasHtmComponentClosingTag, addIsSpaceSensitive, mergeSimpleElementIntoText];
  26948. function preprocess$4(ast, options) {
  26949. for (var _i = 0; _i < PREPROCESS_PIPELINE.length; _i++) {
  26950. var fn = PREPROCESS_PIPELINE[_i];
  26951. ast = fn(ast, options);
  26952. }
  26953. return ast;
  26954. }
  26955. function removeIgnorableFirstLf(ast
  26956. /*, options */
  26957. ) {
  26958. return ast.map(function (node) {
  26959. if (node.type === "element" && node.tagDefinition.ignoreFirstLf && node.children.length !== 0 && node.children[0].type === "text" && node.children[0].value[0] === "\n") {
  26960. var text = node.children[0];
  26961. return node.clone({
  26962. children: text.value.length === 1 ? node.children.slice(1) : [].concat(text.clone({
  26963. value: text.value.slice(1)
  26964. }), node.children.slice(1))
  26965. });
  26966. }
  26967. return node;
  26968. });
  26969. }
  26970. function mergeIeConditonalStartEndCommentIntoElementOpeningTag(ast
  26971. /*, options */
  26972. ) {
  26973. /**
  26974. * <!--[if ...]><!--><target><!--<![endif]-->
  26975. */
  26976. var isTarget = function isTarget(node) {
  26977. return node.type === "element" && node.prev && node.prev.type === "ieConditionalStartComment" && node.prev.sourceSpan.end.offset === node.startSourceSpan.start.offset && node.firstChild && node.firstChild.type === "ieConditionalEndComment" && node.firstChild.sourceSpan.start.offset === node.startSourceSpan.end.offset;
  26978. };
  26979. return ast.map(function (node) {
  26980. if (node.children) {
  26981. var isTargetResults = node.children.map(isTarget);
  26982. if (isTargetResults.some(Boolean)) {
  26983. var newChildren = [];
  26984. for (var i = 0; i < node.children.length; i++) {
  26985. var child = node.children[i];
  26986. if (isTargetResults[i + 1]) {
  26987. // ieConditionalStartComment
  26988. continue;
  26989. }
  26990. if (isTargetResults[i]) {
  26991. var ieConditionalStartComment = child.prev;
  26992. var ieConditionalEndComment = child.firstChild;
  26993. var ParseSourceSpan = child.sourceSpan.constructor;
  26994. var startSourceSpan = new ParseSourceSpan(ieConditionalStartComment.sourceSpan.start, ieConditionalEndComment.sourceSpan.end);
  26995. var sourceSpan = new ParseSourceSpan(startSourceSpan.start, child.sourceSpan.end);
  26996. newChildren.push(child.clone({
  26997. condition: ieConditionalStartComment.condition,
  26998. sourceSpan,
  26999. startSourceSpan,
  27000. children: child.children.slice(1)
  27001. }));
  27002. continue;
  27003. }
  27004. newChildren.push(child);
  27005. }
  27006. return node.clone({
  27007. children: newChildren
  27008. });
  27009. }
  27010. }
  27011. return node;
  27012. });
  27013. }
  27014. function mergeNodeIntoText(ast, shouldMerge, getValue) {
  27015. return ast.map(function (node) {
  27016. if (node.children) {
  27017. var shouldMergeResults = node.children.map(shouldMerge);
  27018. if (shouldMergeResults.some(Boolean)) {
  27019. var newChildren = [];
  27020. for (var i = 0; i < node.children.length; i++) {
  27021. var child = node.children[i];
  27022. if (child.type !== "text" && !shouldMergeResults[i]) {
  27023. newChildren.push(child);
  27024. continue;
  27025. }
  27026. var newChild = child.type === "text" ? child : child.clone({
  27027. type: "text",
  27028. value: getValue(child)
  27029. });
  27030. if (newChildren.length === 0 || newChildren[newChildren.length - 1].type !== "text") {
  27031. newChildren.push(newChild);
  27032. continue;
  27033. }
  27034. var lastChild = newChildren.pop();
  27035. var ParseSourceSpan = lastChild.sourceSpan.constructor;
  27036. newChildren.push(lastChild.clone({
  27037. value: lastChild.value + newChild.value,
  27038. sourceSpan: new ParseSourceSpan(lastChild.sourceSpan.start, newChild.sourceSpan.end)
  27039. }));
  27040. }
  27041. return node.clone({
  27042. children: newChildren
  27043. });
  27044. }
  27045. }
  27046. return node;
  27047. });
  27048. }
  27049. function mergeCdataIntoText(ast
  27050. /*, options */
  27051. ) {
  27052. return mergeNodeIntoText(ast, function (node) {
  27053. return node.type === "cdata";
  27054. }, function (node) {
  27055. return `<![CDATA[${node.value}]]>`;
  27056. });
  27057. }
  27058. function mergeSimpleElementIntoText(ast
  27059. /*, options */
  27060. ) {
  27061. var isSimpleElement = function isSimpleElement(node) {
  27062. return node.type === "element" && node.attrs.length === 0 && node.children.length === 1 && node.firstChild.type === "text" && // \xA0: non-breaking whitespace
  27063. !/[^\S\xA0]/.test(node.children[0].value) && !node.firstChild.hasLeadingSpaces && !node.firstChild.hasTrailingSpaces && node.isLeadingSpaceSensitive && !node.hasLeadingSpaces && node.isTrailingSpaceSensitive && !node.hasTrailingSpaces && node.prev && node.prev.type === "text" && node.next && node.next.type === "text";
  27064. };
  27065. return ast.map(function (node) {
  27066. if (node.children) {
  27067. var isSimpleElementResults = node.children.map(isSimpleElement);
  27068. if (isSimpleElementResults.some(Boolean)) {
  27069. var newChildren = [];
  27070. for (var i = 0; i < node.children.length; i++) {
  27071. var child = node.children[i];
  27072. if (isSimpleElementResults[i]) {
  27073. var lastChild = newChildren.pop();
  27074. var nextChild = node.children[++i];
  27075. var ParseSourceSpan = node.sourceSpan.constructor;
  27076. var isTrailingSpaceSensitive = nextChild.isTrailingSpaceSensitive,
  27077. hasTrailingSpaces = nextChild.hasTrailingSpaces;
  27078. newChildren.push(lastChild.clone({
  27079. value: lastChild.value + `<${child.rawName}>` + child.firstChild.value + `</${child.rawName}>` + nextChild.value,
  27080. sourceSpan: new ParseSourceSpan(lastChild.sourceSpan.start, nextChild.sourceSpan.end),
  27081. isTrailingSpaceSensitive,
  27082. hasTrailingSpaces
  27083. }));
  27084. } else {
  27085. newChildren.push(child);
  27086. }
  27087. }
  27088. return node.clone({
  27089. children: newChildren
  27090. });
  27091. }
  27092. }
  27093. return node;
  27094. });
  27095. }
  27096. function extractInterpolation(ast, options) {
  27097. if (options.parser === "html") {
  27098. return ast;
  27099. }
  27100. var interpolationRegex = /\{\{([\s\S]+?)\}\}/g;
  27101. return ast.map(function (node) {
  27102. if (!canHaveInterpolation$1(node)) {
  27103. return node;
  27104. }
  27105. var newChildren = [];
  27106. var _iteratorNormalCompletion = true;
  27107. var _didIteratorError = false;
  27108. var _iteratorError = undefined;
  27109. try {
  27110. for (var _iterator = node.children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  27111. var child = _step.value;
  27112. if (child.type !== "text") {
  27113. newChildren.push(child);
  27114. continue;
  27115. }
  27116. var ParseSourceSpan = child.sourceSpan.constructor;
  27117. var startSourceSpan = child.sourceSpan.start;
  27118. var endSourceSpan = null;
  27119. var components = child.value.split(interpolationRegex);
  27120. for (var i = 0; i < components.length; i++, startSourceSpan = endSourceSpan) {
  27121. var value = components[i];
  27122. if (i % 2 === 0) {
  27123. endSourceSpan = startSourceSpan.moveBy(value.length);
  27124. if (value.length !== 0) {
  27125. newChildren.push({
  27126. type: "text",
  27127. value,
  27128. sourceSpan: new ParseSourceSpan(startSourceSpan, endSourceSpan)
  27129. });
  27130. }
  27131. continue;
  27132. }
  27133. endSourceSpan = startSourceSpan.moveBy(value.length + 4); // `{{` + `}}`
  27134. newChildren.push({
  27135. type: "interpolation",
  27136. sourceSpan: new ParseSourceSpan(startSourceSpan, endSourceSpan),
  27137. children: value.length === 0 ? [] : [{
  27138. type: "text",
  27139. value,
  27140. sourceSpan: new ParseSourceSpan(startSourceSpan.moveBy(2), endSourceSpan.moveBy(-2))
  27141. }]
  27142. });
  27143. }
  27144. }
  27145. } catch (err) {
  27146. _didIteratorError = true;
  27147. _iteratorError = err;
  27148. } finally {
  27149. try {
  27150. if (!_iteratorNormalCompletion && _iterator.return != null) {
  27151. _iterator.return();
  27152. }
  27153. } finally {
  27154. if (_didIteratorError) {
  27155. throw _iteratorError;
  27156. }
  27157. }
  27158. }
  27159. return node.clone({
  27160. children: newChildren
  27161. });
  27162. });
  27163. }
  27164. /**
  27165. * - add `hasLeadingSpaces` field
  27166. * - add `hasTrailingSpaces` field
  27167. * - add `hasDanglingSpaces` field for parent nodes
  27168. * - add `isWhitespaceSensitive`, `isIndentationSensitive` field for text nodes
  27169. * - remove insensitive whitespaces
  27170. */
  27171. function extractWhitespaces(ast
  27172. /*, options*/
  27173. ) {
  27174. var TYPE_WHITESPACE = "whitespace";
  27175. return ast.map(function (node) {
  27176. if (!node.children) {
  27177. return node;
  27178. }
  27179. if (node.children.length === 0 || node.children.length === 1 && node.children[0].type === "text" && node.children[0].value.trim().length === 0) {
  27180. return node.clone({
  27181. children: [],
  27182. hasDanglingSpaces: node.children.length !== 0
  27183. });
  27184. }
  27185. var isWhitespaceSensitive = isWhitespaceSensitiveNode$1(node);
  27186. var isIndentationSensitive = isIndentationSensitiveNode$1(node);
  27187. return node.clone({
  27188. isWhitespaceSensitive,
  27189. isIndentationSensitive,
  27190. children: node.children // extract whitespace nodes
  27191. .reduce(function (newChildren, child) {
  27192. if (child.type !== "text" || isWhitespaceSensitive) {
  27193. return newChildren.concat(child);
  27194. }
  27195. var localChildren = [];
  27196. var _child$value$match = child.value.match(/^(\s*)([\s\S]*?)(\s*)$/),
  27197. _child$value$match2 = _slicedToArray(_child$value$match, 4),
  27198. leadingSpaces = _child$value$match2[1],
  27199. text = _child$value$match2[2],
  27200. trailingSpaces = _child$value$match2[3];
  27201. if (leadingSpaces) {
  27202. localChildren.push({
  27203. type: TYPE_WHITESPACE
  27204. });
  27205. }
  27206. var ParseSourceSpan = child.sourceSpan.constructor;
  27207. if (text) {
  27208. localChildren.push({
  27209. type: "text",
  27210. value: text,
  27211. sourceSpan: new ParseSourceSpan(child.sourceSpan.start.moveBy(leadingSpaces.length), child.sourceSpan.end.moveBy(-trailingSpaces.length))
  27212. });
  27213. }
  27214. if (trailingSpaces) {
  27215. localChildren.push({
  27216. type: TYPE_WHITESPACE
  27217. });
  27218. }
  27219. return newChildren.concat(localChildren);
  27220. }, []) // set hasLeadingSpaces/hasTrailingSpaces and filter whitespace nodes
  27221. .reduce(function (newChildren, child, i, children) {
  27222. if (child.type === TYPE_WHITESPACE) {
  27223. return newChildren;
  27224. }
  27225. var hasLeadingSpaces = i !== 0 && children[i - 1].type === TYPE_WHITESPACE;
  27226. var hasTrailingSpaces = i !== children.length - 1 && children[i + 1].type === TYPE_WHITESPACE;
  27227. return newChildren.concat(Object.assign({}, child, {
  27228. hasLeadingSpaces,
  27229. hasTrailingSpaces
  27230. }));
  27231. }, [])
  27232. });
  27233. });
  27234. }
  27235. function addIsSelfClosing(ast
  27236. /*, options */
  27237. ) {
  27238. return ast.map(function (node) {
  27239. return Object.assign(node, {
  27240. isSelfClosing: !node.children || node.type === "element" && (node.tagDefinition.isVoid || // self-closing
  27241. node.startSourceSpan === node.endSourceSpan)
  27242. });
  27243. });
  27244. }
  27245. function addHasHtmComponentClosingTag(ast, options) {
  27246. return ast.map(function (node) {
  27247. return node.type !== "element" ? node : Object.assign(node, {
  27248. hasHtmComponentClosingTag: node.endSourceSpan && /^<\s*\/\s*\/\s*>$/.test(options.originalText.slice(node.endSourceSpan.start.offset, node.endSourceSpan.end.offset))
  27249. });
  27250. });
  27251. }
  27252. function addCssDisplay(ast, options) {
  27253. return ast.map(function (node) {
  27254. return Object.assign(node, {
  27255. cssDisplay: getNodeCssStyleDisplay$1(node, options)
  27256. });
  27257. });
  27258. }
  27259. /**
  27260. * - add `isLeadingSpaceSensitive` field
  27261. * - add `isTrailingSpaceSensitive` field
  27262. * - add `isDanglingSpaceSensitive` field for parent nodes
  27263. */
  27264. function addIsSpaceSensitive(ast
  27265. /*, options */
  27266. ) {
  27267. return ast.map(function (node) {
  27268. if (!node.children) {
  27269. return node;
  27270. }
  27271. if (node.children.length === 0) {
  27272. return node.clone({
  27273. isDanglingSpaceSensitive: isDanglingSpaceSensitiveNode$1(node)
  27274. });
  27275. }
  27276. return node.clone({
  27277. children: node.children.map(function (child) {
  27278. return Object.assign({}, child, {
  27279. isLeadingSpaceSensitive: isLeadingSpaceSensitiveNode$1(child),
  27280. isTrailingSpaceSensitive: isTrailingSpaceSensitiveNode$1(child)
  27281. });
  27282. }).map(function (child, index, children) {
  27283. return Object.assign({}, child, {
  27284. isLeadingSpaceSensitive: index === 0 ? child.isLeadingSpaceSensitive : children[index - 1].isTrailingSpaceSensitive && child.isLeadingSpaceSensitive,
  27285. isTrailingSpaceSensitive: index === children.length - 1 ? child.isTrailingSpaceSensitive : children[index + 1].isLeadingSpaceSensitive && child.isTrailingSpaceSensitive
  27286. });
  27287. })
  27288. });
  27289. });
  27290. }
  27291. var preprocess_1$4 = preprocess$4;
  27292. function hasPragma$3(text) {
  27293. return /^\s*<!--\s*@(format|prettier)\s*-->/.test(text);
  27294. }
  27295. function insertPragma$7(text) {
  27296. return "<!-- @format -->\n\n" + text.replace(/^\s*\n/, "");
  27297. }
  27298. var pragma$9 = {
  27299. hasPragma: hasPragma$3,
  27300. insertPragma: insertPragma$7
  27301. };
  27302. var _require$$0$builders$8 = doc.builders;
  27303. var concat$15 = _require$$0$builders$8.concat;
  27304. var group$15 = _require$$0$builders$8.group;
  27305. /**
  27306. * v-for="... in ..."
  27307. * v-for="... of ..."
  27308. * v-for="(..., ...) in ..."
  27309. * v-for="(..., ...) of ..."
  27310. */
  27311. function printVueFor$1(value, textToDoc) {
  27312. var _parseVueFor = parseVueFor(value),
  27313. left = _parseVueFor.left,
  27314. operator = _parseVueFor.operator,
  27315. right = _parseVueFor.right;
  27316. return concat$15([group$15(textToDoc(`function _(${left}) {}`, {
  27317. parser: "babel",
  27318. __isVueForBindingLeft: true
  27319. })), " ", operator, " ", textToDoc(right, {
  27320. parser: "__js_expression"
  27321. })]);
  27322. } // modified from https://github.com/vuejs/vue/blob/v2.5.17/src/compiler/parser/index.js#L370-L387
  27323. function parseVueFor(value) {
  27324. var forAliasRE = /([^]*?)\s+(in|of)\s+([^]*)/;
  27325. var forIteratorRE = /,([^,}\]]*)(?:,([^,}\]]*))?$/;
  27326. var stripParensRE = /^\(|\)$/g;
  27327. var inMatch = value.match(forAliasRE);
  27328. if (!inMatch) {
  27329. return;
  27330. }
  27331. var res = {};
  27332. res.for = inMatch[3].trim();
  27333. var alias = inMatch[1].trim().replace(stripParensRE, "");
  27334. var iteratorMatch = alias.match(forIteratorRE);
  27335. if (iteratorMatch) {
  27336. res.alias = alias.replace(forIteratorRE, "");
  27337. res.iterator1 = iteratorMatch[1].trim();
  27338. if (iteratorMatch[2]) {
  27339. res.iterator2 = iteratorMatch[2].trim();
  27340. }
  27341. } else {
  27342. res.alias = alias;
  27343. }
  27344. return {
  27345. left: `${[res.alias, res.iterator1, res.iterator2].filter(Boolean).join(",")}`,
  27346. operator: inMatch[2],
  27347. right: res.for
  27348. };
  27349. }
  27350. function printVueSlotScope$1(value, textToDoc) {
  27351. return textToDoc(`function _(${value}) {}`, {
  27352. parser: "babel",
  27353. __isVueSlotScope: true
  27354. });
  27355. }
  27356. function isVueEventBindingExpression$3(eventBindingValue) {
  27357. // https://github.com/vuejs/vue/blob/v2.5.17/src/compiler/codegen/events.js#L3-L4
  27358. // arrow function or anonymous function
  27359. var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/; // simple member expression chain (a, a.b, a['b'], a["b"], a[0], a[b])
  27360. var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/; // https://github.com/vuejs/vue/blob/v2.5.17/src/compiler/helpers.js#L104
  27361. var value = eventBindingValue.trim();
  27362. return fnExpRE.test(value) || simplePathRE.test(value);
  27363. }
  27364. var syntaxVue = {
  27365. isVueEventBindingExpression: isVueEventBindingExpression$3,
  27366. printVueFor: printVueFor$1,
  27367. printVueSlotScope: printVueSlotScope$1
  27368. };
  27369. var parseSrcset = createCommonjsModule(function (module) {
  27370. /**
  27371. * Srcset Parser
  27372. *
  27373. * By Alex Bell | MIT License
  27374. *
  27375. * JS Parser for the string value that appears in markup <img srcset="here">
  27376. *
  27377. * @returns Array [{url: _, d: _, w: _, h:_}, ...]
  27378. *
  27379. * Based super duper closely on the reference algorithm at:
  27380. * https://html.spec.whatwg.org/multipage/embedded-content.html#parse-a-srcset-attribute
  27381. *
  27382. * Most comments are copied in directly from the spec
  27383. * (except for comments in parens).
  27384. */
  27385. (function (root, factory) {
  27386. if (typeof undefined === 'function' && undefined.amd) {
  27387. // AMD. Register as an anonymous module.
  27388. undefined([], factory);
  27389. } else if ('object' === 'object' && module.exports) {
  27390. // Node. Does not work with strict CommonJS, but
  27391. // only CommonJS-like environments that support module.exports,
  27392. // like Node.
  27393. module.exports = factory();
  27394. } else {
  27395. // Browser globals (root is window)
  27396. root.parseSrcset = factory();
  27397. }
  27398. })(commonjsGlobal, function () {
  27399. // 1. Let input be the value passed to this algorithm.
  27400. return function (input, options) {
  27401. var logger = options && options.logger || console; // UTILITY FUNCTIONS
  27402. // Manual is faster than RegEx
  27403. // http://bjorn.tipling.com/state-and-regular-expressions-in-javascript
  27404. // http://jsperf.com/whitespace-character/5
  27405. function isSpace(c) {
  27406. return c === "\u0020" || // space
  27407. c === "\u0009" || // horizontal tab
  27408. c === "\u000A" || // new line
  27409. c === "\u000C" || // form feed
  27410. c === "\u000D"; // carriage return
  27411. }
  27412. function collectCharacters(regEx) {
  27413. var chars,
  27414. match = regEx.exec(input.substring(pos));
  27415. if (match) {
  27416. chars = match[0];
  27417. pos += chars.length;
  27418. return chars;
  27419. }
  27420. }
  27421. var inputLength = input.length,
  27422. // (Don't use \s, to avoid matching non-breaking space)
  27423. regexLeadingSpaces = /^[ \t\n\r\u000c]+/,
  27424. regexLeadingCommasOrSpaces = /^[, \t\n\r\u000c]+/,
  27425. regexLeadingNotSpaces = /^[^ \t\n\r\u000c]+/,
  27426. regexTrailingCommas = /[,]+$/,
  27427. regexNonNegativeInteger = /^\d+$/,
  27428. // ( Positive or negative or unsigned integers or decimals, without or without exponents.
  27429. // Must include at least one digit.
  27430. // According to spec tests any decimal point must be followed by a digit.
  27431. // No leading plus sign is allowed.)
  27432. // https://html.spec.whatwg.org/multipage/infrastructure.html#valid-floating-point-number
  27433. regexFloatingPoint = /^-?(?:[0-9]+|[0-9]*\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/,
  27434. url,
  27435. descriptors,
  27436. currentDescriptor,
  27437. state,
  27438. c,
  27439. // 2. Let position be a pointer into input, initially pointing at the start
  27440. // of the string.
  27441. pos = 0,
  27442. // 3. Let candidates be an initially empty source set.
  27443. candidates = []; // 4. Splitting loop: Collect a sequence of characters that are space
  27444. // characters or U+002C COMMA characters. If any U+002C COMMA characters
  27445. // were collected, that is a parse error.
  27446. while (true) {
  27447. collectCharacters(regexLeadingCommasOrSpaces); // 5. If position is past the end of input, return candidates and abort these steps.
  27448. if (pos >= inputLength) {
  27449. return candidates; // (we're done, this is the sole return path)
  27450. } // 6. Collect a sequence of characters that are not space characters,
  27451. // and let that be url.
  27452. url = collectCharacters(regexLeadingNotSpaces); // 7. Let descriptors be a new empty list.
  27453. descriptors = []; // 8. If url ends with a U+002C COMMA character (,), follow these substeps:
  27454. // (1). Remove all trailing U+002C COMMA characters from url. If this removed
  27455. // more than one character, that is a parse error.
  27456. if (url.slice(-1) === ",") {
  27457. url = url.replace(regexTrailingCommas, ""); // (Jump ahead to step 9 to skip tokenization and just push the candidate).
  27458. parseDescriptors(); // Otherwise, follow these substeps:
  27459. } else {
  27460. tokenize();
  27461. } // (close else of step 8)
  27462. // 16. Return to the step labeled splitting loop.
  27463. } // (Close of big while loop.)
  27464. /**
  27465. * Tokenizes descriptor properties prior to parsing
  27466. * Returns undefined.
  27467. */
  27468. function tokenize() {
  27469. // 8.1. Descriptor tokeniser: Skip whitespace
  27470. collectCharacters(regexLeadingSpaces); // 8.2. Let current descriptor be the empty string.
  27471. currentDescriptor = ""; // 8.3. Let state be in descriptor.
  27472. state = "in descriptor";
  27473. while (true) {
  27474. // 8.4. Let c be the character at position.
  27475. c = input.charAt(pos); // Do the following depending on the value of state.
  27476. // For the purpose of this step, "EOF" is a special character representing
  27477. // that position is past the end of input.
  27478. // In descriptor
  27479. if (state === "in descriptor") {
  27480. // Do the following, depending on the value of c:
  27481. // Space character
  27482. // If current descriptor is not empty, append current descriptor to
  27483. // descriptors and let current descriptor be the empty string.
  27484. // Set state to after descriptor.
  27485. if (isSpace(c)) {
  27486. if (currentDescriptor) {
  27487. descriptors.push(currentDescriptor);
  27488. currentDescriptor = "";
  27489. state = "after descriptor";
  27490. } // U+002C COMMA (,)
  27491. // Advance position to the next character in input. If current descriptor
  27492. // is not empty, append current descriptor to descriptors. Jump to the step
  27493. // labeled descriptor parser.
  27494. } else if (c === ",") {
  27495. pos += 1;
  27496. if (currentDescriptor) {
  27497. descriptors.push(currentDescriptor);
  27498. }
  27499. parseDescriptors();
  27500. return; // U+0028 LEFT PARENTHESIS (()
  27501. // Append c to current descriptor. Set state to in parens.
  27502. } else if (c === "\u0028") {
  27503. currentDescriptor = currentDescriptor + c;
  27504. state = "in parens"; // EOF
  27505. // If current descriptor is not empty, append current descriptor to
  27506. // descriptors. Jump to the step labeled descriptor parser.
  27507. } else if (c === "") {
  27508. if (currentDescriptor) {
  27509. descriptors.push(currentDescriptor);
  27510. }
  27511. parseDescriptors();
  27512. return; // Anything else
  27513. // Append c to current descriptor.
  27514. } else {
  27515. currentDescriptor = currentDescriptor + c;
  27516. } // (end "in descriptor"
  27517. // In parens
  27518. } else if (state === "in parens") {
  27519. // U+0029 RIGHT PARENTHESIS ())
  27520. // Append c to current descriptor. Set state to in descriptor.
  27521. if (c === ")") {
  27522. currentDescriptor = currentDescriptor + c;
  27523. state = "in descriptor"; // EOF
  27524. // Append current descriptor to descriptors. Jump to the step labeled
  27525. // descriptor parser.
  27526. } else if (c === "") {
  27527. descriptors.push(currentDescriptor);
  27528. parseDescriptors();
  27529. return; // Anything else
  27530. // Append c to current descriptor.
  27531. } else {
  27532. currentDescriptor = currentDescriptor + c;
  27533. } // After descriptor
  27534. } else if (state === "after descriptor") {
  27535. // Do the following, depending on the value of c:
  27536. // Space character: Stay in this state.
  27537. if (isSpace(c)) {// EOF: Jump to the step labeled descriptor parser.
  27538. } else if (c === "") {
  27539. parseDescriptors();
  27540. return; // Anything else
  27541. // Set state to in descriptor. Set position to the previous character in input.
  27542. } else {
  27543. state = "in descriptor";
  27544. pos -= 1;
  27545. }
  27546. } // Advance position to the next character in input.
  27547. pos += 1; // Repeat this step.
  27548. } // (close while true loop)
  27549. }
  27550. /**
  27551. * Adds descriptor properties to a candidate, pushes to the candidates array
  27552. * @return undefined
  27553. */
  27554. // Declared outside of the while loop so that it's only created once.
  27555. function parseDescriptors() {
  27556. // 9. Descriptor parser: Let error be no.
  27557. var pError = false,
  27558. // 10. Let width be absent.
  27559. // 11. Let density be absent.
  27560. // 12. Let future-compat-h be absent. (We're implementing it now as h)
  27561. w,
  27562. d,
  27563. h,
  27564. i,
  27565. candidate = {},
  27566. desc,
  27567. lastChar,
  27568. value,
  27569. intVal,
  27570. floatVal; // 13. For each descriptor in descriptors, run the appropriate set of steps
  27571. // from the following list:
  27572. for (i = 0; i < descriptors.length; i++) {
  27573. desc = descriptors[i];
  27574. lastChar = desc[desc.length - 1];
  27575. value = desc.substring(0, desc.length - 1);
  27576. intVal = parseInt(value, 10);
  27577. floatVal = parseFloat(value); // If the descriptor consists of a valid non-negative integer followed by
  27578. // a U+0077 LATIN SMALL LETTER W character
  27579. if (regexNonNegativeInteger.test(value) && lastChar === "w") {
  27580. // If width and density are not both absent, then let error be yes.
  27581. if (w || d) {
  27582. pError = true;
  27583. } // Apply the rules for parsing non-negative integers to the descriptor.
  27584. // If the result is zero, let error be yes.
  27585. // Otherwise, let width be the result.
  27586. if (intVal === 0) {
  27587. pError = true;
  27588. } else {
  27589. w = intVal;
  27590. } // If the descriptor consists of a valid floating-point number followed by
  27591. // a U+0078 LATIN SMALL LETTER X character
  27592. } else if (regexFloatingPoint.test(value) && lastChar === "x") {
  27593. // If width, density and future-compat-h are not all absent, then let error
  27594. // be yes.
  27595. if (w || d || h) {
  27596. pError = true;
  27597. } // Apply the rules for parsing floating-point number values to the descriptor.
  27598. // If the result is less than zero, let error be yes. Otherwise, let density
  27599. // be the result.
  27600. if (floatVal < 0) {
  27601. pError = true;
  27602. } else {
  27603. d = floatVal;
  27604. } // If the descriptor consists of a valid non-negative integer followed by
  27605. // a U+0068 LATIN SMALL LETTER H character
  27606. } else if (regexNonNegativeInteger.test(value) && lastChar === "h") {
  27607. // If height and density are not both absent, then let error be yes.
  27608. if (h || d) {
  27609. pError = true;
  27610. } // Apply the rules for parsing non-negative integers to the descriptor.
  27611. // If the result is zero, let error be yes. Otherwise, let future-compat-h
  27612. // be the result.
  27613. if (intVal === 0) {
  27614. pError = true;
  27615. } else {
  27616. h = intVal;
  27617. } // Anything else, Let error be yes.
  27618. } else {
  27619. pError = true;
  27620. }
  27621. } // (close step 13 for loop)
  27622. // 15. If error is still no, then append a new image source to candidates whose
  27623. // URL is url, associated with a width width if not absent and a pixel
  27624. // density density if not absent. Otherwise, there is a parse error.
  27625. if (!pError) {
  27626. candidate.url = url;
  27627. if (w) {
  27628. candidate.w = w;
  27629. }
  27630. if (d) {
  27631. candidate.d = d;
  27632. }
  27633. if (h) {
  27634. candidate.h = h;
  27635. }
  27636. candidates.push(candidate);
  27637. } else if (logger && logger.error) {
  27638. logger.error("Invalid srcset descriptor found in '" + input + "' at '" + desc + "'.");
  27639. }
  27640. } // (close parseDescriptors fn)
  27641. };
  27642. });
  27643. });
  27644. var _require$$0$builders$9 = doc.builders;
  27645. var concat$16 = _require$$0$builders$9.concat;
  27646. var ifBreak$6 = _require$$0$builders$9.ifBreak;
  27647. var join$11 = _require$$0$builders$9.join;
  27648. var line$10 = _require$$0$builders$9.line;
  27649. function printImgSrcset$1(value) {
  27650. var srcset = parseSrcset(value, {
  27651. logger: {
  27652. error(message) {
  27653. throw new Error(message);
  27654. }
  27655. }
  27656. });
  27657. var hasW = srcset.some(function (src) {
  27658. return src.w;
  27659. });
  27660. var hasH = srcset.some(function (src) {
  27661. return src.h;
  27662. });
  27663. var hasX = srcset.some(function (src) {
  27664. return src.d;
  27665. });
  27666. if (hasW + hasH + hasX !== 1) {
  27667. throw new Error(`Mixed descriptor in srcset is not supported`);
  27668. }
  27669. var key = hasW ? "w" : hasH ? "h" : "d";
  27670. var unit = hasW ? "w" : hasH ? "h" : "x";
  27671. var getMax = function getMax(values) {
  27672. return Math.max.apply(Math, values);
  27673. };
  27674. var urls = srcset.map(function (src) {
  27675. return src.url;
  27676. });
  27677. var maxUrlLength = getMax(urls.map(function (url) {
  27678. return url.length;
  27679. }));
  27680. var descriptors = srcset.map(function (src) {
  27681. return src[key];
  27682. }).map(function (descriptor) {
  27683. return descriptor ? descriptor.toString() : "";
  27684. });
  27685. var descriptorLeftLengths = descriptors.map(function (descriptor) {
  27686. var index = descriptor.indexOf(".");
  27687. return index === -1 ? descriptor.length : index;
  27688. });
  27689. var maxDescriptorLeftLength = getMax(descriptorLeftLengths);
  27690. return join$11(concat$16([",", line$10]), urls.map(function (url, index) {
  27691. var parts = [url];
  27692. var descriptor = descriptors[index];
  27693. if (descriptor) {
  27694. var urlPadding = maxUrlLength - url.length + 1;
  27695. var descriptorPadding = maxDescriptorLeftLength - descriptorLeftLengths[index];
  27696. var alignment = " ".repeat(urlPadding + descriptorPadding);
  27697. parts.push(ifBreak$6(alignment, " "), descriptor + unit);
  27698. }
  27699. return concat$16(parts);
  27700. }));
  27701. }
  27702. var syntaxAttribute = {
  27703. printImgSrcset: printImgSrcset$1
  27704. };
  27705. var builders = doc.builders;
  27706. var _require$$0$utils = doc.utils;
  27707. var stripTrailingHardline$2 = _require$$0$utils.stripTrailingHardline;
  27708. var mapDoc$7 = _require$$0$utils.mapDoc;
  27709. var breakParent$3 = builders.breakParent;
  27710. var dedentToRoot$2 = builders.dedentToRoot;
  27711. var fill$5 = builders.fill;
  27712. var group$14 = builders.group;
  27713. var hardline$12 = builders.hardline;
  27714. var ifBreak$5 = builders.ifBreak;
  27715. var indent$9 = builders.indent;
  27716. var join$10 = builders.join;
  27717. var line$9 = builders.line;
  27718. var literalline$6 = builders.literalline;
  27719. var markAsRoot$4 = builders.markAsRoot;
  27720. var softline$7 = builders.softline;
  27721. var countChars = utils$10.countChars;
  27722. var countParents = utils$10.countParents;
  27723. var dedentString = utils$10.dedentString;
  27724. var forceBreakChildren = utils$10.forceBreakChildren;
  27725. var forceBreakContent = utils$10.forceBreakContent;
  27726. var forceNextEmptyLine = utils$10.forceNextEmptyLine;
  27727. var getLastDescendant = utils$10.getLastDescendant;
  27728. var getPrettierIgnoreAttributeCommentData = utils$10.getPrettierIgnoreAttributeCommentData;
  27729. var hasPrettierIgnore$2 = utils$10.hasPrettierIgnore;
  27730. var inferScriptParser = utils$10.inferScriptParser;
  27731. var isScriptLikeTag = utils$10.isScriptLikeTag;
  27732. var isTextLikeNode = utils$10.isTextLikeNode;
  27733. var normalizeParts$1 = utils$10.normalizeParts;
  27734. var preferHardlineAsLeadingSpaces = utils$10.preferHardlineAsLeadingSpaces;
  27735. var shouldNotPrintClosingTag = utils$10.shouldNotPrintClosingTag;
  27736. var shouldPreserveContent = utils$10.shouldPreserveContent;
  27737. var unescapeQuoteEntities = utils$10.unescapeQuoteEntities;
  27738. var replaceEndOfLineWith$2 = util$1.replaceEndOfLineWith;
  27739. var insertPragma$6 = pragma$9.insertPragma;
  27740. var printVueFor = syntaxVue.printVueFor;
  27741. var printVueSlotScope = syntaxVue.printVueSlotScope;
  27742. var isVueEventBindingExpression$2 = syntaxVue.isVueEventBindingExpression;
  27743. var printImgSrcset = syntaxAttribute.printImgSrcset;
  27744. function concat$14(parts) {
  27745. var newParts = normalizeParts$1(parts);
  27746. return newParts.length === 0 ? "" : newParts.length === 1 ? newParts[0] : builders.concat(newParts);
  27747. }
  27748. function embed$6(path$$1, print, textToDoc, options) {
  27749. var node = path$$1.getValue();
  27750. switch (node.type) {
  27751. case "text":
  27752. {
  27753. if (isScriptLikeTag(node.parent)) {
  27754. var parser = inferScriptParser(node.parent);
  27755. if (parser) {
  27756. var value = parser === "markdown" ? dedentString(node.value.replace(/^[^\S\n]*?\n/, "")) : node.value;
  27757. return builders.concat([concat$14([breakParent$3, printOpeningTagPrefix(node, options), stripTrailingHardline$2(textToDoc(value, {
  27758. parser
  27759. })), printClosingTagSuffix(node, options)])]);
  27760. }
  27761. } else if (node.parent.type === "interpolation") {
  27762. return concat$14([indent$9(concat$14([line$9, textToDoc(node.value, Object.assign({
  27763. __isInHtmlInterpolation: true // to avoid unexpected `}}`
  27764. }, options.parser === "angular" ? {
  27765. parser: "__ng_interpolation",
  27766. trailingComma: "none"
  27767. } : options.parser === "vue" ? {
  27768. parser: "__vue_expression"
  27769. } : {
  27770. parser: "__js_expression"
  27771. }))])), node.parent.next && needsToBorrowPrevClosingTagEndMarker(node.parent.next) ? " " : line$9]);
  27772. }
  27773. break;
  27774. }
  27775. case "attribute":
  27776. {
  27777. if (!node.value) {
  27778. break;
  27779. } // lit-html: html`<my-element obj=${obj}></my-element>`
  27780. if (/^PRETTIER_HTML_PLACEHOLDER_\d+_IN_JS$/.test(options.originalText.slice(node.valueSpan.start.offset, node.valueSpan.end.offset))) {
  27781. return concat$14([node.rawName, "=", node.value]);
  27782. }
  27783. var embeddedAttributeValueDoc = printEmbeddedAttributeValue(node, function (code, opts) {
  27784. return (// strictly prefer single quote to avoid unnecessary html entity escape
  27785. textToDoc(code, Object.assign({
  27786. __isInHtmlAttribute: true
  27787. }, opts))
  27788. );
  27789. }, options);
  27790. if (embeddedAttributeValueDoc) {
  27791. return concat$14([node.rawName, '="', group$14(mapDoc$7(embeddedAttributeValueDoc, function (doc$$2) {
  27792. return typeof doc$$2 === "string" ? doc$$2.replace(/"/g, "&quot;") : doc$$2;
  27793. })), '"']);
  27794. }
  27795. break;
  27796. }
  27797. case "yaml":
  27798. return markAsRoot$4(concat$14(["---", hardline$12, node.value.trim().length === 0 ? "" : textToDoc(node.value, {
  27799. parser: "yaml"
  27800. }), "---"]));
  27801. }
  27802. }
  27803. function genericPrint$5(path$$1, options, print) {
  27804. var node = path$$1.getValue();
  27805. switch (node.type) {
  27806. case "root":
  27807. // use original concat to not break stripTrailingHardline
  27808. return builders.concat([group$14(printChildren$1(path$$1, options, print)), hardline$12]);
  27809. case "element":
  27810. case "ieConditionalComment":
  27811. {
  27812. /**
  27813. * do not break:
  27814. *
  27815. * <div>{{
  27816. * ~
  27817. * interpolation
  27818. * }}</div>
  27819. * ~
  27820. *
  27821. * exception: break if the opening tag breaks
  27822. *
  27823. * <div
  27824. * long
  27825. * ~
  27826. * >{{
  27827. * interpolation
  27828. * }}</div
  27829. * ~
  27830. * >
  27831. */
  27832. var shouldHugContent = node.children.length === 1 && node.firstChild.type === "interpolation" && node.firstChild.isLeadingSpaceSensitive && !node.firstChild.hasLeadingSpaces && node.lastChild.isTrailingSpaceSensitive && !node.lastChild.hasTrailingSpaces;
  27833. var attrGroupId = Symbol("element-attr-group-id");
  27834. return concat$14([group$14(concat$14([group$14(printOpeningTag(path$$1, options, print), {
  27835. id: attrGroupId
  27836. }), node.children.length === 0 ? node.hasDanglingSpaces && node.isDanglingSpaceSensitive ? line$9 : "" : concat$14([forceBreakContent(node) ? breakParent$3 : "", function (childrenDoc) {
  27837. return shouldHugContent ? ifBreak$5(indent$9(childrenDoc), childrenDoc, {
  27838. groupId: attrGroupId
  27839. }) : isScriptLikeTag(node) && node.parent.type === "root" && options.parser === "vue" ? childrenDoc : indent$9(childrenDoc);
  27840. }(concat$14([shouldHugContent ? ifBreak$5(softline$7, "", {
  27841. groupId: attrGroupId
  27842. }) : node.firstChild.hasLeadingSpaces && node.firstChild.isLeadingSpaceSensitive ? line$9 : node.firstChild.type === "text" && node.isWhitespaceSensitive && node.isIndentationSensitive ? dedentToRoot$2(softline$7) : softline$7, printChildren$1(path$$1, options, print)])), (node.next ? needsToBorrowPrevClosingTagEndMarker(node.next) : needsToBorrowLastChildClosingTagEndMarker(node.parent)) ? node.lastChild.hasTrailingSpaces && node.lastChild.isTrailingSpaceSensitive ? " " : "" : shouldHugContent ? ifBreak$5(softline$7, "", {
  27843. groupId: attrGroupId
  27844. }) : node.lastChild.hasTrailingSpaces && node.lastChild.isTrailingSpaceSensitive ? line$9 : (node.lastChild.type === "comment" || node.lastChild.type === "text" && node.isWhitespaceSensitive && node.isIndentationSensitive) && new RegExp(`\\n\\s{${options.tabWidth * countParents(path$$1, function (n) {
  27845. return n.parent && n.parent.type !== "root";
  27846. })}}$`).test(node.lastChild.value) ?
  27847. /**
  27848. * <div>
  27849. * <pre>
  27850. * something
  27851. * </pre>
  27852. * ~
  27853. * </div>
  27854. */
  27855. "" : softline$7])])), printClosingTag(node, options)]);
  27856. }
  27857. case "ieConditionalStartComment":
  27858. case "ieConditionalEndComment":
  27859. return concat$14([printOpeningTagStart(node), printClosingTagEnd(node)]);
  27860. case "interpolation":
  27861. return concat$14([printOpeningTagStart(node, options), concat$14(path$$1.map(print, "children")), printClosingTagEnd(node, options)]);
  27862. case "text":
  27863. {
  27864. if (node.parent.type === "interpolation") {
  27865. // replace the trailing literalline with hardline for better readability
  27866. var trailingNewlineRegex = /\n[^\S\n]*?$/;
  27867. var hasTrailingNewline = trailingNewlineRegex.test(node.value);
  27868. var value = hasTrailingNewline ? node.value.replace(trailingNewlineRegex, "") : node.value;
  27869. return concat$14([concat$14(replaceEndOfLineWith$2(value, literalline$6)), hasTrailingNewline ? hardline$12 : ""]);
  27870. }
  27871. return fill$5(normalizeParts$1([].concat(printOpeningTagPrefix(node, options), getTextValueParts(node), printClosingTagSuffix(node, options))));
  27872. }
  27873. case "docType":
  27874. return concat$14([group$14(concat$14([printOpeningTagStart(node, options), " ", node.value.replace(/^html\b/i, "html").replace(/\s+/g, " ")])), printClosingTagEnd(node, options)]);
  27875. case "comment":
  27876. {
  27877. return concat$14([printOpeningTagPrefix(node, options), concat$14(replaceEndOfLineWith$2(options.originalText.slice(options.locStart(node), options.locEnd(node)), literalline$6)), printClosingTagSuffix(node, options)]);
  27878. }
  27879. case "attribute":
  27880. {
  27881. if (node.value === null) {
  27882. return node.rawName;
  27883. }
  27884. var _value = unescapeQuoteEntities(node.value);
  27885. var singleQuoteCount = countChars(_value, "'");
  27886. var doubleQuoteCount = countChars(_value, '"');
  27887. var quote = singleQuoteCount < doubleQuoteCount ? "'" : '"';
  27888. return concat$14([node.rawName, concat$14(["=", quote, concat$14(replaceEndOfLineWith$2(quote === '"' ? _value.replace(/"/g, "&quot;") : _value.replace(/'/g, "&apos;"), literalline$6)), quote])]);
  27889. }
  27890. case "yaml":
  27891. case "toml":
  27892. return concat$14(replaceEndOfLineWith$2(node.raw, literalline$6));
  27893. default:
  27894. throw new Error(`Unexpected node type ${node.type}`);
  27895. }
  27896. }
  27897. function printChildren$1(path$$1, options, print) {
  27898. var node = path$$1.getValue();
  27899. if (forceBreakChildren(node)) {
  27900. return concat$14([breakParent$3, concat$14(path$$1.map(function (childPath) {
  27901. var childNode = childPath.getValue();
  27902. var prevBetweenLine = !childNode.prev ? "" : printBetweenLine(childNode.prev, childNode);
  27903. return concat$14([!prevBetweenLine ? "" : concat$14([prevBetweenLine, forceNextEmptyLine(childNode.prev) ? hardline$12 : ""]), printChild(childPath)]);
  27904. }, "children"))]);
  27905. }
  27906. var groupIds = node.children.map(function () {
  27907. return Symbol("");
  27908. });
  27909. return concat$14(path$$1.map(function (childPath, childIndex) {
  27910. var childNode = childPath.getValue();
  27911. if (isTextLikeNode(childNode)) {
  27912. if (childNode.prev && isTextLikeNode(childNode.prev)) {
  27913. var _prevBetweenLine = printBetweenLine(childNode.prev, childNode);
  27914. if (_prevBetweenLine) {
  27915. if (forceNextEmptyLine(childNode.prev)) {
  27916. return concat$14([hardline$12, hardline$12, printChild(childPath)]);
  27917. }
  27918. return concat$14([_prevBetweenLine, printChild(childPath)]);
  27919. }
  27920. }
  27921. return printChild(childPath);
  27922. }
  27923. var prevParts = [];
  27924. var leadingParts = [];
  27925. var trailingParts = [];
  27926. var nextParts = [];
  27927. var prevBetweenLine = childNode.prev ? printBetweenLine(childNode.prev, childNode) : "";
  27928. var nextBetweenLine = childNode.next ? printBetweenLine(childNode, childNode.next) : "";
  27929. if (prevBetweenLine) {
  27930. if (forceNextEmptyLine(childNode.prev)) {
  27931. prevParts.push(hardline$12, hardline$12);
  27932. } else if (prevBetweenLine === hardline$12) {
  27933. prevParts.push(hardline$12);
  27934. } else {
  27935. if (isTextLikeNode(childNode.prev)) {
  27936. leadingParts.push(prevBetweenLine);
  27937. } else {
  27938. leadingParts.push(ifBreak$5("", softline$7, {
  27939. groupId: groupIds[childIndex - 1]
  27940. }));
  27941. }
  27942. }
  27943. }
  27944. if (nextBetweenLine) {
  27945. if (forceNextEmptyLine(childNode)) {
  27946. if (isTextLikeNode(childNode.next)) {
  27947. nextParts.push(hardline$12, hardline$12);
  27948. }
  27949. } else if (nextBetweenLine === hardline$12) {
  27950. if (isTextLikeNode(childNode.next)) {
  27951. nextParts.push(hardline$12);
  27952. }
  27953. } else {
  27954. trailingParts.push(nextBetweenLine);
  27955. }
  27956. }
  27957. return concat$14([].concat(prevParts, group$14(concat$14([concat$14(leadingParts), group$14(concat$14([printChild(childPath), concat$14(trailingParts)]), {
  27958. id: groupIds[childIndex]
  27959. })])), nextParts));
  27960. }, "children"));
  27961. function printChild(childPath) {
  27962. var child = childPath.getValue();
  27963. if (hasPrettierIgnore$2(child)) {
  27964. return concat$14([].concat(printOpeningTagPrefix(child, options), replaceEndOfLineWith$2(options.originalText.slice(options.locStart(child) + (child.prev && needsToBorrowNextOpeningTagStartMarker(child.prev) ? printOpeningTagStartMarker(child).length : 0), options.locEnd(child) - (child.next && needsToBorrowPrevClosingTagEndMarker(child.next) ? printClosingTagEndMarker(child, options).length : 0)), literalline$6), printClosingTagSuffix(child, options)));
  27965. }
  27966. if (shouldPreserveContent(child, options)) {
  27967. return concat$14([].concat(printOpeningTagPrefix(child, options), group$14(printOpeningTag(childPath, options, print)), replaceEndOfLineWith$2(options.originalText.slice(child.startSourceSpan.end.offset + (child.firstChild && needsToBorrowParentOpeningTagEndMarker(child.firstChild) ? -printOpeningTagEndMarker(child).length : 0), child.endSourceSpan.start.offset + (child.lastChild && needsToBorrowParentClosingTagStartMarker(child.lastChild) ? printClosingTagStartMarker(child, options).length : needsToBorrowLastChildClosingTagEndMarker(child) ? -printClosingTagEndMarker(child.lastChild, options).length : 0)), literalline$6), printClosingTag(child, options), printClosingTagSuffix(child, options)));
  27968. }
  27969. return print(childPath);
  27970. }
  27971. function printBetweenLine(prevNode, nextNode) {
  27972. return isTextLikeNode(prevNode) && isTextLikeNode(nextNode) ? prevNode.isTrailingSpaceSensitive ? prevNode.hasTrailingSpaces ? preferHardlineAsLeadingSpaces(nextNode) ? hardline$12 : line$9 : "" : preferHardlineAsLeadingSpaces(nextNode) ? hardline$12 : softline$7 : needsToBorrowNextOpeningTagStartMarker(prevNode) && (
  27973. /**
  27974. * 123<a
  27975. * ~
  27976. * ><b>
  27977. */
  27978. nextNode.firstChild ||
  27979. /**
  27980. * 123<!--
  27981. * ~
  27982. * -->
  27983. */
  27984. nextNode.isSelfClosing ||
  27985. /**
  27986. * 123<span
  27987. * ~
  27988. * attr
  27989. */
  27990. nextNode.type === "element" && nextNode.attrs.length !== 0) ||
  27991. /**
  27992. * <img
  27993. * src="long"
  27994. * ~
  27995. * />123
  27996. */
  27997. prevNode.type === "element" && prevNode.isSelfClosing && needsToBorrowPrevClosingTagEndMarker(nextNode) ? "" : !nextNode.isLeadingSpaceSensitive || preferHardlineAsLeadingSpaces(nextNode) ||
  27998. /**
  27999. * Want to write us a letter? Use our<a
  28000. * ><b><a>mailing address</a></b></a
  28001. * ~
  28002. * >.
  28003. */
  28004. needsToBorrowPrevClosingTagEndMarker(nextNode) && prevNode.lastChild && needsToBorrowParentClosingTagStartMarker(prevNode.lastChild) && prevNode.lastChild.lastChild && needsToBorrowParentClosingTagStartMarker(prevNode.lastChild.lastChild) ? hardline$12 : nextNode.hasLeadingSpaces ? line$9 : softline$7;
  28005. }
  28006. }
  28007. function printOpeningTag(path$$1, options, print) {
  28008. var node = path$$1.getValue();
  28009. var forceNotToBreakAttrContent = node.type === "element" && node.fullName === "script" && node.attrs.length === 1 && node.attrs[0].fullName === "src" && node.children.length === 0;
  28010. return concat$14([printOpeningTagStart(node, options), !node.attrs || node.attrs.length === 0 ? node.isSelfClosing ?
  28011. /**
  28012. * <br />
  28013. * ^
  28014. */
  28015. " " : "" : concat$14([indent$9(concat$14([forceNotToBreakAttrContent ? " " : line$9, join$10(line$9, function (ignoreAttributeData) {
  28016. var hasPrettierIgnoreAttribute = typeof ignoreAttributeData === "boolean" ? function () {
  28017. return ignoreAttributeData;
  28018. } : Array.isArray(ignoreAttributeData) ? function (attr) {
  28019. return ignoreAttributeData.indexOf(attr.rawName) !== -1;
  28020. } : function () {
  28021. return false;
  28022. };
  28023. return path$$1.map(function (attrPath) {
  28024. var attr = attrPath.getValue();
  28025. return hasPrettierIgnoreAttribute(attr) ? concat$14(replaceEndOfLineWith$2(options.originalText.slice(options.locStart(attr), options.locEnd(attr)), literalline$6)) : print(attrPath);
  28026. }, "attrs");
  28027. }(node.prev && node.prev.type === "comment" && getPrettierIgnoreAttributeCommentData(node.prev.value)))])),
  28028. /**
  28029. * 123<a
  28030. * attr
  28031. * ~
  28032. * >456
  28033. */
  28034. node.firstChild && needsToBorrowParentOpeningTagEndMarker(node.firstChild) ||
  28035. /**
  28036. * <span
  28037. * >123<meta
  28038. * ~
  28039. * /></span>
  28040. */
  28041. node.isSelfClosing && needsToBorrowLastChildClosingTagEndMarker(node.parent) ? "" : node.isSelfClosing ? forceNotToBreakAttrContent ? " " : line$9 : forceNotToBreakAttrContent ? "" : softline$7]), node.isSelfClosing ? "" : printOpeningTagEnd(node)]);
  28042. }
  28043. function printOpeningTagStart(node, options) {
  28044. return node.prev && needsToBorrowNextOpeningTagStartMarker(node.prev) ? "" : concat$14([printOpeningTagPrefix(node, options), printOpeningTagStartMarker(node)]);
  28045. }
  28046. function printOpeningTagEnd(node) {
  28047. return node.firstChild && needsToBorrowParentOpeningTagEndMarker(node.firstChild) ? "" : printOpeningTagEndMarker(node);
  28048. }
  28049. function printClosingTag(node, options) {
  28050. return concat$14([node.isSelfClosing ? "" : printClosingTagStart(node, options), printClosingTagEnd(node, options)]);
  28051. }
  28052. function printClosingTagStart(node, options) {
  28053. return node.lastChild && needsToBorrowParentClosingTagStartMarker(node.lastChild) ? "" : concat$14([printClosingTagPrefix(node, options), printClosingTagStartMarker(node, options)]);
  28054. }
  28055. function printClosingTagEnd(node, options) {
  28056. return (node.next ? needsToBorrowPrevClosingTagEndMarker(node.next) : needsToBorrowLastChildClosingTagEndMarker(node.parent)) ? "" : concat$14([printClosingTagEndMarker(node, options), printClosingTagSuffix(node, options)]);
  28057. }
  28058. function needsToBorrowNextOpeningTagStartMarker(node) {
  28059. /**
  28060. * 123<p
  28061. * ^^
  28062. * >
  28063. */
  28064. return node.next && !isTextLikeNode(node.next) && isTextLikeNode(node) && node.isTrailingSpaceSensitive && !node.hasTrailingSpaces;
  28065. }
  28066. function needsToBorrowParentOpeningTagEndMarker(node) {
  28067. /**
  28068. * <p
  28069. * >123
  28070. * ^
  28071. *
  28072. * <p
  28073. * ><a
  28074. * ^
  28075. */
  28076. return !node.prev && node.isLeadingSpaceSensitive && !node.hasLeadingSpaces;
  28077. }
  28078. function needsToBorrowPrevClosingTagEndMarker(node) {
  28079. /**
  28080. * <p></p
  28081. * >123
  28082. * ^
  28083. *
  28084. * <p></p
  28085. * ><a
  28086. * ^
  28087. */
  28088. return node.prev && !isTextLikeNode(node.prev) && node.isLeadingSpaceSensitive && !node.hasLeadingSpaces;
  28089. }
  28090. function needsToBorrowLastChildClosingTagEndMarker(node) {
  28091. /**
  28092. * <p
  28093. * ><a></a
  28094. * ></p
  28095. * ^
  28096. * >
  28097. */
  28098. return node.lastChild && node.lastChild.isTrailingSpaceSensitive && !node.lastChild.hasTrailingSpaces && !isTextLikeNode(getLastDescendant(node.lastChild));
  28099. }
  28100. function needsToBorrowParentClosingTagStartMarker(node) {
  28101. /**
  28102. * <p>
  28103. * 123</p
  28104. * ^^^
  28105. * >
  28106. *
  28107. * 123</b
  28108. * ></a
  28109. * ^^^
  28110. * >
  28111. */
  28112. return !node.next && !node.hasTrailingSpaces && node.isTrailingSpaceSensitive && isTextLikeNode(getLastDescendant(node));
  28113. }
  28114. function printOpeningTagPrefix(node, options) {
  28115. return needsToBorrowParentOpeningTagEndMarker(node) ? printOpeningTagEndMarker(node.parent) : needsToBorrowPrevClosingTagEndMarker(node) ? printClosingTagEndMarker(node.prev, options) : "";
  28116. }
  28117. function printClosingTagPrefix(node, options) {
  28118. return needsToBorrowLastChildClosingTagEndMarker(node) ? printClosingTagEndMarker(node.lastChild, options) : "";
  28119. }
  28120. function printClosingTagSuffix(node, options) {
  28121. return needsToBorrowParentClosingTagStartMarker(node) ? printClosingTagStartMarker(node.parent, options) : needsToBorrowNextOpeningTagStartMarker(node) ? printOpeningTagStartMarker(node.next) : "";
  28122. }
  28123. function printOpeningTagStartMarker(node) {
  28124. switch (node.type) {
  28125. case "ieConditionalComment":
  28126. case "ieConditionalStartComment":
  28127. return `<!--[if ${node.condition}`;
  28128. case "ieConditionalEndComment":
  28129. return `<!--<!`;
  28130. case "interpolation":
  28131. return "{{";
  28132. case "docType":
  28133. return "<!DOCTYPE";
  28134. case "element":
  28135. if (node.condition) {
  28136. return `<!--[if ${node.condition}]><!--><${node.rawName}`;
  28137. }
  28138. // fall through
  28139. default:
  28140. return `<${node.rawName}`;
  28141. }
  28142. }
  28143. function printOpeningTagEndMarker(node) {
  28144. assert(!node.isSelfClosing);
  28145. switch (node.type) {
  28146. case "ieConditionalComment":
  28147. return "]>";
  28148. case "element":
  28149. if (node.condition) {
  28150. return `><!--<![endif]-->`;
  28151. }
  28152. // fall through
  28153. default:
  28154. return `>`;
  28155. }
  28156. }
  28157. function printClosingTagStartMarker(node, options) {
  28158. assert(!node.isSelfClosing);
  28159. if (shouldNotPrintClosingTag(node, options)) {
  28160. return "";
  28161. }
  28162. switch (node.type) {
  28163. case "ieConditionalComment":
  28164. return "<!";
  28165. case "element":
  28166. if (node.hasHtmComponentClosingTag) {
  28167. return "<//";
  28168. }
  28169. // fall through
  28170. default:
  28171. return `</${node.rawName}`;
  28172. }
  28173. }
  28174. function printClosingTagEndMarker(node, options) {
  28175. if (shouldNotPrintClosingTag(node, options)) {
  28176. return "";
  28177. }
  28178. switch (node.type) {
  28179. case "ieConditionalComment":
  28180. case "ieConditionalEndComment":
  28181. return `[endif]-->`;
  28182. case "ieConditionalStartComment":
  28183. return `]><!-->`;
  28184. case "interpolation":
  28185. return "}}";
  28186. case "element":
  28187. if (node.isSelfClosing) {
  28188. return "/>";
  28189. }
  28190. // fall through
  28191. default:
  28192. return ">";
  28193. }
  28194. }
  28195. function getTextValueParts(node) {
  28196. var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : node.value;
  28197. return node.parent.isWhitespaceSensitive ? node.parent.isIndentationSensitive ? replaceEndOfLineWith$2(value, literalline$6) : replaceEndOfLineWith$2(dedentString(value.replace(/^\s*?\n|\n\s*?$/g, "")), hardline$12) : // https://infra.spec.whatwg.org/#ascii-whitespace
  28198. join$10(line$9, value.split(/[\t\n\f\r ]+/)).parts;
  28199. }
  28200. function printEmbeddedAttributeValue(node, originalTextToDoc, options) {
  28201. var isKeyMatched = function isKeyMatched(patterns) {
  28202. return new RegExp(patterns.join("|")).test(node.fullName);
  28203. };
  28204. var getValue = function getValue() {
  28205. return unescapeQuoteEntities(node.value);
  28206. };
  28207. var shouldHug = false;
  28208. var __onHtmlBindingRoot = function __onHtmlBindingRoot(root) {
  28209. var rootNode = root.type === "NGRoot" ? root.node.type === "NGMicrosyntax" && root.node.body.length === 1 && root.node.body[0].type === "NGMicrosyntaxExpression" ? root.node.body[0].expression : root.node : root.type === "JsExpressionRoot" ? root.node : root;
  28210. if (rootNode && (rootNode.type === "ObjectExpression" || rootNode.type === "ArrayExpression")) {
  28211. shouldHug = true;
  28212. }
  28213. };
  28214. var printHug = function printHug(doc$$2) {
  28215. return group$14(doc$$2);
  28216. };
  28217. var printExpand = function printExpand(doc$$2) {
  28218. return group$14(concat$14([indent$9(concat$14([softline$7, doc$$2])), softline$7]));
  28219. };
  28220. var printMaybeHug = function printMaybeHug(doc$$2) {
  28221. return shouldHug ? printHug(doc$$2) : printExpand(doc$$2);
  28222. };
  28223. var textToDoc = function textToDoc(code, opts) {
  28224. return originalTextToDoc(code, Object.assign({
  28225. __onHtmlBindingRoot
  28226. }, opts));
  28227. };
  28228. if (node.fullName === "srcset" && (node.parent.fullName === "img" || node.parent.fullName === "source")) {
  28229. return printExpand(printImgSrcset(getValue()));
  28230. }
  28231. if (options.parser === "vue") {
  28232. if (node.fullName === "v-for") {
  28233. return printVueFor(getValue(), textToDoc);
  28234. }
  28235. if (node.fullName === "slot-scope") {
  28236. return printVueSlotScope(getValue(), textToDoc);
  28237. }
  28238. /**
  28239. * @click="jsStatement"
  28240. * @click="jsExpression"
  28241. * v-on:click="jsStatement"
  28242. * v-on:click="jsExpression"
  28243. */
  28244. var vueEventBindingPatterns = ["^@", "^v-on:"];
  28245. /**
  28246. * :class="vueExpression"
  28247. * v-bind:id="vueExpression"
  28248. */
  28249. var vueExpressionBindingPatterns = ["^:", "^v-bind:"];
  28250. /**
  28251. * v-if="jsExpression"
  28252. */
  28253. var jsExpressionBindingPatterns = ["^v-"];
  28254. if (isKeyMatched(vueEventBindingPatterns)) {
  28255. var value = getValue();
  28256. return printMaybeHug(isVueEventBindingExpression$2(value) ? textToDoc(value, {
  28257. parser: "__js_expression"
  28258. }) : stripTrailingHardline$2(textToDoc(value, {
  28259. parser: "__vue_event_binding"
  28260. })));
  28261. }
  28262. if (isKeyMatched(vueExpressionBindingPatterns)) {
  28263. return printMaybeHug(textToDoc(getValue(), {
  28264. parser: "__vue_expression"
  28265. }));
  28266. }
  28267. if (isKeyMatched(jsExpressionBindingPatterns)) {
  28268. return printMaybeHug(textToDoc(getValue(), {
  28269. parser: "__js_expression"
  28270. }));
  28271. }
  28272. }
  28273. if (options.parser === "angular") {
  28274. var ngTextToDoc = function ngTextToDoc(code, opts) {
  28275. return (// angular does not allow trailing comma
  28276. textToDoc(code, Object.assign({
  28277. trailingComma: "none"
  28278. }, opts))
  28279. );
  28280. };
  28281. /**
  28282. * *directive="angularDirective"
  28283. */
  28284. var ngDirectiveBindingPatterns = ["^\\*"];
  28285. /**
  28286. * (click)="angularStatement"
  28287. * on-click="angularStatement"
  28288. */
  28289. var ngStatementBindingPatterns = ["^\\(.+\\)$", "^on-"];
  28290. /**
  28291. * [target]="angularExpression"
  28292. * bind-target="angularExpression"
  28293. * [(target)]="angularExpression"
  28294. * bindon-target="angularExpression"
  28295. */
  28296. var ngExpressionBindingPatterns = ["^\\[.+\\]$", "^bind(on)?-"];
  28297. if (isKeyMatched(ngStatementBindingPatterns)) {
  28298. return printMaybeHug(ngTextToDoc(getValue(), {
  28299. parser: "__ng_action"
  28300. }));
  28301. }
  28302. if (isKeyMatched(ngExpressionBindingPatterns)) {
  28303. return printMaybeHug(ngTextToDoc(getValue(), {
  28304. parser: "__ng_binding"
  28305. }));
  28306. }
  28307. if (isKeyMatched(ngDirectiveBindingPatterns)) {
  28308. return printMaybeHug(ngTextToDoc(getValue(), {
  28309. parser: "__ng_directive"
  28310. }));
  28311. }
  28312. var interpolationRegex = /\{\{([\s\S]+?)\}\}/g;
  28313. var _value2 = getValue();
  28314. if (interpolationRegex.test(_value2)) {
  28315. var parts = [];
  28316. _value2.split(interpolationRegex).forEach(function (part, index) {
  28317. if (index % 2 === 0) {
  28318. parts.push(concat$14(replaceEndOfLineWith$2(part, literalline$6)));
  28319. } else {
  28320. try {
  28321. parts.push(group$14(concat$14(["{{", indent$9(concat$14([line$9, ngTextToDoc(part, {
  28322. parser: "__ng_interpolation",
  28323. __isInHtmlInterpolation: true // to avoid unexpected `}}`
  28324. })])), line$9, "}}"])));
  28325. } catch (e) {
  28326. parts.push("{{", concat$14(replaceEndOfLineWith$2(part, literalline$6)), "}}");
  28327. }
  28328. }
  28329. });
  28330. return group$14(concat$14(parts));
  28331. }
  28332. }
  28333. return null;
  28334. }
  28335. var printerHtml = {
  28336. preprocess: preprocess_1$4,
  28337. print: genericPrint$5,
  28338. insertPragma: insertPragma$6,
  28339. massageAstNode: clean$8,
  28340. embed: embed$6
  28341. };
  28342. var CATEGORY_HTML = "HTML"; // format based on https://github.com/prettier/prettier/blob/master/src/main/core-options.js
  28343. var options$16 = {
  28344. htmlWhitespaceSensitivity: {
  28345. since: "1.15.0",
  28346. category: CATEGORY_HTML,
  28347. type: "choice",
  28348. default: "css",
  28349. description: "How to handle whitespaces in HTML.",
  28350. choices: [{
  28351. value: "css",
  28352. description: "Respect the default value of CSS display property."
  28353. }, {
  28354. value: "strict",
  28355. description: "Whitespaces are considered sensitive."
  28356. }, {
  28357. value: "ignore",
  28358. description: "Whitespaces are considered insensitive."
  28359. }]
  28360. }
  28361. };
  28362. var name$14 = "HTML";
  28363. var type$13 = "markup";
  28364. var tmScope$13 = "text.html.basic";
  28365. var aceMode$13 = "html";
  28366. var codemirrorMode$10 = "htmlmixed";
  28367. var codemirrorMimeType$10 = "text/html";
  28368. var color$3 = "#e34c26";
  28369. var aliases$5 = ["xhtml"];
  28370. var extensions$13 = [".html", ".htm", ".html.hl", ".inc", ".st", ".xht", ".xhtml"];
  28371. var languageId$13 = 146;
  28372. var html$1 = {
  28373. name: name$14,
  28374. type: type$13,
  28375. tmScope: tmScope$13,
  28376. aceMode: aceMode$13,
  28377. codemirrorMode: codemirrorMode$10,
  28378. codemirrorMimeType: codemirrorMimeType$10,
  28379. color: color$3,
  28380. aliases: aliases$5,
  28381. extensions: extensions$13,
  28382. languageId: languageId$13
  28383. };
  28384. var html$2 = Object.freeze({
  28385. name: name$14,
  28386. type: type$13,
  28387. tmScope: tmScope$13,
  28388. aceMode: aceMode$13,
  28389. codemirrorMode: codemirrorMode$10,
  28390. codemirrorMimeType: codemirrorMimeType$10,
  28391. color: color$3,
  28392. aliases: aliases$5,
  28393. extensions: extensions$13,
  28394. languageId: languageId$13,
  28395. default: html$1
  28396. });
  28397. var name$15 = "Vue";
  28398. var type$14 = "markup";
  28399. var color$4 = "#2c3e50";
  28400. var extensions$14 = [".vue"];
  28401. var tmScope$14 = "text.html.vue";
  28402. var aceMode$14 = "html";
  28403. var languageId$14 = 391;
  28404. var vue = {
  28405. name: name$15,
  28406. type: type$14,
  28407. color: color$4,
  28408. extensions: extensions$14,
  28409. tmScope: tmScope$14,
  28410. aceMode: aceMode$14,
  28411. languageId: languageId$14
  28412. };
  28413. var vue$1 = Object.freeze({
  28414. name: name$15,
  28415. type: type$14,
  28416. color: color$4,
  28417. extensions: extensions$14,
  28418. tmScope: tmScope$14,
  28419. aceMode: aceMode$14,
  28420. languageId: languageId$14,
  28421. default: vue
  28422. });
  28423. var require$$0$31 = ( html$2 && html$1 ) || html$2;
  28424. var require$$1$11 = ( vue$1 && vue ) || vue$1;
  28425. var languages$5 = [createLanguage(require$$0$31, {
  28426. override: {
  28427. name: "Angular",
  28428. since: "1.15.0",
  28429. parsers: ["angular"],
  28430. vscodeLanguageIds: ["html"],
  28431. extensions: [".component.html"],
  28432. filenames: []
  28433. }
  28434. }), createLanguage(require$$0$31, {
  28435. override: {
  28436. since: "1.15.0",
  28437. parsers: ["html"],
  28438. vscodeLanguageIds: ["html"]
  28439. },
  28440. extend: {
  28441. extensions: [".mjml" // MJML is considered XML in Linguist but it should be formatted as HTML
  28442. ]
  28443. }
  28444. }), createLanguage(require$$1$11, {
  28445. override: {
  28446. since: "1.10.0",
  28447. parsers: ["vue"],
  28448. vscodeLanguageIds: ["vue"]
  28449. }
  28450. })];
  28451. var printers$5 = {
  28452. html: printerHtml
  28453. };
  28454. var languageHtml = {
  28455. languages: languages$5,
  28456. printers: printers$5,
  28457. options: options$16
  28458. };
  28459. function isPragma$1(text) {
  28460. return /^\s*@(prettier|format)\s*$/.test(text);
  28461. }
  28462. function hasPragma$4(text) {
  28463. return /^\s*#[^\n\S]*@(prettier|format)\s*?(\n|$)/.test(text);
  28464. }
  28465. function insertPragma$9(text) {
  28466. return `# @format\n\n${text}`;
  28467. }
  28468. var pragma$11 = {
  28469. isPragma: isPragma$1,
  28470. hasPragma: hasPragma$4,
  28471. insertPragma: insertPragma$9
  28472. };
  28473. var getLast$7 = util$1.getLast;
  28474. function getAncestorCount$1(path$$1, filter) {
  28475. var counter = 0;
  28476. var pathStackLength = path$$1.stack.length - 1;
  28477. for (var i = 0; i < pathStackLength; i++) {
  28478. var value = path$$1.stack[i];
  28479. if (isNode$2(value) && filter(value)) {
  28480. counter++;
  28481. }
  28482. }
  28483. return counter;
  28484. }
  28485. /**
  28486. * @param {any} value
  28487. * @param {string[]=} types
  28488. */
  28489. function isNode$2(value, types) {
  28490. return value && typeof value.type === "string" && (!types || types.indexOf(value.type) !== -1);
  28491. }
  28492. function mapNode$1(node, callback, parent) {
  28493. return callback("children" in node ? Object.assign({}, node, {
  28494. children: node.children.map(function (childNode) {
  28495. return mapNode$1(childNode, callback, node);
  28496. })
  28497. }) : node, parent);
  28498. }
  28499. function defineShortcut$1(x, key, getter) {
  28500. Object.defineProperty(x, key, {
  28501. get: getter,
  28502. enumerable: false
  28503. });
  28504. }
  28505. function isNextLineEmpty$6(node, text) {
  28506. var newlineCount = 0;
  28507. var textLength = text.length;
  28508. for (var i = node.position.end.offset - 1; i < textLength; i++) {
  28509. var char = text[i];
  28510. if (char === "\n") {
  28511. newlineCount++;
  28512. }
  28513. if (newlineCount === 1 && /\S/.test(char)) {
  28514. return false;
  28515. }
  28516. if (newlineCount === 2) {
  28517. return true;
  28518. }
  28519. }
  28520. return false;
  28521. }
  28522. function isLastDescendantNode$1(path$$1) {
  28523. var node = path$$1.getValue();
  28524. switch (node.type) {
  28525. case "tag":
  28526. case "anchor":
  28527. case "comment":
  28528. return false;
  28529. }
  28530. var pathStackLength = path$$1.stack.length;
  28531. for (var i = 1; i < pathStackLength; i++) {
  28532. var item = path$$1.stack[i];
  28533. var parentItem = path$$1.stack[i - 1];
  28534. if (Array.isArray(parentItem) && typeof item === "number" && item !== parentItem.length - 1) {
  28535. return false;
  28536. }
  28537. }
  28538. return true;
  28539. }
  28540. function getLastDescendantNode$2(node) {
  28541. return "children" in node && node.children.length !== 0 ? getLastDescendantNode$2(getLast$7(node.children)) : node;
  28542. }
  28543. function isPrettierIgnore$2(comment) {
  28544. return comment.value.trim() === "prettier-ignore";
  28545. }
  28546. function hasPrettierIgnore$5(path$$1) {
  28547. var node = path$$1.getValue();
  28548. if (node.type === "documentBody") {
  28549. var document = path$$1.getParentNode();
  28550. return hasEndComments$1(document.head) && isPrettierIgnore$2(getLast$7(document.head.endComments));
  28551. }
  28552. return hasLeadingComments$1(node) && isPrettierIgnore$2(getLast$7(node.leadingComments));
  28553. }
  28554. function isEmptyNode$1(node) {
  28555. return (!node.children || node.children.length === 0) && !hasComments(node);
  28556. }
  28557. function hasComments(node) {
  28558. return hasLeadingComments$1(node) || hasMiddleComments$1(node) || hasIndicatorComment$1(node) || hasTrailingComment$2(node) || hasEndComments$1(node);
  28559. }
  28560. function hasLeadingComments$1(node) {
  28561. return node && node.leadingComments && node.leadingComments.length !== 0;
  28562. }
  28563. function hasMiddleComments$1(node) {
  28564. return node && node.middleComments && node.middleComments.length !== 0;
  28565. }
  28566. function hasIndicatorComment$1(node) {
  28567. return node && node.indicatorComment;
  28568. }
  28569. function hasTrailingComment$2(node) {
  28570. return node && node.trailingComment;
  28571. }
  28572. function hasEndComments$1(node) {
  28573. return node && node.endComments && node.endComments.length !== 0;
  28574. }
  28575. /**
  28576. * " a b c d e f " -> [" a b", "c d", "e f "]
  28577. */
  28578. function splitWithSingleSpace(text) {
  28579. var parts = [];
  28580. var lastPart = undefined;
  28581. var _iteratorNormalCompletion = true;
  28582. var _didIteratorError = false;
  28583. var _iteratorError = undefined;
  28584. try {
  28585. for (var _iterator = text.split(/( +)/g)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  28586. var part = _step.value;
  28587. if (part !== " ") {
  28588. if (lastPart === " ") {
  28589. parts.push(part);
  28590. } else {
  28591. parts.push((parts.pop() || "") + part);
  28592. }
  28593. } else if (lastPart === undefined) {
  28594. parts.unshift("");
  28595. }
  28596. lastPart = part;
  28597. }
  28598. } catch (err) {
  28599. _didIteratorError = true;
  28600. _iteratorError = err;
  28601. } finally {
  28602. try {
  28603. if (!_iteratorNormalCompletion && _iterator.return != null) {
  28604. _iterator.return();
  28605. }
  28606. } finally {
  28607. if (_didIteratorError) {
  28608. throw _iteratorError;
  28609. }
  28610. }
  28611. }
  28612. if (lastPart === " ") {
  28613. parts.push((parts.pop() || "") + " ");
  28614. }
  28615. if (parts[0] === "") {
  28616. parts.shift();
  28617. parts.unshift(" " + (parts.shift() || ""));
  28618. }
  28619. return parts;
  28620. }
  28621. function getFlowScalarLineContents$1(nodeType, content, options) {
  28622. var rawLineContents = content.split("\n").map(function (lineContent, index, lineContents) {
  28623. return index === 0 && index === lineContents.length - 1 ? lineContent : index !== 0 && index !== lineContents.length - 1 ? lineContent.trim() : index === 0 ? lineContent.trimRight() : lineContent.trimLeft();
  28624. });
  28625. if (options.proseWrap === "preserve") {
  28626. return rawLineContents.map(function (lineContent) {
  28627. return lineContent.length === 0 ? [] : [lineContent];
  28628. });
  28629. }
  28630. return rawLineContents.map(function (lineContent) {
  28631. return lineContent.length === 0 ? [] : splitWithSingleSpace(lineContent);
  28632. }).reduce(function (reduced, lineContentWords, index) {
  28633. return index !== 0 && rawLineContents[index - 1].length !== 0 && lineContentWords.length !== 0 && !( // trailing backslash in quoteDouble should be preserved
  28634. nodeType === "quoteDouble" && getLast$7(getLast$7(reduced)).endsWith("\\")) ? reduced.concat([reduced.pop().concat(lineContentWords)]) : reduced.concat([lineContentWords]);
  28635. }, []).map(function (lineContentWords) {
  28636. return options.proseWrap === "never" ? [lineContentWords.join(" ")] : lineContentWords;
  28637. });
  28638. }
  28639. function getBlockValueLineContents$1(node, _ref) {
  28640. var parentIndent = _ref.parentIndent,
  28641. isLastDescendant = _ref.isLastDescendant,
  28642. options = _ref.options;
  28643. var content = node.position.start.line === node.position.end.line ? "" : options.originalText.slice(node.position.start.offset, node.position.end.offset) // exclude open line `>` or `|`
  28644. .match(/^[^\n]*?\n([\s\S]*)$/)[1];
  28645. var leadingSpaceCount = node.indent === null ? function (match) {
  28646. return match ? match[1].length : Infinity;
  28647. }(content.match(/^( *)\S/m)) : node.indent - 1 + parentIndent;
  28648. var rawLineContents = content.split("\n").map(function (lineContent) {
  28649. return lineContent.slice(leadingSpaceCount);
  28650. });
  28651. if (options.proseWrap === "preserve" || node.type === "blockLiteral") {
  28652. return removeUnnecessaryTrailingNewlines(rawLineContents.map(function (lineContent) {
  28653. return lineContent.length === 0 ? [] : [lineContent];
  28654. }));
  28655. }
  28656. return removeUnnecessaryTrailingNewlines(rawLineContents.map(function (lineContent) {
  28657. return lineContent.length === 0 ? [] : splitWithSingleSpace(lineContent);
  28658. }).reduce(function (reduced, lineContentWords, index) {
  28659. return index !== 0 && rawLineContents[index - 1].length !== 0 && lineContentWords.length !== 0 && !/^\s/.test(lineContentWords[0]) && !/^\s|\s$/.test(getLast$7(reduced)) ? reduced.concat([reduced.pop().concat(lineContentWords)]) : reduced.concat([lineContentWords]);
  28660. }, []).map(function (lineContentWords) {
  28661. return lineContentWords.reduce(function (reduced, word) {
  28662. return (// disallow trailing spaces
  28663. reduced.length !== 0 && /\s$/.test(getLast$7(reduced)) ? reduced.concat(reduced.pop() + " " + word) : reduced.concat(word)
  28664. );
  28665. }, []);
  28666. }).map(function (lineContentWords) {
  28667. return options.proseWrap === "never" ? [lineContentWords.join(" ")] : lineContentWords;
  28668. }));
  28669. function removeUnnecessaryTrailingNewlines(lineContents) {
  28670. if (node.chomping === "keep") {
  28671. return getLast$7(lineContents).length === 0 ? lineContents.slice(0, -1) : lineContents;
  28672. }
  28673. var trailingNewlineCount = 0;
  28674. for (var i = lineContents.length - 1; i >= 0; i--) {
  28675. if (lineContents[i].length === 0) {
  28676. trailingNewlineCount++;
  28677. } else {
  28678. break;
  28679. }
  28680. }
  28681. return trailingNewlineCount === 0 ? lineContents : trailingNewlineCount >= 2 && !isLastDescendant ? // next empty line
  28682. lineContents.slice(0, -(trailingNewlineCount - 1)) : lineContents.slice(0, -trailingNewlineCount);
  28683. }
  28684. }
  28685. var utils$12 = {
  28686. getLast: getLast$7,
  28687. getAncestorCount: getAncestorCount$1,
  28688. isNode: isNode$2,
  28689. isEmptyNode: isEmptyNode$1,
  28690. mapNode: mapNode$1,
  28691. defineShortcut: defineShortcut$1,
  28692. isNextLineEmpty: isNextLineEmpty$6,
  28693. isLastDescendantNode: isLastDescendantNode$1,
  28694. getBlockValueLineContents: getBlockValueLineContents$1,
  28695. getFlowScalarLineContents: getFlowScalarLineContents$1,
  28696. getLastDescendantNode: getLastDescendantNode$2,
  28697. hasPrettierIgnore: hasPrettierIgnore$5,
  28698. hasLeadingComments: hasLeadingComments$1,
  28699. hasMiddleComments: hasMiddleComments$1,
  28700. hasIndicatorComment: hasIndicatorComment$1,
  28701. hasTrailingComment: hasTrailingComment$2,
  28702. hasEndComments: hasEndComments$1
  28703. };
  28704. var insertPragma$8 = pragma$11.insertPragma;
  28705. var isPragma = pragma$11.isPragma;
  28706. var getAncestorCount = utils$12.getAncestorCount;
  28707. var getBlockValueLineContents = utils$12.getBlockValueLineContents;
  28708. var getFlowScalarLineContents = utils$12.getFlowScalarLineContents;
  28709. var getLast$6 = utils$12.getLast;
  28710. var getLastDescendantNode$1 = utils$12.getLastDescendantNode;
  28711. var hasLeadingComments = utils$12.hasLeadingComments;
  28712. var hasMiddleComments = utils$12.hasMiddleComments;
  28713. var hasIndicatorComment = utils$12.hasIndicatorComment;
  28714. var hasTrailingComment$1 = utils$12.hasTrailingComment;
  28715. var hasEndComments = utils$12.hasEndComments;
  28716. var hasPrettierIgnore$4 = utils$12.hasPrettierIgnore;
  28717. var isLastDescendantNode = utils$12.isLastDescendantNode;
  28718. var isNextLineEmpty$5 = utils$12.isNextLineEmpty;
  28719. var isNode$1 = utils$12.isNode;
  28720. var isEmptyNode = utils$12.isEmptyNode;
  28721. var defineShortcut = utils$12.defineShortcut;
  28722. var mapNode = utils$12.mapNode;
  28723. var docBuilders$3 = doc.builders;
  28724. var conditionalGroup$2 = docBuilders$3.conditionalGroup;
  28725. var breakParent$4 = docBuilders$3.breakParent;
  28726. var concat$17 = docBuilders$3.concat;
  28727. var dedent$4 = docBuilders$3.dedent;
  28728. var dedentToRoot$3 = docBuilders$3.dedentToRoot;
  28729. var fill$6 = docBuilders$3.fill;
  28730. var group$16 = docBuilders$3.group;
  28731. var hardline$13 = docBuilders$3.hardline;
  28732. var ifBreak$7 = docBuilders$3.ifBreak;
  28733. var join$12 = docBuilders$3.join;
  28734. var line$11 = docBuilders$3.line;
  28735. var lineSuffix$2 = docBuilders$3.lineSuffix;
  28736. var literalline$7 = docBuilders$3.literalline;
  28737. var markAsRoot$5 = docBuilders$3.markAsRoot;
  28738. var softline$8 = docBuilders$3.softline;
  28739. var replaceEndOfLineWith$3 = util$1.replaceEndOfLineWith;
  28740. function preprocess$6(ast) {
  28741. return mapNode(ast, defineShortcuts);
  28742. }
  28743. function defineShortcuts(node) {
  28744. switch (node.type) {
  28745. case "document":
  28746. defineShortcut(node, "head", function () {
  28747. return node.children[0];
  28748. });
  28749. defineShortcut(node, "body", function () {
  28750. return node.children[1];
  28751. });
  28752. break;
  28753. case "documentBody":
  28754. case "sequenceItem":
  28755. case "flowSequenceItem":
  28756. case "mappingKey":
  28757. case "mappingValue":
  28758. defineShortcut(node, "content", function () {
  28759. return node.children[0];
  28760. });
  28761. break;
  28762. case "mappingItem":
  28763. case "flowMappingItem":
  28764. defineShortcut(node, "key", function () {
  28765. return node.children[0];
  28766. });
  28767. defineShortcut(node, "value", function () {
  28768. return node.children[1];
  28769. });
  28770. break;
  28771. }
  28772. return node;
  28773. }
  28774. function genericPrint$6(path$$1, options, print) {
  28775. var node = path$$1.getValue();
  28776. var parentNode = path$$1.getParentNode();
  28777. var tag = !node.tag ? "" : path$$1.call(print, "tag");
  28778. var anchor = !node.anchor ? "" : path$$1.call(print, "anchor");
  28779. var nextEmptyLine = isNode$1(node, ["mapping", "sequence", "comment", "directive", "mappingItem", "sequenceItem"]) && !isLastDescendantNode(path$$1) ? printNextEmptyLine(path$$1, options.originalText) : "";
  28780. return concat$17([node.type !== "mappingValue" && hasLeadingComments(node) ? concat$17([join$12(hardline$13, path$$1.map(print, "leadingComments")), hardline$13]) : "", tag, tag && anchor ? " " : "", anchor, tag || anchor ? isNode$1(node, ["sequence", "mapping"]) && !hasMiddleComments(node) ? hardline$13 : " " : "", hasMiddleComments(node) ? concat$17([node.middleComments.length === 1 ? "" : hardline$13, join$12(hardline$13, path$$1.map(print, "middleComments")), hardline$13]) : "", hasPrettierIgnore$4(path$$1) ? concat$17(replaceEndOfLineWith$3(options.originalText.slice(node.position.start.offset, node.position.end.offset), literalline$7)) : group$16(_print(node, parentNode, path$$1, options, print)), hasTrailingComment$1(node) && !isNode$1(node, ["document", "documentHead"]) ? lineSuffix$2(concat$17([node.type === "mappingValue" && !node.content ? "" : " ", parentNode.type === "mappingKey" && path$$1.getParentNode(2).type === "mapping" && isInlineNode(node) ? "" : breakParent$4, path$$1.call(print, "trailingComment")])) : "", nextEmptyLine, hasEndComments(node) && !isNode$1(node, ["documentHead", "documentBody"]) ? align$3(node.type === "sequenceItem" ? 2 : 0, concat$17([hardline$13, join$12(hardline$13, path$$1.map(print, "endComments"))])) : ""]);
  28781. }
  28782. function _print(node, parentNode, path$$1, options, print) {
  28783. switch (node.type) {
  28784. case "root":
  28785. return concat$17([join$12(hardline$13, path$$1.map(function (childPath, index) {
  28786. var document = node.children[index];
  28787. var nextDocument = node.children[index + 1];
  28788. return concat$17([print(childPath), shouldPrintDocumentEndMarker(document, nextDocument) ? concat$17([hardline$13, "...", hasTrailingComment$1(document) ? concat$17([" ", path$$1.call(print, "trailingComment")]) : ""]) : !nextDocument || hasTrailingComment$1(nextDocument.head) ? "" : concat$17([hardline$13, "---"])]);
  28789. }, "children")), node.children.length === 0 || function (lastDescendantNode) {
  28790. return isNode$1(lastDescendantNode, ["blockLiteral", "blockFolded"]) && lastDescendantNode.chomping === "keep";
  28791. }(getLastDescendantNode$1(node)) ? "" : hardline$13]);
  28792. case "document":
  28793. {
  28794. var nextDocument = parentNode.children[path$$1.getName() + 1];
  28795. return join$12(hardline$13, [shouldPrintDocumentHeadEndMarker(node, nextDocument, parentNode, options) === "head" ? join$12(hardline$13, [node.head.children.length === 0 && node.head.endComments.length === 0 ? "" : path$$1.call(print, "head"), concat$17(["---", hasTrailingComment$1(node.head) ? concat$17([" ", path$$1.call(print, "head", "trailingComment")]) : ""])].filter(Boolean)) : "", shouldPrintDocumentBody(node) ? path$$1.call(print, "body") : ""].filter(Boolean));
  28796. }
  28797. case "documentHead":
  28798. return join$12(hardline$13, [].concat(path$$1.map(print, "children"), path$$1.map(print, "endComments")));
  28799. case "documentBody":
  28800. {
  28801. var children = join$12(hardline$13, path$$1.map(print, "children")).parts;
  28802. var endComments = join$12(hardline$13, path$$1.map(print, "endComments")).parts;
  28803. var separator = children.length === 0 || endComments.length === 0 ? "" : function (lastDescendantNode) {
  28804. return isNode$1(lastDescendantNode, ["blockFolded", "blockLiteral"]) ? lastDescendantNode.chomping === "keep" ? // there's already a newline printed at the end of blockValue (chomping=keep, lastDescendant=true)
  28805. "" : // an extra newline for better readability
  28806. concat$17([hardline$13, hardline$13]) : hardline$13;
  28807. }(getLastDescendantNode$1(node));
  28808. return concat$17([].concat(children, separator, endComments));
  28809. }
  28810. case "directive":
  28811. return concat$17(["%", join$12(" ", [node.name].concat(node.parameters))]);
  28812. case "comment":
  28813. return concat$17(["#", node.value]);
  28814. case "alias":
  28815. return concat$17(["*", node.value]);
  28816. case "tag":
  28817. return options.originalText.slice(node.position.start.offset, node.position.end.offset);
  28818. case "anchor":
  28819. return concat$17(["&", node.value]);
  28820. case "plain":
  28821. return printFlowScalarContent(node.type, options.originalText.slice(node.position.start.offset, node.position.end.offset), options);
  28822. case "quoteDouble":
  28823. case "quoteSingle":
  28824. {
  28825. var singleQuote = "'";
  28826. var doubleQuote = '"';
  28827. var raw = options.originalText.slice(node.position.start.offset + 1, node.position.end.offset - 1);
  28828. if (node.type === "quoteSingle" && raw.includes("\\") || node.type === "quoteDouble" && /\\[^"]/.test(raw)) {
  28829. // only quoteDouble can use escape chars
  28830. // and quoteSingle do not need to escape backslashes
  28831. var originalQuote = node.type === "quoteDouble" ? doubleQuote : singleQuote;
  28832. return concat$17([originalQuote, printFlowScalarContent(node.type, raw, options), originalQuote]);
  28833. } else if (raw.includes(doubleQuote)) {
  28834. return concat$17([singleQuote, printFlowScalarContent(node.type, node.type === "quoteDouble" ? raw // double quote needs to be escaped by backslash in quoteDouble
  28835. .replace(/\\"/g, doubleQuote).replace(/'/g, singleQuote.repeat(2)) : raw, options), singleQuote]);
  28836. }
  28837. if (raw.includes(singleQuote)) {
  28838. return concat$17([doubleQuote, printFlowScalarContent(node.type, node.type === "quoteSingle" ? // single quote needs to be escaped by 2 single quotes in quoteSingle
  28839. raw.replace(/''/g, singleQuote) : raw, options), doubleQuote]);
  28840. }
  28841. var quote = options.singleQuote ? singleQuote : doubleQuote;
  28842. return concat$17([quote, printFlowScalarContent(node.type, raw, options), quote]);
  28843. }
  28844. case "blockFolded":
  28845. case "blockLiteral":
  28846. {
  28847. var parentIndent = getAncestorCount(path$$1, function (ancestorNode) {
  28848. return isNode$1(ancestorNode, ["sequence", "mapping"]);
  28849. });
  28850. var isLastDescendant = isLastDescendantNode(path$$1);
  28851. return concat$17([node.type === "blockFolded" ? ">" : "|", node.indent === null ? "" : node.indent.toString(), node.chomping === "clip" ? "" : node.chomping === "keep" ? "+" : "-", hasIndicatorComment(node) ? concat$17([" ", path$$1.call(print, "indicatorComment")]) : "", (node.indent === null ? dedent$4 : dedentToRoot$3)(align$3(node.indent === null ? options.tabWidth : node.indent - 1 + parentIndent, concat$17(getBlockValueLineContents(node, {
  28852. parentIndent,
  28853. isLastDescendant,
  28854. options
  28855. }).reduce(function (reduced, lineWords, index, lineContents) {
  28856. return reduced.concat(index === 0 ? hardline$13 : "", fill$6(join$12(line$11, lineWords).parts), index !== lineContents.length - 1 ? lineWords.length === 0 ? hardline$13 : markAsRoot$5(literalline$7) : node.chomping === "keep" && isLastDescendant ? lineWords.length === 0 ? dedentToRoot$3(hardline$13) : dedentToRoot$3(literalline$7) : "");
  28857. }, []))))]);
  28858. }
  28859. case "sequence":
  28860. return join$12(hardline$13, path$$1.map(print, "children"));
  28861. case "sequenceItem":
  28862. return concat$17(["- ", align$3(2, !node.content ? "" : path$$1.call(print, "content"))]);
  28863. case "mappingKey":
  28864. return !node.content ? "" : path$$1.call(print, "content");
  28865. case "mappingValue":
  28866. return !node.content ? "" : path$$1.call(print, "content");
  28867. case "mapping":
  28868. return join$12(hardline$13, path$$1.map(print, "children"));
  28869. case "mappingItem":
  28870. case "flowMappingItem":
  28871. {
  28872. var isEmptyMappingKey = isEmptyNode(node.key);
  28873. var isEmptyMappingValue = isEmptyNode(node.value);
  28874. if (isEmptyMappingKey && isEmptyMappingValue) {
  28875. return concat$17([": "]);
  28876. }
  28877. var key = path$$1.call(print, "key");
  28878. var value = path$$1.call(print, "value");
  28879. if (isEmptyMappingValue) {
  28880. return node.type === "flowMappingItem" && parentNode.type === "flowMapping" ? key : node.type === "mappingItem" && isAbsolutelyPrintedAsSingleLineNode(node.key.content, options) && !hasTrailingComment$1(node.key.content) && (!parentNode.tag || parentNode.tag.value !== "tag:yaml.org,2002:set") ? concat$17([key, needsSpaceInFrontOfMappingValue(node) ? " " : "", ":"]) : concat$17(["? ", align$3(2, key)]);
  28881. }
  28882. if (isEmptyMappingKey) {
  28883. return concat$17([": ", align$3(2, value)]);
  28884. }
  28885. var groupId = Symbol("mappingKey");
  28886. var forceExplicitKey = hasLeadingComments(node.value) || !isInlineNode(node.key.content);
  28887. return forceExplicitKey ? concat$17(["? ", align$3(2, key), hardline$13, join$12("", path$$1.map(print, "value", "leadingComments").map(function (comment) {
  28888. return concat$17([comment, hardline$13]);
  28889. })), ": ", align$3(2, value)]) : // force singleline
  28890. isSingleLineNode(node.key.content) && !hasLeadingComments(node.key.content) && !hasMiddleComments(node.key.content) && !hasTrailingComment$1(node.key.content) && !hasEndComments(node.key) && !hasLeadingComments(node.value.content) && !hasMiddleComments(node.value.content) && !hasEndComments(node.value) && isAbsolutelyPrintedAsSingleLineNode(node.value.content, options) ? concat$17([key, needsSpaceInFrontOfMappingValue(node) ? " " : "", ": ", value]) : conditionalGroup$2([concat$17([group$16(concat$17([ifBreak$7("? "), group$16(align$3(2, key), {
  28891. id: groupId
  28892. })])), ifBreak$7(concat$17([hardline$13, ": ", align$3(2, value)]), indent(concat$17([needsSpaceInFrontOfMappingValue(node) ? " " : "", ":", hasLeadingComments(node.value.content) || hasEndComments(node.value) && node.value.content && !isNode$1(node.value.content, ["mapping", "sequence"]) || parentNode.type === "mapping" && hasTrailingComment$1(node.key.content) && isInlineNode(node.value.content) || isNode$1(node.value.content, ["mapping", "sequence"]) && node.value.content.tag === null && node.value.content.anchor === null ? hardline$13 : !node.value.content ? "" : line$11, value])), {
  28893. groupId
  28894. })])]);
  28895. }
  28896. case "flowMapping":
  28897. case "flowSequence":
  28898. {
  28899. var openMarker = node.type === "flowMapping" ? "{" : "[";
  28900. var closeMarker = node.type === "flowMapping" ? "}" : "]";
  28901. var bracketSpacing = node.type === "flowMapping" && node.children.length !== 0 && options.bracketSpacing ? line$11 : softline$8;
  28902. var isLastItemEmptyMappingItem = node.children.length !== 0 && function (lastItem) {
  28903. return lastItem.type === "flowMappingItem" && isEmptyNode(lastItem.key) && isEmptyNode(lastItem.value);
  28904. }(getLast$6(node.children));
  28905. return concat$17([openMarker, indent(concat$17([bracketSpacing, concat$17(path$$1.map(function (childPath, index) {
  28906. return concat$17([print(childPath), index === node.children.length - 1 ? "" : concat$17([",", line$11, node.children[index].position.start.line !== node.children[index + 1].position.start.line ? printNextEmptyLine(childPath, options.originalText) : ""])]);
  28907. }, "children")), ifBreak$7(",", "")])), isLastItemEmptyMappingItem ? "" : bracketSpacing, closeMarker]);
  28908. }
  28909. case "flowSequenceItem":
  28910. return path$$1.call(print, "content");
  28911. // istanbul ignore next
  28912. default:
  28913. throw new Error(`Unexpected node type ${node.type}`);
  28914. }
  28915. function indent(doc$$2) {
  28916. return docBuilders$3.align(" ".repeat(options.tabWidth), doc$$2);
  28917. }
  28918. }
  28919. function align$3(n, doc$$2) {
  28920. return typeof n === "number" && n > 0 ? docBuilders$3.align(" ".repeat(n), doc$$2) : docBuilders$3.align(n, doc$$2);
  28921. }
  28922. function isInlineNode(node) {
  28923. if (!node) {
  28924. return true;
  28925. }
  28926. switch (node.type) {
  28927. case "plain":
  28928. case "quoteDouble":
  28929. case "quoteSingle":
  28930. case "alias":
  28931. case "flowMapping":
  28932. case "flowSequence":
  28933. return true;
  28934. default:
  28935. return false;
  28936. }
  28937. }
  28938. function isSingleLineNode(node) {
  28939. if (!node) {
  28940. return true;
  28941. }
  28942. switch (node.type) {
  28943. case "plain":
  28944. case "quoteDouble":
  28945. case "quoteSingle":
  28946. return node.position.start.line === node.position.end.line;
  28947. case "alias":
  28948. return true;
  28949. default:
  28950. return false;
  28951. }
  28952. }
  28953. function shouldPrintDocumentBody(document) {
  28954. return document.body.children.length !== 0 || hasEndComments(document.body);
  28955. }
  28956. function shouldPrintDocumentEndMarker(document, nextDocument) {
  28957. return (
  28958. /**
  28959. *... # trailingComment
  28960. */
  28961. hasTrailingComment$1(document) || nextDocument && (
  28962. /**
  28963. * ...
  28964. * %DIRECTIVE
  28965. * ---
  28966. */
  28967. nextDocument.head.children.length !== 0 ||
  28968. /**
  28969. * ...
  28970. * # endComment
  28971. * ---
  28972. */
  28973. hasEndComments(nextDocument.head))
  28974. );
  28975. }
  28976. function shouldPrintDocumentHeadEndMarker(document, nextDocument, root, options) {
  28977. if (
  28978. /**
  28979. * ---
  28980. * preserve the first document head end marker
  28981. */
  28982. root.children[0] === document && /---(\s|$)/.test(options.originalText.slice(options.locStart(document), options.locStart(document) + 4)) ||
  28983. /**
  28984. * %DIRECTIVE
  28985. * ---
  28986. */
  28987. document.head.children.length !== 0 ||
  28988. /**
  28989. * # end comment
  28990. * ---
  28991. */
  28992. hasEndComments(document.head) ||
  28993. /**
  28994. * --- # trailing comment
  28995. */
  28996. hasTrailingComment$1(document.head)) {
  28997. return "head";
  28998. }
  28999. if (shouldPrintDocumentEndMarker(document, nextDocument)) {
  29000. return false;
  29001. }
  29002. return nextDocument ? "root" : false;
  29003. }
  29004. function isAbsolutelyPrintedAsSingleLineNode(node, options) {
  29005. if (!node) {
  29006. return true;
  29007. }
  29008. switch (node.type) {
  29009. case "plain":
  29010. case "quoteSingle":
  29011. case "quoteDouble":
  29012. break;
  29013. case "alias":
  29014. return true;
  29015. default:
  29016. return false;
  29017. }
  29018. if (options.proseWrap === "preserve") {
  29019. return node.position.start.line === node.position.end.line;
  29020. }
  29021. if ( // backslash-newline
  29022. /\\$/m.test(options.originalText.slice(node.position.start.offset, node.position.end.offset))) {
  29023. return false;
  29024. }
  29025. switch (options.proseWrap) {
  29026. case "never":
  29027. return node.value.indexOf("\n") === -1;
  29028. case "always":
  29029. return !/[\n ]/.test(node.value);
  29030. // istanbul ignore next
  29031. default:
  29032. return false;
  29033. }
  29034. }
  29035. function needsSpaceInFrontOfMappingValue(node) {
  29036. return node.key.content && node.key.content.type === "alias";
  29037. }
  29038. function printNextEmptyLine(path$$1, originalText) {
  29039. var node = path$$1.getValue();
  29040. var root = path$$1.stack[0];
  29041. root.isNextEmptyLinePrintedChecklist = root.isNextEmptyLinePrintedChecklist || [];
  29042. if (!root.isNextEmptyLinePrintedChecklist[node.position.end.line]) {
  29043. if (isNextLineEmpty$5(node, originalText)) {
  29044. root.isNextEmptyLinePrintedChecklist[node.position.end.line] = true;
  29045. return softline$8;
  29046. }
  29047. }
  29048. return "";
  29049. }
  29050. function printFlowScalarContent(nodeType, content, options) {
  29051. var lineContents = getFlowScalarLineContents(nodeType, content, options);
  29052. return join$12(hardline$13, lineContents.map(function (lineContentWords) {
  29053. return fill$6(join$12(line$11, lineContentWords).parts);
  29054. }));
  29055. }
  29056. function clean$11(node, newNode
  29057. /*, parent */
  29058. ) {
  29059. if (isNode$1(newNode)) {
  29060. delete newNode.position;
  29061. switch (newNode.type) {
  29062. case "comment":
  29063. // insert pragma
  29064. if (isPragma(newNode.value)) {
  29065. return null;
  29066. }
  29067. break;
  29068. case "quoteDouble":
  29069. case "quoteSingle":
  29070. newNode.type = "quote";
  29071. break;
  29072. }
  29073. }
  29074. }
  29075. var printerYaml = {
  29076. preprocess: preprocess$6,
  29077. print: genericPrint$6,
  29078. massageAstNode: clean$11,
  29079. insertPragma: insertPragma$8
  29080. };
  29081. var options$19 = {
  29082. bracketSpacing: commonOptions.bracketSpacing,
  29083. singleQuote: commonOptions.singleQuote,
  29084. proseWrap: commonOptions.proseWrap
  29085. };
  29086. var name$16 = "YAML";
  29087. var type$15 = "data";
  29088. var tmScope$15 = "source.yaml";
  29089. var aliases$6 = ["yml"];
  29090. var extensions$15 = [".yml", ".mir", ".reek", ".rviz", ".sublime-syntax", ".syntax", ".yaml", ".yaml-tmlanguage", ".yml.mysql"];
  29091. var filenames$3 = [".clang-format", ".clang-tidy", ".gemrc", "glide.lock"];
  29092. var aceMode$15 = "yaml";
  29093. var codemirrorMode$11 = "yaml";
  29094. var codemirrorMimeType$11 = "text/x-yaml";
  29095. var languageId$15 = 407;
  29096. var yaml = {
  29097. name: name$16,
  29098. type: type$15,
  29099. tmScope: tmScope$15,
  29100. aliases: aliases$6,
  29101. extensions: extensions$15,
  29102. filenames: filenames$3,
  29103. aceMode: aceMode$15,
  29104. codemirrorMode: codemirrorMode$11,
  29105. codemirrorMimeType: codemirrorMimeType$11,
  29106. languageId: languageId$15
  29107. };
  29108. var yaml$1 = Object.freeze({
  29109. name: name$16,
  29110. type: type$15,
  29111. tmScope: tmScope$15,
  29112. aliases: aliases$6,
  29113. extensions: extensions$15,
  29114. filenames: filenames$3,
  29115. aceMode: aceMode$15,
  29116. codemirrorMode: codemirrorMode$11,
  29117. codemirrorMimeType: codemirrorMimeType$11,
  29118. languageId: languageId$15,
  29119. default: yaml
  29120. });
  29121. var require$$0$33 = ( yaml$1 && yaml ) || yaml$1;
  29122. var languages$6 = [createLanguage(require$$0$33, {
  29123. override: {
  29124. since: "1.14.0",
  29125. parsers: ["yaml"],
  29126. vscodeLanguageIds: ["yaml"]
  29127. }
  29128. })];
  29129. var languageYaml = {
  29130. languages: languages$6,
  29131. printers: {
  29132. yaml: printerYaml
  29133. },
  29134. options: options$19
  29135. };
  29136. // plugin will look for `eval("require")()` and transform to `require()` in the bundle,
  29137. // and rewrite the paths to require from the top-level.
  29138. // We need to list the parsers and getters so we can load them only when necessary.
  29139. var internalPlugins = [// JS
  29140. languageJs, {
  29141. parsers: {
  29142. // JS - Babel
  29143. get babel() {
  29144. return require("./parser-babylon").parsers.babel;
  29145. },
  29146. get "babel-flow"() {
  29147. return require("./parser-babylon").parsers["babel-flow"];
  29148. },
  29149. get babylon() {
  29150. return require("./parser-babylon").parsers.babel;
  29151. },
  29152. get json() {
  29153. return require("./parser-babylon").parsers.json;
  29154. },
  29155. get json5() {
  29156. return require("./parser-babylon").parsers.json5;
  29157. },
  29158. get "json-stringify"() {
  29159. return require("./parser-babylon").parsers["json-stringify"];
  29160. },
  29161. get __js_expression() {
  29162. return require("./parser-babylon").parsers.__js_expression;
  29163. },
  29164. get __vue_expression() {
  29165. return require("./parser-babylon").parsers.__vue_expression;
  29166. },
  29167. get __vue_event_binding() {
  29168. return require("./parser-babylon").parsers.__vue_event_binding;
  29169. },
  29170. // JS - Flow
  29171. get flow() {
  29172. return require("./parser-flow").parsers.flow;
  29173. },
  29174. // JS - TypeScript
  29175. get typescript() {
  29176. return require("./parser-typescript").parsers.typescript;
  29177. },
  29178. /**
  29179. * TODO: Remove this old alias in a major version
  29180. */
  29181. get "typescript-eslint"() {
  29182. return require("./parser-typescript").parsers.typescript;
  29183. },
  29184. // JS - Angular Action
  29185. get __ng_action() {
  29186. return require("./parser-angular").parsers.__ng_action;
  29187. },
  29188. // JS - Angular Binding
  29189. get __ng_binding() {
  29190. return require("./parser-angular").parsers.__ng_binding;
  29191. },
  29192. // JS - Angular Interpolation
  29193. get __ng_interpolation() {
  29194. return require("./parser-angular").parsers.__ng_interpolation;
  29195. },
  29196. // JS - Angular Directive
  29197. get __ng_directive() {
  29198. return require("./parser-angular").parsers.__ng_directive;
  29199. }
  29200. }
  29201. }, // CSS
  29202. languageCss, {
  29203. parsers: {
  29204. // TODO: switch these to just `postcss` and use `language` instead.
  29205. get css() {
  29206. return require("./parser-postcss").parsers.css;
  29207. },
  29208. get less() {
  29209. return require("./parser-postcss").parsers.css;
  29210. },
  29211. get scss() {
  29212. return require("./parser-postcss").parsers.css;
  29213. }
  29214. }
  29215. }, // Handlebars
  29216. languageHandlebars, {
  29217. parsers: {
  29218. get glimmer() {
  29219. return require("./parser-glimmer").parsers.glimmer;
  29220. }
  29221. }
  29222. }, // GraphQL
  29223. languageGraphql, {
  29224. parsers: {
  29225. get graphql() {
  29226. return require("./parser-graphql").parsers.graphql;
  29227. }
  29228. }
  29229. }, // Markdown
  29230. languageMarkdown, {
  29231. parsers: {
  29232. get remark() {
  29233. return require("./parser-markdown").parsers.remark;
  29234. },
  29235. // TODO: Delete this in 2.0
  29236. get markdown() {
  29237. return require("./parser-markdown").parsers.remark;
  29238. },
  29239. get mdx() {
  29240. return require("./parser-markdown").parsers.mdx;
  29241. }
  29242. }
  29243. }, languageHtml, {
  29244. parsers: {
  29245. // HTML
  29246. get html() {
  29247. return require("./parser-html").parsers.html;
  29248. },
  29249. // Vue
  29250. get vue() {
  29251. return require("./parser-html").parsers.vue;
  29252. },
  29253. // Angular
  29254. get angular() {
  29255. return require("./parser-html").parsers.angular;
  29256. }
  29257. }
  29258. }, // YAML
  29259. languageYaml, {
  29260. parsers: {
  29261. get yaml() {
  29262. return require("./parser-yaml").parsers.yaml;
  29263. }
  29264. }
  29265. }];
  29266. var partition = function partition(array, fn) {
  29267. var a = [];
  29268. var b = [];
  29269. array.forEach(function (item) {
  29270. if (fn(item)) {
  29271. a.push(item);
  29272. } else {
  29273. b.push(item);
  29274. }
  29275. });
  29276. return [a, b];
  29277. };
  29278. var thirdParty$1 = ( thirdParty && thirdParty__default ) || thirdParty;
  29279. function loadPlugins(plugins, pluginSearchDirs) {
  29280. if (!plugins) {
  29281. plugins = [];
  29282. }
  29283. if (!pluginSearchDirs) {
  29284. pluginSearchDirs = [];
  29285. } // unless pluginSearchDirs are provided, auto-load plugins from node_modules that are parent to Prettier
  29286. if (!pluginSearchDirs.length) {
  29287. var autoLoadDir = thirdParty$1.findParentDir(__dirname, "node_modules");
  29288. if (autoLoadDir) {
  29289. pluginSearchDirs = [autoLoadDir];
  29290. }
  29291. }
  29292. var _partition = partition(plugins, function (plugin) {
  29293. return typeof plugin === "string";
  29294. }),
  29295. _partition2 = _slicedToArray(_partition, 2),
  29296. externalPluginNames = _partition2[0],
  29297. externalPluginInstances = _partition2[1];
  29298. var externalManualLoadPluginInfos = externalPluginNames.map(function (pluginName) {
  29299. var requirePath;
  29300. try {
  29301. // try local files
  29302. requirePath = resolve$1.sync(path.resolve(process.cwd(), pluginName));
  29303. } catch (e) {
  29304. // try node modules
  29305. requirePath = resolve$1.sync(pluginName, {
  29306. basedir: process.cwd()
  29307. });
  29308. }
  29309. return {
  29310. name: pluginName,
  29311. requirePath
  29312. };
  29313. });
  29314. var externalAutoLoadPluginInfos = pluginSearchDirs.map(function (pluginSearchDir) {
  29315. var resolvedPluginSearchDir = path.resolve(process.cwd(), pluginSearchDir);
  29316. if (!isDirectory(resolvedPluginSearchDir)) {
  29317. throw new Error(`${pluginSearchDir} does not exist or is not a directory`);
  29318. }
  29319. var nodeModulesDir = path.resolve(resolvedPluginSearchDir, "node_modules");
  29320. return findPluginsInNodeModules(nodeModulesDir).map(function (pluginName) {
  29321. return {
  29322. name: pluginName,
  29323. requirePath: resolve$1.sync(pluginName, {
  29324. basedir: resolvedPluginSearchDir
  29325. })
  29326. };
  29327. });
  29328. }).reduce(function (a, b) {
  29329. return a.concat(b);
  29330. }, []);
  29331. var externalPlugins = lodash_uniqby(externalManualLoadPluginInfos.concat(externalAutoLoadPluginInfos), "requirePath").map(function (externalPluginInfo) {
  29332. return Object.assign({
  29333. name: externalPluginInfo.name
  29334. }, require(externalPluginInfo.requirePath));
  29335. }).concat(externalPluginInstances);
  29336. return internalPlugins.concat(externalPlugins);
  29337. }
  29338. function findPluginsInNodeModules(nodeModulesDir) {
  29339. var pluginPackageJsonPaths = globby.sync(["prettier-plugin-*/package.json", "@prettier/plugin-*/package.json"], {
  29340. cwd: nodeModulesDir
  29341. });
  29342. return pluginPackageJsonPaths.map(path.dirname);
  29343. }
  29344. function isDirectory(dir) {
  29345. try {
  29346. return fs.statSync(dir).isDirectory();
  29347. } catch (e) {
  29348. return false;
  29349. }
  29350. }
  29351. var loadPlugins_1 = loadPlugins;
  29352. var mimicFn = function mimicFn(to, from) {
  29353. // TODO: use `Reflect.ownKeys()` when targeting Node.js 6
  29354. var _iteratorNormalCompletion = true;
  29355. var _didIteratorError = false;
  29356. var _iteratorError = undefined;
  29357. try {
  29358. for (var _iterator = Object.getOwnPropertyNames(from).concat(Object.getOwnPropertySymbols(from))[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  29359. var prop = _step.value;
  29360. Object.defineProperty(to, prop, Object.getOwnPropertyDescriptor(from, prop));
  29361. }
  29362. } catch (err) {
  29363. _didIteratorError = true;
  29364. _iteratorError = err;
  29365. } finally {
  29366. try {
  29367. if (!_iteratorNormalCompletion && _iterator.return != null) {
  29368. _iterator.return();
  29369. }
  29370. } finally {
  29371. if (_didIteratorError) {
  29372. throw _iteratorError;
  29373. }
  29374. }
  29375. }
  29376. };
  29377. var mem = createCommonjsModule(function (module) {
  29378. 'use strict';
  29379. var cacheStore = new WeakMap();
  29380. var defaultCacheKey = function defaultCacheKey(x) {
  29381. if (arguments.length === 1 && (x === null || x === undefined || typeof x !== 'function' && typeof x !== 'object')) {
  29382. return x;
  29383. }
  29384. return JSON.stringify(arguments);
  29385. };
  29386. module.exports = function (fn, opts) {
  29387. opts = Object.assign({
  29388. cacheKey: defaultCacheKey,
  29389. cache: new Map()
  29390. }, opts);
  29391. var memoized = function memoized() {
  29392. var cache = cacheStore.get(memoized);
  29393. var key = opts.cacheKey.apply(null, arguments);
  29394. if (cache.has(key)) {
  29395. var c = cache.get(key);
  29396. if (typeof opts.maxAge !== 'number' || Date.now() < c.maxAge) {
  29397. return c.data;
  29398. }
  29399. }
  29400. var ret = fn.apply(null, arguments);
  29401. cache.set(key, {
  29402. data: ret,
  29403. maxAge: Date.now() + (opts.maxAge || 0)
  29404. });
  29405. return ret;
  29406. };
  29407. mimicFn(memoized, fn);
  29408. cacheStore.set(memoized, opts.cache);
  29409. return memoized;
  29410. };
  29411. module.exports.clear = function (fn) {
  29412. var cache = cacheStore.get(fn);
  29413. if (cache && typeof cache.clear === 'function') {
  29414. cache.clear();
  29415. }
  29416. };
  29417. });
  29418. var semver$3 = createCommonjsModule(function (module, exports) {
  29419. exports = module.exports = SemVer; // The debug function is excluded entirely from the minified version.
  29420. /* nomin */
  29421. var debug;
  29422. /* nomin */
  29423. if (typeof process === 'object' &&
  29424. /* nomin */
  29425. process.env &&
  29426. /* nomin */
  29427. process.env.NODE_DEBUG &&
  29428. /* nomin */
  29429. /\bsemver\b/i.test(process.env.NODE_DEBUG))
  29430. /* nomin */
  29431. debug = function debug() {
  29432. /* nomin */
  29433. var args = Array.prototype.slice.call(arguments, 0);
  29434. /* nomin */
  29435. args.unshift('SEMVER');
  29436. /* nomin */
  29437. console.log.apply(console, args);
  29438. /* nomin */
  29439. };
  29440. /* nomin */
  29441. else
  29442. /* nomin */
  29443. debug = function debug() {}; // Note: this is the semver.org version of the spec that it implements
  29444. // Not necessarily the package version of this code.
  29445. exports.SEMVER_SPEC_VERSION = '2.0.0';
  29446. var MAX_LENGTH = 256;
  29447. var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991; // Max safe segment length for coercion.
  29448. var MAX_SAFE_COMPONENT_LENGTH = 16; // The actual regexps go on exports.re
  29449. var re = exports.re = [];
  29450. var src = exports.src = [];
  29451. var R = 0; // The following Regular Expressions can be used for tokenizing,
  29452. // validating, and parsing SemVer version strings.
  29453. // ## Numeric Identifier
  29454. // A single `0`, or a non-zero digit followed by zero or more digits.
  29455. var NUMERICIDENTIFIER = R++;
  29456. src[NUMERICIDENTIFIER] = '0|[1-9]\\d*';
  29457. var NUMERICIDENTIFIERLOOSE = R++;
  29458. src[NUMERICIDENTIFIERLOOSE] = '[0-9]+'; // ## Non-numeric Identifier
  29459. // Zero or more digits, followed by a letter or hyphen, and then zero or
  29460. // more letters, digits, or hyphens.
  29461. var NONNUMERICIDENTIFIER = R++;
  29462. src[NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*'; // ## Main Version
  29463. // Three dot-separated numeric identifiers.
  29464. var MAINVERSION = R++;
  29465. src[MAINVERSION] = '(' + src[NUMERICIDENTIFIER] + ')\\.' + '(' + src[NUMERICIDENTIFIER] + ')\\.' + '(' + src[NUMERICIDENTIFIER] + ')';
  29466. var MAINVERSIONLOOSE = R++;
  29467. src[MAINVERSIONLOOSE] = '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' + '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' + '(' + src[NUMERICIDENTIFIERLOOSE] + ')'; // ## Pre-release Version Identifier
  29468. // A numeric identifier, or a non-numeric identifier.
  29469. var PRERELEASEIDENTIFIER = R++;
  29470. src[PRERELEASEIDENTIFIER] = '(?:' + src[NUMERICIDENTIFIER] + '|' + src[NONNUMERICIDENTIFIER] + ')';
  29471. var PRERELEASEIDENTIFIERLOOSE = R++;
  29472. src[PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[NUMERICIDENTIFIERLOOSE] + '|' + src[NONNUMERICIDENTIFIER] + ')'; // ## Pre-release Version
  29473. // Hyphen, followed by one or more dot-separated pre-release version
  29474. // identifiers.
  29475. var PRERELEASE = R++;
  29476. src[PRERELEASE] = '(?:-(' + src[PRERELEASEIDENTIFIER] + '(?:\\.' + src[PRERELEASEIDENTIFIER] + ')*))';
  29477. var PRERELEASELOOSE = R++;
  29478. src[PRERELEASELOOSE] = '(?:-?(' + src[PRERELEASEIDENTIFIERLOOSE] + '(?:\\.' + src[PRERELEASEIDENTIFIERLOOSE] + ')*))'; // ## Build Metadata Identifier
  29479. // Any combination of digits, letters, or hyphens.
  29480. var BUILDIDENTIFIER = R++;
  29481. src[BUILDIDENTIFIER] = '[0-9A-Za-z-]+'; // ## Build Metadata
  29482. // Plus sign, followed by one or more period-separated build metadata
  29483. // identifiers.
  29484. var BUILD = R++;
  29485. src[BUILD] = '(?:\\+(' + src[BUILDIDENTIFIER] + '(?:\\.' + src[BUILDIDENTIFIER] + ')*))'; // ## Full Version String
  29486. // A main version, followed optionally by a pre-release version and
  29487. // build metadata.
  29488. // Note that the only major, minor, patch, and pre-release sections of
  29489. // the version string are capturing groups. The build metadata is not a
  29490. // capturing group, because it should not ever be used in version
  29491. // comparison.
  29492. var FULL = R++;
  29493. var FULLPLAIN = 'v?' + src[MAINVERSION] + src[PRERELEASE] + '?' + src[BUILD] + '?';
  29494. src[FULL] = '^' + FULLPLAIN + '$'; // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
  29495. // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
  29496. // common in the npm registry.
  29497. var LOOSEPLAIN = '[v=\\s]*' + src[MAINVERSIONLOOSE] + src[PRERELEASELOOSE] + '?' + src[BUILD] + '?';
  29498. var LOOSE = R++;
  29499. src[LOOSE] = '^' + LOOSEPLAIN + '$';
  29500. var GTLT = R++;
  29501. src[GTLT] = '((?:<|>)?=?)'; // Something like "2.*" or "1.2.x".
  29502. // Note that "x.x" is a valid xRange identifer, meaning "any version"
  29503. // Only the first item is strictly required.
  29504. var XRANGEIDENTIFIERLOOSE = R++;
  29505. src[XRANGEIDENTIFIERLOOSE] = src[NUMERICIDENTIFIERLOOSE] + '|x|X|\\*';
  29506. var XRANGEIDENTIFIER = R++;
  29507. src[XRANGEIDENTIFIER] = src[NUMERICIDENTIFIER] + '|x|X|\\*';
  29508. var XRANGEPLAIN = R++;
  29509. src[XRANGEPLAIN] = '[v=\\s]*(' + src[XRANGEIDENTIFIER] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' + '(?:' + src[PRERELEASE] + ')?' + src[BUILD] + '?' + ')?)?';
  29510. var XRANGEPLAINLOOSE = R++;
  29511. src[XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:' + src[PRERELEASELOOSE] + ')?' + src[BUILD] + '?' + ')?)?';
  29512. var XRANGE = R++;
  29513. src[XRANGE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAIN] + '$';
  29514. var XRANGELOOSE = R++;
  29515. src[XRANGELOOSE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAINLOOSE] + '$'; // Coercion.
  29516. // Extract anything that could conceivably be a part of a valid semver
  29517. var COERCE = R++;
  29518. src[COERCE] = '(?:^|[^\\d])' + '(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + '(?:$|[^\\d])'; // Tilde ranges.
  29519. // Meaning is "reasonably at or greater than"
  29520. var LONETILDE = R++;
  29521. src[LONETILDE] = '(?:~>?)';
  29522. var TILDETRIM = R++;
  29523. src[TILDETRIM] = '(\\s*)' + src[LONETILDE] + '\\s+';
  29524. re[TILDETRIM] = new RegExp(src[TILDETRIM], 'g');
  29525. var tildeTrimReplace = '$1~';
  29526. var TILDE = R++;
  29527. src[TILDE] = '^' + src[LONETILDE] + src[XRANGEPLAIN] + '$';
  29528. var TILDELOOSE = R++;
  29529. src[TILDELOOSE] = '^' + src[LONETILDE] + src[XRANGEPLAINLOOSE] + '$'; // Caret ranges.
  29530. // Meaning is "at least and backwards compatible with"
  29531. var LONECARET = R++;
  29532. src[LONECARET] = '(?:\\^)';
  29533. var CARETTRIM = R++;
  29534. src[CARETTRIM] = '(\\s*)' + src[LONECARET] + '\\s+';
  29535. re[CARETTRIM] = new RegExp(src[CARETTRIM], 'g');
  29536. var caretTrimReplace = '$1^';
  29537. var CARET = R++;
  29538. src[CARET] = '^' + src[LONECARET] + src[XRANGEPLAIN] + '$';
  29539. var CARETLOOSE = R++;
  29540. src[CARETLOOSE] = '^' + src[LONECARET] + src[XRANGEPLAINLOOSE] + '$'; // A simple gt/lt/eq thing, or just "" to indicate "any version"
  29541. var COMPARATORLOOSE = R++;
  29542. src[COMPARATORLOOSE] = '^' + src[GTLT] + '\\s*(' + LOOSEPLAIN + ')$|^$';
  29543. var COMPARATOR = R++;
  29544. src[COMPARATOR] = '^' + src[GTLT] + '\\s*(' + FULLPLAIN + ')$|^$'; // An expression to strip any whitespace between the gtlt and the thing
  29545. // it modifies, so that `> 1.2.3` ==> `>1.2.3`
  29546. var COMPARATORTRIM = R++;
  29547. src[COMPARATORTRIM] = '(\\s*)' + src[GTLT] + '\\s*(' + LOOSEPLAIN + '|' + src[XRANGEPLAIN] + ')'; // this one has to use the /g flag
  29548. re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], 'g');
  29549. var comparatorTrimReplace = '$1$2$3'; // Something like `1.2.3 - 1.2.4`
  29550. // Note that these all use the loose form, because they'll be
  29551. // checked against either the strict or loose comparator form
  29552. // later.
  29553. var HYPHENRANGE = R++;
  29554. src[HYPHENRANGE] = '^\\s*(' + src[XRANGEPLAIN] + ')' + '\\s+-\\s+' + '(' + src[XRANGEPLAIN] + ')' + '\\s*$';
  29555. var HYPHENRANGELOOSE = R++;
  29556. src[HYPHENRANGELOOSE] = '^\\s*(' + src[XRANGEPLAINLOOSE] + ')' + '\\s+-\\s+' + '(' + src[XRANGEPLAINLOOSE] + ')' + '\\s*$'; // Star ranges basically just allow anything at all.
  29557. var STAR = R++;
  29558. src[STAR] = '(<|>)?=?\\s*\\*'; // Compile to actual regexp objects.
  29559. // All are flag-free, unless they were created above with a flag.
  29560. for (var i = 0; i < R; i++) {
  29561. debug(i, src[i]);
  29562. if (!re[i]) re[i] = new RegExp(src[i]);
  29563. }
  29564. exports.parse = parse;
  29565. function parse(version, options) {
  29566. if (!options || typeof options !== 'object') options = {
  29567. loose: !!options,
  29568. includePrerelease: false
  29569. };
  29570. if (version instanceof SemVer) return version;
  29571. if (typeof version !== 'string') return null;
  29572. if (version.length > MAX_LENGTH) return null;
  29573. var r = options.loose ? re[LOOSE] : re[FULL];
  29574. if (!r.test(version)) return null;
  29575. try {
  29576. return new SemVer(version, options);
  29577. } catch (er) {
  29578. return null;
  29579. }
  29580. }
  29581. exports.valid = valid;
  29582. function valid(version, options) {
  29583. var v = parse(version, options);
  29584. return v ? v.version : null;
  29585. }
  29586. exports.clean = clean;
  29587. function clean(version, options) {
  29588. var s = parse(version.trim().replace(/^[=v]+/, ''), options);
  29589. return s ? s.version : null;
  29590. }
  29591. exports.SemVer = SemVer;
  29592. function SemVer(version, options) {
  29593. if (!options || typeof options !== 'object') options = {
  29594. loose: !!options,
  29595. includePrerelease: false
  29596. };
  29597. if (version instanceof SemVer) {
  29598. if (version.loose === options.loose) return version;else version = version.version;
  29599. } else if (typeof version !== 'string') {
  29600. throw new TypeError('Invalid Version: ' + version);
  29601. }
  29602. if (version.length > MAX_LENGTH) throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters');
  29603. if (!(this instanceof SemVer)) return new SemVer(version, options);
  29604. debug('SemVer', version, options);
  29605. this.options = options;
  29606. this.loose = !!options.loose;
  29607. var m = version.trim().match(options.loose ? re[LOOSE] : re[FULL]);
  29608. if (!m) throw new TypeError('Invalid Version: ' + version);
  29609. this.raw = version; // these are actually numbers
  29610. this.major = +m[1];
  29611. this.minor = +m[2];
  29612. this.patch = +m[3];
  29613. if (this.major > MAX_SAFE_INTEGER || this.major < 0) throw new TypeError('Invalid major version');
  29614. if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) throw new TypeError('Invalid minor version');
  29615. if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) throw new TypeError('Invalid patch version'); // numberify any prerelease numeric ids
  29616. if (!m[4]) this.prerelease = [];else this.prerelease = m[4].split('.').map(function (id) {
  29617. if (/^[0-9]+$/.test(id)) {
  29618. var num = +id;
  29619. if (num >= 0 && num < MAX_SAFE_INTEGER) return num;
  29620. }
  29621. return id;
  29622. });
  29623. this.build = m[5] ? m[5].split('.') : [];
  29624. this.format();
  29625. }
  29626. SemVer.prototype.format = function () {
  29627. this.version = this.major + '.' + this.minor + '.' + this.patch;
  29628. if (this.prerelease.length) this.version += '-' + this.prerelease.join('.');
  29629. return this.version;
  29630. };
  29631. SemVer.prototype.toString = function () {
  29632. return this.version;
  29633. };
  29634. SemVer.prototype.compare = function (other) {
  29635. debug('SemVer.compare', this.version, this.options, other);
  29636. if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
  29637. return this.compareMain(other) || this.comparePre(other);
  29638. };
  29639. SemVer.prototype.compareMain = function (other) {
  29640. if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
  29641. return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
  29642. };
  29643. SemVer.prototype.comparePre = function (other) {
  29644. if (!(other instanceof SemVer)) other = new SemVer(other, this.options); // NOT having a prerelease is > having one
  29645. if (this.prerelease.length && !other.prerelease.length) return -1;else if (!this.prerelease.length && other.prerelease.length) return 1;else if (!this.prerelease.length && !other.prerelease.length) return 0;
  29646. var i = 0;
  29647. do {
  29648. var a = this.prerelease[i];
  29649. var b = other.prerelease[i];
  29650. debug('prerelease compare', i, a, b);
  29651. if (a === undefined && b === undefined) return 0;else if (b === undefined) return 1;else if (a === undefined) return -1;else if (a === b) continue;else return compareIdentifiers(a, b);
  29652. } while (++i);
  29653. }; // preminor will bump the version up to the next minor release, and immediately
  29654. // down to pre-release. premajor and prepatch work the same way.
  29655. SemVer.prototype.inc = function (release, identifier) {
  29656. switch (release) {
  29657. case 'premajor':
  29658. this.prerelease.length = 0;
  29659. this.patch = 0;
  29660. this.minor = 0;
  29661. this.major++;
  29662. this.inc('pre', identifier);
  29663. break;
  29664. case 'preminor':
  29665. this.prerelease.length = 0;
  29666. this.patch = 0;
  29667. this.minor++;
  29668. this.inc('pre', identifier);
  29669. break;
  29670. case 'prepatch':
  29671. // If this is already a prerelease, it will bump to the next version
  29672. // drop any prereleases that might already exist, since they are not
  29673. // relevant at this point.
  29674. this.prerelease.length = 0;
  29675. this.inc('patch', identifier);
  29676. this.inc('pre', identifier);
  29677. break;
  29678. // If the input is a non-prerelease version, this acts the same as
  29679. // prepatch.
  29680. case 'prerelease':
  29681. if (this.prerelease.length === 0) this.inc('patch', identifier);
  29682. this.inc('pre', identifier);
  29683. break;
  29684. case 'major':
  29685. // If this is a pre-major version, bump up to the same major version.
  29686. // Otherwise increment major.
  29687. // 1.0.0-5 bumps to 1.0.0
  29688. // 1.1.0 bumps to 2.0.0
  29689. if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) this.major++;
  29690. this.minor = 0;
  29691. this.patch = 0;
  29692. this.prerelease = [];
  29693. break;
  29694. case 'minor':
  29695. // If this is a pre-minor version, bump up to the same minor version.
  29696. // Otherwise increment minor.
  29697. // 1.2.0-5 bumps to 1.2.0
  29698. // 1.2.1 bumps to 1.3.0
  29699. if (this.patch !== 0 || this.prerelease.length === 0) this.minor++;
  29700. this.patch = 0;
  29701. this.prerelease = [];
  29702. break;
  29703. case 'patch':
  29704. // If this is not a pre-release version, it will increment the patch.
  29705. // If it is a pre-release it will bump up to the same patch version.
  29706. // 1.2.0-5 patches to 1.2.0
  29707. // 1.2.0 patches to 1.2.1
  29708. if (this.prerelease.length === 0) this.patch++;
  29709. this.prerelease = [];
  29710. break;
  29711. // This probably shouldn't be used publicly.
  29712. // 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
  29713. case 'pre':
  29714. if (this.prerelease.length === 0) this.prerelease = [0];else {
  29715. var i = this.prerelease.length;
  29716. while (--i >= 0) {
  29717. if (typeof this.prerelease[i] === 'number') {
  29718. this.prerelease[i]++;
  29719. i = -2;
  29720. }
  29721. }
  29722. if (i === -1) // didn't increment anything
  29723. this.prerelease.push(0);
  29724. }
  29725. if (identifier) {
  29726. // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
  29727. // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
  29728. if (this.prerelease[0] === identifier) {
  29729. if (isNaN(this.prerelease[1])) this.prerelease = [identifier, 0];
  29730. } else this.prerelease = [identifier, 0];
  29731. }
  29732. break;
  29733. default:
  29734. throw new Error('invalid increment argument: ' + release);
  29735. }
  29736. this.format();
  29737. this.raw = this.version;
  29738. return this;
  29739. };
  29740. exports.inc = inc;
  29741. function inc(version, release, loose, identifier) {
  29742. if (typeof loose === 'string') {
  29743. identifier = loose;
  29744. loose = undefined;
  29745. }
  29746. try {
  29747. return new SemVer(version, loose).inc(release, identifier).version;
  29748. } catch (er) {
  29749. return null;
  29750. }
  29751. }
  29752. exports.diff = diff;
  29753. function diff(version1, version2) {
  29754. if (eq(version1, version2)) {
  29755. return null;
  29756. } else {
  29757. var v1 = parse(version1);
  29758. var v2 = parse(version2);
  29759. if (v1.prerelease.length || v2.prerelease.length) {
  29760. for (var key in v1) {
  29761. if (key === 'major' || key === 'minor' || key === 'patch') {
  29762. if (v1[key] !== v2[key]) {
  29763. return 'pre' + key;
  29764. }
  29765. }
  29766. }
  29767. return 'prerelease';
  29768. }
  29769. for (var key in v1) {
  29770. if (key === 'major' || key === 'minor' || key === 'patch') {
  29771. if (v1[key] !== v2[key]) {
  29772. return key;
  29773. }
  29774. }
  29775. }
  29776. }
  29777. }
  29778. exports.compareIdentifiers = compareIdentifiers;
  29779. var numeric = /^[0-9]+$/;
  29780. function compareIdentifiers(a, b) {
  29781. var anum = numeric.test(a);
  29782. var bnum = numeric.test(b);
  29783. if (anum && bnum) {
  29784. a = +a;
  29785. b = +b;
  29786. }
  29787. return anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : a > b ? 1 : 0;
  29788. }
  29789. exports.rcompareIdentifiers = rcompareIdentifiers;
  29790. function rcompareIdentifiers(a, b) {
  29791. return compareIdentifiers(b, a);
  29792. }
  29793. exports.major = major;
  29794. function major(a, loose) {
  29795. return new SemVer(a, loose).major;
  29796. }
  29797. exports.minor = minor;
  29798. function minor(a, loose) {
  29799. return new SemVer(a, loose).minor;
  29800. }
  29801. exports.patch = patch;
  29802. function patch(a, loose) {
  29803. return new SemVer(a, loose).patch;
  29804. }
  29805. exports.compare = compare;
  29806. function compare(a, b, loose) {
  29807. return new SemVer(a, loose).compare(new SemVer(b, loose));
  29808. }
  29809. exports.compareLoose = compareLoose;
  29810. function compareLoose(a, b) {
  29811. return compare(a, b, true);
  29812. }
  29813. exports.rcompare = rcompare;
  29814. function rcompare(a, b, loose) {
  29815. return compare(b, a, loose);
  29816. }
  29817. exports.sort = sort;
  29818. function sort(list, loose) {
  29819. return list.sort(function (a, b) {
  29820. return exports.compare(a, b, loose);
  29821. });
  29822. }
  29823. exports.rsort = rsort;
  29824. function rsort(list, loose) {
  29825. return list.sort(function (a, b) {
  29826. return exports.rcompare(a, b, loose);
  29827. });
  29828. }
  29829. exports.gt = gt;
  29830. function gt(a, b, loose) {
  29831. return compare(a, b, loose) > 0;
  29832. }
  29833. exports.lt = lt;
  29834. function lt(a, b, loose) {
  29835. return compare(a, b, loose) < 0;
  29836. }
  29837. exports.eq = eq;
  29838. function eq(a, b, loose) {
  29839. return compare(a, b, loose) === 0;
  29840. }
  29841. exports.neq = neq;
  29842. function neq(a, b, loose) {
  29843. return compare(a, b, loose) !== 0;
  29844. }
  29845. exports.gte = gte;
  29846. function gte(a, b, loose) {
  29847. return compare(a, b, loose) >= 0;
  29848. }
  29849. exports.lte = lte;
  29850. function lte(a, b, loose) {
  29851. return compare(a, b, loose) <= 0;
  29852. }
  29853. exports.cmp = cmp;
  29854. function cmp(a, op, b, loose) {
  29855. var ret;
  29856. switch (op) {
  29857. case '===':
  29858. if (typeof a === 'object') a = a.version;
  29859. if (typeof b === 'object') b = b.version;
  29860. ret = a === b;
  29861. break;
  29862. case '!==':
  29863. if (typeof a === 'object') a = a.version;
  29864. if (typeof b === 'object') b = b.version;
  29865. ret = a !== b;
  29866. break;
  29867. case '':
  29868. case '=':
  29869. case '==':
  29870. ret = eq(a, b, loose);
  29871. break;
  29872. case '!=':
  29873. ret = neq(a, b, loose);
  29874. break;
  29875. case '>':
  29876. ret = gt(a, b, loose);
  29877. break;
  29878. case '>=':
  29879. ret = gte(a, b, loose);
  29880. break;
  29881. case '<':
  29882. ret = lt(a, b, loose);
  29883. break;
  29884. case '<=':
  29885. ret = lte(a, b, loose);
  29886. break;
  29887. default:
  29888. throw new TypeError('Invalid operator: ' + op);
  29889. }
  29890. return ret;
  29891. }
  29892. exports.Comparator = Comparator;
  29893. function Comparator(comp, options) {
  29894. if (!options || typeof options !== 'object') options = {
  29895. loose: !!options,
  29896. includePrerelease: false
  29897. };
  29898. if (comp instanceof Comparator) {
  29899. if (comp.loose === !!options.loose) return comp;else comp = comp.value;
  29900. }
  29901. if (!(this instanceof Comparator)) return new Comparator(comp, options);
  29902. debug('comparator', comp, options);
  29903. this.options = options;
  29904. this.loose = !!options.loose;
  29905. this.parse(comp);
  29906. if (this.semver === ANY) this.value = '';else this.value = this.operator + this.semver.version;
  29907. debug('comp', this);
  29908. }
  29909. var ANY = {};
  29910. Comparator.prototype.parse = function (comp) {
  29911. var r = this.options.loose ? re[COMPARATORLOOSE] : re[COMPARATOR];
  29912. var m = comp.match(r);
  29913. if (!m) throw new TypeError('Invalid comparator: ' + comp);
  29914. this.operator = m[1];
  29915. if (this.operator === '=') this.operator = ''; // if it literally is just '>' or '' then allow anything.
  29916. if (!m[2]) this.semver = ANY;else this.semver = new SemVer(m[2], this.options.loose);
  29917. };
  29918. Comparator.prototype.toString = function () {
  29919. return this.value;
  29920. };
  29921. Comparator.prototype.test = function (version) {
  29922. debug('Comparator.test', version, this.options.loose);
  29923. if (this.semver === ANY) return true;
  29924. if (typeof version === 'string') version = new SemVer(version, this.options);
  29925. return cmp(version, this.operator, this.semver, this.options);
  29926. };
  29927. Comparator.prototype.intersects = function (comp, options) {
  29928. if (!(comp instanceof Comparator)) {
  29929. throw new TypeError('a Comparator is required');
  29930. }
  29931. if (!options || typeof options !== 'object') options = {
  29932. loose: !!options,
  29933. includePrerelease: false
  29934. };
  29935. var rangeTmp;
  29936. if (this.operator === '') {
  29937. rangeTmp = new Range(comp.value, options);
  29938. return satisfies(this.value, rangeTmp, options);
  29939. } else if (comp.operator === '') {
  29940. rangeTmp = new Range(this.value, options);
  29941. return satisfies(comp.semver, rangeTmp, options);
  29942. }
  29943. var sameDirectionIncreasing = (this.operator === '>=' || this.operator === '>') && (comp.operator === '>=' || comp.operator === '>');
  29944. var sameDirectionDecreasing = (this.operator === '<=' || this.operator === '<') && (comp.operator === '<=' || comp.operator === '<');
  29945. var sameSemVer = this.semver.version === comp.semver.version;
  29946. var differentDirectionsInclusive = (this.operator === '>=' || this.operator === '<=') && (comp.operator === '>=' || comp.operator === '<=');
  29947. var oppositeDirectionsLessThan = cmp(this.semver, '<', comp.semver, options) && (this.operator === '>=' || this.operator === '>') && (comp.operator === '<=' || comp.operator === '<');
  29948. var oppositeDirectionsGreaterThan = cmp(this.semver, '>', comp.semver, options) && (this.operator === '<=' || this.operator === '<') && (comp.operator === '>=' || comp.operator === '>');
  29949. return sameDirectionIncreasing || sameDirectionDecreasing || sameSemVer && differentDirectionsInclusive || oppositeDirectionsLessThan || oppositeDirectionsGreaterThan;
  29950. };
  29951. exports.Range = Range;
  29952. function Range(range, options) {
  29953. if (!options || typeof options !== 'object') options = {
  29954. loose: !!options,
  29955. includePrerelease: false
  29956. };
  29957. if (range instanceof Range) {
  29958. if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
  29959. return range;
  29960. } else {
  29961. return new Range(range.raw, options);
  29962. }
  29963. }
  29964. if (range instanceof Comparator) {
  29965. return new Range(range.value, options);
  29966. }
  29967. if (!(this instanceof Range)) return new Range(range, options);
  29968. this.options = options;
  29969. this.loose = !!options.loose;
  29970. this.includePrerelease = !!options.includePrerelease; // First, split based on boolean or ||
  29971. this.raw = range;
  29972. this.set = range.split(/\s*\|\|\s*/).map(function (range) {
  29973. return this.parseRange(range.trim());
  29974. }, this).filter(function (c) {
  29975. // throw out any that are not relevant for whatever reason
  29976. return c.length;
  29977. });
  29978. if (!this.set.length) {
  29979. throw new TypeError('Invalid SemVer Range: ' + range);
  29980. }
  29981. this.format();
  29982. }
  29983. Range.prototype.format = function () {
  29984. this.range = this.set.map(function (comps) {
  29985. return comps.join(' ').trim();
  29986. }).join('||').trim();
  29987. return this.range;
  29988. };
  29989. Range.prototype.toString = function () {
  29990. return this.range;
  29991. };
  29992. Range.prototype.parseRange = function (range) {
  29993. var loose = this.options.loose;
  29994. range = range.trim(); // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
  29995. var hr = loose ? re[HYPHENRANGELOOSE] : re[HYPHENRANGE];
  29996. range = range.replace(hr, hyphenReplace);
  29997. debug('hyphen replace', range); // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
  29998. range = range.replace(re[COMPARATORTRIM], comparatorTrimReplace);
  29999. debug('comparator trim', range, re[COMPARATORTRIM]); // `~ 1.2.3` => `~1.2.3`
  30000. range = range.replace(re[TILDETRIM], tildeTrimReplace); // `^ 1.2.3` => `^1.2.3`
  30001. range = range.replace(re[CARETTRIM], caretTrimReplace); // normalize spaces
  30002. range = range.split(/\s+/).join(' '); // At this point, the range is completely trimmed and
  30003. // ready to be split into comparators.
  30004. var compRe = loose ? re[COMPARATORLOOSE] : re[COMPARATOR];
  30005. var set = range.split(' ').map(function (comp) {
  30006. return parseComparator(comp, this.options);
  30007. }, this).join(' ').split(/\s+/);
  30008. if (this.options.loose) {
  30009. // in loose mode, throw out any that are not valid comparators
  30010. set = set.filter(function (comp) {
  30011. return !!comp.match(compRe);
  30012. });
  30013. }
  30014. set = set.map(function (comp) {
  30015. return new Comparator(comp, this.options);
  30016. }, this);
  30017. return set;
  30018. };
  30019. Range.prototype.intersects = function (range, options) {
  30020. if (!(range instanceof Range)) {
  30021. throw new TypeError('a Range is required');
  30022. }
  30023. return this.set.some(function (thisComparators) {
  30024. return thisComparators.every(function (thisComparator) {
  30025. return range.set.some(function (rangeComparators) {
  30026. return rangeComparators.every(function (rangeComparator) {
  30027. return thisComparator.intersects(rangeComparator, options);
  30028. });
  30029. });
  30030. });
  30031. });
  30032. }; // Mostly just for testing and legacy API reasons
  30033. exports.toComparators = toComparators;
  30034. function toComparators(range, options) {
  30035. return new Range(range, options).set.map(function (comp) {
  30036. return comp.map(function (c) {
  30037. return c.value;
  30038. }).join(' ').trim().split(' ');
  30039. });
  30040. } // comprised of xranges, tildes, stars, and gtlt's at this point.
  30041. // already replaced the hyphen ranges
  30042. // turn into a set of JUST comparators.
  30043. function parseComparator(comp, options) {
  30044. debug('comp', comp, options);
  30045. comp = replaceCarets(comp, options);
  30046. debug('caret', comp);
  30047. comp = replaceTildes(comp, options);
  30048. debug('tildes', comp);
  30049. comp = replaceXRanges(comp, options);
  30050. debug('xrange', comp);
  30051. comp = replaceStars(comp, options);
  30052. debug('stars', comp);
  30053. return comp;
  30054. }
  30055. function isX(id) {
  30056. return !id || id.toLowerCase() === 'x' || id === '*';
  30057. } // ~, ~> --> * (any, kinda silly)
  30058. // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
  30059. // ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
  30060. // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
  30061. // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
  30062. // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
  30063. function replaceTildes(comp, options) {
  30064. return comp.trim().split(/\s+/).map(function (comp) {
  30065. return replaceTilde(comp, options);
  30066. }).join(' ');
  30067. }
  30068. function replaceTilde(comp, options) {
  30069. if (!options || typeof options !== 'object') options = {
  30070. loose: !!options,
  30071. includePrerelease: false
  30072. };
  30073. var r = options.loose ? re[TILDELOOSE] : re[TILDE];
  30074. return comp.replace(r, function (_, M, m, p, pr) {
  30075. debug('tilde', comp, _, M, m, p, pr);
  30076. var ret;
  30077. if (isX(M)) ret = '';else if (isX(m)) ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';else if (isX(p)) // ~1.2 == >=1.2.0 <1.3.0
  30078. ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';else if (pr) {
  30079. debug('replaceTilde pr', pr);
  30080. if (pr.charAt(0) !== '-') pr = '-' + pr;
  30081. ret = '>=' + M + '.' + m + '.' + p + pr + ' <' + M + '.' + (+m + 1) + '.0';
  30082. } else // ~1.2.3 == >=1.2.3 <1.3.0
  30083. ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + (+m + 1) + '.0';
  30084. debug('tilde return', ret);
  30085. return ret;
  30086. });
  30087. } // ^ --> * (any, kinda silly)
  30088. // ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0
  30089. // ^2.0, ^2.0.x --> >=2.0.0 <3.0.0
  30090. // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
  30091. // ^1.2.3 --> >=1.2.3 <2.0.0
  30092. // ^1.2.0 --> >=1.2.0 <2.0.0
  30093. function replaceCarets(comp, options) {
  30094. return comp.trim().split(/\s+/).map(function (comp) {
  30095. return replaceCaret(comp, options);
  30096. }).join(' ');
  30097. }
  30098. function replaceCaret(comp, options) {
  30099. debug('caret', comp, options);
  30100. if (!options || typeof options !== 'object') options = {
  30101. loose: !!options,
  30102. includePrerelease: false
  30103. };
  30104. var r = options.loose ? re[CARETLOOSE] : re[CARET];
  30105. return comp.replace(r, function (_, M, m, p, pr) {
  30106. debug('caret', comp, _, M, m, p, pr);
  30107. var ret;
  30108. if (isX(M)) ret = '';else if (isX(m)) ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';else if (isX(p)) {
  30109. if (M === '0') ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';else ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0';
  30110. } else if (pr) {
  30111. debug('replaceCaret pr', pr);
  30112. if (pr.charAt(0) !== '-') pr = '-' + pr;
  30113. if (M === '0') {
  30114. if (m === '0') ret = '>=' + M + '.' + m + '.' + p + pr + ' <' + M + '.' + m + '.' + (+p + 1);else ret = '>=' + M + '.' + m + '.' + p + pr + ' <' + M + '.' + (+m + 1) + '.0';
  30115. } else ret = '>=' + M + '.' + m + '.' + p + pr + ' <' + (+M + 1) + '.0.0';
  30116. } else {
  30117. debug('no pr');
  30118. if (M === '0') {
  30119. if (m === '0') ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + m + '.' + (+p + 1);else ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + (+m + 1) + '.0';
  30120. } else ret = '>=' + M + '.' + m + '.' + p + ' <' + (+M + 1) + '.0.0';
  30121. }
  30122. debug('caret return', ret);
  30123. return ret;
  30124. });
  30125. }
  30126. function replaceXRanges(comp, options) {
  30127. debug('replaceXRanges', comp, options);
  30128. return comp.split(/\s+/).map(function (comp) {
  30129. return replaceXRange(comp, options);
  30130. }).join(' ');
  30131. }
  30132. function replaceXRange(comp, options) {
  30133. comp = comp.trim();
  30134. if (!options || typeof options !== 'object') options = {
  30135. loose: !!options,
  30136. includePrerelease: false
  30137. };
  30138. var r = options.loose ? re[XRANGELOOSE] : re[XRANGE];
  30139. return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
  30140. debug('xRange', comp, ret, gtlt, M, m, p, pr);
  30141. var xM = isX(M);
  30142. var xm = xM || isX(m);
  30143. var xp = xm || isX(p);
  30144. var anyX = xp;
  30145. if (gtlt === '=' && anyX) gtlt = '';
  30146. if (xM) {
  30147. if (gtlt === '>' || gtlt === '<') {
  30148. // nothing is allowed
  30149. ret = '<0.0.0';
  30150. } else {
  30151. // nothing is forbidden
  30152. ret = '*';
  30153. }
  30154. } else if (gtlt && anyX) {
  30155. // replace X with 0
  30156. if (xm) m = 0;
  30157. if (xp) p = 0;
  30158. if (gtlt === '>') {
  30159. // >1 => >=2.0.0
  30160. // >1.2 => >=1.3.0
  30161. // >1.2.3 => >= 1.2.4
  30162. gtlt = '>=';
  30163. if (xm) {
  30164. M = +M + 1;
  30165. m = 0;
  30166. p = 0;
  30167. } else if (xp) {
  30168. m = +m + 1;
  30169. p = 0;
  30170. }
  30171. } else if (gtlt === '<=') {
  30172. // <=0.7.x is actually <0.8.0, since any 0.7.x should
  30173. // pass. Similarly, <=7.x is actually <8.0.0, etc.
  30174. gtlt = '<';
  30175. if (xm) M = +M + 1;else m = +m + 1;
  30176. }
  30177. ret = gtlt + M + '.' + m + '.' + p;
  30178. } else if (xm) {
  30179. ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
  30180. } else if (xp) {
  30181. ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
  30182. }
  30183. debug('xRange return', ret);
  30184. return ret;
  30185. });
  30186. } // Because * is AND-ed with everything else in the comparator,
  30187. // and '' means "any version", just remove the *s entirely.
  30188. function replaceStars(comp, options) {
  30189. debug('replaceStars', comp, options); // Looseness is ignored here. star is always as loose as it gets!
  30190. return comp.trim().replace(re[STAR], '');
  30191. } // This function is passed to string.replace(re[HYPHENRANGE])
  30192. // M, m, patch, prerelease, build
  30193. // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
  30194. // 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
  30195. // 1.2 - 3.4 => >=1.2.0 <3.5.0
  30196. function hyphenReplace($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) {
  30197. if (isX(fM)) from = '';else if (isX(fm)) from = '>=' + fM + '.0.0';else if (isX(fp)) from = '>=' + fM + '.' + fm + '.0';else from = '>=' + from;
  30198. if (isX(tM)) to = '';else if (isX(tm)) to = '<' + (+tM + 1) + '.0.0';else if (isX(tp)) to = '<' + tM + '.' + (+tm + 1) + '.0';else if (tpr) to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr;else to = '<=' + to;
  30199. return (from + ' ' + to).trim();
  30200. } // if ANY of the sets match ALL of its comparators, then pass
  30201. Range.prototype.test = function (version) {
  30202. if (!version) return false;
  30203. if (typeof version === 'string') version = new SemVer(version, this.options);
  30204. for (var i = 0; i < this.set.length; i++) {
  30205. if (testSet(this.set[i], version, this.options)) return true;
  30206. }
  30207. return false;
  30208. };
  30209. function testSet(set, version, options) {
  30210. for (var i = 0; i < set.length; i++) {
  30211. if (!set[i].test(version)) return false;
  30212. }
  30213. if (!options) options = {};
  30214. if (version.prerelease.length && !options.includePrerelease) {
  30215. // Find the set of versions that are allowed to have prereleases
  30216. // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
  30217. // That should allow `1.2.3-pr.2` to pass.
  30218. // However, `1.2.4-alpha.notready` should NOT be allowed,
  30219. // even though it's within the range set by the comparators.
  30220. for (var i = 0; i < set.length; i++) {
  30221. debug(set[i].semver);
  30222. if (set[i].semver === ANY) continue;
  30223. if (set[i].semver.prerelease.length > 0) {
  30224. var allowed = set[i].semver;
  30225. if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) return true;
  30226. }
  30227. } // Version has a -pre, but it's not one of the ones we like.
  30228. return false;
  30229. }
  30230. return true;
  30231. }
  30232. exports.satisfies = satisfies;
  30233. function satisfies(version, range, options) {
  30234. try {
  30235. range = new Range(range, options);
  30236. } catch (er) {
  30237. return false;
  30238. }
  30239. return range.test(version);
  30240. }
  30241. exports.maxSatisfying = maxSatisfying;
  30242. function maxSatisfying(versions, range, options) {
  30243. var max = null;
  30244. var maxSV = null;
  30245. try {
  30246. var rangeObj = new Range(range, options);
  30247. } catch (er) {
  30248. return null;
  30249. }
  30250. versions.forEach(function (v) {
  30251. if (rangeObj.test(v)) {
  30252. // satisfies(v, range, options)
  30253. if (!max || maxSV.compare(v) === -1) {
  30254. // compare(max, v, true)
  30255. max = v;
  30256. maxSV = new SemVer(max, options);
  30257. }
  30258. }
  30259. });
  30260. return max;
  30261. }
  30262. exports.minSatisfying = minSatisfying;
  30263. function minSatisfying(versions, range, options) {
  30264. var min = null;
  30265. var minSV = null;
  30266. try {
  30267. var rangeObj = new Range(range, options);
  30268. } catch (er) {
  30269. return null;
  30270. }
  30271. versions.forEach(function (v) {
  30272. if (rangeObj.test(v)) {
  30273. // satisfies(v, range, options)
  30274. if (!min || minSV.compare(v) === 1) {
  30275. // compare(min, v, true)
  30276. min = v;
  30277. minSV = new SemVer(min, options);
  30278. }
  30279. }
  30280. });
  30281. return min;
  30282. }
  30283. exports.validRange = validRange;
  30284. function validRange(range, options) {
  30285. try {
  30286. // Return '*' instead of '' so that truthiness works.
  30287. // This will throw if it's invalid anyway
  30288. return new Range(range, options).range || '*';
  30289. } catch (er) {
  30290. return null;
  30291. }
  30292. } // Determine if version is less than all the versions possible in the range
  30293. exports.ltr = ltr;
  30294. function ltr(version, range, options) {
  30295. return outside(version, range, '<', options);
  30296. } // Determine if version is greater than all the versions possible in the range.
  30297. exports.gtr = gtr;
  30298. function gtr(version, range, options) {
  30299. return outside(version, range, '>', options);
  30300. }
  30301. exports.outside = outside;
  30302. function outside(version, range, hilo, options) {
  30303. version = new SemVer(version, options);
  30304. range = new Range(range, options);
  30305. var gtfn, ltefn, ltfn, comp, ecomp;
  30306. switch (hilo) {
  30307. case '>':
  30308. gtfn = gt;
  30309. ltefn = lte;
  30310. ltfn = lt;
  30311. comp = '>';
  30312. ecomp = '>=';
  30313. break;
  30314. case '<':
  30315. gtfn = lt;
  30316. ltefn = gte;
  30317. ltfn = gt;
  30318. comp = '<';
  30319. ecomp = '<=';
  30320. break;
  30321. default:
  30322. throw new TypeError('Must provide a hilo val of "<" or ">"');
  30323. } // If it satisifes the range it is not outside
  30324. if (satisfies(version, range, options)) {
  30325. return false;
  30326. } // From now on, variable terms are as if we're in "gtr" mode.
  30327. // but note that everything is flipped for the "ltr" function.
  30328. for (var i = 0; i < range.set.length; ++i) {
  30329. var comparators = range.set[i];
  30330. var high = null;
  30331. var low = null;
  30332. comparators.forEach(function (comparator) {
  30333. if (comparator.semver === ANY) {
  30334. comparator = new Comparator('>=0.0.0');
  30335. }
  30336. high = high || comparator;
  30337. low = low || comparator;
  30338. if (gtfn(comparator.semver, high.semver, options)) {
  30339. high = comparator;
  30340. } else if (ltfn(comparator.semver, low.semver, options)) {
  30341. low = comparator;
  30342. }
  30343. }); // If the edge version comparator has a operator then our version
  30344. // isn't outside it
  30345. if (high.operator === comp || high.operator === ecomp) {
  30346. return false;
  30347. } // If the lowest version comparator has an operator and our version
  30348. // is less than it then it isn't higher than the range
  30349. if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
  30350. return false;
  30351. } else if (low.operator === ecomp && ltfn(version, low.semver)) {
  30352. return false;
  30353. }
  30354. }
  30355. return true;
  30356. }
  30357. exports.prerelease = prerelease;
  30358. function prerelease(version, options) {
  30359. var parsed = parse(version, options);
  30360. return parsed && parsed.prerelease.length ? parsed.prerelease : null;
  30361. }
  30362. exports.intersects = intersects;
  30363. function intersects(r1, r2, options) {
  30364. r1 = new Range(r1, options);
  30365. r2 = new Range(r2, options);
  30366. return r1.intersects(r2);
  30367. }
  30368. exports.coerce = coerce;
  30369. function coerce(version) {
  30370. if (version instanceof SemVer) return version;
  30371. if (typeof version !== 'string') return null;
  30372. var match = version.match(re[COERCE]);
  30373. if (match == null) return null;
  30374. return parse((match[1] || '0') + '.' + (match[2] || '0') + '.' + (match[3] || '0'));
  30375. }
  30376. });
  30377. var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
  30378. var pseudomap = PseudoMap;
  30379. function PseudoMap(set) {
  30380. if (!(this instanceof PseudoMap)) // whyyyyyyy
  30381. throw new TypeError("Constructor PseudoMap requires 'new'");
  30382. this.clear();
  30383. if (set) {
  30384. if (set instanceof PseudoMap || typeof Map === 'function' && set instanceof Map) set.forEach(function (value, key) {
  30385. this.set(key, value);
  30386. }, this);else if (Array.isArray(set)) set.forEach(function (kv) {
  30387. this.set(kv[0], kv[1]);
  30388. }, this);else throw new TypeError('invalid argument');
  30389. }
  30390. }
  30391. PseudoMap.prototype.forEach = function (fn, thisp) {
  30392. thisp = thisp || this;
  30393. Object.keys(this._data).forEach(function (k) {
  30394. if (k !== 'size') fn.call(thisp, this._data[k].value, this._data[k].key);
  30395. }, this);
  30396. };
  30397. PseudoMap.prototype.has = function (k) {
  30398. return !!find(this._data, k);
  30399. };
  30400. PseudoMap.prototype.get = function (k) {
  30401. var res = find(this._data, k);
  30402. return res && res.value;
  30403. };
  30404. PseudoMap.prototype.set = function (k, v) {
  30405. set$1(this._data, k, v);
  30406. };
  30407. PseudoMap.prototype.delete = function (k) {
  30408. var res = find(this._data, k);
  30409. if (res) {
  30410. delete this._data[res._index];
  30411. this._data.size--;
  30412. }
  30413. };
  30414. PseudoMap.prototype.clear = function () {
  30415. var data = Object.create(null);
  30416. data.size = 0;
  30417. Object.defineProperty(this, '_data', {
  30418. value: data,
  30419. enumerable: false,
  30420. configurable: true,
  30421. writable: false
  30422. });
  30423. };
  30424. Object.defineProperty(PseudoMap.prototype, 'size', {
  30425. get: function get() {
  30426. return this._data.size;
  30427. },
  30428. set: function set(n) {},
  30429. enumerable: true,
  30430. configurable: true
  30431. });
  30432. PseudoMap.prototype.values = PseudoMap.prototype.keys = PseudoMap.prototype.entries = function () {
  30433. throw new Error('iterators are not implemented in this version');
  30434. }; // Either identical, or both NaN
  30435. function same(a, b) {
  30436. return a === b || a !== a && b !== b;
  30437. }
  30438. function Entry$1(k, v, i) {
  30439. this.key = k;
  30440. this.value = v;
  30441. this._index = i;
  30442. }
  30443. function find(data, k) {
  30444. for (var i = 0, s = '_' + k, key = s; hasOwnProperty$1.call(data, key); key = s + i++) {
  30445. if (same(data[key].key, k)) return data[key];
  30446. }
  30447. }
  30448. function set$1(data, k, v) {
  30449. for (var i = 0, s = '_' + k, key = s; hasOwnProperty$1.call(data, key); key = s + i++) {
  30450. if (same(data[key].key, k)) {
  30451. data[key].value = v;
  30452. return;
  30453. }
  30454. }
  30455. data.size++;
  30456. data[key] = new Entry$1(k, v, key);
  30457. }
  30458. var map$1 = createCommonjsModule(function (module) {
  30459. if (process.env.npm_package_name === 'pseudomap' && process.env.npm_lifecycle_script === 'test') process.env.TEST_PSEUDOMAP = 'true';
  30460. if (typeof Map === 'function' && !process.env.TEST_PSEUDOMAP) {
  30461. module.exports = Map;
  30462. } else {
  30463. module.exports = pseudomap;
  30464. }
  30465. });
  30466. var yallist = Yallist;
  30467. Yallist.Node = Node;
  30468. Yallist.create = Yallist;
  30469. function Yallist(list) {
  30470. var self = this;
  30471. if (!(self instanceof Yallist)) {
  30472. self = new Yallist();
  30473. }
  30474. self.tail = null;
  30475. self.head = null;
  30476. self.length = 0;
  30477. if (list && typeof list.forEach === 'function') {
  30478. list.forEach(function (item) {
  30479. self.push(item);
  30480. });
  30481. } else if (arguments.length > 0) {
  30482. for (var i = 0, l = arguments.length; i < l; i++) {
  30483. self.push(arguments[i]);
  30484. }
  30485. }
  30486. return self;
  30487. }
  30488. Yallist.prototype.removeNode = function (node) {
  30489. if (node.list !== this) {
  30490. throw new Error('removing node which does not belong to this list');
  30491. }
  30492. var next = node.next;
  30493. var prev = node.prev;
  30494. if (next) {
  30495. next.prev = prev;
  30496. }
  30497. if (prev) {
  30498. prev.next = next;
  30499. }
  30500. if (node === this.head) {
  30501. this.head = next;
  30502. }
  30503. if (node === this.tail) {
  30504. this.tail = prev;
  30505. }
  30506. node.list.length--;
  30507. node.next = null;
  30508. node.prev = null;
  30509. node.list = null;
  30510. };
  30511. Yallist.prototype.unshiftNode = function (node) {
  30512. if (node === this.head) {
  30513. return;
  30514. }
  30515. if (node.list) {
  30516. node.list.removeNode(node);
  30517. }
  30518. var head = this.head;
  30519. node.list = this;
  30520. node.next = head;
  30521. if (head) {
  30522. head.prev = node;
  30523. }
  30524. this.head = node;
  30525. if (!this.tail) {
  30526. this.tail = node;
  30527. }
  30528. this.length++;
  30529. };
  30530. Yallist.prototype.pushNode = function (node) {
  30531. if (node === this.tail) {
  30532. return;
  30533. }
  30534. if (node.list) {
  30535. node.list.removeNode(node);
  30536. }
  30537. var tail = this.tail;
  30538. node.list = this;
  30539. node.prev = tail;
  30540. if (tail) {
  30541. tail.next = node;
  30542. }
  30543. this.tail = node;
  30544. if (!this.head) {
  30545. this.head = node;
  30546. }
  30547. this.length++;
  30548. };
  30549. Yallist.prototype.push = function () {
  30550. for (var i = 0, l = arguments.length; i < l; i++) {
  30551. push(this, arguments[i]);
  30552. }
  30553. return this.length;
  30554. };
  30555. Yallist.prototype.unshift = function () {
  30556. for (var i = 0, l = arguments.length; i < l; i++) {
  30557. unshift(this, arguments[i]);
  30558. }
  30559. return this.length;
  30560. };
  30561. Yallist.prototype.pop = function () {
  30562. if (!this.tail) {
  30563. return undefined;
  30564. }
  30565. var res = this.tail.value;
  30566. this.tail = this.tail.prev;
  30567. if (this.tail) {
  30568. this.tail.next = null;
  30569. } else {
  30570. this.head = null;
  30571. }
  30572. this.length--;
  30573. return res;
  30574. };
  30575. Yallist.prototype.shift = function () {
  30576. if (!this.head) {
  30577. return undefined;
  30578. }
  30579. var res = this.head.value;
  30580. this.head = this.head.next;
  30581. if (this.head) {
  30582. this.head.prev = null;
  30583. } else {
  30584. this.tail = null;
  30585. }
  30586. this.length--;
  30587. return res;
  30588. };
  30589. Yallist.prototype.forEach = function (fn, thisp) {
  30590. thisp = thisp || this;
  30591. for (var walker = this.head, i = 0; walker !== null; i++) {
  30592. fn.call(thisp, walker.value, i, this);
  30593. walker = walker.next;
  30594. }
  30595. };
  30596. Yallist.prototype.forEachReverse = function (fn, thisp) {
  30597. thisp = thisp || this;
  30598. for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {
  30599. fn.call(thisp, walker.value, i, this);
  30600. walker = walker.prev;
  30601. }
  30602. };
  30603. Yallist.prototype.get = function (n) {
  30604. for (var i = 0, walker = this.head; walker !== null && i < n; i++) {
  30605. // abort out of the list early if we hit a cycle
  30606. walker = walker.next;
  30607. }
  30608. if (i === n && walker !== null) {
  30609. return walker.value;
  30610. }
  30611. };
  30612. Yallist.prototype.getReverse = function (n) {
  30613. for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {
  30614. // abort out of the list early if we hit a cycle
  30615. walker = walker.prev;
  30616. }
  30617. if (i === n && walker !== null) {
  30618. return walker.value;
  30619. }
  30620. };
  30621. Yallist.prototype.map = function (fn, thisp) {
  30622. thisp = thisp || this;
  30623. var res = new Yallist();
  30624. for (var walker = this.head; walker !== null;) {
  30625. res.push(fn.call(thisp, walker.value, this));
  30626. walker = walker.next;
  30627. }
  30628. return res;
  30629. };
  30630. Yallist.prototype.mapReverse = function (fn, thisp) {
  30631. thisp = thisp || this;
  30632. var res = new Yallist();
  30633. for (var walker = this.tail; walker !== null;) {
  30634. res.push(fn.call(thisp, walker.value, this));
  30635. walker = walker.prev;
  30636. }
  30637. return res;
  30638. };
  30639. Yallist.prototype.reduce = function (fn, initial) {
  30640. var acc;
  30641. var walker = this.head;
  30642. if (arguments.length > 1) {
  30643. acc = initial;
  30644. } else if (this.head) {
  30645. walker = this.head.next;
  30646. acc = this.head.value;
  30647. } else {
  30648. throw new TypeError('Reduce of empty list with no initial value');
  30649. }
  30650. for (var i = 0; walker !== null; i++) {
  30651. acc = fn(acc, walker.value, i);
  30652. walker = walker.next;
  30653. }
  30654. return acc;
  30655. };
  30656. Yallist.prototype.reduceReverse = function (fn, initial) {
  30657. var acc;
  30658. var walker = this.tail;
  30659. if (arguments.length > 1) {
  30660. acc = initial;
  30661. } else if (this.tail) {
  30662. walker = this.tail.prev;
  30663. acc = this.tail.value;
  30664. } else {
  30665. throw new TypeError('Reduce of empty list with no initial value');
  30666. }
  30667. for (var i = this.length - 1; walker !== null; i--) {
  30668. acc = fn(acc, walker.value, i);
  30669. walker = walker.prev;
  30670. }
  30671. return acc;
  30672. };
  30673. Yallist.prototype.toArray = function () {
  30674. var arr = new Array(this.length);
  30675. for (var i = 0, walker = this.head; walker !== null; i++) {
  30676. arr[i] = walker.value;
  30677. walker = walker.next;
  30678. }
  30679. return arr;
  30680. };
  30681. Yallist.prototype.toArrayReverse = function () {
  30682. var arr = new Array(this.length);
  30683. for (var i = 0, walker = this.tail; walker !== null; i++) {
  30684. arr[i] = walker.value;
  30685. walker = walker.prev;
  30686. }
  30687. return arr;
  30688. };
  30689. Yallist.prototype.slice = function (from, to) {
  30690. to = to || this.length;
  30691. if (to < 0) {
  30692. to += this.length;
  30693. }
  30694. from = from || 0;
  30695. if (from < 0) {
  30696. from += this.length;
  30697. }
  30698. var ret = new Yallist();
  30699. if (to < from || to < 0) {
  30700. return ret;
  30701. }
  30702. if (from < 0) {
  30703. from = 0;
  30704. }
  30705. if (to > this.length) {
  30706. to = this.length;
  30707. }
  30708. for (var i = 0, walker = this.head; walker !== null && i < from; i++) {
  30709. walker = walker.next;
  30710. }
  30711. for (; walker !== null && i < to; i++, walker = walker.next) {
  30712. ret.push(walker.value);
  30713. }
  30714. return ret;
  30715. };
  30716. Yallist.prototype.sliceReverse = function (from, to) {
  30717. to = to || this.length;
  30718. if (to < 0) {
  30719. to += this.length;
  30720. }
  30721. from = from || 0;
  30722. if (from < 0) {
  30723. from += this.length;
  30724. }
  30725. var ret = new Yallist();
  30726. if (to < from || to < 0) {
  30727. return ret;
  30728. }
  30729. if (from < 0) {
  30730. from = 0;
  30731. }
  30732. if (to > this.length) {
  30733. to = this.length;
  30734. }
  30735. for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {
  30736. walker = walker.prev;
  30737. }
  30738. for (; walker !== null && i > from; i--, walker = walker.prev) {
  30739. ret.push(walker.value);
  30740. }
  30741. return ret;
  30742. };
  30743. Yallist.prototype.reverse = function () {
  30744. var head = this.head;
  30745. var tail = this.tail;
  30746. for (var walker = head; walker !== null; walker = walker.prev) {
  30747. var p = walker.prev;
  30748. walker.prev = walker.next;
  30749. walker.next = p;
  30750. }
  30751. this.head = tail;
  30752. this.tail = head;
  30753. return this;
  30754. };
  30755. function push(self, item) {
  30756. self.tail = new Node(item, self.tail, null, self);
  30757. if (!self.head) {
  30758. self.head = self.tail;
  30759. }
  30760. self.length++;
  30761. }
  30762. function unshift(self, item) {
  30763. self.head = new Node(item, null, self.head, self);
  30764. if (!self.tail) {
  30765. self.tail = self.head;
  30766. }
  30767. self.length++;
  30768. }
  30769. function Node(value, prev, next, list) {
  30770. if (!(this instanceof Node)) {
  30771. return new Node(value, prev, next, list);
  30772. }
  30773. this.list = list;
  30774. this.value = value;
  30775. if (prev) {
  30776. prev.next = this;
  30777. this.prev = prev;
  30778. } else {
  30779. this.prev = null;
  30780. }
  30781. if (next) {
  30782. next.prev = this;
  30783. this.next = next;
  30784. } else {
  30785. this.next = null;
  30786. }
  30787. }
  30788. var lruCache = LRUCache; // This will be a proper iterable 'Map' in engines that support it,
  30789. // or a fakey-fake PseudoMap in older versions.
  30790. // A linked list to keep track of recently-used-ness
  30791. // use symbols if possible, otherwise just _props
  30792. var hasSymbol = typeof Symbol === 'function';
  30793. var makeSymbol;
  30794. if (hasSymbol) {
  30795. makeSymbol = function makeSymbol(key) {
  30796. return Symbol(key);
  30797. };
  30798. } else {
  30799. makeSymbol = function makeSymbol(key) {
  30800. return '_' + key;
  30801. };
  30802. }
  30803. var MAX = makeSymbol('max');
  30804. var LENGTH = makeSymbol('length');
  30805. var LENGTH_CALCULATOR = makeSymbol('lengthCalculator');
  30806. var ALLOW_STALE = makeSymbol('allowStale');
  30807. var MAX_AGE = makeSymbol('maxAge');
  30808. var DISPOSE = makeSymbol('dispose');
  30809. var NO_DISPOSE_ON_SET = makeSymbol('noDisposeOnSet');
  30810. var LRU_LIST = makeSymbol('lruList');
  30811. var CACHE = makeSymbol('cache');
  30812. function naiveLength() {
  30813. return 1;
  30814. } // lruList is a yallist where the head is the youngest
  30815. // item, and the tail is the oldest. the list contains the Hit
  30816. // objects as the entries.
  30817. // Each Hit object has a reference to its Yallist.Node. This
  30818. // never changes.
  30819. //
  30820. // cache is a Map (or PseudoMap) that matches the keys to
  30821. // the Yallist.Node object.
  30822. function LRUCache(options) {
  30823. if (!(this instanceof LRUCache)) {
  30824. return new LRUCache(options);
  30825. }
  30826. if (typeof options === 'number') {
  30827. options = {
  30828. max: options
  30829. };
  30830. }
  30831. if (!options) {
  30832. options = {};
  30833. }
  30834. var max = this[MAX] = options.max; // Kind of weird to have a default max of Infinity, but oh well.
  30835. if (!max || !(typeof max === 'number') || max <= 0) {
  30836. this[MAX] = Infinity;
  30837. }
  30838. var lc = options.length || naiveLength;
  30839. if (typeof lc !== 'function') {
  30840. lc = naiveLength;
  30841. }
  30842. this[LENGTH_CALCULATOR] = lc;
  30843. this[ALLOW_STALE] = options.stale || false;
  30844. this[MAX_AGE] = options.maxAge || 0;
  30845. this[DISPOSE] = options.dispose;
  30846. this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false;
  30847. this.reset();
  30848. } // resize the cache when the max changes.
  30849. Object.defineProperty(LRUCache.prototype, 'max', {
  30850. set: function set(mL) {
  30851. if (!mL || !(typeof mL === 'number') || mL <= 0) {
  30852. mL = Infinity;
  30853. }
  30854. this[MAX] = mL;
  30855. trim$2(this);
  30856. },
  30857. get: function get() {
  30858. return this[MAX];
  30859. },
  30860. enumerable: true
  30861. });
  30862. Object.defineProperty(LRUCache.prototype, 'allowStale', {
  30863. set: function set(allowStale) {
  30864. this[ALLOW_STALE] = !!allowStale;
  30865. },
  30866. get: function get() {
  30867. return this[ALLOW_STALE];
  30868. },
  30869. enumerable: true
  30870. });
  30871. Object.defineProperty(LRUCache.prototype, 'maxAge', {
  30872. set: function set(mA) {
  30873. if (!mA || !(typeof mA === 'number') || mA < 0) {
  30874. mA = 0;
  30875. }
  30876. this[MAX_AGE] = mA;
  30877. trim$2(this);
  30878. },
  30879. get: function get() {
  30880. return this[MAX_AGE];
  30881. },
  30882. enumerable: true
  30883. }); // resize the cache when the lengthCalculator changes.
  30884. Object.defineProperty(LRUCache.prototype, 'lengthCalculator', {
  30885. set: function set(lC) {
  30886. if (typeof lC !== 'function') {
  30887. lC = naiveLength;
  30888. }
  30889. if (lC !== this[LENGTH_CALCULATOR]) {
  30890. this[LENGTH_CALCULATOR] = lC;
  30891. this[LENGTH] = 0;
  30892. this[LRU_LIST].forEach(function (hit) {
  30893. hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key);
  30894. this[LENGTH] += hit.length;
  30895. }, this);
  30896. }
  30897. trim$2(this);
  30898. },
  30899. get: function get() {
  30900. return this[LENGTH_CALCULATOR];
  30901. },
  30902. enumerable: true
  30903. });
  30904. Object.defineProperty(LRUCache.prototype, 'length', {
  30905. get: function get() {
  30906. return this[LENGTH];
  30907. },
  30908. enumerable: true
  30909. });
  30910. Object.defineProperty(LRUCache.prototype, 'itemCount', {
  30911. get: function get() {
  30912. return this[LRU_LIST].length;
  30913. },
  30914. enumerable: true
  30915. });
  30916. LRUCache.prototype.rforEach = function (fn, thisp) {
  30917. thisp = thisp || this;
  30918. for (var walker = this[LRU_LIST].tail; walker !== null;) {
  30919. var prev = walker.prev;
  30920. forEachStep(this, fn, walker, thisp);
  30921. walker = prev;
  30922. }
  30923. };
  30924. function forEachStep(self, fn, node, thisp) {
  30925. var hit = node.value;
  30926. if (isStale(self, hit)) {
  30927. del$1(self, node);
  30928. if (!self[ALLOW_STALE]) {
  30929. hit = undefined;
  30930. }
  30931. }
  30932. if (hit) {
  30933. fn.call(thisp, hit.value, hit.key, self);
  30934. }
  30935. }
  30936. LRUCache.prototype.forEach = function (fn, thisp) {
  30937. thisp = thisp || this;
  30938. for (var walker = this[LRU_LIST].head; walker !== null;) {
  30939. var next = walker.next;
  30940. forEachStep(this, fn, walker, thisp);
  30941. walker = next;
  30942. }
  30943. };
  30944. LRUCache.prototype.keys = function () {
  30945. return this[LRU_LIST].toArray().map(function (k) {
  30946. return k.key;
  30947. }, this);
  30948. };
  30949. LRUCache.prototype.values = function () {
  30950. return this[LRU_LIST].toArray().map(function (k) {
  30951. return k.value;
  30952. }, this);
  30953. };
  30954. LRUCache.prototype.reset = function () {
  30955. if (this[DISPOSE] && this[LRU_LIST] && this[LRU_LIST].length) {
  30956. this[LRU_LIST].forEach(function (hit) {
  30957. this[DISPOSE](hit.key, hit.value);
  30958. }, this);
  30959. }
  30960. this[CACHE] = new map$1(); // hash of items by key
  30961. this[LRU_LIST] = new yallist(); // list of items in order of use recency
  30962. this[LENGTH] = 0; // length of items in the list
  30963. };
  30964. LRUCache.prototype.dump = function () {
  30965. return this[LRU_LIST].map(function (hit) {
  30966. if (!isStale(this, hit)) {
  30967. return {
  30968. k: hit.key,
  30969. v: hit.value,
  30970. e: hit.now + (hit.maxAge || 0)
  30971. };
  30972. }
  30973. }, this).toArray().filter(function (h) {
  30974. return h;
  30975. });
  30976. };
  30977. LRUCache.prototype.dumpLru = function () {
  30978. return this[LRU_LIST];
  30979. };
  30980. LRUCache.prototype.inspect = function (n, opts) {
  30981. var str = 'LRUCache {';
  30982. var extras = false;
  30983. var as = this[ALLOW_STALE];
  30984. if (as) {
  30985. str += '\n allowStale: true';
  30986. extras = true;
  30987. }
  30988. var max = this[MAX];
  30989. if (max && max !== Infinity) {
  30990. if (extras) {
  30991. str += ',';
  30992. }
  30993. str += '\n max: ' + util.inspect(max, opts);
  30994. extras = true;
  30995. }
  30996. var maxAge = this[MAX_AGE];
  30997. if (maxAge) {
  30998. if (extras) {
  30999. str += ',';
  31000. }
  31001. str += '\n maxAge: ' + util.inspect(maxAge, opts);
  31002. extras = true;
  31003. }
  31004. var lc = this[LENGTH_CALCULATOR];
  31005. if (lc && lc !== naiveLength) {
  31006. if (extras) {
  31007. str += ',';
  31008. }
  31009. str += '\n length: ' + util.inspect(this[LENGTH], opts);
  31010. extras = true;
  31011. }
  31012. var didFirst = false;
  31013. this[LRU_LIST].forEach(function (item) {
  31014. if (didFirst) {
  31015. str += ',\n ';
  31016. } else {
  31017. if (extras) {
  31018. str += ',\n';
  31019. }
  31020. didFirst = true;
  31021. str += '\n ';
  31022. }
  31023. var key = util.inspect(item.key).split('\n').join('\n ');
  31024. var val = {
  31025. value: item.value
  31026. };
  31027. if (item.maxAge !== maxAge) {
  31028. val.maxAge = item.maxAge;
  31029. }
  31030. if (lc !== naiveLength) {
  31031. val.length = item.length;
  31032. }
  31033. if (isStale(this, item)) {
  31034. val.stale = true;
  31035. }
  31036. val = util.inspect(val, opts).split('\n').join('\n ');
  31037. str += key + ' => ' + val;
  31038. });
  31039. if (didFirst || extras) {
  31040. str += '\n';
  31041. }
  31042. str += '}';
  31043. return str;
  31044. };
  31045. LRUCache.prototype.set = function (key, value, maxAge) {
  31046. maxAge = maxAge || this[MAX_AGE];
  31047. var now = maxAge ? Date.now() : 0;
  31048. var len = this[LENGTH_CALCULATOR](value, key);
  31049. if (this[CACHE].has(key)) {
  31050. if (len > this[MAX]) {
  31051. del$1(this, this[CACHE].get(key));
  31052. return false;
  31053. }
  31054. var node = this[CACHE].get(key);
  31055. var item = node.value; // dispose of the old one before overwriting
  31056. // split out into 2 ifs for better coverage tracking
  31057. if (this[DISPOSE]) {
  31058. if (!this[NO_DISPOSE_ON_SET]) {
  31059. this[DISPOSE](key, item.value);
  31060. }
  31061. }
  31062. item.now = now;
  31063. item.maxAge = maxAge;
  31064. item.value = value;
  31065. this[LENGTH] += len - item.length;
  31066. item.length = len;
  31067. this.get(key);
  31068. trim$2(this);
  31069. return true;
  31070. }
  31071. var hit = new Entry(key, value, len, now, maxAge); // oversized objects fall out of cache automatically.
  31072. if (hit.length > this[MAX]) {
  31073. if (this[DISPOSE]) {
  31074. this[DISPOSE](key, value);
  31075. }
  31076. return false;
  31077. }
  31078. this[LENGTH] += hit.length;
  31079. this[LRU_LIST].unshift(hit);
  31080. this[CACHE].set(key, this[LRU_LIST].head);
  31081. trim$2(this);
  31082. return true;
  31083. };
  31084. LRUCache.prototype.has = function (key) {
  31085. if (!this[CACHE].has(key)) return false;
  31086. var hit = this[CACHE].get(key).value;
  31087. if (isStale(this, hit)) {
  31088. return false;
  31089. }
  31090. return true;
  31091. };
  31092. LRUCache.prototype.get = function (key) {
  31093. return get(this, key, true);
  31094. };
  31095. LRUCache.prototype.peek = function (key) {
  31096. return get(this, key, false);
  31097. };
  31098. LRUCache.prototype.pop = function () {
  31099. var node = this[LRU_LIST].tail;
  31100. if (!node) return null;
  31101. del$1(this, node);
  31102. return node.value;
  31103. };
  31104. LRUCache.prototype.del = function (key) {
  31105. del$1(this, this[CACHE].get(key));
  31106. };
  31107. LRUCache.prototype.load = function (arr) {
  31108. // reset the cache
  31109. this.reset();
  31110. var now = Date.now(); // A previous serialized cache has the most recent items first
  31111. for (var l = arr.length - 1; l >= 0; l--) {
  31112. var hit = arr[l];
  31113. var expiresAt = hit.e || 0;
  31114. if (expiresAt === 0) {
  31115. // the item was created without expiration in a non aged cache
  31116. this.set(hit.k, hit.v);
  31117. } else {
  31118. var maxAge = expiresAt - now; // dont add already expired items
  31119. if (maxAge > 0) {
  31120. this.set(hit.k, hit.v, maxAge);
  31121. }
  31122. }
  31123. }
  31124. };
  31125. LRUCache.prototype.prune = function () {
  31126. var self = this;
  31127. this[CACHE].forEach(function (value, key) {
  31128. get(self, key, false);
  31129. });
  31130. };
  31131. function get(self, key, doUse) {
  31132. var node = self[CACHE].get(key);
  31133. if (node) {
  31134. var hit = node.value;
  31135. if (isStale(self, hit)) {
  31136. del$1(self, node);
  31137. if (!self[ALLOW_STALE]) hit = undefined;
  31138. } else {
  31139. if (doUse) {
  31140. self[LRU_LIST].unshiftNode(node);
  31141. }
  31142. }
  31143. if (hit) hit = hit.value;
  31144. }
  31145. return hit;
  31146. }
  31147. function isStale(self, hit) {
  31148. if (!hit || !hit.maxAge && !self[MAX_AGE]) {
  31149. return false;
  31150. }
  31151. var stale = false;
  31152. var diff = Date.now() - hit.now;
  31153. if (hit.maxAge) {
  31154. stale = diff > hit.maxAge;
  31155. } else {
  31156. stale = self[MAX_AGE] && diff > self[MAX_AGE];
  31157. }
  31158. return stale;
  31159. }
  31160. function trim$2(self) {
  31161. if (self[LENGTH] > self[MAX]) {
  31162. for (var walker = self[LRU_LIST].tail; self[LENGTH] > self[MAX] && walker !== null;) {
  31163. // We know that we're about to delete this one, and also
  31164. // what the next least recently used key will be, so just
  31165. // go ahead and set it now.
  31166. var prev = walker.prev;
  31167. del$1(self, walker);
  31168. walker = prev;
  31169. }
  31170. }
  31171. }
  31172. function del$1(self, node) {
  31173. if (node) {
  31174. var hit = node.value;
  31175. if (self[DISPOSE]) {
  31176. self[DISPOSE](hit.key, hit.value);
  31177. }
  31178. self[LENGTH] -= hit.length;
  31179. self[CACHE].delete(hit.key);
  31180. self[LRU_LIST].removeNode(node);
  31181. }
  31182. } // classy, since V8 prefers predictable objects.
  31183. function Entry(key, value, length, now, maxAge) {
  31184. this.key = key;
  31185. this.value = value;
  31186. this.length = length;
  31187. this.now = now;
  31188. this.maxAge = maxAge || 0;
  31189. }
  31190. var sigmund_1 = sigmund;
  31191. function sigmund(subject, maxSessions) {
  31192. maxSessions = maxSessions || 10;
  31193. var notes = [];
  31194. var analysis = '';
  31195. var RE = RegExp;
  31196. function psychoAnalyze(subject, session) {
  31197. if (session > maxSessions) return;
  31198. if (typeof subject === 'function' || typeof subject === 'undefined') {
  31199. return;
  31200. }
  31201. if (typeof subject !== 'object' || !subject || subject instanceof RE) {
  31202. analysis += subject;
  31203. return;
  31204. }
  31205. if (notes.indexOf(subject) !== -1 || session === maxSessions) return;
  31206. notes.push(subject);
  31207. analysis += '{';
  31208. Object.keys(subject).forEach(function (issue, _, __) {
  31209. // pseudo-private values. skip those.
  31210. if (issue.charAt(0) === '_') return;
  31211. var to = typeof subject[issue];
  31212. if (to === 'function' || to === 'undefined') return;
  31213. analysis += issue;
  31214. psychoAnalyze(subject[issue], session + 1);
  31215. });
  31216. }
  31217. psychoAnalyze(subject, 0);
  31218. return analysis;
  31219. } // vim: set softtabstop=4 shiftwidth=4:
  31220. var fnmatch = createCommonjsModule(function (module, exports) {
  31221. // Based on minimatch.js by isaacs <https://npmjs.org/package/minimatch>
  31222. var platform = typeof process === "object" ? process.platform : "win32";
  31223. if (module) module.exports = minimatch;else exports.minimatch = minimatch;
  31224. minimatch.Minimatch = Minimatch;
  31225. var cache = minimatch.cache = new lruCache({
  31226. max: 100
  31227. }),
  31228. GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {};
  31229. var qmark = "[^/]" // * => any number of characters
  31230. ,
  31231. star = qmark + "*?" // ** when dots are allowed. Anything goes, except .. and .
  31232. // not (^ or / followed by one or two dots followed by $ or /),
  31233. // followed by anything, any number of times.
  31234. ,
  31235. twoStarDot = "(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?" // not a ^ or / followed by a dot,
  31236. // followed by anything, any number of times.
  31237. ,
  31238. twoStarNoDot = "(?:(?!(?:\\\/|^)\\.).)*?" // characters that need to be escaped in RegExp.
  31239. ,
  31240. reSpecials = charSet("().*{}+?[]^$\\!"); // "abc" -> { a:true, b:true, c:true }
  31241. function charSet(s) {
  31242. return s.split("").reduce(function (set, c) {
  31243. set[c] = true;
  31244. return set;
  31245. }, {});
  31246. } // normalizes slashes.
  31247. var slashSplit = /\/+/;
  31248. minimatch.monkeyPatch = monkeyPatch;
  31249. function monkeyPatch() {
  31250. var desc = Object.getOwnPropertyDescriptor(String.prototype, "match");
  31251. var orig = desc.value;
  31252. desc.value = function (p) {
  31253. if (p instanceof Minimatch) return p.match(this);
  31254. return orig.call(this, p);
  31255. };
  31256. Object.defineProperty(String.prototype, desc);
  31257. }
  31258. minimatch.filter = filter;
  31259. function filter(pattern, options) {
  31260. options = options || {};
  31261. return function (p, i, list) {
  31262. return minimatch(p, pattern, options);
  31263. };
  31264. }
  31265. function ext(a, b) {
  31266. a = a || {};
  31267. b = b || {};
  31268. var t = {};
  31269. Object.keys(b).forEach(function (k) {
  31270. t[k] = b[k];
  31271. });
  31272. Object.keys(a).forEach(function (k) {
  31273. t[k] = a[k];
  31274. });
  31275. return t;
  31276. }
  31277. minimatch.defaults = function (def) {
  31278. if (!def || !Object.keys(def).length) return minimatch;
  31279. var orig = minimatch;
  31280. var m = function minimatch(p, pattern, options) {
  31281. return orig.minimatch(p, pattern, ext(def, options));
  31282. };
  31283. m.Minimatch = function Minimatch(pattern, options) {
  31284. return new orig.Minimatch(pattern, ext(def, options));
  31285. };
  31286. return m;
  31287. };
  31288. Minimatch.defaults = function (def) {
  31289. if (!def || !Object.keys(def).length) return Minimatch;
  31290. return minimatch.defaults(def).Minimatch;
  31291. };
  31292. function minimatch(p, pattern, options) {
  31293. if (typeof pattern !== "string") {
  31294. throw new TypeError("glob pattern string required");
  31295. }
  31296. if (!options) options = {}; // shortcut: comments match nothing.
  31297. if (!options.nocomment && pattern.charAt(0) === "#") {
  31298. return false;
  31299. } // "" only matches ""
  31300. if (pattern.trim() === "") return p === "";
  31301. return new Minimatch(pattern, options).match(p);
  31302. }
  31303. function Minimatch(pattern, options) {
  31304. if (!(this instanceof Minimatch)) {
  31305. return new Minimatch(pattern, options, cache);
  31306. }
  31307. if (typeof pattern !== "string") {
  31308. throw new TypeError("glob pattern string required");
  31309. }
  31310. if (!options) options = {}; // windows: need to use /, not \
  31311. // On other platforms, \ is a valid (albeit bad) filename char.
  31312. if (platform === "win32") {
  31313. pattern = pattern.split("\\").join("/");
  31314. } // lru storage.
  31315. // these things aren't particularly big, but walking down the string
  31316. // and turning it into a regexp can get pretty costly.
  31317. var cacheKey = pattern + "\n" + sigmund_1(options);
  31318. var cached = minimatch.cache.get(cacheKey);
  31319. if (cached) return cached;
  31320. minimatch.cache.set(cacheKey, this);
  31321. this.options = options;
  31322. this.set = [];
  31323. this.pattern = pattern;
  31324. this.regexp = null;
  31325. this.negate = false;
  31326. this.comment = false;
  31327. this.empty = false; // make the set of regexps etc.
  31328. this.make();
  31329. }
  31330. Minimatch.prototype.make = make;
  31331. function make() {
  31332. // don't do it more than once.
  31333. if (this._made) return;
  31334. var pattern = this.pattern;
  31335. var options = this.options; // empty patterns and comments match nothing.
  31336. if (!options.nocomment && pattern.charAt(0) === "#") {
  31337. this.comment = true;
  31338. return;
  31339. }
  31340. if (!pattern) {
  31341. this.empty = true;
  31342. return;
  31343. } // step 1: figure out negation, etc.
  31344. this.parseNegate(); // step 2: expand braces
  31345. var set = this.globSet = this.braceExpand();
  31346. if (options.debug) console.error(this.pattern, set); // step 3: now we have a set, so turn each one into a series of path-portion
  31347. // matching patterns.
  31348. // These will be regexps, except in the case of "**", which is
  31349. // set to the GLOBSTAR object for globstar behavior,
  31350. // and will not contain any / characters
  31351. set = this.globParts = set.map(function (s) {
  31352. return s.split(slashSplit);
  31353. });
  31354. if (options.debug) console.error(this.pattern, set); // glob --> regexps
  31355. set = set.map(function (s, si, set) {
  31356. return s.map(this.parse, this);
  31357. }, this);
  31358. if (options.debug) console.error(this.pattern, set); // filter out everything that didn't compile properly.
  31359. set = set.filter(function (s) {
  31360. return -1 === s.indexOf(false);
  31361. });
  31362. if (options.debug) console.error(this.pattern, set);
  31363. this.set = set;
  31364. }
  31365. Minimatch.prototype.parseNegate = parseNegate;
  31366. function parseNegate() {
  31367. var pattern = this.pattern,
  31368. negate = false,
  31369. options = this.options,
  31370. negateOffset = 0;
  31371. if (options.nonegate) return;
  31372. for (var i = 0, l = pattern.length; i < l && pattern.charAt(i) === "!"; i++) {
  31373. negate = !negate;
  31374. negateOffset++;
  31375. }
  31376. if (negateOffset) this.pattern = pattern.substr(negateOffset);
  31377. this.negate = negate;
  31378. } // Brace expansion:
  31379. // a{b,c}d -> abd acd
  31380. // a{b,}c -> abc ac
  31381. // a{0..3}d -> a0d a1d a2d a3d
  31382. // a{b,c{d,e}f}g -> abg acdfg acefg
  31383. // a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg
  31384. //
  31385. // Invalid sets are not expanded.
  31386. // a{2..}b -> a{2..}b
  31387. // a{b}c -> a{b}c
  31388. minimatch.braceExpand = function (pattern, options) {
  31389. return new Minimatch(pattern, options).braceExpand();
  31390. };
  31391. Minimatch.prototype.braceExpand = braceExpand;
  31392. function braceExpand(pattern, options) {
  31393. options = options || this.options;
  31394. pattern = typeof pattern === "undefined" ? this.pattern : pattern;
  31395. if (typeof pattern === "undefined") {
  31396. throw new Error("undefined pattern");
  31397. }
  31398. if (options.nobrace || !pattern.match(/\{.*\}/)) {
  31399. // shortcut. no need to expand.
  31400. return [pattern];
  31401. }
  31402. var escaping = false; // examples and comments refer to this crazy pattern:
  31403. // a{b,c{d,e},{f,g}h}x{y,z}
  31404. // expected:
  31405. // abxy
  31406. // abxz
  31407. // acdxy
  31408. // acdxz
  31409. // acexy
  31410. // acexz
  31411. // afhxy
  31412. // afhxz
  31413. // aghxy
  31414. // aghxz
  31415. // everything before the first \{ is just a prefix.
  31416. // So, we pluck that off, and work with the rest,
  31417. // and then prepend it to everything we find.
  31418. if (pattern.charAt(0) !== "{") {
  31419. // console.error(pattern)
  31420. var prefix = null;
  31421. for (var i = 0, l = pattern.length; i < l; i++) {
  31422. var c = pattern.charAt(i); // console.error(i, c)
  31423. if (c === "\\") {
  31424. escaping = !escaping;
  31425. } else if (c === "{" && !escaping) {
  31426. prefix = pattern.substr(0, i);
  31427. break;
  31428. }
  31429. } // actually no sets, all { were escaped.
  31430. if (prefix === null) {
  31431. // console.error("no sets")
  31432. return [pattern];
  31433. }
  31434. var tail = braceExpand(pattern.substr(i), options);
  31435. return tail.map(function (t) {
  31436. return prefix + t;
  31437. });
  31438. } // now we have something like:
  31439. // {b,c{d,e},{f,g}h}x{y,z}
  31440. // walk through the set, expanding each part, until
  31441. // the set ends. then, we'll expand the suffix.
  31442. // If the set only has a single member, then'll put the {} back
  31443. // first, handle numeric sets, since they're easier
  31444. var numset = pattern.match(/^\{(-?[0-9]+)\.\.(-?[0-9]+)\}/);
  31445. if (numset) {
  31446. // console.error("numset", numset[1], numset[2])
  31447. var suf = braceExpand(pattern.substr(numset[0].length), options),
  31448. start = +numset[1],
  31449. end = +numset[2],
  31450. inc = start > end ? -1 : 1,
  31451. set = [];
  31452. for (var i = start; i != end + inc; i += inc) {
  31453. // append all the suffixes
  31454. for (var ii = 0, ll = suf.length; ii < ll; ii++) {
  31455. set.push(i + suf[ii]);
  31456. }
  31457. }
  31458. return set;
  31459. } // ok, walk through the set
  31460. // We hope, somewhat optimistically, that there
  31461. // will be a } at the end.
  31462. // If the closing brace isn't found, then the pattern is
  31463. // interpreted as braceExpand("\\" + pattern) so that
  31464. // the leading \{ will be interpreted literally.
  31465. var i = 1 // skip the \{
  31466. ,
  31467. depth = 1,
  31468. set = [],
  31469. member = "",
  31470. sawEnd = false,
  31471. escaping = false;
  31472. function addMember() {
  31473. set.push(member);
  31474. member = "";
  31475. } // console.error("Entering for")
  31476. FOR: for (i = 1, l = pattern.length; i < l; i++) {
  31477. var c = pattern.charAt(i); // console.error("", i, c)
  31478. if (escaping) {
  31479. escaping = false;
  31480. member += "\\" + c;
  31481. } else {
  31482. switch (c) {
  31483. case "\\":
  31484. escaping = true;
  31485. continue;
  31486. case "{":
  31487. depth++;
  31488. member += "{";
  31489. continue;
  31490. case "}":
  31491. depth--; // if this closes the actual set, then we're done
  31492. if (depth === 0) {
  31493. addMember(); // pluck off the close-brace
  31494. i++;
  31495. break FOR;
  31496. } else {
  31497. member += c;
  31498. continue;
  31499. }
  31500. case ",":
  31501. if (depth === 1) {
  31502. addMember();
  31503. } else {
  31504. member += c;
  31505. }
  31506. continue;
  31507. default:
  31508. member += c;
  31509. continue;
  31510. } // switch
  31511. } // else
  31512. } // for
  31513. // now we've either finished the set, and the suffix is
  31514. // pattern.substr(i), or we have *not* closed the set,
  31515. // and need to escape the leading brace
  31516. if (depth !== 0) {
  31517. // console.error("didn't close", pattern)
  31518. return braceExpand("\\" + pattern, options);
  31519. } // x{y,z} -> ["xy", "xz"]
  31520. // console.error("set", set)
  31521. // console.error("suffix", pattern.substr(i))
  31522. var suf = braceExpand(pattern.substr(i), options); // ["b", "c{d,e}","{f,g}h"] ->
  31523. // [["b"], ["cd", "ce"], ["fh", "gh"]]
  31524. var addBraces = set.length === 1; // console.error("set pre-expanded", set)
  31525. set = set.map(function (p) {
  31526. return braceExpand(p, options);
  31527. }); // console.error("set expanded", set)
  31528. // [["b"], ["cd", "ce"], ["fh", "gh"]] ->
  31529. // ["b", "cd", "ce", "fh", "gh"]
  31530. set = set.reduce(function (l, r) {
  31531. return l.concat(r);
  31532. });
  31533. if (addBraces) {
  31534. set = set.map(function (s) {
  31535. return "{" + s + "}";
  31536. });
  31537. } // now attach the suffixes.
  31538. var ret = [];
  31539. for (var i = 0, l = set.length; i < l; i++) {
  31540. for (var ii = 0, ll = suf.length; ii < ll; ii++) {
  31541. ret.push(set[i] + suf[ii]);
  31542. }
  31543. }
  31544. return ret;
  31545. } // parse a component of the expanded set.
  31546. // At this point, no pattern may contain "/" in it
  31547. // so we're going to return a 2d array, where each entry is the full
  31548. // pattern, split on '/', and then turned into a regular expression.
  31549. // A regexp is made at the end which joins each array with an
  31550. // escaped /, and another full one which joins each regexp with |.
  31551. //
  31552. // Following the lead of Bash 4.1, note that "**" only has special meaning
  31553. // when it is the *only* thing in a path portion. Otherwise, any series
  31554. // of * is equivalent to a single *. Globstar behavior is enabled by
  31555. // default, and can be disabled by setting options.noglobstar.
  31556. Minimatch.prototype.parse = parse;
  31557. var SUBPARSE = {};
  31558. function parse(pattern, isSub) {
  31559. var options = this.options; // shortcuts
  31560. if (!options.noglobstar && pattern === "**") return GLOBSTAR;
  31561. if (pattern === "") return "";
  31562. var re = "",
  31563. hasMagic = !!options.nocase,
  31564. escaping = false // ? => one single character
  31565. ,
  31566. patternListStack = [],
  31567. plType,
  31568. stateChar,
  31569. inClass = false,
  31570. reClassStart = -1,
  31571. classStart = -1 // . and .. never match anything that doesn't start with .,
  31572. // even when options.dot is set.
  31573. ,
  31574. patternStart = pattern.charAt(0) === "." ? "" // anything
  31575. // not (start or / followed by . or .. followed by / or end)
  31576. : options.dot ? "(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))" : "(?!\\.)";
  31577. function clearStateChar() {
  31578. if (stateChar) {
  31579. // we had some state-tracking character
  31580. // that wasn't consumed by this pass.
  31581. switch (stateChar) {
  31582. case "*":
  31583. re += star;
  31584. hasMagic = true;
  31585. break;
  31586. case "?":
  31587. re += qmark;
  31588. hasMagic = true;
  31589. break;
  31590. default:
  31591. re += "\\" + stateChar;
  31592. break;
  31593. }
  31594. stateChar = false;
  31595. }
  31596. }
  31597. for (var i = 0, len = pattern.length, c; i < len && (c = pattern.charAt(i)); i++) {
  31598. if (options.debug) {
  31599. console.error("%s\t%s %s %j", pattern, i, re, c);
  31600. } // skip over any that are escaped.
  31601. if (escaping && reSpecials[c]) {
  31602. re += "\\" + c;
  31603. escaping = false;
  31604. continue;
  31605. }
  31606. SWITCH: switch (c) {
  31607. case "/":
  31608. // completely not allowed, even escaped.
  31609. // Should already be path-split by now.
  31610. return false;
  31611. case "\\":
  31612. clearStateChar();
  31613. escaping = true;
  31614. continue;
  31615. // the various stateChar values
  31616. // for the "extglob" stuff.
  31617. case "?":
  31618. case "*":
  31619. case "+":
  31620. case "@":
  31621. case "!":
  31622. if (options.debug) {
  31623. console.error("%s\t%s %s %j <-- stateChar", pattern, i, re, c);
  31624. } // all of those are literals inside a class, except that
  31625. // the glob [!a] means [^a] in regexp
  31626. if (inClass) {
  31627. if (c === "!" && i === classStart + 1) c = "^";
  31628. re += c;
  31629. continue;
  31630. } // if we already have a stateChar, then it means
  31631. // that there was something like ** or +? in there.
  31632. // Handle the stateChar, then proceed with this one.
  31633. clearStateChar();
  31634. stateChar = c; // if extglob is disabled, then +(asdf|foo) isn't a thing.
  31635. // just clear the statechar *now*, rather than even diving into
  31636. // the patternList stuff.
  31637. if (options.noext) clearStateChar();
  31638. continue;
  31639. case "(":
  31640. if (inClass) {
  31641. re += "(";
  31642. continue;
  31643. }
  31644. if (!stateChar) {
  31645. re += "\\(";
  31646. continue;
  31647. }
  31648. plType = stateChar;
  31649. patternListStack.push({
  31650. type: plType,
  31651. start: i - 1,
  31652. reStart: re.length
  31653. }); // negation is (?:(?!js)[^/]*)
  31654. re += stateChar === "!" ? "(?:(?!" : "(?:";
  31655. stateChar = false;
  31656. continue;
  31657. case ")":
  31658. if (inClass || !patternListStack.length) {
  31659. re += "\\)";
  31660. continue;
  31661. }
  31662. hasMagic = true;
  31663. re += ")";
  31664. plType = patternListStack.pop().type; // negation is (?:(?!js)[^/]*)
  31665. // The others are (?:<pattern>)<type>
  31666. switch (plType) {
  31667. case "!":
  31668. re += "[^/]*?)";
  31669. break;
  31670. case "?":
  31671. case "+":
  31672. case "*":
  31673. re += plType;
  31674. case "@":
  31675. break;
  31676. // the default anyway
  31677. }
  31678. continue;
  31679. case "|":
  31680. if (inClass || !patternListStack.length || escaping) {
  31681. re += "\\|";
  31682. escaping = false;
  31683. continue;
  31684. }
  31685. re += "|";
  31686. continue;
  31687. // these are mostly the same in regexp and glob
  31688. case "[":
  31689. // swallow any state-tracking char before the [
  31690. clearStateChar();
  31691. if (inClass) {
  31692. re += "\\" + c;
  31693. continue;
  31694. }
  31695. inClass = true;
  31696. classStart = i;
  31697. reClassStart = re.length;
  31698. re += c;
  31699. continue;
  31700. case "]":
  31701. // a right bracket shall lose its special
  31702. // meaning and represent itself in
  31703. // a bracket expression if it occurs
  31704. // first in the list. -- POSIX.2 2.8.3.2
  31705. if (i === classStart + 1 || !inClass) {
  31706. re += "\\" + c;
  31707. escaping = false;
  31708. continue;
  31709. } // finish up the class.
  31710. hasMagic = true;
  31711. inClass = false;
  31712. re += c;
  31713. continue;
  31714. default:
  31715. // swallow any state char that wasn't consumed
  31716. clearStateChar();
  31717. if (escaping) {
  31718. // no need
  31719. escaping = false;
  31720. } else if (reSpecials[c] && !(c === "^" && inClass)) {
  31721. re += "\\";
  31722. }
  31723. re += c;
  31724. } // switch
  31725. } // for
  31726. // handle the case where we left a class open.
  31727. // "[abc" is valid, equivalent to "\[abc"
  31728. if (inClass) {
  31729. // split where the last [ was, and escape it
  31730. // this is a huge pita. We now have to re-walk
  31731. // the contents of the would-be class to re-translate
  31732. // any characters that were passed through as-is
  31733. var cs = pattern.substr(classStart + 1),
  31734. sp = this.parse(cs, SUBPARSE);
  31735. re = re.substr(0, reClassStart) + "\\[" + sp[0];
  31736. hasMagic = hasMagic || sp[1];
  31737. } // handle the case where we had a +( thing at the *end*
  31738. // of the pattern.
  31739. // each pattern list stack adds 3 chars, and we need to go through
  31740. // and escape any | chars that were passed through as-is for the regexp.
  31741. // Go through and escape them, taking care not to double-escape any
  31742. // | chars that were already escaped.
  31743. var pl;
  31744. while (pl = patternListStack.pop()) {
  31745. var tail = re.slice(pl.reStart + 3); // maybe some even number of \, then maybe 1 \, followed by a |
  31746. tail = tail.replace(/((?:\\{2})*)(\\?)\|/g, function (_, $1, $2) {
  31747. if (!$2) {
  31748. // the | isn't already escaped, so escape it.
  31749. $2 = "\\";
  31750. } // need to escape all those slashes *again*, without escaping the
  31751. // one that we need for escaping the | character. As it works out,
  31752. // escaping an even number of slashes can be done by simply repeating
  31753. // it exactly after itself. That's why this trick works.
  31754. //
  31755. // I am sorry that you have to see this.
  31756. return $1 + $1 + $2 + "|";
  31757. }); // console.error("tail=%j\n %s", tail, tail)
  31758. var t = pl.type === "*" ? star : pl.type === "?" ? qmark : "\\" + pl.type;
  31759. hasMagic = true;
  31760. re = re.slice(0, pl.reStart) + t + "\\(" + tail;
  31761. } // handle trailing things that only matter at the very end.
  31762. clearStateChar();
  31763. if (escaping) {
  31764. // trailing \\
  31765. re += "\\\\";
  31766. } // only need to apply the nodot start if the re starts with
  31767. // something that could conceivably capture a dot
  31768. var addPatternStart = false;
  31769. switch (re.charAt(0)) {
  31770. case ".":
  31771. case "[":
  31772. case "(":
  31773. addPatternStart = true;
  31774. } // if the re is not "" at this point, then we need to make sure
  31775. // it doesn't match against an empty path part.
  31776. // Otherwise a/* will match a/, which it should not.
  31777. if (re !== "" && hasMagic) re = "(?=.)" + re;
  31778. if (addPatternStart) re = patternStart + re; // parsing just a piece of a larger pattern.
  31779. if (isSub === SUBPARSE) {
  31780. return [re, hasMagic];
  31781. } // skip the regexp for non-magical patterns
  31782. // unescape anything in it, though, so that it'll be
  31783. // an exact match against a file etc.
  31784. if (!hasMagic) {
  31785. return globUnescape(pattern);
  31786. }
  31787. var flags = options.nocase ? "i" : "",
  31788. regExp = new RegExp("^" + re + "$", flags);
  31789. regExp._glob = pattern;
  31790. regExp._src = re;
  31791. return regExp;
  31792. }
  31793. minimatch.makeRe = function (pattern, options) {
  31794. return new Minimatch(pattern, options || {}).makeRe();
  31795. };
  31796. Minimatch.prototype.makeRe = makeRe;
  31797. function makeRe() {
  31798. if (this.regexp || this.regexp === false) return this.regexp; // at this point, this.set is a 2d array of partial
  31799. // pattern strings, or "**".
  31800. //
  31801. // It's better to use .match(). This function shouldn't
  31802. // be used, really, but it's pretty convenient sometimes,
  31803. // when you just want to work with a regex.
  31804. var set = this.set;
  31805. if (!set.length) return this.regexp = false;
  31806. var options = this.options;
  31807. var twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot,
  31808. flags = options.nocase ? "i" : "";
  31809. var re = set.map(function (pattern) {
  31810. return pattern.map(function (p) {
  31811. return p === GLOBSTAR ? twoStar : typeof p === "string" ? regExpEscape(p) : p._src;
  31812. }).join("\\\/");
  31813. }).join("|"); // must match entire pattern
  31814. // ending in a * or ** will make it less strict.
  31815. re = "^(?:" + re + ")$"; // can match anything, as long as it's not this.
  31816. if (this.negate) re = "^(?!" + re + ").*$";
  31817. try {
  31818. return this.regexp = new RegExp(re, flags);
  31819. } catch (ex) {
  31820. return this.regexp = false;
  31821. }
  31822. }
  31823. minimatch.match = function (list, pattern, options) {
  31824. var mm = new Minimatch(pattern, options);
  31825. list = list.filter(function (f) {
  31826. return mm.match(f);
  31827. });
  31828. if (options.nonull && !list.length) {
  31829. list.push(pattern);
  31830. }
  31831. return list;
  31832. };
  31833. Minimatch.prototype.match = match;
  31834. function match(f, partial) {
  31835. // console.error("match", f, this.pattern)
  31836. // short-circuit in the case of busted things.
  31837. // comments, etc.
  31838. if (this.comment) return false;
  31839. if (this.empty) return f === "";
  31840. if (f === "/" && partial) return true;
  31841. var options = this.options; // windows: need to use /, not \
  31842. // On other platforms, \ is a valid (albeit bad) filename char.
  31843. if (platform === "win32") {
  31844. f = f.split("\\").join("/");
  31845. } // treat the test path as a set of pathparts.
  31846. f = f.split(slashSplit);
  31847. if (options.debug) {
  31848. console.error(this.pattern, "split", f);
  31849. } // just ONE of the pattern sets in this.set needs to match
  31850. // in order for it to be valid. If negating, then just one
  31851. // match means that we have failed.
  31852. // Either way, return on the first hit.
  31853. var set = this.set; // console.error(this.pattern, "set", set)
  31854. for (var i = 0, l = set.length; i < l; i++) {
  31855. var pattern = set[i];
  31856. var hit = this.matchOne(f, pattern, partial);
  31857. if (hit) {
  31858. if (options.flipNegate) return true;
  31859. return !this.negate;
  31860. }
  31861. } // didn't get any hits. this is success if it's a negative
  31862. // pattern, failure otherwise.
  31863. if (options.flipNegate) return false;
  31864. return this.negate;
  31865. } // set partial to true to test if, for example,
  31866. // "/a/b" matches the start of "/*/b/*/d"
  31867. // Partial means, if you run out of file before you run
  31868. // out of pattern, then that's fine, as long as all
  31869. // the parts match.
  31870. Minimatch.prototype.matchOne = function (file, pattern, partial) {
  31871. var options = this.options;
  31872. if (options.debug) {
  31873. console.error("matchOne", {
  31874. "this": this,
  31875. file: file,
  31876. pattern: pattern
  31877. });
  31878. }
  31879. if (options.matchBase && pattern.length === 1) {
  31880. file = path.basename(file.join("/")).split("/");
  31881. }
  31882. if (options.debug) {
  31883. console.error("matchOne", file.length, pattern.length);
  31884. }
  31885. for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
  31886. if (options.debug) {
  31887. console.error("matchOne loop");
  31888. }
  31889. var p = pattern[pi],
  31890. f = file[fi];
  31891. if (options.debug) {
  31892. console.error(pattern, p, f);
  31893. } // should be impossible.
  31894. // some invalid regexp stuff in the set.
  31895. if (p === false) return false;
  31896. if (p === GLOBSTAR) {
  31897. if (options.debug) console.error('GLOBSTAR', [pattern, p, f]); // "**"
  31898. // a/**/b/**/c would match the following:
  31899. // a/b/x/y/z/c
  31900. // a/x/y/z/b/c
  31901. // a/b/x/b/x/c
  31902. // a/b/c
  31903. // To do this, take the rest of the pattern after
  31904. // the **, and see if it would match the file remainder.
  31905. // If so, return success.
  31906. // If not, the ** "swallows" a segment, and try again.
  31907. // This is recursively awful.
  31908. //
  31909. // a/**/b/**/c matching a/b/x/y/z/c
  31910. // - a matches a
  31911. // - doublestar
  31912. // - matchOne(b/x/y/z/c, b/**/c)
  31913. // - b matches b
  31914. // - doublestar
  31915. // - matchOne(x/y/z/c, c) -> no
  31916. // - matchOne(y/z/c, c) -> no
  31917. // - matchOne(z/c, c) -> no
  31918. // - matchOne(c, c) yes, hit
  31919. var fr = fi,
  31920. pr = pi + 1;
  31921. if (pr === pl) {
  31922. if (options.debug) console.error('** at the end'); // a ** at the end will just swallow the rest.
  31923. // We have found a match.
  31924. // however, it will not swallow /.x, unless
  31925. // options.dot is set.
  31926. // . and .. are *never* matched by **, for explosively
  31927. // exponential reasons.
  31928. for (; fi < fl; fi++) {
  31929. if (file[fi] === "." || file[fi] === ".." || !options.dot && file[fi].charAt(0) === ".") return false;
  31930. }
  31931. return true;
  31932. } // ok, let's see if we can swallow whatever we can.
  31933. WHILE: while (fr < fl) {
  31934. var swallowee = file[fr];
  31935. if (options.debug) {
  31936. console.error('\nglobstar while', file, fr, pattern, pr, swallowee);
  31937. } // XXX remove this slice. Just pass the start index.
  31938. if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
  31939. if (options.debug) console.error('globstar found match!', fr, fl, swallowee); // found a match.
  31940. return true;
  31941. } else {
  31942. // can't swallow "." or ".." ever.
  31943. // can only swallow ".foo" when explicitly asked.
  31944. if (swallowee === "." || swallowee === ".." || !options.dot && swallowee.charAt(0) === ".") {
  31945. if (options.debug) console.error("dot detected!", file, fr, pattern, pr);
  31946. break WHILE;
  31947. } // ** swallows a segment, and continue.
  31948. if (options.debug) console.error('globstar swallow a segment, and continue');
  31949. fr++;
  31950. }
  31951. } // no match was found.
  31952. // However, in partial mode, we can't say this is necessarily over.
  31953. // If there's more *pattern* left, then
  31954. if (partial) {
  31955. // ran out of file
  31956. // console.error("\n>>> no match, partial?", file, fr, pattern, pr)
  31957. if (fr === fl) return true;
  31958. }
  31959. return false;
  31960. } // something other than **
  31961. // non-magic patterns just have to match exactly
  31962. // patterns with magic have been turned into regexps.
  31963. var hit;
  31964. if (typeof p === "string") {
  31965. if (options.nocase) {
  31966. hit = f.toLowerCase() === p.toLowerCase();
  31967. } else {
  31968. hit = f === p;
  31969. }
  31970. if (options.debug) {
  31971. console.error("string match", p, f, hit);
  31972. }
  31973. } else {
  31974. hit = f.match(p);
  31975. if (options.debug) {
  31976. console.error("pattern match", p, f, hit);
  31977. }
  31978. }
  31979. if (!hit) return false;
  31980. } // Note: ending in / means that we'll get a final ""
  31981. // at the end of the pattern. This can only match a
  31982. // corresponding "" at the end of the file.
  31983. // If the file ends in /, then it can only match a
  31984. // a pattern that ends in /, unless the pattern just
  31985. // doesn't have any more for it. But, a/b/ should *not*
  31986. // match "a/b/*", even though "" matches against the
  31987. // [^/]*? pattern, except in partial mode, where it might
  31988. // simply not be reached yet.
  31989. // However, a/b/ should still satisfy a/*
  31990. // now either we fell off the end of the pattern, or we're done.
  31991. if (fi === fl && pi === pl) {
  31992. // ran out of pattern and filename at the same time.
  31993. // an exact hit!
  31994. return true;
  31995. } else if (fi === fl) {
  31996. // ran out of file, but still had pattern left.
  31997. // this is ok if we're doing the match as part of
  31998. // a glob fs traversal.
  31999. return partial;
  32000. } else if (pi === pl) {
  32001. // ran out of pattern, still have file left.
  32002. // this is only acceptable if we're on the very last
  32003. // empty segment of a file with a trailing slash.
  32004. // a/* should match a/b/
  32005. var emptyFileEnd = fi === fl - 1 && file[fi] === "";
  32006. return emptyFileEnd;
  32007. } // should be unreachable.
  32008. throw new Error("wtf?");
  32009. }; // replace stuff like \* with *
  32010. function globUnescape(s) {
  32011. return s.replace(/\\(.)/g, "$1");
  32012. }
  32013. function regExpEscape(s) {
  32014. return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
  32015. }
  32016. });
  32017. var ini = createCommonjsModule(function (module, exports) {
  32018. "use strict"; // Based on iniparser by shockie <https://npmjs.org/package/iniparser>
  32019. var __awaiter = commonjsGlobal && commonjsGlobal.__awaiter || function (thisArg, _arguments, P, generator) {
  32020. return new (P || (P = Promise))(function (resolve, reject) {
  32021. function fulfilled(value) {
  32022. try {
  32023. step(generator.next(value));
  32024. } catch (e) {
  32025. reject(e);
  32026. }
  32027. }
  32028. function rejected(value) {
  32029. try {
  32030. step(generator["throw"](value));
  32031. } catch (e) {
  32032. reject(e);
  32033. }
  32034. }
  32035. function step(result) {
  32036. result.done ? resolve(result.value) : new P(function (resolve) {
  32037. resolve(result.value);
  32038. }).then(fulfilled, rejected);
  32039. }
  32040. step((generator = generator.apply(thisArg, _arguments || [])).next());
  32041. });
  32042. };
  32043. var __generator = commonjsGlobal && commonjsGlobal.__generator || function (thisArg, body) {
  32044. var _ = {
  32045. label: 0,
  32046. sent: function sent() {
  32047. if (t[0] & 1) throw t[1];
  32048. return t[1];
  32049. },
  32050. trys: [],
  32051. ops: []
  32052. },
  32053. f,
  32054. y,
  32055. t,
  32056. g;
  32057. return g = {
  32058. next: verb(0),
  32059. "throw": verb(1),
  32060. "return": verb(2)
  32061. }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
  32062. return this;
  32063. }), g;
  32064. function verb(n) {
  32065. return function (v) {
  32066. return step([n, v]);
  32067. };
  32068. }
  32069. function step(op) {
  32070. if (f) throw new TypeError("Generator is already executing.");
  32071. while (_) {
  32072. try {
  32073. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  32074. if (y = 0, t) op = [op[0] & 2, t.value];
  32075. switch (op[0]) {
  32076. case 0:
  32077. case 1:
  32078. t = op;
  32079. break;
  32080. case 4:
  32081. _.label++;
  32082. return {
  32083. value: op[1],
  32084. done: false
  32085. };
  32086. case 5:
  32087. _.label++;
  32088. y = op[1];
  32089. op = [0];
  32090. continue;
  32091. case 7:
  32092. op = _.ops.pop();
  32093. _.trys.pop();
  32094. continue;
  32095. default:
  32096. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
  32097. _ = 0;
  32098. continue;
  32099. }
  32100. if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
  32101. _.label = op[1];
  32102. break;
  32103. }
  32104. if (op[0] === 6 && _.label < t[1]) {
  32105. _.label = t[1];
  32106. t = op;
  32107. break;
  32108. }
  32109. if (t && _.label < t[2]) {
  32110. _.label = t[2];
  32111. _.ops.push(op);
  32112. break;
  32113. }
  32114. if (t[2]) _.ops.pop();
  32115. _.trys.pop();
  32116. continue;
  32117. }
  32118. op = body.call(thisArg, _);
  32119. } catch (e) {
  32120. op = [6, e];
  32121. y = 0;
  32122. } finally {
  32123. f = t = 0;
  32124. }
  32125. }
  32126. if (op[0] & 5) throw op[1];
  32127. return {
  32128. value: op[0] ? op[1] : void 0,
  32129. done: true
  32130. };
  32131. }
  32132. };
  32133. var __importStar = commonjsGlobal && commonjsGlobal.__importStar || function (mod) {
  32134. if (mod && mod.__esModule) return mod;
  32135. var result = {};
  32136. if (mod != null) for (var k in mod) {
  32137. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  32138. }
  32139. result["default"] = mod;
  32140. return result;
  32141. };
  32142. Object.defineProperty(exports, "__esModule", {
  32143. value: true
  32144. });
  32145. var fs$$2 = __importStar(fs);
  32146. /**
  32147. * define the possible values:
  32148. * section: [section]
  32149. * param: key=value
  32150. * comment: ;this is a comment
  32151. */
  32152. var regex = {
  32153. section: /^\s*\[(([^#;]|\\#|\\;)+)\]\s*([#;].*)?$/,
  32154. param: /^\s*([\w\.\-\_]+)\s*[=:]\s*(.*?)\s*([#;].*)?$/,
  32155. comment: /^\s*[#;].*$/
  32156. };
  32157. /**
  32158. * Parses an .ini file
  32159. * @param file The location of the .ini file
  32160. */
  32161. function parse(file) {
  32162. return __awaiter(this, void 0, void 0, function () {
  32163. return __generator(this, function (_a) {
  32164. return [2
  32165. /*return*/
  32166. , new Promise(function (resolve, reject) {
  32167. fs$$2.readFile(file, 'utf8', function (err, data) {
  32168. if (err) {
  32169. reject(err);
  32170. return;
  32171. }
  32172. resolve(parseString(data));
  32173. });
  32174. })];
  32175. });
  32176. });
  32177. }
  32178. exports.parse = parse;
  32179. function parseSync(file) {
  32180. return parseString(fs$$2.readFileSync(file, 'utf8'));
  32181. }
  32182. exports.parseSync = parseSync;
  32183. function parseString(data) {
  32184. var sectionBody = {};
  32185. var sectionName = null;
  32186. var value = [[sectionName, sectionBody]];
  32187. var lines = data.split(/\r\n|\r|\n/);
  32188. lines.forEach(function (line) {
  32189. var match;
  32190. if (regex.comment.test(line)) {
  32191. return;
  32192. }
  32193. if (regex.param.test(line)) {
  32194. match = line.match(regex.param);
  32195. sectionBody[match[1]] = match[2];
  32196. } else if (regex.section.test(line)) {
  32197. match = line.match(regex.section);
  32198. sectionName = match[1];
  32199. sectionBody = {};
  32200. value.push([sectionName, sectionBody]);
  32201. }
  32202. });
  32203. return value;
  32204. }
  32205. exports.parseString = parseString;
  32206. });
  32207. unwrapExports(ini);
  32208. var name$17 = "editorconfig";
  32209. var version$3 = "0.15.2";
  32210. var description$1 = "EditorConfig File Locator and Interpreter for Node.js";
  32211. var keywords = ["editorconfig", "core"];
  32212. var main$1 = "src/index.js";
  32213. var contributors = ["Hong Xu (topbug.net)", "Jed Mao (https://github.com/jedmao/)", "Trey Hunner (http://treyhunner.com)"];
  32214. var directories = {
  32215. "bin": "./bin",
  32216. "lib": "./lib"
  32217. };
  32218. var scripts$1 = {
  32219. "clean": "rimraf dist",
  32220. "prebuild": "npm run clean",
  32221. "build": "tsc",
  32222. "pretest": "npm run lint && npm run build && npm run copy && cmake .",
  32223. "test": "ctest .",
  32224. "pretest:ci": "npm run pretest",
  32225. "test:ci": "ctest -VV --output-on-failure .",
  32226. "lint": "npm run eclint && npm run tslint",
  32227. "eclint": "eclint check --indent_size ignore \"src/**\"",
  32228. "tslint": "tslint --project tsconfig.json --exclude package.json",
  32229. "copy": "cpy .npmignore LICENSE README.md CHANGELOG.md dist && cpy bin/* dist/bin && cpy src/lib/fnmatch*.* dist/src/lib",
  32230. "prepub": "npm run lint && npm run build && npm run copy",
  32231. "pub": "npm publish ./dist"
  32232. };
  32233. var repository$1 = {
  32234. "type": "git",
  32235. "url": "git://github.com/editorconfig/editorconfig-core-js.git"
  32236. };
  32237. var bugs = "https://github.com/editorconfig/editorconfig-core-js/issues";
  32238. var author$1 = "EditorConfig Team";
  32239. var license$1 = "MIT";
  32240. var dependencies$1 = {
  32241. "@types/node": "^10.11.7",
  32242. "@types/semver": "^5.5.0",
  32243. "commander": "^2.19.0",
  32244. "lru-cache": "^4.1.3",
  32245. "semver": "^5.6.0",
  32246. "sigmund": "^1.0.1"
  32247. };
  32248. var devDependencies$1 = {
  32249. "@types/mocha": "^5.2.5",
  32250. "cpy-cli": "^2.0.0",
  32251. "eclint": "^2.8.0",
  32252. "mocha": "^5.2.0",
  32253. "rimraf": "^2.6.2",
  32254. "should": "^13.2.3",
  32255. "tslint": "^5.11.0",
  32256. "typescript": "^3.1.3"
  32257. };
  32258. var _package$2 = {
  32259. name: name$17,
  32260. version: version$3,
  32261. description: description$1,
  32262. keywords: keywords,
  32263. main: main$1,
  32264. contributors: contributors,
  32265. directories: directories,
  32266. scripts: scripts$1,
  32267. repository: repository$1,
  32268. bugs: bugs,
  32269. author: author$1,
  32270. license: license$1,
  32271. dependencies: dependencies$1,
  32272. devDependencies: devDependencies$1
  32273. };
  32274. var _package$3 = Object.freeze({
  32275. name: name$17,
  32276. version: version$3,
  32277. description: description$1,
  32278. keywords: keywords,
  32279. main: main$1,
  32280. contributors: contributors,
  32281. directories: directories,
  32282. scripts: scripts$1,
  32283. repository: repository$1,
  32284. bugs: bugs,
  32285. author: author$1,
  32286. license: license$1,
  32287. dependencies: dependencies$1,
  32288. devDependencies: devDependencies$1,
  32289. default: _package$2
  32290. });
  32291. var require$$4$6 = ( _package$3 && _package$2 ) || _package$3;
  32292. var src$2 = createCommonjsModule(function (module, exports) {
  32293. "use strict";
  32294. var __awaiter = commonjsGlobal && commonjsGlobal.__awaiter || function (thisArg, _arguments, P, generator) {
  32295. return new (P || (P = Promise))(function (resolve, reject) {
  32296. function fulfilled(value) {
  32297. try {
  32298. step(generator.next(value));
  32299. } catch (e) {
  32300. reject(e);
  32301. }
  32302. }
  32303. function rejected(value) {
  32304. try {
  32305. step(generator["throw"](value));
  32306. } catch (e) {
  32307. reject(e);
  32308. }
  32309. }
  32310. function step(result) {
  32311. result.done ? resolve(result.value) : new P(function (resolve) {
  32312. resolve(result.value);
  32313. }).then(fulfilled, rejected);
  32314. }
  32315. step((generator = generator.apply(thisArg, _arguments || [])).next());
  32316. });
  32317. };
  32318. var __generator = commonjsGlobal && commonjsGlobal.__generator || function (thisArg, body) {
  32319. var _ = {
  32320. label: 0,
  32321. sent: function sent() {
  32322. if (t[0] & 1) throw t[1];
  32323. return t[1];
  32324. },
  32325. trys: [],
  32326. ops: []
  32327. },
  32328. f,
  32329. y,
  32330. t,
  32331. g;
  32332. return g = {
  32333. next: verb(0),
  32334. "throw": verb(1),
  32335. "return": verb(2)
  32336. }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
  32337. return this;
  32338. }), g;
  32339. function verb(n) {
  32340. return function (v) {
  32341. return step([n, v]);
  32342. };
  32343. }
  32344. function step(op) {
  32345. if (f) throw new TypeError("Generator is already executing.");
  32346. while (_) {
  32347. try {
  32348. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  32349. if (y = 0, t) op = [op[0] & 2, t.value];
  32350. switch (op[0]) {
  32351. case 0:
  32352. case 1:
  32353. t = op;
  32354. break;
  32355. case 4:
  32356. _.label++;
  32357. return {
  32358. value: op[1],
  32359. done: false
  32360. };
  32361. case 5:
  32362. _.label++;
  32363. y = op[1];
  32364. op = [0];
  32365. continue;
  32366. case 7:
  32367. op = _.ops.pop();
  32368. _.trys.pop();
  32369. continue;
  32370. default:
  32371. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
  32372. _ = 0;
  32373. continue;
  32374. }
  32375. if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
  32376. _.label = op[1];
  32377. break;
  32378. }
  32379. if (op[0] === 6 && _.label < t[1]) {
  32380. _.label = t[1];
  32381. t = op;
  32382. break;
  32383. }
  32384. if (t && _.label < t[2]) {
  32385. _.label = t[2];
  32386. _.ops.push(op);
  32387. break;
  32388. }
  32389. if (t[2]) _.ops.pop();
  32390. _.trys.pop();
  32391. continue;
  32392. }
  32393. op = body.call(thisArg, _);
  32394. } catch (e) {
  32395. op = [6, e];
  32396. y = 0;
  32397. } finally {
  32398. f = t = 0;
  32399. }
  32400. }
  32401. if (op[0] & 5) throw op[1];
  32402. return {
  32403. value: op[0] ? op[1] : void 0,
  32404. done: true
  32405. };
  32406. }
  32407. };
  32408. var __importStar = commonjsGlobal && commonjsGlobal.__importStar || function (mod) {
  32409. if (mod && mod.__esModule) return mod;
  32410. var result = {};
  32411. if (mod != null) for (var k in mod) {
  32412. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  32413. }
  32414. result["default"] = mod;
  32415. return result;
  32416. };
  32417. var __importDefault = commonjsGlobal && commonjsGlobal.__importDefault || function (mod) {
  32418. return mod && mod.__esModule ? mod : {
  32419. "default": mod
  32420. };
  32421. };
  32422. Object.defineProperty(exports, "__esModule", {
  32423. value: true
  32424. });
  32425. var fs$$2 = __importStar(fs);
  32426. var path$$2 = __importStar(path);
  32427. var semver = __importStar(semver$3);
  32428. var fnmatch_1 = __importDefault(fnmatch);
  32429. exports.parseString = ini.parseString;
  32430. var package_json_1 = __importDefault(require$$4$6);
  32431. var knownProps = {
  32432. end_of_line: true,
  32433. indent_style: true,
  32434. indent_size: true,
  32435. insert_final_newline: true,
  32436. trim_trailing_whitespace: true,
  32437. charset: true
  32438. };
  32439. function fnmatch$$1(filepath, glob) {
  32440. var matchOptions = {
  32441. matchBase: true,
  32442. dot: true,
  32443. noext: true
  32444. };
  32445. glob = glob.replace(/\*\*/g, '{*,**/**/**}');
  32446. return fnmatch_1.default(filepath, glob, matchOptions);
  32447. }
  32448. function getConfigFileNames(filepath, options) {
  32449. var paths = [];
  32450. do {
  32451. filepath = path$$2.dirname(filepath);
  32452. paths.push(path$$2.join(filepath, options.config));
  32453. } while (filepath !== options.root);
  32454. return paths;
  32455. }
  32456. function processMatches(matches, version) {
  32457. // Set indent_size to 'tab' if indent_size is unspecified and
  32458. // indent_style is set to 'tab'.
  32459. if ('indent_style' in matches && matches.indent_style === 'tab' && !('indent_size' in matches) && semver.gte(version, '0.10.0')) {
  32460. matches.indent_size = 'tab';
  32461. } // Set tab_width to indent_size if indent_size is specified and
  32462. // tab_width is unspecified
  32463. if ('indent_size' in matches && !('tab_width' in matches) && matches.indent_size !== 'tab') {
  32464. matches.tab_width = matches.indent_size;
  32465. } // Set indent_size to tab_width if indent_size is 'tab'
  32466. if ('indent_size' in matches && 'tab_width' in matches && matches.indent_size === 'tab') {
  32467. matches.indent_size = matches.tab_width;
  32468. }
  32469. return matches;
  32470. }
  32471. function processOptions(options, filepath) {
  32472. if (options === void 0) {
  32473. options = {};
  32474. }
  32475. return {
  32476. config: options.config || '.editorconfig',
  32477. version: options.version || package_json_1.default.version,
  32478. root: path$$2.resolve(options.root || path$$2.parse(filepath).root)
  32479. };
  32480. }
  32481. function buildFullGlob(pathPrefix, glob) {
  32482. switch (glob.indexOf('/')) {
  32483. case -1:
  32484. glob = '**/' + glob;
  32485. break;
  32486. case 0:
  32487. glob = glob.substring(1);
  32488. break;
  32489. default:
  32490. break;
  32491. }
  32492. return path$$2.join(pathPrefix, glob);
  32493. }
  32494. function extendProps(props, options) {
  32495. if (props === void 0) {
  32496. props = {};
  32497. }
  32498. if (options === void 0) {
  32499. options = {};
  32500. }
  32501. for (var key in options) {
  32502. if (options.hasOwnProperty(key)) {
  32503. var value = options[key];
  32504. var key2 = key.toLowerCase();
  32505. var value2 = value;
  32506. if (knownProps[key2]) {
  32507. value2 = value.toLowerCase();
  32508. }
  32509. try {
  32510. value2 = JSON.parse(value);
  32511. } catch (e) {}
  32512. if (typeof value === 'undefined' || value === null) {
  32513. // null and undefined are values specific to JSON (no special meaning
  32514. // in editorconfig) & should just be returned as regular strings.
  32515. value2 = String(value);
  32516. }
  32517. props[key2] = value2;
  32518. }
  32519. }
  32520. return props;
  32521. }
  32522. function parseFromConfigs(configs, filepath, options) {
  32523. return processMatches(configs.reverse().reduce(function (matches, file) {
  32524. var pathPrefix = path$$2.dirname(file.name);
  32525. file.contents.forEach(function (section) {
  32526. var glob = section[0];
  32527. var options2 = section[1];
  32528. if (!glob) {
  32529. return;
  32530. }
  32531. var fullGlob = buildFullGlob(pathPrefix, glob);
  32532. if (!fnmatch$$1(filepath, fullGlob)) {
  32533. return;
  32534. }
  32535. matches = extendProps(matches, options2);
  32536. });
  32537. return matches;
  32538. }, {}), options.version);
  32539. }
  32540. function getConfigsForFiles(files) {
  32541. var configs = [];
  32542. for (var i in files) {
  32543. if (files.hasOwnProperty(i)) {
  32544. var file = files[i];
  32545. var contents = ini.parseString(file.contents);
  32546. configs.push({
  32547. name: file.name,
  32548. contents: contents
  32549. });
  32550. if ((contents[0][1].root || '').toLowerCase() === 'true') {
  32551. break;
  32552. }
  32553. }
  32554. }
  32555. return configs;
  32556. }
  32557. function readConfigFiles(filepaths) {
  32558. return __awaiter(this, void 0, void 0, function () {
  32559. return __generator(this, function (_a) {
  32560. return [2
  32561. /*return*/
  32562. , Promise.all(filepaths.map(function (name) {
  32563. return new Promise(function (resolve) {
  32564. fs$$2.readFile(name, 'utf8', function (err, data) {
  32565. resolve({
  32566. name: name,
  32567. contents: err ? '' : data
  32568. });
  32569. });
  32570. });
  32571. }))];
  32572. });
  32573. });
  32574. }
  32575. function readConfigFilesSync(filepaths) {
  32576. var files = [];
  32577. var file;
  32578. filepaths.forEach(function (filepath) {
  32579. try {
  32580. file = fs$$2.readFileSync(filepath, 'utf8');
  32581. } catch (e) {
  32582. file = '';
  32583. }
  32584. files.push({
  32585. name: filepath,
  32586. contents: file
  32587. });
  32588. });
  32589. return files;
  32590. }
  32591. function opts(filepath, options) {
  32592. if (options === void 0) {
  32593. options = {};
  32594. }
  32595. var resolvedFilePath = path$$2.resolve(filepath);
  32596. return [resolvedFilePath, processOptions(options, resolvedFilePath)];
  32597. }
  32598. function parseFromFiles(filepath, files, options) {
  32599. if (options === void 0) {
  32600. options = {};
  32601. }
  32602. return __awaiter(this, void 0, void 0, function () {
  32603. var _a, resolvedFilePath, processedOptions;
  32604. return __generator(this, function (_b) {
  32605. _a = opts(filepath, options), resolvedFilePath = _a[0], processedOptions = _a[1];
  32606. return [2
  32607. /*return*/
  32608. , files.then(getConfigsForFiles).then(function (configs) {
  32609. return parseFromConfigs(configs, resolvedFilePath, processedOptions);
  32610. })];
  32611. });
  32612. });
  32613. }
  32614. exports.parseFromFiles = parseFromFiles;
  32615. function parseFromFilesSync(filepath, files, options) {
  32616. if (options === void 0) {
  32617. options = {};
  32618. }
  32619. var _a = opts(filepath, options),
  32620. resolvedFilePath = _a[0],
  32621. processedOptions = _a[1];
  32622. return parseFromConfigs(getConfigsForFiles(files), resolvedFilePath, processedOptions);
  32623. }
  32624. exports.parseFromFilesSync = parseFromFilesSync;
  32625. function parse(_filepath, _options) {
  32626. if (_options === void 0) {
  32627. _options = {};
  32628. }
  32629. return __awaiter(this, void 0, void 0, function () {
  32630. var _a, resolvedFilePath, processedOptions, filepaths;
  32631. return __generator(this, function (_b) {
  32632. _a = opts(_filepath, _options), resolvedFilePath = _a[0], processedOptions = _a[1];
  32633. filepaths = getConfigFileNames(resolvedFilePath, processedOptions);
  32634. return [2
  32635. /*return*/
  32636. , readConfigFiles(filepaths).then(getConfigsForFiles).then(function (configs) {
  32637. return parseFromConfigs(configs, resolvedFilePath, processedOptions);
  32638. })];
  32639. });
  32640. });
  32641. }
  32642. exports.parse = parse;
  32643. function parseSync(_filepath, _options) {
  32644. if (_options === void 0) {
  32645. _options = {};
  32646. }
  32647. var _a = opts(_filepath, _options),
  32648. resolvedFilePath = _a[0],
  32649. processedOptions = _a[1];
  32650. var filepaths = getConfigFileNames(resolvedFilePath, processedOptions);
  32651. var files = readConfigFilesSync(filepaths);
  32652. return parseFromConfigs(getConfigsForFiles(files), resolvedFilePath, processedOptions);
  32653. }
  32654. exports.parseSync = parseSync;
  32655. });
  32656. unwrapExports(src$2);
  32657. var editorconfigToPrettier = editorConfigToPrettier;
  32658. function removeUnset(editorConfig) {
  32659. var result = {};
  32660. var keys = Object.keys(editorConfig);
  32661. for (var i = 0; i < keys.length; i++) {
  32662. var key = keys[i];
  32663. if (editorConfig[key] === "unset") {
  32664. continue;
  32665. }
  32666. result[key] = editorConfig[key];
  32667. }
  32668. return result;
  32669. }
  32670. function editorConfigToPrettier(editorConfig) {
  32671. if (!editorConfig) {
  32672. return null;
  32673. }
  32674. editorConfig = removeUnset(editorConfig);
  32675. if (Object.keys(editorConfig).length === 0) {
  32676. return null;
  32677. }
  32678. var result = {};
  32679. if (editorConfig.indent_style) {
  32680. result.useTabs = editorConfig.indent_style === "tab";
  32681. }
  32682. if (editorConfig.indent_size === "tab") {
  32683. result.useTabs = true;
  32684. }
  32685. if (result.useTabs && editorConfig.tab_width) {
  32686. result.tabWidth = editorConfig.tab_width;
  32687. } else if (editorConfig.indent_style === "space" && editorConfig.indent_size && editorConfig.indent_size !== "tab") {
  32688. result.tabWidth = editorConfig.indent_size;
  32689. } else if (editorConfig.tab_width !== undefined) {
  32690. result.tabWidth = editorConfig.tab_width;
  32691. }
  32692. if (editorConfig.max_line_length && editorConfig.max_line_length !== "off") {
  32693. result.printWidth = editorConfig.max_line_length;
  32694. }
  32695. if (editorConfig.quote_type === "single") {
  32696. result.singleQuote = true;
  32697. } else if (editorConfig.quote_type === "double") {
  32698. result.singleQuote = false;
  32699. }
  32700. if (["cr", "crlf", "lf"].indexOf(editorConfig.end_of_line) !== -1) {
  32701. result.endOfLine = editorConfig.end_of_line;
  32702. }
  32703. return result;
  32704. }
  32705. function markerExists(files, markers) {
  32706. return markers.some(function (marker) {
  32707. return files.some(function (file) {
  32708. return file === marker;
  32709. });
  32710. });
  32711. }
  32712. function traverseFolder(directory, levels, markers) {
  32713. var files = fs.readdirSync(directory);
  32714. if (levels === 0) {
  32715. return null;
  32716. } else if (markerExists(files, markers)) {
  32717. return directory;
  32718. } else {
  32719. return traverseFolder(path.resolve(directory, '..'), levels - 1, markers);
  32720. }
  32721. }
  32722. var findProjectRoot = function findRoot(dir, opts) {
  32723. if (!dir) throw new Error("Directory not defined");
  32724. opts = opts || {};
  32725. var levels = opts.maxDepth || findRoot.MAX_DEPTH;
  32726. var markers = opts.markers || findRoot.MARKERS;
  32727. return traverseFolder(dir, levels, markers);
  32728. };
  32729. var MAX_DEPTH = 9;
  32730. var MARKERS = ['.git', '.hg'];
  32731. findProjectRoot.MAX_DEPTH = MAX_DEPTH;
  32732. findProjectRoot.MARKERS = MARKERS;
  32733. var resolveConfigEditorconfig = createCommonjsModule(function (module) {
  32734. "use strict";
  32735. var maybeParse = function maybeParse(filePath, config, parse) {
  32736. var root = findProjectRoot(path.dirname(path.resolve(filePath)));
  32737. return filePath && parse(filePath, {
  32738. root
  32739. });
  32740. };
  32741. var editorconfigAsyncNoCache = function editorconfigAsyncNoCache(filePath, config) {
  32742. return Promise.resolve(maybeParse(filePath, config, src$2.parse)).then(editorconfigToPrettier);
  32743. };
  32744. var editorconfigAsyncWithCache = mem(editorconfigAsyncNoCache);
  32745. var editorconfigSyncNoCache = function editorconfigSyncNoCache(filePath, config) {
  32746. return editorconfigToPrettier(maybeParse(filePath, config, src$2.parseSync));
  32747. };
  32748. var editorconfigSyncWithCache = mem(editorconfigSyncNoCache);
  32749. function getLoadFunction(opts) {
  32750. if (!opts.editorconfig) {
  32751. return function () {
  32752. return null;
  32753. };
  32754. }
  32755. if (opts.sync) {
  32756. return opts.cache ? editorconfigSyncWithCache : editorconfigSyncNoCache;
  32757. }
  32758. return opts.cache ? editorconfigAsyncWithCache : editorconfigAsyncNoCache;
  32759. }
  32760. function clearCache() {
  32761. mem.clear(editorconfigSyncWithCache);
  32762. mem.clear(editorconfigAsyncWithCache);
  32763. }
  32764. module.exports = {
  32765. getLoadFunction,
  32766. clearCache
  32767. };
  32768. });
  32769. var ParserEND = 0x110000;
  32770. var ParserError =
  32771. /*#__PURE__*/
  32772. function (_Error) {
  32773. _inherits(ParserError, _Error);
  32774. /* istanbul ignore next */
  32775. function ParserError(msg, filename, linenumber) {
  32776. var _this;
  32777. _classCallCheck(this, ParserError);
  32778. _this = _possibleConstructorReturn(this, _getPrototypeOf(ParserError).call(this, '[ParserError] ' + msg, filename, linenumber));
  32779. _this.code = 'ParserError';
  32780. if (Error.captureStackTrace) Error.captureStackTrace(_assertThisInitialized(_assertThisInitialized(_this)), ParserError);
  32781. return _this;
  32782. }
  32783. return ParserError;
  32784. }(_wrapNativeSuper(Error));
  32785. var State = function State(parser) {
  32786. _classCallCheck(this, State);
  32787. this.parser = parser;
  32788. this.buf = '';
  32789. this.returned = null;
  32790. this.result = null;
  32791. this.resultTable = null;
  32792. this.resultArr = null;
  32793. };
  32794. var Parser =
  32795. /*#__PURE__*/
  32796. function () {
  32797. function Parser() {
  32798. _classCallCheck(this, Parser);
  32799. this.pos = 0;
  32800. this.col = 0;
  32801. this.line = 0;
  32802. this.obj = {};
  32803. this.ctx = this.obj;
  32804. this.stack = [];
  32805. this._buf = '';
  32806. this.char = null;
  32807. this.ii = 0;
  32808. this.state = new State(this.parseStart);
  32809. }
  32810. _createClass(Parser, [{
  32811. key: "parse",
  32812. value: function parse(str) {
  32813. /* istanbul ignore next */
  32814. if (str.length === 0 || str.length == null) return;
  32815. this._buf = String(str);
  32816. this.ii = -1;
  32817. this.char = -1;
  32818. var getNext;
  32819. while (getNext === false || this.nextChar()) {
  32820. getNext = this.runOne();
  32821. }
  32822. this._buf = null;
  32823. }
  32824. }, {
  32825. key: "nextChar",
  32826. value: function nextChar() {
  32827. if (this.char === 0x0A) {
  32828. ++this.line;
  32829. this.col = -1;
  32830. }
  32831. ++this.ii;
  32832. this.char = this._buf.codePointAt(this.ii);
  32833. ++this.pos;
  32834. ++this.col;
  32835. return this.haveBuffer();
  32836. }
  32837. }, {
  32838. key: "haveBuffer",
  32839. value: function haveBuffer() {
  32840. return this.ii < this._buf.length;
  32841. }
  32842. }, {
  32843. key: "runOne",
  32844. value: function runOne() {
  32845. return this.state.parser.call(this, this.state.returned);
  32846. }
  32847. }, {
  32848. key: "finish",
  32849. value: function finish() {
  32850. this.char = ParserEND;
  32851. var last;
  32852. do {
  32853. last = this.state.parser;
  32854. this.runOne();
  32855. } while (this.state.parser !== last);
  32856. this.ctx = null;
  32857. this.state = null;
  32858. this._buf = null;
  32859. return this.obj;
  32860. }
  32861. }, {
  32862. key: "next",
  32863. value: function next(fn) {
  32864. /* istanbul ignore next */
  32865. if (typeof fn !== 'function') throw new ParserError('Tried to set state to non-existent state: ' + JSON.stringify(fn));
  32866. this.state.parser = fn;
  32867. }
  32868. }, {
  32869. key: "goto",
  32870. value: function goto(fn) {
  32871. this.next(fn);
  32872. return this.runOne();
  32873. }
  32874. }, {
  32875. key: "call",
  32876. value: function call(fn, returnWith) {
  32877. if (returnWith) this.next(returnWith);
  32878. this.stack.push(this.state);
  32879. this.state = new State(fn);
  32880. }
  32881. }, {
  32882. key: "callNow",
  32883. value: function callNow(fn, returnWith) {
  32884. this.call(fn, returnWith);
  32885. return this.runOne();
  32886. }
  32887. }, {
  32888. key: "return",
  32889. value: function _return(value) {
  32890. /* istanbul ignore next */
  32891. if (!this.stack.length) throw this.error(new ParserError('Stack underflow'));
  32892. if (value === undefined) value = this.state.buf;
  32893. this.state = this.stack.pop();
  32894. this.state.returned = value;
  32895. }
  32896. }, {
  32897. key: "returnNow",
  32898. value: function returnNow(value) {
  32899. this.return(value);
  32900. return this.runOne();
  32901. }
  32902. }, {
  32903. key: "consume",
  32904. value: function consume() {
  32905. /* istanbul ignore next */
  32906. if (this.char === ParserEND) throw this.error(new ParserError('Unexpected end-of-buffer'));
  32907. this.state.buf += this._buf[this.ii];
  32908. }
  32909. }, {
  32910. key: "error",
  32911. value: function error(err) {
  32912. err.line = this.line;
  32913. err.col = this.col;
  32914. err.pos = this.pos;
  32915. return err;
  32916. }
  32917. /* istanbul ignore next */
  32918. }, {
  32919. key: "parseStart",
  32920. value: function parseStart() {
  32921. throw new ParserError('Must declare a parseStart method');
  32922. }
  32923. }]);
  32924. return Parser;
  32925. }();
  32926. Parser.END = ParserEND;
  32927. Parser.Error = ParserError;
  32928. var parser$2 = Parser;
  32929. var createDatetime = createCommonjsModule(function (module) {
  32930. 'use strict';
  32931. module.exports = function (value) {
  32932. var date = new Date(value);
  32933. /* istanbul ignore if */
  32934. if (isNaN(date)) {
  32935. throw new TypeError('Invalid Datetime');
  32936. } else {
  32937. return date;
  32938. }
  32939. };
  32940. });
  32941. var formatNum = createCommonjsModule(function (module) {
  32942. 'use strict';
  32943. module.exports = function (d, num) {
  32944. num = String(num);
  32945. while (num.length < d) {
  32946. num = '0' + num;
  32947. }
  32948. return num;
  32949. };
  32950. });
  32951. var createDatetimeFloat = createCommonjsModule(function (module) {
  32952. 'use strict';
  32953. var FloatingDateTime =
  32954. /*#__PURE__*/
  32955. function (_Date) {
  32956. _inherits(FloatingDateTime, _Date);
  32957. function FloatingDateTime(value) {
  32958. var _this;
  32959. _classCallCheck(this, FloatingDateTime);
  32960. _this = _possibleConstructorReturn(this, _getPrototypeOf(FloatingDateTime).call(this, value + 'Z'));
  32961. _this.isFloating = true;
  32962. return _this;
  32963. }
  32964. _createClass(FloatingDateTime, [{
  32965. key: "toISOString",
  32966. value: function toISOString() {
  32967. var date = `${this.getUTCFullYear()}-${formatNum(2, this.getUTCMonth() + 1)}-${formatNum(2, this.getUTCDate())}`;
  32968. var time = `${formatNum(2, this.getUTCHours())}:${formatNum(2, this.getUTCMinutes())}:${formatNum(2, this.getUTCSeconds())}.${formatNum(3, this.getUTCMilliseconds())}`;
  32969. return `${date}T${time}`;
  32970. }
  32971. }]);
  32972. return FloatingDateTime;
  32973. }(_wrapNativeSuper(Date));
  32974. module.exports = function (value) {
  32975. var date = new FloatingDateTime(value);
  32976. /* istanbul ignore if */
  32977. if (isNaN(date)) {
  32978. throw new TypeError('Invalid Datetime');
  32979. } else {
  32980. return date;
  32981. }
  32982. };
  32983. });
  32984. var createDate = createCommonjsModule(function (module) {
  32985. 'use strict';
  32986. var DateTime = commonjsGlobal.Date;
  32987. var Date =
  32988. /*#__PURE__*/
  32989. function (_DateTime) {
  32990. _inherits(Date, _DateTime);
  32991. function Date(value) {
  32992. var _this;
  32993. _classCallCheck(this, Date);
  32994. _this = _possibleConstructorReturn(this, _getPrototypeOf(Date).call(this, value));
  32995. _this.isDate = true;
  32996. return _this;
  32997. }
  32998. _createClass(Date, [{
  32999. key: "toISOString",
  33000. value: function toISOString() {
  33001. return `${this.getUTCFullYear()}-${formatNum(2, this.getUTCMonth() + 1)}-${formatNum(2, this.getUTCDate())}`;
  33002. }
  33003. }]);
  33004. return Date;
  33005. }(DateTime);
  33006. module.exports = function (value) {
  33007. var date = new Date(value);
  33008. /* istanbul ignore if */
  33009. if (isNaN(date)) {
  33010. throw new TypeError('Invalid Datetime');
  33011. } else {
  33012. return date;
  33013. }
  33014. };
  33015. });
  33016. var createTime = createCommonjsModule(function (module) {
  33017. 'use strict';
  33018. var Time =
  33019. /*#__PURE__*/
  33020. function (_Date) {
  33021. _inherits(Time, _Date);
  33022. function Time(value) {
  33023. var _this;
  33024. _classCallCheck(this, Time);
  33025. _this = _possibleConstructorReturn(this, _getPrototypeOf(Time).call(this, `0000-01-01T${value}Z`));
  33026. _this.isTime = true;
  33027. return _this;
  33028. }
  33029. _createClass(Time, [{
  33030. key: "toISOString",
  33031. value: function toISOString() {
  33032. return `${formatNum(2, this.getUTCHours())}:${formatNum(2, this.getUTCMinutes())}:${formatNum(2, this.getUTCSeconds())}.${formatNum(3, this.getUTCMilliseconds())}`;
  33033. }
  33034. }]);
  33035. return Time;
  33036. }(_wrapNativeSuper(Date));
  33037. module.exports = function (value) {
  33038. var date = new Time(value);
  33039. /* istanbul ignore if */
  33040. if (isNaN(date)) {
  33041. throw new TypeError('Invalid Datetime');
  33042. } else {
  33043. return date;
  33044. }
  33045. };
  33046. });
  33047. var tomlParser = createCommonjsModule(function (module) {
  33048. 'use strict';
  33049. /* eslint-disable no-new-wrappers, no-eval, camelcase, operator-linebreak */
  33050. module.exports = makeParserClass(parser$2);
  33051. module.exports.makeParserClass = makeParserClass;
  33052. var TomlError =
  33053. /*#__PURE__*/
  33054. function (_Error) {
  33055. _inherits(TomlError, _Error);
  33056. function TomlError(msg) {
  33057. var _this;
  33058. _classCallCheck(this, TomlError);
  33059. _this = _possibleConstructorReturn(this, _getPrototypeOf(TomlError).call(this, msg));
  33060. /* istanbul ignore next */
  33061. if (Error.captureStackTrace) Error.captureStackTrace(_assertThisInitialized(_assertThisInitialized(_this)), TomlError);
  33062. _this.fromTOML = true;
  33063. _this.wrapped = null;
  33064. return _this;
  33065. }
  33066. return TomlError;
  33067. }(_wrapNativeSuper(Error));
  33068. TomlError.wrap = function (err) {
  33069. var terr = new TomlError(err.message);
  33070. terr.code = err.code;
  33071. terr.wrapped = err;
  33072. return terr;
  33073. };
  33074. module.exports.TomlError = TomlError;
  33075. var CTRL_I = 0x09;
  33076. var CTRL_J = 0x0A;
  33077. var CTRL_M = 0x0D;
  33078. var CTRL_CHAR_BOUNDARY = 0x1F; // the last non-character in the latin1 region of unicode, except DEL
  33079. var CHAR_SP = 0x20;
  33080. var CHAR_QUOT = 0x22;
  33081. var CHAR_NUM = 0x23;
  33082. var CHAR_APOS = 0x27;
  33083. var CHAR_PLUS = 0x2B;
  33084. var CHAR_COMMA = 0x2C;
  33085. var CHAR_HYPHEN = 0x2D;
  33086. var CHAR_PERIOD = 0x2E;
  33087. var CHAR_0 = 0x30;
  33088. var CHAR_1 = 0x31;
  33089. var CHAR_7 = 0x37;
  33090. var CHAR_9 = 0x39;
  33091. var CHAR_COLON = 0x3A;
  33092. var CHAR_EQUALS = 0x3D;
  33093. var CHAR_A = 0x41;
  33094. var CHAR_E = 0x45;
  33095. var CHAR_F = 0x46;
  33096. var CHAR_T = 0x54;
  33097. var CHAR_U = 0x55;
  33098. var CHAR_Z = 0x5A;
  33099. var CHAR_LOWBAR = 0x5F;
  33100. var CHAR_a = 0x61;
  33101. var CHAR_b = 0x62;
  33102. var CHAR_e = 0x65;
  33103. var CHAR_f = 0x66;
  33104. var CHAR_i = 0x69;
  33105. var CHAR_l = 0x6C;
  33106. var CHAR_n = 0x6E;
  33107. var CHAR_o = 0x6F;
  33108. var CHAR_r = 0x72;
  33109. var CHAR_s = 0x73;
  33110. var CHAR_t = 0x74;
  33111. var CHAR_u = 0x75;
  33112. var CHAR_x = 0x78;
  33113. var CHAR_z = 0x7A;
  33114. var CHAR_LCUB = 0x7B;
  33115. var CHAR_RCUB = 0x7D;
  33116. var CHAR_LSQB = 0x5B;
  33117. var CHAR_BSOL = 0x5C;
  33118. var CHAR_RSQB = 0x5D;
  33119. var CHAR_DEL = 0x7F;
  33120. var SURROGATE_FIRST = 0xD800;
  33121. var SURROGATE_LAST = 0xDFFF;
  33122. var escapes = {
  33123. [CHAR_b]: '\x08',
  33124. [CHAR_t]: '\x09',
  33125. [CHAR_n]: '\x0a',
  33126. [CHAR_f]: '\x0c',
  33127. [CHAR_r]: '\x0d',
  33128. [CHAR_QUOT]: '\x22',
  33129. [CHAR_BSOL]: '\x5c'
  33130. };
  33131. function isDigit(cp) {
  33132. return cp >= CHAR_0 && cp <= CHAR_9;
  33133. }
  33134. function isHexit(cp) {
  33135. return cp >= CHAR_A && cp <= CHAR_F || cp >= CHAR_a && cp <= CHAR_f || cp >= CHAR_0 && cp <= CHAR_9;
  33136. }
  33137. function isBit(cp) {
  33138. return cp === CHAR_1 || cp === CHAR_0;
  33139. }
  33140. function isOctit(cp) {
  33141. return cp >= CHAR_0 && cp <= CHAR_7;
  33142. }
  33143. function isAlphaNumQuoteHyphen(cp) {
  33144. return cp >= CHAR_A && cp <= CHAR_Z || cp >= CHAR_a && cp <= CHAR_z || cp >= CHAR_0 && cp <= CHAR_9 || cp === CHAR_APOS || cp === CHAR_QUOT || cp === CHAR_LOWBAR || cp === CHAR_HYPHEN;
  33145. }
  33146. function isAlphaNumHyphen(cp) {
  33147. return cp >= CHAR_A && cp <= CHAR_Z || cp >= CHAR_a && cp <= CHAR_z || cp >= CHAR_0 && cp <= CHAR_9 || cp === CHAR_LOWBAR || cp === CHAR_HYPHEN;
  33148. }
  33149. var _type = Symbol('type');
  33150. var _declared = Symbol('declared');
  33151. var INLINE_TABLE = Symbol('inline-table');
  33152. function InlineTable() {
  33153. return Object.defineProperties({}, {
  33154. [_type]: {
  33155. value: INLINE_TABLE
  33156. }
  33157. });
  33158. }
  33159. function isInlineTable(obj) {
  33160. if (obj === null || typeof obj !== 'object') return false;
  33161. return obj[_type] === INLINE_TABLE;
  33162. }
  33163. var TABLE = Symbol('table');
  33164. function Table() {
  33165. return Object.defineProperties({}, {
  33166. [_type]: {
  33167. value: TABLE
  33168. },
  33169. [_declared]: {
  33170. value: false,
  33171. writable: true
  33172. }
  33173. });
  33174. }
  33175. function isTable(obj) {
  33176. if (obj === null || typeof obj !== 'object') return false;
  33177. return obj[_type] === TABLE;
  33178. }
  33179. var _contentType = Symbol('content-type');
  33180. var INLINE_LIST = Symbol('inline-list');
  33181. function InlineList(type) {
  33182. return Object.defineProperties([], {
  33183. [_type]: {
  33184. value: INLINE_LIST
  33185. },
  33186. [_contentType]: {
  33187. value: type
  33188. }
  33189. });
  33190. }
  33191. function isInlineList(obj) {
  33192. if (obj === null || typeof obj !== 'object') return false;
  33193. return obj[_type] === INLINE_LIST;
  33194. }
  33195. var LIST = Symbol('list');
  33196. function List() {
  33197. return Object.defineProperties([], {
  33198. [_type]: {
  33199. value: LIST
  33200. }
  33201. });
  33202. }
  33203. function isList(obj) {
  33204. if (obj === null || typeof obj !== 'object') return false;
  33205. return obj[_type] === LIST;
  33206. } // in an eval, to let bundlers not slurp in a util proxy
  33207. var utilInspect = eval(`require('util').inspect`);
  33208. /* istanbul ignore next */
  33209. var _inspect = utilInspect && utilInspect.custom || 'inspect';
  33210. var BoxedBigInt =
  33211. /*#__PURE__*/
  33212. function () {
  33213. function BoxedBigInt(value) {
  33214. _classCallCheck(this, BoxedBigInt);
  33215. try {
  33216. this.value = commonjsGlobal.BigInt(value);
  33217. } catch (_) {
  33218. /* istanbul ignore next */
  33219. this.value = null;
  33220. }
  33221. Object.defineProperty(this, _type, {
  33222. value: INTEGER
  33223. });
  33224. }
  33225. _createClass(BoxedBigInt, [{
  33226. key: "isNaN",
  33227. value: function isNaN() {
  33228. return this.value === null;
  33229. }
  33230. /* istanbul ignore next */
  33231. }, {
  33232. key: "toString",
  33233. value: function toString() {
  33234. return String(this.value);
  33235. }
  33236. /* istanbul ignore next */
  33237. }, {
  33238. key: _inspect,
  33239. value: function value() {
  33240. return `[BigInt: ${this.toString()}]}`;
  33241. }
  33242. }, {
  33243. key: "valueOf",
  33244. value: function valueOf() {
  33245. return this.value;
  33246. }
  33247. }]);
  33248. return BoxedBigInt;
  33249. }();
  33250. var INTEGER = Symbol('integer');
  33251. function Integer(_value) {
  33252. var num = Number(_value); // -0 is a float thing, not an int thing
  33253. if (Object.is(num, -0)) num = 0;
  33254. /* istanbul ignore else */
  33255. if (commonjsGlobal.BigInt && !Number.isSafeInteger(num)) {
  33256. return new BoxedBigInt(_value);
  33257. } else {
  33258. /* istanbul ignore next */
  33259. return Object.defineProperties(new Number(num), {
  33260. isNaN: {
  33261. value: function value() {
  33262. return isNaN(this);
  33263. }
  33264. },
  33265. [_type]: {
  33266. value: INTEGER
  33267. },
  33268. [_inspect]: {
  33269. value: function value() {
  33270. return `[Integer: ${_value}]`;
  33271. }
  33272. }
  33273. });
  33274. }
  33275. }
  33276. function isInteger(obj) {
  33277. if (obj === null || typeof obj !== 'object') return false;
  33278. return obj[_type] === INTEGER;
  33279. }
  33280. var FLOAT = Symbol('float');
  33281. function Float(_value2) {
  33282. /* istanbul ignore next */
  33283. return Object.defineProperties(new Number(_value2), {
  33284. [_type]: {
  33285. value: FLOAT
  33286. },
  33287. [_inspect]: {
  33288. value: function value() {
  33289. return `[Float: ${_value2}]`;
  33290. }
  33291. }
  33292. });
  33293. }
  33294. function isFloat(obj) {
  33295. if (obj === null || typeof obj !== 'object') return false;
  33296. return obj[_type] === FLOAT;
  33297. }
  33298. function tomlType(value) {
  33299. var type = typeof value;
  33300. if (type === 'object') {
  33301. /* istanbul ignore if */
  33302. if (value === null) return 'null';
  33303. if (value instanceof Date) return 'datetime';
  33304. /* istanbul ignore else */
  33305. if (_type in value) {
  33306. switch (value[_type]) {
  33307. case INLINE_TABLE:
  33308. return 'inline-table';
  33309. case INLINE_LIST:
  33310. return 'inline-list';
  33311. /* istanbul ignore next */
  33312. case TABLE:
  33313. return 'table';
  33314. /* istanbul ignore next */
  33315. case LIST:
  33316. return 'list';
  33317. case FLOAT:
  33318. return 'float';
  33319. case INTEGER:
  33320. return 'integer';
  33321. }
  33322. }
  33323. }
  33324. return type;
  33325. }
  33326. function makeParserClass(Parser) {
  33327. var TOMLParser =
  33328. /*#__PURE__*/
  33329. function (_Parser) {
  33330. _inherits(TOMLParser, _Parser);
  33331. function TOMLParser() {
  33332. var _this2;
  33333. _classCallCheck(this, TOMLParser);
  33334. _this2 = _possibleConstructorReturn(this, _getPrototypeOf(TOMLParser).call(this));
  33335. _this2.ctx = _this2.obj = Table();
  33336. return _this2;
  33337. }
  33338. /* MATCH HELPER */
  33339. _createClass(TOMLParser, [{
  33340. key: "atEndOfWord",
  33341. value: function atEndOfWord() {
  33342. return this.char === CHAR_NUM || this.char === CTRL_I || this.char === CHAR_SP || this.atEndOfLine();
  33343. }
  33344. }, {
  33345. key: "atEndOfLine",
  33346. value: function atEndOfLine() {
  33347. return this.char === Parser.END || this.char === CTRL_J || this.char === CTRL_M;
  33348. }
  33349. }, {
  33350. key: "parseStart",
  33351. value: function parseStart() {
  33352. if (this.char === Parser.END) {
  33353. return null;
  33354. } else if (this.char === CHAR_LSQB) {
  33355. return this.call(this.parseTableOrList);
  33356. } else if (this.char === CHAR_NUM) {
  33357. return this.call(this.parseComment);
  33358. } else if (this.char === CTRL_J || this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M) {
  33359. return null;
  33360. } else if (isAlphaNumQuoteHyphen(this.char)) {
  33361. return this.callNow(this.parseAssignStatement);
  33362. } else {
  33363. throw this.error(new TomlError(`Unknown character "${this.char}"`));
  33364. }
  33365. } // HELPER, this strips any whitespace and comments to the end of the line
  33366. // then RETURNS. Last state in a production.
  33367. }, {
  33368. key: "parseWhitespaceToEOL",
  33369. value: function parseWhitespaceToEOL() {
  33370. if (this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M) {
  33371. return null;
  33372. } else if (this.char === CHAR_NUM) {
  33373. return this.goto(this.parseComment);
  33374. } else if (this.char === Parser.END || this.char === CTRL_J) {
  33375. return this.return();
  33376. } else {
  33377. throw this.error(new TomlError('Unexpected character, expected only whitespace or comments till end of line'));
  33378. }
  33379. }
  33380. /* ASSIGNMENT: key = value */
  33381. }, {
  33382. key: "parseAssignStatement",
  33383. value: function parseAssignStatement() {
  33384. return this.callNow(this.parseAssign, this.recordAssignStatement);
  33385. }
  33386. }, {
  33387. key: "recordAssignStatement",
  33388. value: function recordAssignStatement(kv) {
  33389. var target = this.ctx;
  33390. var finalKey = kv.key.pop();
  33391. var _iteratorNormalCompletion = true;
  33392. var _didIteratorError = false;
  33393. var _iteratorError = undefined;
  33394. try {
  33395. for (var _iterator = kv.key[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  33396. var kw = _step.value;
  33397. if (kw in target && (!isTable(target[kw]) || target[kw][_declared])) {
  33398. throw this.error(new TomlError("Can't redefine existing key"));
  33399. }
  33400. target = target[kw] = target[kw] || Table();
  33401. }
  33402. } catch (err) {
  33403. _didIteratorError = true;
  33404. _iteratorError = err;
  33405. } finally {
  33406. try {
  33407. if (!_iteratorNormalCompletion && _iterator.return != null) {
  33408. _iterator.return();
  33409. }
  33410. } finally {
  33411. if (_didIteratorError) {
  33412. throw _iteratorError;
  33413. }
  33414. }
  33415. }
  33416. if (finalKey in target) {
  33417. throw this.error(new TomlError("Can't redefine existing key"));
  33418. } // unbox our numbers
  33419. if (isInteger(kv.value) || isFloat(kv.value)) {
  33420. target[finalKey] = kv.value.valueOf();
  33421. } else {
  33422. target[finalKey] = kv.value;
  33423. }
  33424. return this.goto(this.parseWhitespaceToEOL);
  33425. }
  33426. /* ASSSIGNMENT expression, key = value possibly inside an inline table */
  33427. }, {
  33428. key: "parseAssign",
  33429. value: function parseAssign() {
  33430. return this.callNow(this.parseKeyword, this.recordAssignKeyword);
  33431. }
  33432. }, {
  33433. key: "recordAssignKeyword",
  33434. value: function recordAssignKeyword(key) {
  33435. if (this.state.resultTable) {
  33436. this.state.resultTable.push(key);
  33437. } else {
  33438. this.state.resultTable = [key];
  33439. }
  33440. return this.goto(this.parseAssignKeywordPreDot);
  33441. }
  33442. }, {
  33443. key: "parseAssignKeywordPreDot",
  33444. value: function parseAssignKeywordPreDot() {
  33445. if (this.char === CHAR_PERIOD) {
  33446. return this.next(this.parseAssignKeywordPostDot);
  33447. } else if (this.char !== CHAR_SP && this.char !== CTRL_I) {
  33448. return this.goto(this.parseAssignEqual);
  33449. }
  33450. }
  33451. }, {
  33452. key: "parseAssignKeywordPostDot",
  33453. value: function parseAssignKeywordPostDot() {
  33454. if (this.char !== CHAR_SP && this.char !== CTRL_I) {
  33455. return this.callNow(this.parseKeyword, this.recordAssignKeyword);
  33456. }
  33457. }
  33458. }, {
  33459. key: "parseAssignEqual",
  33460. value: function parseAssignEqual() {
  33461. if (this.char === CHAR_EQUALS) {
  33462. return this.next(this.parseAssignPreValue);
  33463. } else {
  33464. throw this.error(new TomlError('Invalid character, expected "="'));
  33465. }
  33466. }
  33467. }, {
  33468. key: "parseAssignPreValue",
  33469. value: function parseAssignPreValue() {
  33470. if (this.char === CHAR_SP || this.char === CTRL_I) {
  33471. return null;
  33472. } else {
  33473. return this.callNow(this.parseValue, this.recordAssignValue);
  33474. }
  33475. }
  33476. }, {
  33477. key: "recordAssignValue",
  33478. value: function recordAssignValue(value) {
  33479. return this.returnNow({
  33480. key: this.state.resultTable,
  33481. value: value
  33482. });
  33483. }
  33484. /* COMMENTS: #...eol */
  33485. }, {
  33486. key: "parseComment",
  33487. value: function parseComment() {
  33488. do {
  33489. if (this.char === Parser.END || this.char === CTRL_J) {
  33490. return this.return();
  33491. }
  33492. } while (this.nextChar());
  33493. }
  33494. /* TABLES AND LISTS, [foo] and [[foo]] */
  33495. }, {
  33496. key: "parseTableOrList",
  33497. value: function parseTableOrList() {
  33498. if (this.char === CHAR_LSQB) {
  33499. this.next(this.parseList);
  33500. } else {
  33501. return this.goto(this.parseTable);
  33502. }
  33503. }
  33504. /* TABLE [foo.bar.baz] */
  33505. }, {
  33506. key: "parseTable",
  33507. value: function parseTable() {
  33508. this.ctx = this.obj;
  33509. return this.goto(this.parseTableNext);
  33510. }
  33511. }, {
  33512. key: "parseTableNext",
  33513. value: function parseTableNext() {
  33514. if (this.char === CHAR_SP || this.char === CTRL_I) {
  33515. return null;
  33516. } else {
  33517. return this.callNow(this.parseKeyword, this.parseTableMore);
  33518. }
  33519. }
  33520. }, {
  33521. key: "parseTableMore",
  33522. value: function parseTableMore(keyword) {
  33523. if (this.char === CHAR_SP || this.char === CTRL_I) {
  33524. return null;
  33525. } else if (this.char === CHAR_RSQB) {
  33526. if (keyword in this.ctx && (!isTable(this.ctx[keyword]) || this.ctx[keyword][_declared])) {
  33527. throw this.error(new TomlError("Can't redefine existing key"));
  33528. } else {
  33529. this.ctx = this.ctx[keyword] = this.ctx[keyword] || Table();
  33530. this.ctx[_declared] = true;
  33531. }
  33532. return this.next(this.parseWhitespaceToEOL);
  33533. } else if (this.char === CHAR_PERIOD) {
  33534. if (!(keyword in this.ctx)) {
  33535. this.ctx = this.ctx[keyword] = Table();
  33536. } else if (isTable(this.ctx[keyword])) {
  33537. this.ctx = this.ctx[keyword];
  33538. } else if (isList(this.ctx[keyword])) {
  33539. this.ctx = this.ctx[keyword][this.ctx[keyword].length - 1];
  33540. } else {
  33541. throw this.error(new TomlError("Can't redefine existing key"));
  33542. }
  33543. return this.next(this.parseTableNext);
  33544. } else {
  33545. throw this.error(new TomlError('Unexpected character, expected whitespace, . or ]'));
  33546. }
  33547. }
  33548. /* LIST [[a.b.c]] */
  33549. }, {
  33550. key: "parseList",
  33551. value: function parseList() {
  33552. this.ctx = this.obj;
  33553. return this.goto(this.parseListNext);
  33554. }
  33555. }, {
  33556. key: "parseListNext",
  33557. value: function parseListNext() {
  33558. if (this.char === CHAR_SP || this.char === CTRL_I) {
  33559. return null;
  33560. } else {
  33561. return this.callNow(this.parseKeyword, this.parseListMore);
  33562. }
  33563. }
  33564. }, {
  33565. key: "parseListMore",
  33566. value: function parseListMore(keyword) {
  33567. if (this.char === CHAR_SP || this.char === CTRL_I) {
  33568. return null;
  33569. } else if (this.char === CHAR_RSQB) {
  33570. if (!(keyword in this.ctx)) {
  33571. this.ctx[keyword] = List();
  33572. }
  33573. if (isInlineList(this.ctx[keyword])) {
  33574. throw this.error(new TomlError("Can't extend an inline array"));
  33575. } else if (isList(this.ctx[keyword])) {
  33576. var next = Table();
  33577. this.ctx[keyword].push(next);
  33578. this.ctx = next;
  33579. } else {
  33580. throw this.error(new TomlError("Can't redefine an existing key"));
  33581. }
  33582. return this.next(this.parseListEnd);
  33583. } else if (this.char === CHAR_PERIOD) {
  33584. if (!(keyword in this.ctx)) {
  33585. this.ctx = this.ctx[keyword] = Table();
  33586. } else if (isInlineList(this.ctx[keyword])) {
  33587. throw this.error(new TomlError("Can't extend an inline array"));
  33588. } else if (isInlineTable(this.ctx[keyword])) {
  33589. throw this.error(new TomlError("Can't extend an inline table"));
  33590. } else if (isList(this.ctx[keyword])) {
  33591. this.ctx = this.ctx[keyword][this.ctx[keyword].length - 1];
  33592. } else if (isTable(this.ctx[keyword])) {
  33593. this.ctx = this.ctx[keyword];
  33594. } else {
  33595. throw this.error(new TomlError("Can't redefine an existing key"));
  33596. }
  33597. return this.next(this.parseListNext);
  33598. } else {
  33599. throw this.error(new TomlError('Unexpected character, expected whitespace, . or ]'));
  33600. }
  33601. }
  33602. }, {
  33603. key: "parseListEnd",
  33604. value: function parseListEnd(keyword) {
  33605. if (this.char === CHAR_RSQB) {
  33606. return this.next(this.parseWhitespaceToEOL);
  33607. } else {
  33608. throw this.error(new TomlError('Unexpected character, expected whitespace, . or ]'));
  33609. }
  33610. }
  33611. /* VALUE string, number, boolean, inline list, inline object */
  33612. }, {
  33613. key: "parseValue",
  33614. value: function parseValue() {
  33615. if (this.char === Parser.END) {
  33616. throw this.error(new TomlError('Key without value'));
  33617. } else if (this.char === CHAR_QUOT) {
  33618. return this.next(this.parseDoubleString);
  33619. }
  33620. if (this.char === CHAR_APOS) {
  33621. return this.next(this.parseSingleString);
  33622. } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS) {
  33623. return this.goto(this.parseNumberSign);
  33624. } else if (this.char === CHAR_i) {
  33625. return this.next(this.parseInf);
  33626. } else if (this.char === CHAR_n) {
  33627. return this.next(this.parseNan);
  33628. } else if (isDigit(this.char)) {
  33629. return this.goto(this.parseNumberOrDateTime);
  33630. } else if (this.char === CHAR_t || this.char === CHAR_f) {
  33631. return this.goto(this.parseBoolean);
  33632. } else if (this.char === CHAR_LSQB) {
  33633. return this.call(this.parseInlineList, this.recordValue);
  33634. } else if (this.char === CHAR_LCUB) {
  33635. return this.call(this.parseInlineTable, this.recordValue);
  33636. } else {
  33637. throw this.error(new TomlError('Unexpected character, expecting string, number, datetime, boolean, inline array or inline table'));
  33638. }
  33639. }
  33640. }, {
  33641. key: "recordValue",
  33642. value: function recordValue(value) {
  33643. return this.returnNow(value);
  33644. }
  33645. }, {
  33646. key: "parseInf",
  33647. value: function parseInf() {
  33648. if (this.char === CHAR_n) {
  33649. return this.next(this.parseInf2);
  33650. } else {
  33651. throw this.error(new TomlError('Unexpected character, expected "inf", "+inf" or "-inf"'));
  33652. }
  33653. }
  33654. }, {
  33655. key: "parseInf2",
  33656. value: function parseInf2() {
  33657. if (this.char === CHAR_f) {
  33658. if (this.state.buf === '-') {
  33659. return this.return(-Infinity);
  33660. } else {
  33661. return this.return(Infinity);
  33662. }
  33663. } else {
  33664. throw this.error(new TomlError('Unexpected character, expected "inf", "+inf" or "-inf"'));
  33665. }
  33666. }
  33667. }, {
  33668. key: "parseNan",
  33669. value: function parseNan() {
  33670. if (this.char === CHAR_a) {
  33671. return this.next(this.parseNan2);
  33672. } else {
  33673. throw this.error(new TomlError('Unexpected character, expected "nan"'));
  33674. }
  33675. }
  33676. }, {
  33677. key: "parseNan2",
  33678. value: function parseNan2() {
  33679. if (this.char === CHAR_n) {
  33680. return this.return(NaN);
  33681. } else {
  33682. throw this.error(new TomlError('Unexpected character, expected "nan"'));
  33683. }
  33684. }
  33685. /* KEYS, barewords or basic, literal, or dotted */
  33686. }, {
  33687. key: "parseKeyword",
  33688. value: function parseKeyword() {
  33689. if (this.char === CHAR_QUOT) {
  33690. return this.next(this.parseBasicString);
  33691. } else if (this.char === CHAR_APOS) {
  33692. return this.next(this.parseLiteralString);
  33693. } else {
  33694. return this.goto(this.parseBareKey);
  33695. }
  33696. }
  33697. /* KEYS: barewords */
  33698. }, {
  33699. key: "parseBareKey",
  33700. value: function parseBareKey() {
  33701. do {
  33702. if (this.char === Parser.END) {
  33703. throw this.error(new TomlError('Key ended without value'));
  33704. } else if (isAlphaNumHyphen(this.char)) {
  33705. this.consume();
  33706. } else if (this.state.buf.length === 0) {
  33707. throw this.error(new TomlError('Empty bare keys are not allowed'));
  33708. } else {
  33709. return this.returnNow();
  33710. }
  33711. } while (this.nextChar());
  33712. }
  33713. /* STRINGS, single quoted (literal) */
  33714. }, {
  33715. key: "parseSingleString",
  33716. value: function parseSingleString() {
  33717. if (this.char === CHAR_APOS) {
  33718. return this.next(this.parseLiteralMultiStringMaybe);
  33719. } else {
  33720. return this.goto(this.parseLiteralString);
  33721. }
  33722. }
  33723. }, {
  33724. key: "parseLiteralString",
  33725. value: function parseLiteralString() {
  33726. do {
  33727. if (this.char === CHAR_APOS) {
  33728. return this.return();
  33729. } else if (this.atEndOfLine()) {
  33730. throw this.error(new TomlError('Unterminated string'));
  33731. } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I) {
  33732. throw this.errorControlCharInString();
  33733. } else {
  33734. this.consume();
  33735. }
  33736. } while (this.nextChar());
  33737. }
  33738. }, {
  33739. key: "parseLiteralMultiStringMaybe",
  33740. value: function parseLiteralMultiStringMaybe() {
  33741. if (this.char === CHAR_APOS) {
  33742. return this.next(this.parseLiteralMultiString);
  33743. } else {
  33744. return this.returnNow();
  33745. }
  33746. }
  33747. }, {
  33748. key: "parseLiteralMultiString",
  33749. value: function parseLiteralMultiString() {
  33750. if (this.char === CTRL_M) {
  33751. return null;
  33752. } else if (this.char === CTRL_J) {
  33753. return this.next(this.parseLiteralMultiStringContent);
  33754. } else {
  33755. return this.goto(this.parseLiteralMultiStringContent);
  33756. }
  33757. }
  33758. }, {
  33759. key: "parseLiteralMultiStringContent",
  33760. value: function parseLiteralMultiStringContent() {
  33761. do {
  33762. if (this.char === CHAR_APOS) {
  33763. return this.next(this.parseLiteralMultiEnd);
  33764. } else if (this.char === Parser.END) {
  33765. throw this.error(new TomlError('Unterminated multi-line string'));
  33766. } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I && this.char !== CTRL_J && this.char !== CTRL_M) {
  33767. throw this.errorControlCharInString();
  33768. } else {
  33769. this.consume();
  33770. }
  33771. } while (this.nextChar());
  33772. }
  33773. }, {
  33774. key: "parseLiteralMultiEnd",
  33775. value: function parseLiteralMultiEnd() {
  33776. if (this.char === CHAR_APOS) {
  33777. return this.next(this.parseLiteralMultiEnd2);
  33778. } else {
  33779. this.state.buf += "'";
  33780. return this.goto(this.parseLiteralMultiStringContent);
  33781. }
  33782. }
  33783. }, {
  33784. key: "parseLiteralMultiEnd2",
  33785. value: function parseLiteralMultiEnd2() {
  33786. if (this.char === CHAR_APOS) {
  33787. return this.return();
  33788. } else {
  33789. this.state.buf += "''";
  33790. return this.goto(this.parseLiteralMultiStringContent);
  33791. }
  33792. }
  33793. /* STRINGS double quoted */
  33794. }, {
  33795. key: "parseDoubleString",
  33796. value: function parseDoubleString() {
  33797. if (this.char === CHAR_QUOT) {
  33798. return this.next(this.parseMultiStringMaybe);
  33799. } else {
  33800. return this.goto(this.parseBasicString);
  33801. }
  33802. }
  33803. }, {
  33804. key: "parseBasicString",
  33805. value: function parseBasicString() {
  33806. do {
  33807. if (this.char === CHAR_BSOL) {
  33808. return this.call(this.parseEscape, this.recordEscapeReplacement);
  33809. } else if (this.char === CHAR_QUOT) {
  33810. return this.return();
  33811. } else if (this.atEndOfLine()) {
  33812. throw this.error(new TomlError('Unterminated string'));
  33813. } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I) {
  33814. throw this.errorControlCharInString();
  33815. } else {
  33816. this.consume();
  33817. }
  33818. } while (this.nextChar());
  33819. }
  33820. }, {
  33821. key: "recordEscapeReplacement",
  33822. value: function recordEscapeReplacement(replacement) {
  33823. this.state.buf += replacement;
  33824. return this.goto(this.parseBasicString);
  33825. }
  33826. }, {
  33827. key: "parseMultiStringMaybe",
  33828. value: function parseMultiStringMaybe() {
  33829. if (this.char === CHAR_QUOT) {
  33830. return this.next(this.parseMultiString);
  33831. } else {
  33832. return this.returnNow();
  33833. }
  33834. }
  33835. }, {
  33836. key: "parseMultiString",
  33837. value: function parseMultiString() {
  33838. if (this.char === CTRL_M) {
  33839. return null;
  33840. } else if (this.char === CTRL_J) {
  33841. return this.next(this.parseMultiStringContent);
  33842. } else {
  33843. return this.goto(this.parseMultiStringContent);
  33844. }
  33845. }
  33846. }, {
  33847. key: "parseMultiStringContent",
  33848. value: function parseMultiStringContent() {
  33849. do {
  33850. if (this.char === CHAR_BSOL) {
  33851. return this.call(this.parseMultiEscape, this.recordMultiEscapeReplacement);
  33852. } else if (this.char === CHAR_QUOT) {
  33853. return this.next(this.parseMultiEnd);
  33854. } else if (this.char === Parser.END) {
  33855. throw this.error(new TomlError('Unterminated multi-line string'));
  33856. } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I && this.char !== CTRL_J && this.char !== CTRL_M) {
  33857. throw this.errorControlCharInString();
  33858. } else {
  33859. this.consume();
  33860. }
  33861. } while (this.nextChar());
  33862. }
  33863. }, {
  33864. key: "errorControlCharInString",
  33865. value: function errorControlCharInString() {
  33866. var displayCode = '\\u00';
  33867. if (this.char < 16) {
  33868. displayCode += '0';
  33869. }
  33870. displayCode += this.char.toString(16);
  33871. return this.error(new TomlError(`Control characters (codes < 0x1f and 0x7f) are not allowed in strings, use ${displayCode} instead`));
  33872. }
  33873. }, {
  33874. key: "recordMultiEscapeReplacement",
  33875. value: function recordMultiEscapeReplacement(replacement) {
  33876. this.state.buf += replacement;
  33877. return this.goto(this.parseMultiStringContent);
  33878. }
  33879. }, {
  33880. key: "parseMultiEnd",
  33881. value: function parseMultiEnd() {
  33882. if (this.char === CHAR_QUOT) {
  33883. return this.next(this.parseMultiEnd2);
  33884. } else {
  33885. this.state.buf += '"';
  33886. return this.goto(this.parseMultiStringContent);
  33887. }
  33888. }
  33889. }, {
  33890. key: "parseMultiEnd2",
  33891. value: function parseMultiEnd2() {
  33892. if (this.char === CHAR_QUOT) {
  33893. return this.return();
  33894. } else {
  33895. this.state.buf += '""';
  33896. return this.goto(this.parseMultiStringContent);
  33897. }
  33898. }
  33899. }, {
  33900. key: "parseMultiEscape",
  33901. value: function parseMultiEscape() {
  33902. if (this.char === CTRL_M || this.char === CTRL_J) {
  33903. return this.next(this.parseMultiTrim);
  33904. } else if (this.char === CHAR_SP || this.char === CTRL_I) {
  33905. return this.next(this.parsePreMultiTrim);
  33906. } else {
  33907. return this.goto(this.parseEscape);
  33908. }
  33909. }
  33910. }, {
  33911. key: "parsePreMultiTrim",
  33912. value: function parsePreMultiTrim() {
  33913. if (this.char === CHAR_SP || this.char === CTRL_I) {
  33914. return null;
  33915. } else if (this.char === CTRL_M || this.char === CTRL_J) {
  33916. return this.next(this.parseMultiTrim);
  33917. } else {
  33918. throw this.error(new TomlError("Can't escape whitespace"));
  33919. }
  33920. }
  33921. }, {
  33922. key: "parseMultiTrim",
  33923. value: function parseMultiTrim() {
  33924. // explicitly whitespace here, END should follow the same path as chars
  33925. if (this.char === CTRL_J || this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M) {
  33926. return null;
  33927. } else {
  33928. return this.returnNow();
  33929. }
  33930. }
  33931. }, {
  33932. key: "parseEscape",
  33933. value: function parseEscape() {
  33934. if (this.char in escapes) {
  33935. return this.return(escapes[this.char]);
  33936. } else if (this.char === CHAR_u) {
  33937. return this.call(this.parseSmallUnicode, this.parseUnicodeReturn);
  33938. } else if (this.char === CHAR_U) {
  33939. return this.call(this.parseLargeUnicode, this.parseUnicodeReturn);
  33940. } else {
  33941. throw this.error(new TomlError('Unknown escape character: ' + this.char));
  33942. }
  33943. }
  33944. }, {
  33945. key: "parseUnicodeReturn",
  33946. value: function parseUnicodeReturn(char) {
  33947. try {
  33948. var codePoint = parseInt(char, 16);
  33949. if (codePoint >= SURROGATE_FIRST && codePoint <= SURROGATE_LAST) {
  33950. throw this.error(new TomlError('Invalid unicode, character in range 0xD800 - 0xDFFF is reserved'));
  33951. }
  33952. return this.returnNow(String.fromCodePoint(codePoint));
  33953. } catch (ex) {
  33954. throw this.error(TomlError.wrap(ex));
  33955. }
  33956. }
  33957. }, {
  33958. key: "parseSmallUnicode",
  33959. value: function parseSmallUnicode() {
  33960. if (!isHexit(this.char)) {
  33961. throw this.error(new TomlError('Invalid character in unicode sequence, expected hex'));
  33962. } else {
  33963. this.consume();
  33964. if (this.state.buf.length >= 4) return this.return();
  33965. }
  33966. }
  33967. }, {
  33968. key: "parseLargeUnicode",
  33969. value: function parseLargeUnicode() {
  33970. if (!isHexit(this.char)) {
  33971. throw this.error(new TomlError('Invalid character in unicode sequence, expected hex'));
  33972. } else {
  33973. this.consume();
  33974. if (this.state.buf.length >= 8) return this.return();
  33975. }
  33976. }
  33977. /* NUMBERS */
  33978. }, {
  33979. key: "parseNumberSign",
  33980. value: function parseNumberSign() {
  33981. this.consume();
  33982. return this.next(this.parseMaybeSignedInfOrNan);
  33983. }
  33984. }, {
  33985. key: "parseMaybeSignedInfOrNan",
  33986. value: function parseMaybeSignedInfOrNan() {
  33987. if (this.char === CHAR_i) {
  33988. return this.next(this.parseInf);
  33989. } else if (this.char === CHAR_n) {
  33990. return this.next(this.parseNan);
  33991. } else {
  33992. return this.callNow(this.parseNoUnder, this.parseNumberInteger);
  33993. }
  33994. }
  33995. }, {
  33996. key: "parseNumberInteger",
  33997. value: function parseNumberInteger() {
  33998. if (isDigit(this.char)) {
  33999. this.consume();
  34000. } else if (this.char === CHAR_LOWBAR) {
  34001. return this.call(this.parseNoUnder);
  34002. } else if (this.char === CHAR_E || this.char === CHAR_e) {
  34003. this.consume();
  34004. return this.next(this.parseNumberExponentSign);
  34005. } else if (this.char === CHAR_PERIOD) {
  34006. this.consume();
  34007. return this.call(this.parseNoUnder, this.parseNumberFloat);
  34008. } else {
  34009. var result = Integer(this.state.buf);
  34010. /* istanbul ignore if */
  34011. if (result.isNaN()) {
  34012. throw this.error(new TomlError('Invalid number'));
  34013. } else {
  34014. return this.returnNow(result);
  34015. }
  34016. }
  34017. }
  34018. }, {
  34019. key: "parseNoUnder",
  34020. value: function parseNoUnder() {
  34021. if (this.char === CHAR_LOWBAR) {
  34022. throw this.error(new TomlError('Unexpected character, expected digit, exponent marker(e) or whitespace'));
  34023. } else if (this.atEndOfWord() || this.char === CHAR_E || this.char === CHAR_e) {
  34024. throw this.error(new TomlError('Incomplete number'));
  34025. }
  34026. return this.returnNow();
  34027. }
  34028. }, {
  34029. key: "parseNumberFloat",
  34030. value: function parseNumberFloat() {
  34031. if (this.char === CHAR_LOWBAR) {
  34032. return this.call(this.parseNoUnder, this.parseNumberFloat);
  34033. } else if (isDigit(this.char)) {
  34034. this.consume();
  34035. } else if (this.char === CHAR_E || this.char === CHAR_e) {
  34036. this.consume();
  34037. return this.next(this.parseNumberExponentSign);
  34038. } else {
  34039. return this.returnNow(Float(this.state.buf));
  34040. }
  34041. }
  34042. }, {
  34043. key: "parseNumberExponentSign",
  34044. value: function parseNumberExponentSign() {
  34045. if (isDigit(this.char)) {
  34046. return this.goto(this.parseNumberExponent);
  34047. } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS) {
  34048. this.consume();
  34049. this.call(this.parseNoUnder, this.parseNumberExponent);
  34050. } else {
  34051. throw this.error(new TomlError('Unexpected character, expected -, + or digit'));
  34052. }
  34053. }
  34054. }, {
  34055. key: "parseNumberExponent",
  34056. value: function parseNumberExponent() {
  34057. if (isDigit(this.char)) {
  34058. this.consume();
  34059. } else if (this.char === CHAR_LOWBAR) {
  34060. return this.call(this.parseNoUnder);
  34061. } else {
  34062. return this.returnNow(Float(this.state.buf));
  34063. }
  34064. }
  34065. /* NUMBERS or DATETIMES */
  34066. }, {
  34067. key: "parseNumberOrDateTime",
  34068. value: function parseNumberOrDateTime() {
  34069. if (this.char === CHAR_0) {
  34070. this.consume();
  34071. return this.next(this.parseNumberBaseOrDateTime);
  34072. } else {
  34073. return this.goto(this.parseNumberOrDateTimeOnly);
  34074. }
  34075. }
  34076. }, {
  34077. key: "parseNumberOrDateTimeOnly",
  34078. value: function parseNumberOrDateTimeOnly() {
  34079. // note, if two zeros are in a row then it MUST be a date
  34080. if (this.char === CHAR_LOWBAR) {
  34081. return this.call(this.parseNoUnder, this.parseNumberInteger);
  34082. } else if (isDigit(this.char)) {
  34083. this.consume();
  34084. if (this.state.buf.length > 4) this.next(this.parseNumberInteger);
  34085. } else if (this.char === CHAR_E || this.char === CHAR_e) {
  34086. this.consume();
  34087. return this.next(this.parseNumberExponentSign);
  34088. } else if (this.char === CHAR_PERIOD) {
  34089. this.consume();
  34090. return this.call(this.parseNoUnder, this.parseNumberFloat);
  34091. } else if (this.char === CHAR_HYPHEN) {
  34092. return this.goto(this.parseDateTime);
  34093. } else if (this.char === CHAR_COLON) {
  34094. return this.goto(this.parseOnlyTimeHour);
  34095. } else {
  34096. return this.returnNow(Integer(this.state.buf));
  34097. }
  34098. }
  34099. }, {
  34100. key: "parseDateTimeOnly",
  34101. value: function parseDateTimeOnly() {
  34102. if (this.state.buf.length < 4) {
  34103. if (isDigit(this.char)) {
  34104. return this.consume();
  34105. } else if (this.char === CHAR_COLON) {
  34106. return this.goto(this.parseOnlyTimeHour);
  34107. } else {
  34108. throw this.error(new TomlError('Expected digit while parsing year part of a date'));
  34109. }
  34110. } else {
  34111. if (this.char === CHAR_HYPHEN) {
  34112. return this.goto(this.parseDateTime);
  34113. } else {
  34114. throw this.error(new TomlError('Expected hyphen (-) while parsing year part of date'));
  34115. }
  34116. }
  34117. }
  34118. }, {
  34119. key: "parseNumberBaseOrDateTime",
  34120. value: function parseNumberBaseOrDateTime() {
  34121. if (this.char === CHAR_b) {
  34122. this.consume();
  34123. return this.call(this.parseNoUnder, this.parseIntegerBin);
  34124. } else if (this.char === CHAR_o) {
  34125. this.consume();
  34126. return this.call(this.parseNoUnder, this.parseIntegerOct);
  34127. } else if (this.char === CHAR_x) {
  34128. this.consume();
  34129. return this.call(this.parseNoUnder, this.parseIntegerHex);
  34130. } else if (this.char === CHAR_PERIOD) {
  34131. return this.goto(this.parseNumberInteger);
  34132. } else if (isDigit(this.char)) {
  34133. return this.goto(this.parseDateTimeOnly);
  34134. } else {
  34135. return this.returnNow(Integer(this.state.buf));
  34136. }
  34137. }
  34138. }, {
  34139. key: "parseIntegerHex",
  34140. value: function parseIntegerHex() {
  34141. if (isHexit(this.char)) {
  34142. this.consume();
  34143. } else if (this.char === CHAR_LOWBAR) {
  34144. return this.call(this.parseNoUnder);
  34145. } else {
  34146. var result = Integer(this.state.buf);
  34147. /* istanbul ignore if */
  34148. if (result.isNaN()) {
  34149. throw this.error(new TomlError('Invalid number'));
  34150. } else {
  34151. return this.returnNow(result);
  34152. }
  34153. }
  34154. }
  34155. }, {
  34156. key: "parseIntegerOct",
  34157. value: function parseIntegerOct() {
  34158. if (isOctit(this.char)) {
  34159. this.consume();
  34160. } else if (this.char === CHAR_LOWBAR) {
  34161. return this.call(this.parseNoUnder);
  34162. } else {
  34163. var result = Integer(this.state.buf);
  34164. /* istanbul ignore if */
  34165. if (result.isNaN()) {
  34166. throw this.error(new TomlError('Invalid number'));
  34167. } else {
  34168. return this.returnNow(result);
  34169. }
  34170. }
  34171. }
  34172. }, {
  34173. key: "parseIntegerBin",
  34174. value: function parseIntegerBin() {
  34175. if (isBit(this.char)) {
  34176. this.consume();
  34177. } else if (this.char === CHAR_LOWBAR) {
  34178. return this.call(this.parseNoUnder);
  34179. } else {
  34180. var result = Integer(this.state.buf);
  34181. /* istanbul ignore if */
  34182. if (result.isNaN()) {
  34183. throw this.error(new TomlError('Invalid number'));
  34184. } else {
  34185. return this.returnNow(result);
  34186. }
  34187. }
  34188. }
  34189. /* DATETIME */
  34190. }, {
  34191. key: "parseDateTime",
  34192. value: function parseDateTime() {
  34193. // we enter here having just consumed the year and about to consume the hyphen
  34194. if (this.state.buf.length < 4) {
  34195. throw this.error(new TomlError('Years less than 1000 must be zero padded to four characters'));
  34196. }
  34197. this.state.result = this.state.buf;
  34198. this.state.buf = '';
  34199. return this.next(this.parseDateMonth);
  34200. }
  34201. }, {
  34202. key: "parseDateMonth",
  34203. value: function parseDateMonth() {
  34204. if (this.char === CHAR_HYPHEN) {
  34205. if (this.state.buf.length < 2) {
  34206. throw this.error(new TomlError('Months less than 10 must be zero padded to two characters'));
  34207. }
  34208. this.state.result += '-' + this.state.buf;
  34209. this.state.buf = '';
  34210. return this.next(this.parseDateDay);
  34211. } else if (isDigit(this.char)) {
  34212. this.consume();
  34213. } else {
  34214. throw this.error(new TomlError('Incomplete datetime'));
  34215. }
  34216. }
  34217. }, {
  34218. key: "parseDateDay",
  34219. value: function parseDateDay() {
  34220. if (this.char === CHAR_T || this.char === CHAR_SP) {
  34221. if (this.state.buf.length < 2) {
  34222. throw this.error(new TomlError('Days less than 10 must be zero padded to two characters'));
  34223. }
  34224. this.state.result += '-' + this.state.buf;
  34225. this.state.buf = '';
  34226. return this.next(this.parseStartTimeHour);
  34227. } else if (this.atEndOfWord()) {
  34228. return this.return(createDate(this.state.result + '-' + this.state.buf));
  34229. } else if (isDigit(this.char)) {
  34230. this.consume();
  34231. } else {
  34232. throw this.error(new TomlError('Incomplete datetime'));
  34233. }
  34234. }
  34235. }, {
  34236. key: "parseStartTimeHour",
  34237. value: function parseStartTimeHour() {
  34238. if (this.atEndOfWord()) {
  34239. return this.returnNow(createDate(this.state.result));
  34240. } else {
  34241. return this.goto(this.parseTimeHour);
  34242. }
  34243. }
  34244. }, {
  34245. key: "parseTimeHour",
  34246. value: function parseTimeHour() {
  34247. if (this.char === CHAR_COLON) {
  34248. if (this.state.buf.length < 2) {
  34249. throw this.error(new TomlError('Hours less than 10 must be zero padded to two characters'));
  34250. }
  34251. this.state.result += 'T' + this.state.buf;
  34252. this.state.buf = '';
  34253. return this.next(this.parseTimeMin);
  34254. } else if (isDigit(this.char)) {
  34255. this.consume();
  34256. } else {
  34257. throw this.error(new TomlError('Incomplete datetime'));
  34258. }
  34259. }
  34260. }, {
  34261. key: "parseTimeMin",
  34262. value: function parseTimeMin() {
  34263. if (this.state.buf.length < 2 && isDigit(this.char)) {
  34264. this.consume();
  34265. } else if (this.state.buf.length === 2 && this.char === CHAR_COLON) {
  34266. this.state.result += ':' + this.state.buf;
  34267. this.state.buf = '';
  34268. return this.next(this.parseTimeSec);
  34269. } else {
  34270. throw this.error(new TomlError('Incomplete datetime'));
  34271. }
  34272. }
  34273. }, {
  34274. key: "parseTimeSec",
  34275. value: function parseTimeSec() {
  34276. if (isDigit(this.char)) {
  34277. this.consume();
  34278. if (this.state.buf.length === 2) {
  34279. this.state.result += ':' + this.state.buf;
  34280. this.state.buf = '';
  34281. return this.next(this.parseTimeZoneOrFraction);
  34282. }
  34283. } else {
  34284. throw this.error(new TomlError('Incomplete datetime'));
  34285. }
  34286. }
  34287. }, {
  34288. key: "parseOnlyTimeHour",
  34289. value: function parseOnlyTimeHour() {
  34290. /* istanbul ignore else */
  34291. if (this.char === CHAR_COLON) {
  34292. if (this.state.buf.length < 2) {
  34293. throw this.error(new TomlError('Hours less than 10 must be zero padded to two characters'));
  34294. }
  34295. this.state.result = this.state.buf;
  34296. this.state.buf = '';
  34297. return this.next(this.parseOnlyTimeMin);
  34298. } else {
  34299. throw this.error(new TomlError('Incomplete time'));
  34300. }
  34301. }
  34302. }, {
  34303. key: "parseOnlyTimeMin",
  34304. value: function parseOnlyTimeMin() {
  34305. if (this.state.buf.length < 2 && isDigit(this.char)) {
  34306. this.consume();
  34307. } else if (this.state.buf.length === 2 && this.char === CHAR_COLON) {
  34308. this.state.result += ':' + this.state.buf;
  34309. this.state.buf = '';
  34310. return this.next(this.parseOnlyTimeSec);
  34311. } else {
  34312. throw this.error(new TomlError('Incomplete time'));
  34313. }
  34314. }
  34315. }, {
  34316. key: "parseOnlyTimeSec",
  34317. value: function parseOnlyTimeSec() {
  34318. if (isDigit(this.char)) {
  34319. this.consume();
  34320. if (this.state.buf.length === 2) {
  34321. return this.next(this.parseOnlyTimeFractionMaybe);
  34322. }
  34323. } else {
  34324. throw this.error(new TomlError('Incomplete time'));
  34325. }
  34326. }
  34327. }, {
  34328. key: "parseOnlyTimeFractionMaybe",
  34329. value: function parseOnlyTimeFractionMaybe() {
  34330. this.state.result += ':' + this.state.buf;
  34331. if (this.char === CHAR_PERIOD) {
  34332. this.state.buf = '';
  34333. this.next(this.parseOnlyTimeFraction);
  34334. } else {
  34335. return this.return(createTime(this.state.result));
  34336. }
  34337. }
  34338. }, {
  34339. key: "parseOnlyTimeFraction",
  34340. value: function parseOnlyTimeFraction() {
  34341. if (isDigit(this.char)) {
  34342. this.consume();
  34343. } else if (this.atEndOfWord()) {
  34344. if (this.state.buf.length === 0) throw this.error(new TomlError('Expected digit in milliseconds'));
  34345. return this.returnNow(createTime(this.state.result + '.' + this.state.buf));
  34346. } else {
  34347. throw this.error(new TomlError('Unexpected character in datetime, expected period (.), minus (-), plus (+) or Z'));
  34348. }
  34349. }
  34350. }, {
  34351. key: "parseTimeZoneOrFraction",
  34352. value: function parseTimeZoneOrFraction() {
  34353. if (this.char === CHAR_PERIOD) {
  34354. this.consume();
  34355. this.next(this.parseDateTimeFraction);
  34356. } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS) {
  34357. this.consume();
  34358. this.next(this.parseTimeZoneHour);
  34359. } else if (this.char === CHAR_Z) {
  34360. this.consume();
  34361. return this.return(createDatetime(this.state.result + this.state.buf));
  34362. } else if (this.atEndOfWord()) {
  34363. return this.returnNow(createDatetimeFloat(this.state.result + this.state.buf));
  34364. } else {
  34365. throw this.error(new TomlError('Unexpected character in datetime, expected period (.), minus (-), plus (+) or Z'));
  34366. }
  34367. }
  34368. }, {
  34369. key: "parseDateTimeFraction",
  34370. value: function parseDateTimeFraction() {
  34371. if (isDigit(this.char)) {
  34372. this.consume();
  34373. } else if (this.state.buf.length === 1) {
  34374. throw this.error(new TomlError('Expected digit in milliseconds'));
  34375. } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS) {
  34376. this.consume();
  34377. this.next(this.parseTimeZoneHour);
  34378. } else if (this.char === CHAR_Z) {
  34379. this.consume();
  34380. return this.return(createDatetime(this.state.result + this.state.buf));
  34381. } else if (this.atEndOfWord()) {
  34382. return this.returnNow(createDatetimeFloat(this.state.result + this.state.buf));
  34383. } else {
  34384. throw this.error(new TomlError('Unexpected character in datetime, expected period (.), minus (-), plus (+) or Z'));
  34385. }
  34386. }
  34387. }, {
  34388. key: "parseTimeZoneHour",
  34389. value: function parseTimeZoneHour() {
  34390. if (isDigit(this.char)) {
  34391. this.consume(); // FIXME: No more regexps
  34392. if (/\d\d$/.test(this.state.buf)) return this.next(this.parseTimeZoneSep);
  34393. } else {
  34394. throw this.error(new TomlError('Unexpected character in datetime, expected digit'));
  34395. }
  34396. }
  34397. }, {
  34398. key: "parseTimeZoneSep",
  34399. value: function parseTimeZoneSep() {
  34400. if (this.char === CHAR_COLON) {
  34401. this.consume();
  34402. this.next(this.parseTimeZoneMin);
  34403. } else {
  34404. throw this.error(new TomlError('Unexpected character in datetime, expected colon'));
  34405. }
  34406. }
  34407. }, {
  34408. key: "parseTimeZoneMin",
  34409. value: function parseTimeZoneMin() {
  34410. if (isDigit(this.char)) {
  34411. this.consume();
  34412. if (/\d\d$/.test(this.state.buf)) return this.return(createDatetime(this.state.result + this.state.buf));
  34413. } else {
  34414. throw this.error(new TomlError('Unexpected character in datetime, expected digit'));
  34415. }
  34416. }
  34417. /* BOOLEAN */
  34418. }, {
  34419. key: "parseBoolean",
  34420. value: function parseBoolean() {
  34421. /* istanbul ignore else */
  34422. if (this.char === CHAR_t) {
  34423. this.consume();
  34424. return this.next(this.parseTrue_r);
  34425. } else if (this.char === CHAR_f) {
  34426. this.consume();
  34427. return this.next(this.parseFalse_a);
  34428. }
  34429. }
  34430. }, {
  34431. key: "parseTrue_r",
  34432. value: function parseTrue_r() {
  34433. if (this.char === CHAR_r) {
  34434. this.consume();
  34435. return this.next(this.parseTrue_u);
  34436. } else {
  34437. throw this.error(new TomlError('Invalid boolean, expected true or false'));
  34438. }
  34439. }
  34440. }, {
  34441. key: "parseTrue_u",
  34442. value: function parseTrue_u() {
  34443. if (this.char === CHAR_u) {
  34444. this.consume();
  34445. return this.next(this.parseTrue_e);
  34446. } else {
  34447. throw this.error(new TomlError('Invalid boolean, expected true or false'));
  34448. }
  34449. }
  34450. }, {
  34451. key: "parseTrue_e",
  34452. value: function parseTrue_e() {
  34453. if (this.char === CHAR_e) {
  34454. return this.return(true);
  34455. } else {
  34456. throw this.error(new TomlError('Invalid boolean, expected true or false'));
  34457. }
  34458. }
  34459. }, {
  34460. key: "parseFalse_a",
  34461. value: function parseFalse_a() {
  34462. if (this.char === CHAR_a) {
  34463. this.consume();
  34464. return this.next(this.parseFalse_l);
  34465. } else {
  34466. throw this.error(new TomlError('Invalid boolean, expected true or false'));
  34467. }
  34468. }
  34469. }, {
  34470. key: "parseFalse_l",
  34471. value: function parseFalse_l() {
  34472. if (this.char === CHAR_l) {
  34473. this.consume();
  34474. return this.next(this.parseFalse_s);
  34475. } else {
  34476. throw this.error(new TomlError('Invalid boolean, expected true or false'));
  34477. }
  34478. }
  34479. }, {
  34480. key: "parseFalse_s",
  34481. value: function parseFalse_s() {
  34482. if (this.char === CHAR_s) {
  34483. this.consume();
  34484. return this.next(this.parseFalse_e);
  34485. } else {
  34486. throw this.error(new TomlError('Invalid boolean, expected true or false'));
  34487. }
  34488. }
  34489. }, {
  34490. key: "parseFalse_e",
  34491. value: function parseFalse_e() {
  34492. if (this.char === CHAR_e) {
  34493. return this.return(false);
  34494. } else {
  34495. throw this.error(new TomlError('Invalid boolean, expected true or false'));
  34496. }
  34497. }
  34498. /* INLINE LISTS */
  34499. }, {
  34500. key: "parseInlineList",
  34501. value: function parseInlineList() {
  34502. if (this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M || this.char === CTRL_J) {
  34503. return null;
  34504. } else if (this.char === Parser.END) {
  34505. throw this.error(new TomlError('Unterminated inline array'));
  34506. } else if (this.char === CHAR_NUM) {
  34507. return this.call(this.parseComment);
  34508. } else if (this.char === CHAR_RSQB) {
  34509. return this.return(this.state.resultArr || InlineList());
  34510. } else {
  34511. return this.callNow(this.parseValue, this.recordInlineListValue);
  34512. }
  34513. }
  34514. }, {
  34515. key: "recordInlineListValue",
  34516. value: function recordInlineListValue(value) {
  34517. if (this.state.resultArr) {
  34518. var listType = this.state.resultArr[_contentType];
  34519. var valueType = tomlType(value);
  34520. if (listType !== valueType) {
  34521. throw this.error(new TomlError(`Inline lists must be a single type, not a mix of ${listType} and ${valueType}`));
  34522. }
  34523. } else {
  34524. this.state.resultArr = InlineList(tomlType(value));
  34525. }
  34526. if (isFloat(value) || isInteger(value)) {
  34527. // unbox now that we've verified they're ok
  34528. this.state.resultArr.push(value.valueOf());
  34529. } else {
  34530. this.state.resultArr.push(value);
  34531. }
  34532. return this.goto(this.parseInlineListNext);
  34533. }
  34534. }, {
  34535. key: "parseInlineListNext",
  34536. value: function parseInlineListNext() {
  34537. if (this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M || this.char === CTRL_J) {
  34538. return null;
  34539. } else if (this.char === CHAR_NUM) {
  34540. return this.call(this.parseComment);
  34541. } else if (this.char === CHAR_COMMA) {
  34542. return this.next(this.parseInlineList);
  34543. } else if (this.char === CHAR_RSQB) {
  34544. return this.goto(this.parseInlineList);
  34545. } else {
  34546. throw this.error(new TomlError('Invalid character, expected whitespace, comma (,) or close bracket (])'));
  34547. }
  34548. }
  34549. /* INLINE TABLE */
  34550. }, {
  34551. key: "parseInlineTable",
  34552. value: function parseInlineTable() {
  34553. if (this.char === CHAR_SP || this.char === CTRL_I) {
  34554. return null;
  34555. } else if (this.char === Parser.END || this.char === CHAR_NUM || this.char === CTRL_J || this.char === CTRL_M) {
  34556. throw this.error(new TomlError('Unterminated inline array'));
  34557. } else if (this.char === CHAR_RCUB) {
  34558. return this.return(this.state.resultTable || InlineTable());
  34559. } else {
  34560. if (!this.state.resultTable) this.state.resultTable = InlineTable();
  34561. return this.callNow(this.parseAssign, this.recordInlineTableValue);
  34562. }
  34563. }
  34564. }, {
  34565. key: "recordInlineTableValue",
  34566. value: function recordInlineTableValue(kv) {
  34567. var target = this.state.resultTable;
  34568. var finalKey = kv.key.pop();
  34569. var _iteratorNormalCompletion2 = true;
  34570. var _didIteratorError2 = false;
  34571. var _iteratorError2 = undefined;
  34572. try {
  34573. for (var _iterator2 = kv.key[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  34574. var kw = _step2.value;
  34575. if (kw in target && (!isTable(target[kw]) || target[kw][_declared])) {
  34576. throw this.error(new TomlError("Can't redefine existing key"));
  34577. }
  34578. target = target[kw] = target[kw] || Table();
  34579. }
  34580. } catch (err) {
  34581. _didIteratorError2 = true;
  34582. _iteratorError2 = err;
  34583. } finally {
  34584. try {
  34585. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  34586. _iterator2.return();
  34587. }
  34588. } finally {
  34589. if (_didIteratorError2) {
  34590. throw _iteratorError2;
  34591. }
  34592. }
  34593. }
  34594. if (finalKey in target) {
  34595. throw this.error(new TomlError("Can't redefine existing key"));
  34596. }
  34597. if (isInteger(kv.value) || isFloat(kv.value)) {
  34598. target[finalKey] = kv.value.valueOf();
  34599. } else {
  34600. target[finalKey] = kv.value;
  34601. }
  34602. return this.goto(this.parseInlineTableNext);
  34603. }
  34604. }, {
  34605. key: "parseInlineTableNext",
  34606. value: function parseInlineTableNext() {
  34607. if (this.char === CHAR_SP || this.char === CTRL_I) {
  34608. return null;
  34609. } else if (this.char === Parser.END || this.char === CHAR_NUM || this.char === CTRL_J || this.char === CTRL_M) {
  34610. throw this.error(new TomlError('Unterminated inline array'));
  34611. } else if (this.char === CHAR_COMMA) {
  34612. return this.next(this.parseInlineTable);
  34613. } else if (this.char === CHAR_RCUB) {
  34614. return this.goto(this.parseInlineTable);
  34615. } else {
  34616. throw this.error(new TomlError('Invalid character, expected whitespace, comma (,) or close bracket (])'));
  34617. }
  34618. }
  34619. }]);
  34620. return TOMLParser;
  34621. }(Parser);
  34622. return TOMLParser;
  34623. }
  34624. });
  34625. var parsePrettyError = prettyError;
  34626. function prettyError(err, buf) {
  34627. /* istanbul ignore if */
  34628. if (err.pos == null || err.line == null) return err;
  34629. var msg = err.message;
  34630. msg += ` at row ${err.line + 1}, col ${err.col + 1}, pos ${err.pos}:\n`;
  34631. /* istanbul ignore else */
  34632. if (buf && buf.split) {
  34633. var lines = buf.split(/\n/);
  34634. var lineNumWidth = String(Math.min(lines.length, err.line + 3)).length;
  34635. var linePadding = ' ';
  34636. while (linePadding.length < lineNumWidth) {
  34637. linePadding += ' ';
  34638. }
  34639. for (var ii = Math.max(0, err.line - 1); ii < Math.min(lines.length, err.line + 2); ++ii) {
  34640. var lineNum = String(ii + 1);
  34641. if (lineNum.length < lineNumWidth) lineNum = ' ' + lineNum;
  34642. if (err.line === ii) {
  34643. msg += lineNum + '> ' + lines[ii] + '\n';
  34644. msg += linePadding + ' ';
  34645. for (var hh = 0; hh < err.col; ++hh) {
  34646. msg += ' ';
  34647. }
  34648. msg += '^\n';
  34649. } else {
  34650. msg += lineNum + ': ' + lines[ii] + '\n';
  34651. }
  34652. }
  34653. }
  34654. err.message = msg + '\n';
  34655. return err;
  34656. }
  34657. var parseString_1 = parseString;
  34658. function parseString(str) {
  34659. if (commonjsGlobal.Buffer && commonjsGlobal.Buffer.isBuffer(str)) {
  34660. str = str.toString('utf8');
  34661. }
  34662. var parser = new tomlParser();
  34663. try {
  34664. parser.parse(str);
  34665. return parser.finish();
  34666. } catch (ex) {
  34667. throw parsePrettyError(ex, str);
  34668. }
  34669. }
  34670. var loadToml = function loadToml(filePath, content) {
  34671. try {
  34672. return parseString_1(content);
  34673. } catch (error) {
  34674. error.message = `TOML Error in ${filePath}:\n${error.message}`;
  34675. throw error;
  34676. }
  34677. };
  34678. var resolveConfig_1 = createCommonjsModule(function (module) {
  34679. "use strict";
  34680. var getExplorerMemoized = mem(function (opts) {
  34681. var explorer = thirdParty$1.cosmiconfig("prettier", {
  34682. cache: opts.cache,
  34683. transform: function transform(result) {
  34684. if (result && result.config) {
  34685. if (typeof result.config !== "object") {
  34686. throw new Error(`Config is only allowed to be an object, ` + `but received ${typeof result.config} in "${result.filepath}"`);
  34687. }
  34688. delete result.config.$schema;
  34689. }
  34690. return result;
  34691. },
  34692. searchPlaces: ["package.json", ".prettierrc", ".prettierrc.json", ".prettierrc.yaml", ".prettierrc.yml", ".prettierrc.js", "prettier.config.js", ".prettierrc.toml"],
  34693. loaders: {
  34694. ".toml": loadToml
  34695. }
  34696. });
  34697. var _load = opts.sync ? explorer.loadSync : explorer.load;
  34698. var search = opts.sync ? explorer.searchSync : explorer.search;
  34699. return {
  34700. // cosmiconfig v4 interface
  34701. load: function load(searchPath, configPath) {
  34702. return configPath ? _load(configPath) : search(searchPath);
  34703. }
  34704. };
  34705. });
  34706. /** @param {{ cache: boolean, sync: boolean }} opts */
  34707. function getLoadFunction(opts) {
  34708. // Normalize opts before passing to a memoized function
  34709. opts = Object.assign({
  34710. sync: false,
  34711. cache: false
  34712. }, opts);
  34713. return getExplorerMemoized(opts).load;
  34714. }
  34715. function _resolveConfig(filePath, opts, sync) {
  34716. opts = Object.assign({
  34717. useCache: true
  34718. }, opts);
  34719. var loadOpts = {
  34720. cache: !!opts.useCache,
  34721. sync: !!sync,
  34722. editorconfig: !!opts.editorconfig
  34723. };
  34724. var load = getLoadFunction(loadOpts);
  34725. var loadEditorConfig = resolveConfigEditorconfig.getLoadFunction(loadOpts);
  34726. var arr = [load, loadEditorConfig].map(function (l) {
  34727. return l(filePath, opts.config);
  34728. });
  34729. var unwrapAndMerge = function unwrapAndMerge(arr) {
  34730. var result = arr[0];
  34731. var editorConfigured = arr[1];
  34732. var merged = Object.assign({}, editorConfigured, mergeOverrides(Object.assign({}, result), filePath));
  34733. ["plugins", "pluginSearchDirs"].forEach(function (optionName) {
  34734. if (Array.isArray(merged[optionName])) {
  34735. merged[optionName] = merged[optionName].map(function (value) {
  34736. return typeof value === "string" && value.startsWith(".") // relative path
  34737. ? path.resolve(path.dirname(result.filepath), value) : value;
  34738. });
  34739. }
  34740. });
  34741. if (!result && !editorConfigured) {
  34742. return null;
  34743. }
  34744. return merged;
  34745. };
  34746. if (loadOpts.sync) {
  34747. return unwrapAndMerge(arr);
  34748. }
  34749. return Promise.all(arr).then(unwrapAndMerge);
  34750. }
  34751. var resolveConfig = function resolveConfig(filePath, opts) {
  34752. return _resolveConfig(filePath, opts, false);
  34753. };
  34754. resolveConfig.sync = function (filePath, opts) {
  34755. return _resolveConfig(filePath, opts, true);
  34756. };
  34757. function clearCache() {
  34758. mem.clear(getExplorerMemoized);
  34759. resolveConfigEditorconfig.clearCache();
  34760. }
  34761. function resolveConfigFile(filePath) {
  34762. var load = getLoadFunction({
  34763. sync: false
  34764. });
  34765. return load(filePath).then(function (result) {
  34766. return result ? result.filepath : null;
  34767. });
  34768. }
  34769. resolveConfigFile.sync = function (filePath) {
  34770. var load = getLoadFunction({
  34771. sync: true
  34772. });
  34773. var result = load(filePath);
  34774. return result ? result.filepath : null;
  34775. };
  34776. function mergeOverrides(configResult, filePath) {
  34777. var options = Object.assign({}, configResult.config);
  34778. if (filePath && options.overrides) {
  34779. var relativeFilePath = path.relative(path.dirname(configResult.filepath), filePath);
  34780. var _iteratorNormalCompletion = true;
  34781. var _didIteratorError = false;
  34782. var _iteratorError = undefined;
  34783. try {
  34784. for (var _iterator = options.overrides[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  34785. var override = _step.value;
  34786. if (pathMatchesGlobs(relativeFilePath, override.files, override.excludeFiles)) {
  34787. Object.assign(options, override.options);
  34788. }
  34789. }
  34790. } catch (err) {
  34791. _didIteratorError = true;
  34792. _iteratorError = err;
  34793. } finally {
  34794. try {
  34795. if (!_iteratorNormalCompletion && _iterator.return != null) {
  34796. _iterator.return();
  34797. }
  34798. } finally {
  34799. if (_didIteratorError) {
  34800. throw _iteratorError;
  34801. }
  34802. }
  34803. }
  34804. }
  34805. delete options.overrides;
  34806. return options;
  34807. } // Based on eslint: https://github.com/eslint/eslint/blob/master/lib/config/config-ops.js
  34808. function pathMatchesGlobs(filePath, patterns, excludedPatterns) {
  34809. var patternList = [].concat(patterns);
  34810. var excludedPatternList = [].concat(excludedPatterns || []);
  34811. var opts = {
  34812. matchBase: true
  34813. };
  34814. return patternList.some(function (pattern) {
  34815. return minimatch_1(filePath, pattern, opts);
  34816. }) && !excludedPatternList.some(function (excludedPattern) {
  34817. return minimatch_1(filePath, excludedPattern, opts);
  34818. });
  34819. }
  34820. module.exports = {
  34821. resolveConfig,
  34822. resolveConfigFile,
  34823. clearCache
  34824. };
  34825. });
  34826. var version = require$$0.version;
  34827. var getSupportInfo = support.getSupportInfo; // Luckily `opts` is always the 2nd argument
  34828. function _withPlugins(fn) {
  34829. return function () {
  34830. var args = Array.from(arguments);
  34831. var opts = args[1] || {};
  34832. args[1] = Object.assign({}, opts, {
  34833. plugins: loadPlugins_1(opts.plugins, opts.pluginSearchDirs)
  34834. });
  34835. return fn.apply(null, args);
  34836. };
  34837. }
  34838. function withPlugins(fn) {
  34839. var resultingFn = _withPlugins(fn);
  34840. if (fn.sync) {
  34841. resultingFn.sync = _withPlugins(fn.sync);
  34842. }
  34843. return resultingFn;
  34844. }
  34845. var formatWithCursor = withPlugins(core.formatWithCursor);
  34846. var src = {
  34847. formatWithCursor,
  34848. format(text, opts) {
  34849. return formatWithCursor(text, opts).formatted;
  34850. },
  34851. check: function check(text, opts) {
  34852. var formatted = formatWithCursor(text, opts).formatted;
  34853. return formatted === text;
  34854. },
  34855. doc,
  34856. resolveConfig: resolveConfig_1.resolveConfig,
  34857. resolveConfigFile: resolveConfig_1.resolveConfigFile,
  34858. clearConfigCache: resolveConfig_1.clearCache,
  34859. getFileInfo: withPlugins(getFileInfo_1),
  34860. getSupportInfo: withPlugins(getSupportInfo),
  34861. version,
  34862. util: utilShared,
  34863. /* istanbul ignore next */
  34864. __debug: {
  34865. parse: withPlugins(core.parse),
  34866. formatAST: withPlugins(core.formatAST),
  34867. formatDoc: withPlugins(core.formatDoc),
  34868. printToDoc: withPlugins(core.printToDoc),
  34869. printDocToString: withPlugins(core.printDocToString)
  34870. }
  34871. };
  34872. var prettier = src;
  34873. module.exports = prettier;