aliyun-oss-sdk.js 1.2 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472
  1. // Aliyun OSS SDK for JavaScript v6.13.2
  2. // Copyright Aliyun.com, Inc. or its affiliates. All Rights Reserved.
  3. // License at https://github.com/ali-sdk/ali-oss/blob/master/LICENSE
  4. (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.OSS = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
  5. "use strict";
  6. var OSS = require('./browser/client');
  7. OSS.Buffer = require('buffer').Buffer;
  8. OSS.urllib = require('../shims/xhr');
  9. OSS.version = require('./browser/version').version;
  10. module.exports = OSS;
  11. },{"../shims/xhr":397,"./browser/client":2,"./browser/version":5,"buffer":98}],2:[function(require,module,exports){
  12. (function (Buffer,process){
  13. "use strict";
  14. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  15. require("core-js/modules/es.symbol");
  16. require("core-js/modules/es.symbol.description");
  17. require("core-js/modules/es.array.concat");
  18. require("core-js/modules/es.array.includes");
  19. require("core-js/modules/es.array.index-of");
  20. require("core-js/modules/es.array.slice");
  21. require("core-js/modules/es.function.name");
  22. require("core-js/modules/es.object.assign");
  23. require("core-js/modules/es.object.to-string");
  24. require("core-js/modules/es.promise");
  25. require("core-js/modules/es.regexp.exec");
  26. require("core-js/modules/es.regexp.to-string");
  27. require("core-js/modules/es.string.replace");
  28. require("core-js/modules/es.string.split");
  29. require("core-js/modules/es.string.starts-with");
  30. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  31. require("regenerator-runtime/runtime");
  32. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  33. var debug = require('debug')('ali-oss');
  34. var xml = require('xml2js');
  35. var AgentKeepalive = require('agentkeepalive');
  36. var merge = require('merge-descriptors');
  37. var platform = require('platform');
  38. var utility = require('utility');
  39. var urllib = require('urllib');
  40. var pkg = require('./version');
  41. var bowser = require('bowser');
  42. var signUtils = require('../common/signUtils');
  43. var _initOptions = require('../common/client/initOptions');
  44. var _require = require('../common/utils/createRequest'),
  45. createRequest = _require.createRequest;
  46. var _require2 = require('../common/utils/encoder'),
  47. encoder = _require2.encoder;
  48. var _require3 = require('../common/client/getReqUrl'),
  49. getReqUrl = _require3.getReqUrl;
  50. var _require4 = require('../common/utils/setSTSToken'),
  51. setSTSToken = _require4.setSTSToken;
  52. var _require5 = require('../common/utils/retry'),
  53. retry = _require5.retry;
  54. var globalHttpAgent = new AgentKeepalive();
  55. function _unSupportBrowserTip() {
  56. var name = platform.name,
  57. version = platform.version;
  58. if (name && name.toLowerCase && name.toLowerCase() === 'ie' && version.split('.')[0] < 10) {
  59. // eslint-disable-next-line no-console
  60. console.warn('ali-oss does not support the current browser');
  61. }
  62. } // check local web protocol,if https secure default set true , if http secure default set false
  63. function isHttpsWebProtocol() {
  64. // for web worker not use window.location.
  65. // eslint-disable-next-line no-restricted-globals
  66. return location && location.protocol === 'https:';
  67. }
  68. function Client(options, ctx) {
  69. _unSupportBrowserTip();
  70. if (!(this instanceof Client)) {
  71. return new Client(options, ctx);
  72. }
  73. if (options && options.inited) {
  74. this.options = options;
  75. } else {
  76. this.options = Client.initOptions(options);
  77. }
  78. this.options.cancelFlag = false; // cancel flag: if true need to be cancelled, default false
  79. // support custom agent and urllib client
  80. if (this.options.urllib) {
  81. this.urllib = this.options.urllib;
  82. } else {
  83. this.urllib = urllib;
  84. this.agent = this.options.agent || globalHttpAgent;
  85. }
  86. this.ctx = ctx;
  87. this.userAgent = this._getUserAgent(); // record the time difference between client and server
  88. this.options.amendTimeSkewed = 0;
  89. }
  90. /**
  91. * Expose `Client`
  92. */
  93. module.exports = Client;
  94. Client.initOptions = function initOptions(options) {
  95. if (!options.stsToken) {
  96. console.warn('Please use STS Token for safety, see more details at https://help.aliyun.com/document_detail/32077.html');
  97. }
  98. var opts = Object.assign({
  99. secure: isHttpsWebProtocol(),
  100. // for browser compatibility disable fetch.
  101. useFetch: false
  102. }, options);
  103. return _initOptions(opts);
  104. };
  105. /**
  106. * prototype
  107. */
  108. var proto = Client.prototype; // mount debug on proto
  109. proto.debug = debug;
  110. /**
  111. * Object operations
  112. */
  113. merge(proto, require('./object'));
  114. /**
  115. * Bucket operations
  116. */
  117. merge(proto, require('../common/bucket/getBucketWebsite'));
  118. merge(proto, require('../common/bucket/putBucketWebsite'));
  119. merge(proto, require('../common/bucket/deleteBucketWebsite')); // lifecycle
  120. merge(proto, require('../common/bucket/getBucketLifecycle'));
  121. merge(proto, require('../common/bucket/putBucketLifecycle'));
  122. merge(proto, require('../common/bucket/deleteBucketLifecycle')); // multiversion
  123. merge(proto, require('../common/bucket/putBucketVersioning'));
  124. merge(proto, require('../common/bucket/getBucketVersioning')); // inventory
  125. merge(proto, require('../common/bucket/getBucketInventory'));
  126. merge(proto, require('../common/bucket/deleteBucketInventory'));
  127. merge(proto, require('../common/bucket/listBucketInventory'));
  128. merge(proto, require('../common/bucket/putBucketInventory')); // worm
  129. merge(proto, require('../common/bucket/abortBucketWorm'));
  130. merge(proto, require('../common/bucket/completeBucketWorm'));
  131. merge(proto, require('../common/bucket/extendBucketWorm'));
  132. merge(proto, require('../common/bucket/getBucketWorm'));
  133. merge(proto, require('../common/bucket/initiateBucketWorm')); // multipart upload
  134. merge(proto, require('./managed-upload'));
  135. /**
  136. * Multipart operations
  137. */
  138. merge(proto, require('../common/multipart'));
  139. /**
  140. * Common module parallel
  141. */
  142. merge(proto, require('../common/parallel'));
  143. /**
  144. * get OSS signature
  145. * @param {String} stringToSign
  146. * @return {String} the signature
  147. */
  148. proto.signature = function signature(stringToSign) {
  149. this.debug('authorization stringToSign: %s', stringToSign, 'info');
  150. return signUtils.computeSignature(this.options.accessKeySecret, stringToSign, this.options.headerEncoding);
  151. };
  152. proto._getReqUrl = getReqUrl;
  153. /**
  154. * get author header
  155. *
  156. * "Authorization: OSS " + Access Key Id + ":" + Signature
  157. *
  158. * Signature = base64(hmac-sha1(Access Key Secret + "\n"
  159. * + VERB + "\n"
  160. * + CONTENT-MD5 + "\n"
  161. * + CONTENT-TYPE + "\n"
  162. * + DATE + "\n"
  163. * + CanonicalizedOSSHeaders
  164. * + CanonicalizedResource))
  165. *
  166. * @param {String} method
  167. * @param {String} resource
  168. * @param {Object} header
  169. * @return {String}
  170. *
  171. * @api private
  172. */
  173. proto.authorization = function authorization(method, resource, subres, headers) {
  174. var stringToSign = signUtils.buildCanonicalString(method.toUpperCase(), resource, {
  175. headers: headers,
  176. parameters: subres
  177. });
  178. return signUtils.authorization(this.options.accessKeyId, this.options.accessKeySecret, stringToSign, this.options.headerEncoding);
  179. };
  180. /**
  181. * request oss server
  182. * @param {Object} params
  183. * - {String} object
  184. * - {String} bucket
  185. * - {Object} [headers]
  186. * - {Object} [query]
  187. * - {Buffer} [content]
  188. * - {Stream} [stream]
  189. * - {Stream} [writeStream]
  190. * - {String} [mime]
  191. * - {Boolean} [xmlResponse]
  192. * - {Boolean} [customResponse]
  193. * - {Number} [timeout]
  194. * - {Object} [ctx] request context, default is `this.ctx`
  195. *
  196. * @api private
  197. */
  198. proto.request = /*#__PURE__*/function () {
  199. var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(params) {
  200. var _this = this;
  201. var isAvailableStream;
  202. return _regenerator.default.wrap(function _callee$(_context) {
  203. while (1) {
  204. switch (_context.prev = _context.next) {
  205. case 0:
  206. isAvailableStream = params.stream ? params.stream.readable : true;
  207. if (this.options.retryMax && isAvailableStream) {
  208. this.request = retry(request.bind(this), this.options.retryMax, {
  209. errorHandler: function errorHandler(err) {
  210. var _errHandle = function _errHandle(_err) {
  211. var statusErr = [-1, -2].includes(_err.status);
  212. var requestErrorRetryHandle = _this.options.requestErrorRetryHandle || function () {
  213. return true;
  214. };
  215. return statusErr && requestErrorRetryHandle(_err);
  216. };
  217. if (_errHandle(err)) return true;
  218. return false;
  219. }
  220. });
  221. } else {
  222. this.request = request.bind(this);
  223. }
  224. _context.next = 4;
  225. return this.request(params);
  226. case 4:
  227. return _context.abrupt("return", _context.sent);
  228. case 5:
  229. case "end":
  230. return _context.stop();
  231. }
  232. }
  233. }, _callee, this);
  234. }));
  235. return function (_x) {
  236. return _ref.apply(this, arguments);
  237. };
  238. }();
  239. function request(_x2) {
  240. return _request.apply(this, arguments);
  241. }
  242. function _request() {
  243. _request = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(params) {
  244. var reqParams, result, reqErr, useStream, err, parseData;
  245. return _regenerator.default.wrap(function _callee3$(_context3) {
  246. while (1) {
  247. switch (_context3.prev = _context3.next) {
  248. case 0:
  249. reqParams = createRequest.call(this, params);
  250. if (!this.options.useFetch) {
  251. reqParams.params.mode = 'disable-fetch';
  252. }
  253. useStream = !!params.stream;
  254. _context3.prev = 3;
  255. _context3.next = 6;
  256. return this.urllib.request(reqParams.url, reqParams.params);
  257. case 6:
  258. result = _context3.sent;
  259. this.debug('response %s %s, got %s, headers: %j', params.method, reqParams.url, result.status, result.headers, 'info');
  260. _context3.next = 13;
  261. break;
  262. case 10:
  263. _context3.prev = 10;
  264. _context3.t0 = _context3["catch"](3);
  265. reqErr = _context3.t0;
  266. case 13:
  267. if (!(result && params.successStatuses && params.successStatuses.indexOf(result.status) === -1)) {
  268. _context3.next = 25;
  269. break;
  270. }
  271. _context3.next = 16;
  272. return this.requestError(result);
  273. case 16:
  274. err = _context3.sent;
  275. if (!(err.code === 'RequestTimeTooSkewed' && !useStream)) {
  276. _context3.next = 22;
  277. break;
  278. }
  279. this.options.amendTimeSkewed = +new Date(err.serverTime) - new Date();
  280. _context3.next = 21;
  281. return this.request(params);
  282. case 21:
  283. return _context3.abrupt("return", _context3.sent);
  284. case 22:
  285. err.params = params;
  286. _context3.next = 29;
  287. break;
  288. case 25:
  289. if (!reqErr) {
  290. _context3.next = 29;
  291. break;
  292. }
  293. _context3.next = 28;
  294. return this.requestError(reqErr);
  295. case 28:
  296. err = _context3.sent;
  297. case 29:
  298. if (!err) {
  299. _context3.next = 37;
  300. break;
  301. }
  302. if (!(err.status === 403 && err.code === 'InvalidAccessKeyId' && this.options.accessKeyId.startsWith('STS.') && typeof this.options.refreshSTSToken === 'function')) {
  303. _context3.next = 36;
  304. break;
  305. }
  306. if (!(!this._setOptions || Date.now() - this._setOptions > 10000)) {
  307. _context3.next = 36;
  308. break;
  309. }
  310. this._setOptions = Date.now();
  311. _context3.next = 35;
  312. return setSTSToken.call(this);
  313. case 35:
  314. return _context3.abrupt("return", this.request(params));
  315. case 36:
  316. throw err;
  317. case 37:
  318. if (!params.xmlResponse) {
  319. _context3.next = 42;
  320. break;
  321. }
  322. _context3.next = 40;
  323. return this.parseXML(result.data);
  324. case 40:
  325. parseData = _context3.sent;
  326. result.data = parseData;
  327. case 42:
  328. return _context3.abrupt("return", result);
  329. case 43:
  330. case "end":
  331. return _context3.stop();
  332. }
  333. }
  334. }, _callee3, this, [[3, 10]]);
  335. }));
  336. return _request.apply(this, arguments);
  337. }
  338. ;
  339. proto._getResource = function _getResource(params) {
  340. var resource = '/';
  341. if (params.bucket) resource += "".concat(params.bucket, "/");
  342. if (params.object) resource += encoder(params.object, this.options.headerEncoding);
  343. return resource;
  344. };
  345. proto._escape = function _escape(name) {
  346. return utility.encodeURIComponent(name).replace(/%2F/g, '/');
  347. };
  348. /*
  349. * Get User-Agent for browser & node.js
  350. * @example
  351. * aliyun-sdk-nodejs/4.1.2 Node.js 5.3.0 on Darwin 64-bit
  352. * aliyun-sdk-js/4.1.2 Safari 9.0 on Apple iPhone(iOS 9.2.1)
  353. * aliyun-sdk-js/4.1.2 Chrome 43.0.2357.134 32-bit on Windows Server 2008 R2 / 7 64-bit
  354. */
  355. proto._getUserAgent = function _getUserAgent() {
  356. var agent = process && process.browser ? 'js' : 'nodejs';
  357. var sdk = "aliyun-sdk-".concat(agent, "/").concat(pkg.version);
  358. var plat = platform.description;
  359. if (!plat && process) {
  360. plat = "Node.js ".concat(process.version.slice(1), " on ").concat(process.platform, " ").concat(process.arch);
  361. }
  362. return this._checkUserAgent("".concat(sdk, " ").concat(plat));
  363. };
  364. proto._checkUserAgent = function _checkUserAgent(ua) {
  365. var userAgent = ua.replace(/\u03b1/, 'alpha').replace(/\u03b2/, 'beta');
  366. return userAgent;
  367. };
  368. /*
  369. * Check Browser And Version
  370. * @param {String} [name] browser name: like IE, Chrome, Firefox
  371. * @param {String} [version] browser major version: like 10(IE 10.x), 55(Chrome 55.x), 50(Firefox 50.x)
  372. * @return {Bool} true or false
  373. * @api private
  374. */
  375. proto.checkBrowserAndVersion = function checkBrowserAndVersion(name, version) {
  376. return bowser.name === name && bowser.version.split('.')[0] === version;
  377. };
  378. /**
  379. * thunkify xml.parseString
  380. * @param {String|Buffer} str
  381. *
  382. * @api private
  383. */
  384. proto.parseXML = function parseXMLThunk(str) {
  385. return new Promise(function (resolve, reject) {
  386. if (Buffer.isBuffer(str)) {
  387. str = str.toString();
  388. }
  389. xml.parseString(str, {
  390. explicitRoot: false,
  391. explicitArray: false
  392. }, function (err, result) {
  393. if (err) {
  394. reject(err);
  395. } else {
  396. resolve(result);
  397. }
  398. });
  399. });
  400. };
  401. /**
  402. * generater a request error with request response
  403. * @param {Object} result
  404. *
  405. * @api private
  406. */
  407. proto.requestError = /*#__PURE__*/function () {
  408. var _requestError = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(result) {
  409. var err, message, info, msg;
  410. return _regenerator.default.wrap(function _callee2$(_context2) {
  411. while (1) {
  412. switch (_context2.prev = _context2.next) {
  413. case 0:
  414. err = null;
  415. if (!(!result.data || !result.data.length)) {
  416. _context2.next = 5;
  417. break;
  418. }
  419. if (result.status === -1 || result.status === -2) {
  420. // -1 is net error , -2 is timeout
  421. err = new Error(result.message);
  422. err.name = result.name;
  423. err.status = result.status;
  424. err.code = result.name;
  425. } else {
  426. // HEAD not exists resource
  427. if (result.status === 404) {
  428. err = new Error('Object not exists');
  429. err.name = 'NoSuchKeyError';
  430. err.status = 404;
  431. err.code = 'NoSuchKey';
  432. } else if (result.status === 412) {
  433. err = new Error('Pre condition failed');
  434. err.name = 'PreconditionFailedError';
  435. err.status = 412;
  436. err.code = 'PreconditionFailed';
  437. } else {
  438. err = new Error("Unknow error, status: ".concat(result.status));
  439. err.name = 'UnknowError';
  440. err.status = result.status;
  441. }
  442. err.requestId = result.headers['x-oss-request-id'];
  443. err.host = '';
  444. }
  445. _context2.next = 32;
  446. break;
  447. case 5:
  448. message = String(result.data);
  449. this.debug('request response error data: %s', message, 'error');
  450. _context2.prev = 7;
  451. _context2.next = 10;
  452. return this.parseXML(message);
  453. case 10:
  454. _context2.t0 = _context2.sent;
  455. if (_context2.t0) {
  456. _context2.next = 13;
  457. break;
  458. }
  459. _context2.t0 = {};
  460. case 13:
  461. info = _context2.t0;
  462. _context2.next = 23;
  463. break;
  464. case 16:
  465. _context2.prev = 16;
  466. _context2.t1 = _context2["catch"](7);
  467. this.debug(message, 'error');
  468. _context2.t1.message += "\nraw xml: ".concat(message);
  469. _context2.t1.status = result.status;
  470. _context2.t1.requestId = result.headers['x-oss-request-id'];
  471. return _context2.abrupt("return", _context2.t1);
  472. case 23:
  473. msg = info.Message || "unknow request error, status: ".concat(result.status);
  474. if (info.Condition) {
  475. msg += " (condition: ".concat(info.Condition, ")");
  476. }
  477. err = new Error(msg);
  478. err.name = info.Code ? "".concat(info.Code, "Error") : 'UnknowError';
  479. err.status = result.status;
  480. err.code = info.Code;
  481. err.requestId = info.RequestId;
  482. err.hostId = info.HostId;
  483. err.serverTime = info.ServerTime;
  484. case 32:
  485. this.debug('generate error %j', err, 'error');
  486. return _context2.abrupt("return", err);
  487. case 34:
  488. case "end":
  489. return _context2.stop();
  490. }
  491. }
  492. }, _callee2, this, [[7, 16]]);
  493. }));
  494. function requestError(_x3) {
  495. return _requestError.apply(this, arguments);
  496. }
  497. return requestError;
  498. }();
  499. }).call(this,{"isBuffer":require("../../node_modules/is-buffer/index.js")},require('_process'))
  500. },{"../../node_modules/is-buffer/index.js":308,"../common/bucket/abortBucketWorm":6,"../common/bucket/completeBucketWorm":7,"../common/bucket/deleteBucketInventory":8,"../common/bucket/deleteBucketLifecycle":9,"../common/bucket/deleteBucketWebsite":10,"../common/bucket/extendBucketWorm":11,"../common/bucket/getBucketInventory":12,"../common/bucket/getBucketLifecycle":13,"../common/bucket/getBucketVersioning":14,"../common/bucket/getBucketWebsite":15,"../common/bucket/getBucketWorm":16,"../common/bucket/initiateBucketWorm":17,"../common/bucket/listBucketInventory":18,"../common/bucket/putBucketInventory":19,"../common/bucket/putBucketLifecycle":20,"../common/bucket/putBucketVersioning":21,"../common/bucket/putBucketWebsite":22,"../common/client/getReqUrl":24,"../common/client/initOptions":25,"../common/multipart":28,"../common/parallel":46,"../common/signUtils":47,"../common/utils/createRequest":52,"../common/utils/encoder":55,"../common/utils/retry":67,"../common/utils/setSTSToken":69,"./managed-upload":3,"./object":4,"./version":5,"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"_process":393,"agentkeepalive":75,"bowser":77,"core-js/modules/es.array.concat":234,"core-js/modules/es.array.includes":240,"core-js/modules/es.array.index-of":241,"core-js/modules/es.array.slice":246,"core-js/modules/es.function.name":249,"core-js/modules/es.object.assign":251,"core-js/modules/es.object.to-string":254,"core-js/modules/es.promise":255,"core-js/modules/es.regexp.exec":256,"core-js/modules/es.regexp.to-string":257,"core-js/modules/es.string.replace":261,"core-js/modules/es.string.split":263,"core-js/modules/es.string.starts-with":264,"core-js/modules/es.symbol":267,"core-js/modules/es.symbol.description":266,"debug":391,"merge-descriptors":311,"platform":317,"regenerator-runtime/runtime":337,"urllib":397,"utility":396,"xml2js":352}],3:[function(require,module,exports){
  501. (function (Buffer){
  502. "use strict";
  503. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  504. require("core-js/modules/es.array.concat");
  505. require("core-js/modules/es.array.filter");
  506. require("core-js/modules/es.array.find");
  507. require("core-js/modules/es.array.from");
  508. require("core-js/modules/es.array.index-of");
  509. require("core-js/modules/es.array.iterator");
  510. require("core-js/modules/es.array.map");
  511. require("core-js/modules/es.array.slice");
  512. require("core-js/modules/es.array.splice");
  513. require("core-js/modules/es.array-buffer.slice");
  514. require("core-js/modules/es.function.name");
  515. require("core-js/modules/es.object.to-string");
  516. require("core-js/modules/es.promise");
  517. require("core-js/modules/es.regexp.to-string");
  518. require("core-js/modules/es.string.iterator");
  519. require("core-js/modules/es.typed-array.uint8-array");
  520. require("core-js/modules/es.typed-array.copy-within");
  521. require("core-js/modules/es.typed-array.every");
  522. require("core-js/modules/es.typed-array.fill");
  523. require("core-js/modules/es.typed-array.filter");
  524. require("core-js/modules/es.typed-array.find");
  525. require("core-js/modules/es.typed-array.find-index");
  526. require("core-js/modules/es.typed-array.for-each");
  527. require("core-js/modules/es.typed-array.includes");
  528. require("core-js/modules/es.typed-array.index-of");
  529. require("core-js/modules/es.typed-array.iterator");
  530. require("core-js/modules/es.typed-array.join");
  531. require("core-js/modules/es.typed-array.last-index-of");
  532. require("core-js/modules/es.typed-array.map");
  533. require("core-js/modules/es.typed-array.reduce");
  534. require("core-js/modules/es.typed-array.reduce-right");
  535. require("core-js/modules/es.typed-array.reverse");
  536. require("core-js/modules/es.typed-array.set");
  537. require("core-js/modules/es.typed-array.slice");
  538. require("core-js/modules/es.typed-array.some");
  539. require("core-js/modules/es.typed-array.sort");
  540. require("core-js/modules/es.typed-array.subarray");
  541. require("core-js/modules/es.typed-array.to-locale-string");
  542. require("core-js/modules/es.typed-array.to-string");
  543. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  544. require("regenerator-runtime/runtime");
  545. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  546. // var debug = require('debug')('ali-oss:multipart');
  547. var util = require('util');
  548. var path = require('path');
  549. var mime = require('mime');
  550. var copy = require('copy-to');
  551. var _require = require('../common/utils/isBlob'),
  552. isBlob = _require.isBlob;
  553. var _require2 = require('../common/utils/isFile'),
  554. isFile = _require2.isFile;
  555. var _require3 = require('../common/utils/isArray'),
  556. isArray = _require3.isArray;
  557. var _require4 = require('../common/utils/isBuffer'),
  558. isBuffer = _require4.isBuffer;
  559. var proto = exports;
  560. /**
  561. * Multipart operations
  562. */
  563. /**
  564. * Upload a file to OSS using multipart uploads
  565. * @param {String} name
  566. * @param {String|File|Buffer} file
  567. * @param {Object} options
  568. * {Object} options.callback The callback parameter is composed of a JSON string encoded in Base64
  569. * {String} options.callback.url the OSS sends a callback request to this URL
  570. * {String} options.callback.host The host header value for initiating callback requests
  571. * {String} options.callback.body The value of the request body when a callback is initiated
  572. * {String} options.callback.contentType The Content-Type of the callback requests initiatiated
  573. * {Object} options.callback.customValue Custom parameters are a map of key-values, e.g:
  574. * customValue = {
  575. * key1: 'value1',
  576. * key2: 'value2'
  577. * }
  578. */
  579. proto.multipartUpload = /*#__PURE__*/function () {
  580. var _multipartUpload = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, file) {
  581. var options,
  582. minPartSize,
  583. fileSize,
  584. result,
  585. ret,
  586. initResult,
  587. uploadId,
  588. partSize,
  589. checkpoint,
  590. _args = arguments;
  591. return _regenerator.default.wrap(function _callee$(_context) {
  592. while (1) {
  593. switch (_context.prev = _context.next) {
  594. case 0:
  595. options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
  596. this.resetCancelFlag();
  597. if (!(options.checkpoint && options.checkpoint.uploadId)) {
  598. _context.next = 7;
  599. break;
  600. }
  601. if (file && isFile(file)) options.checkpoint.file = file;
  602. _context.next = 6;
  603. return this._resumeMultipart(options.checkpoint, options);
  604. case 6:
  605. return _context.abrupt("return", _context.sent);
  606. case 7:
  607. minPartSize = 100 * 1024;
  608. if (!options.mime) {
  609. if (isFile(file)) {
  610. options.mime = mime.getType(path.extname(file.name));
  611. } else if (isBlob(file)) {
  612. options.mime = file.type;
  613. } else if (isBuffer(file)) {
  614. options.mime = '';
  615. } else {
  616. options.mime = mime.getType(path.extname(file));
  617. }
  618. }
  619. options.headers = options.headers || {};
  620. this._convertMetaToHeaders(options.meta, options.headers);
  621. _context.next = 13;
  622. return this._getFileSize(file);
  623. case 13:
  624. fileSize = _context.sent;
  625. if (!(fileSize < minPartSize)) {
  626. _context.next = 25;
  627. break;
  628. }
  629. options.contentLength = fileSize;
  630. _context.next = 18;
  631. return this.put(name, file, options);
  632. case 18:
  633. result = _context.sent;
  634. if (!(options && options.progress)) {
  635. _context.next = 22;
  636. break;
  637. }
  638. _context.next = 22;
  639. return options.progress(1);
  640. case 22:
  641. ret = {
  642. res: result.res,
  643. bucket: this.options.bucket,
  644. name: name,
  645. etag: result.res.headers.etag
  646. };
  647. if (options.headers && options.headers['x-oss-callback'] || options.callback) {
  648. ret.data = result.data;
  649. }
  650. return _context.abrupt("return", ret);
  651. case 25:
  652. if (!(options.partSize && !(parseInt(options.partSize, 10) === options.partSize))) {
  653. _context.next = 27;
  654. break;
  655. }
  656. throw new Error('partSize must be int number');
  657. case 27:
  658. if (!(options.partSize && options.partSize < minPartSize)) {
  659. _context.next = 29;
  660. break;
  661. }
  662. throw new Error("partSize must not be smaller than ".concat(minPartSize));
  663. case 29:
  664. _context.next = 31;
  665. return this.initMultipartUpload(name, options);
  666. case 31:
  667. initResult = _context.sent;
  668. uploadId = initResult.uploadId;
  669. partSize = this._getPartSize(fileSize, options.partSize);
  670. checkpoint = {
  671. file: file,
  672. name: name,
  673. fileSize: fileSize,
  674. partSize: partSize,
  675. uploadId: uploadId,
  676. doneParts: []
  677. };
  678. if (!(options && options.progress)) {
  679. _context.next = 38;
  680. break;
  681. }
  682. _context.next = 38;
  683. return options.progress(0, checkpoint, initResult.res);
  684. case 38:
  685. _context.next = 40;
  686. return this._resumeMultipart(checkpoint, options);
  687. case 40:
  688. return _context.abrupt("return", _context.sent);
  689. case 41:
  690. case "end":
  691. return _context.stop();
  692. }
  693. }
  694. }, _callee, this);
  695. }));
  696. function multipartUpload(_x, _x2) {
  697. return _multipartUpload.apply(this, arguments);
  698. }
  699. return multipartUpload;
  700. }();
  701. /*
  702. * Resume multipart upload from checkpoint. The checkpoint will be
  703. * updated after each successful part upload.
  704. * @param {Object} checkpoint the checkpoint
  705. * @param {Object} options
  706. */
  707. proto._resumeMultipart = /*#__PURE__*/function () {
  708. var _resumeMultipart2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(checkpoint, options) {
  709. var that, file, fileSize, partSize, uploadId, doneParts, name, internalDoneParts, partOffs, numParts, multipartFinish, uploadPartJob, all, done, todo, defaultParallel, parallel, jobErr, abortEvent;
  710. return _regenerator.default.wrap(function _callee3$(_context3) {
  711. while (1) {
  712. switch (_context3.prev = _context3.next) {
  713. case 0:
  714. that = this;
  715. if (!this.isCancel()) {
  716. _context3.next = 3;
  717. break;
  718. }
  719. throw this._makeCancelEvent();
  720. case 3:
  721. file = checkpoint.file, fileSize = checkpoint.fileSize, partSize = checkpoint.partSize, uploadId = checkpoint.uploadId, doneParts = checkpoint.doneParts, name = checkpoint.name;
  722. internalDoneParts = [];
  723. if (doneParts.length > 0) {
  724. copy(doneParts).to(internalDoneParts);
  725. }
  726. partOffs = this._divideParts(fileSize, partSize);
  727. numParts = partOffs.length;
  728. multipartFinish = false;
  729. uploadPartJob = function uploadPartJob(self, partNo) {
  730. // eslint-disable-next-line no-async-promise-executor
  731. return new Promise( /*#__PURE__*/function () {
  732. var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(resolve, reject) {
  733. var pi, stream, data, removeStreamFromMultipartUploadStreams, result, tempErr;
  734. return _regenerator.default.wrap(function _callee2$(_context2) {
  735. while (1) {
  736. switch (_context2.prev = _context2.next) {
  737. case 0:
  738. _context2.prev = 0;
  739. if (self.isCancel()) {
  740. _context2.next = 33;
  741. break;
  742. }
  743. pi = partOffs[partNo - 1];
  744. stream = self._createStream(file, pi.start, pi.end);
  745. data = {
  746. stream: stream,
  747. size: pi.end - pi.start
  748. };
  749. if (isArray(self.multipartUploadStreams)) {
  750. self.multipartUploadStreams.push(stream);
  751. } else {
  752. self.multipartUploadStreams = [stream];
  753. }
  754. removeStreamFromMultipartUploadStreams = function removeStreamFromMultipartUploadStreams() {
  755. if (!stream.destroyed) {
  756. stream.destroy();
  757. }
  758. var index = self.multipartUploadStreams.indexOf(stream);
  759. if (index !== -1) {
  760. self.multipartUploadStreams.splice(index, 1);
  761. }
  762. };
  763. stream.on('close', removeStreamFromMultipartUploadStreams);
  764. stream.on('end', removeStreamFromMultipartUploadStreams);
  765. stream.on('error', removeStreamFromMultipartUploadStreams);
  766. _context2.prev = 10;
  767. _context2.next = 13;
  768. return self._uploadPart(name, uploadId, partNo, data);
  769. case 13:
  770. result = _context2.sent;
  771. _context2.next = 22;
  772. break;
  773. case 16:
  774. _context2.prev = 16;
  775. _context2.t0 = _context2["catch"](10);
  776. removeStreamFromMultipartUploadStreams();
  777. if (!(_context2.t0.status === 404)) {
  778. _context2.next = 21;
  779. break;
  780. }
  781. throw self._makeAbortEvent();
  782. case 21:
  783. throw _context2.t0;
  784. case 22:
  785. if (!(!self.isCancel() && !multipartFinish)) {
  786. _context2.next = 30;
  787. break;
  788. }
  789. checkpoint.doneParts.push({
  790. number: partNo,
  791. etag: result.res.headers.etag
  792. });
  793. if (!options.progress) {
  794. _context2.next = 27;
  795. break;
  796. }
  797. _context2.next = 27;
  798. return options.progress(doneParts.length / numParts, checkpoint, result.res);
  799. case 27:
  800. resolve({
  801. number: partNo,
  802. etag: result.res.headers.etag
  803. });
  804. _context2.next = 31;
  805. break;
  806. case 30:
  807. resolve();
  808. case 31:
  809. _context2.next = 34;
  810. break;
  811. case 33:
  812. resolve();
  813. case 34:
  814. _context2.next = 45;
  815. break;
  816. case 36:
  817. _context2.prev = 36;
  818. _context2.t1 = _context2["catch"](0);
  819. tempErr = new Error();
  820. tempErr.name = _context2.t1.name;
  821. tempErr.message = _context2.t1.message;
  822. tempErr.stack = _context2.t1.stack;
  823. tempErr.partNum = partNo;
  824. copy(_context2.t1).to(tempErr);
  825. reject(tempErr);
  826. case 45:
  827. case "end":
  828. return _context2.stop();
  829. }
  830. }
  831. }, _callee2, null, [[0, 36], [10, 16]]);
  832. }));
  833. return function (_x5, _x6) {
  834. return _ref.apply(this, arguments);
  835. };
  836. }());
  837. };
  838. all = Array.from(new Array(numParts), function (x, i) {
  839. return i + 1;
  840. });
  841. done = internalDoneParts.map(function (p) {
  842. return p.number;
  843. });
  844. todo = all.filter(function (p) {
  845. return done.indexOf(p) < 0;
  846. });
  847. defaultParallel = 5;
  848. parallel = options.parallel || defaultParallel; // upload in parallel
  849. _context3.next = 17;
  850. return this._parallel(todo, parallel, function (value) {
  851. return new Promise(function (resolve, reject) {
  852. uploadPartJob(that, value).then(function (result) {
  853. if (result) {
  854. internalDoneParts.push(result);
  855. }
  856. resolve();
  857. }).catch(function (err) {
  858. reject(err);
  859. });
  860. });
  861. });
  862. case 17:
  863. jobErr = _context3.sent;
  864. multipartFinish = true;
  865. abortEvent = jobErr.find(function (err) {
  866. return err.name === 'abort';
  867. });
  868. if (!abortEvent) {
  869. _context3.next = 22;
  870. break;
  871. }
  872. throw abortEvent;
  873. case 22:
  874. if (!this.isCancel()) {
  875. _context3.next = 25;
  876. break;
  877. }
  878. uploadPartJob = null;
  879. throw this._makeCancelEvent();
  880. case 25:
  881. if (!(jobErr && jobErr.length > 0)) {
  882. _context3.next = 28;
  883. break;
  884. }
  885. jobErr[0].message = "Failed to upload some parts with error: ".concat(jobErr[0].toString(), " part_num: ").concat(jobErr[0].partNum);
  886. throw jobErr[0];
  887. case 28:
  888. _context3.next = 30;
  889. return this.completeMultipartUpload(name, uploadId, internalDoneParts, options);
  890. case 30:
  891. return _context3.abrupt("return", _context3.sent);
  892. case 31:
  893. case "end":
  894. return _context3.stop();
  895. }
  896. }
  897. }, _callee3, this);
  898. }));
  899. function _resumeMultipart(_x3, _x4) {
  900. return _resumeMultipart2.apply(this, arguments);
  901. }
  902. return _resumeMultipart;
  903. }();
  904. /**
  905. * Get file size
  906. */
  907. proto._getFileSize = /*#__PURE__*/function () {
  908. var _getFileSize2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(file) {
  909. return _regenerator.default.wrap(function _callee4$(_context4) {
  910. while (1) {
  911. switch (_context4.prev = _context4.next) {
  912. case 0:
  913. if (!isBuffer(file)) {
  914. _context4.next = 4;
  915. break;
  916. }
  917. return _context4.abrupt("return", file.length);
  918. case 4:
  919. if (!(isBlob(file) || isFile(file))) {
  920. _context4.next = 6;
  921. break;
  922. }
  923. return _context4.abrupt("return", file.size);
  924. case 6:
  925. throw new Error('_getFileSize requires Buffer/File/Blob.');
  926. case 7:
  927. case "end":
  928. return _context4.stop();
  929. }
  930. }
  931. }, _callee4);
  932. }));
  933. function _getFileSize(_x7) {
  934. return _getFileSize2.apply(this, arguments);
  935. }
  936. return _getFileSize;
  937. }();
  938. /*
  939. * Readable stream for Web File
  940. */
  941. var _require5 = require('stream'),
  942. Readable = _require5.Readable;
  943. function WebFileReadStream(file, options) {
  944. if (!(this instanceof WebFileReadStream)) {
  945. return new WebFileReadStream(file, options);
  946. }
  947. Readable.call(this, options);
  948. this.file = file;
  949. this.reader = new FileReader();
  950. this.start = 0;
  951. this.finish = false;
  952. this.fileBuffer = null;
  953. }
  954. util.inherits(WebFileReadStream, Readable);
  955. WebFileReadStream.prototype.readFileAndPush = function readFileAndPush(size) {
  956. if (this.fileBuffer) {
  957. var pushRet = true;
  958. while (pushRet && this.fileBuffer && this.start < this.fileBuffer.length) {
  959. var start = this.start;
  960. var end = start + size;
  961. end = end > this.fileBuffer.length ? this.fileBuffer.length : end;
  962. this.start = end;
  963. pushRet = this.push(this.fileBuffer.slice(start, end));
  964. }
  965. }
  966. };
  967. WebFileReadStream.prototype._read = function _read(size) {
  968. if (this.file && this.start >= this.file.size || this.fileBuffer && this.start >= this.fileBuffer.length || this.finish || this.start === 0 && !this.file) {
  969. if (!this.finish) {
  970. this.fileBuffer = null;
  971. this.finish = true;
  972. }
  973. this.push(null);
  974. return;
  975. }
  976. var defaultReadSize = 16 * 1024;
  977. size = size || defaultReadSize;
  978. var that = this;
  979. this.reader.onload = function onload(e) {
  980. that.fileBuffer = Buffer.from(new Uint8Array(e.target.result));
  981. that.file = null;
  982. that.readFileAndPush(size);
  983. };
  984. if (this.start === 0) {
  985. this.reader.readAsArrayBuffer(this.file);
  986. } else {
  987. this.readFileAndPush(size);
  988. }
  989. };
  990. proto._createStream = function _createStream(file, start, end) {
  991. if (isBlob(file) || isFile(file)) {
  992. return new WebFileReadStream(file.slice(start, end));
  993. } else if (isBuffer(file)) {
  994. // we can't use Readable.from() since it is only support in Node v10
  995. var iterable = file.subarray(start, end);
  996. return new Readable({
  997. read: function read() {
  998. this.push(iterable);
  999. this.push(null);
  1000. }
  1001. });
  1002. }
  1003. throw new Error('_createStream requires Buffer/File/Blob.');
  1004. };
  1005. proto._getPartSize = function _getPartSize(fileSize, partSize) {
  1006. var maxNumParts = 10 * 1000;
  1007. var defaultPartSize = 1 * 1024 * 1024;
  1008. if (!partSize) partSize = defaultPartSize;
  1009. var safeSize = Math.ceil(fileSize / maxNumParts);
  1010. if (partSize < safeSize) {
  1011. partSize = safeSize;
  1012. console.warn("partSize has been set to ".concat(partSize, ", because the partSize you provided causes partNumber to be greater than 10,000"));
  1013. }
  1014. return partSize;
  1015. };
  1016. proto._divideParts = function _divideParts(fileSize, partSize) {
  1017. var numParts = Math.ceil(fileSize / partSize);
  1018. var partOffs = [];
  1019. for (var i = 0; i < numParts; i++) {
  1020. var start = partSize * i;
  1021. var end = Math.min(start + partSize, fileSize);
  1022. partOffs.push({
  1023. start: start,
  1024. end: end
  1025. });
  1026. }
  1027. return partOffs;
  1028. };
  1029. }).call(this,require("buffer").Buffer)
  1030. },{"../common/utils/isArray":59,"../common/utils/isBlob":60,"../common/utils/isBuffer":61,"../common/utils/isFile":62,"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"buffer":98,"copy-to":101,"core-js/modules/es.array-buffer.slice":233,"core-js/modules/es.array.concat":234,"core-js/modules/es.array.filter":236,"core-js/modules/es.array.find":237,"core-js/modules/es.array.from":239,"core-js/modules/es.array.index-of":241,"core-js/modules/es.array.iterator":242,"core-js/modules/es.array.map":245,"core-js/modules/es.array.slice":246,"core-js/modules/es.array.splice":248,"core-js/modules/es.function.name":249,"core-js/modules/es.object.to-string":254,"core-js/modules/es.promise":255,"core-js/modules/es.regexp.to-string":257,"core-js/modules/es.string.iterator":259,"core-js/modules/es.typed-array.copy-within":268,"core-js/modules/es.typed-array.every":269,"core-js/modules/es.typed-array.fill":270,"core-js/modules/es.typed-array.filter":271,"core-js/modules/es.typed-array.find":273,"core-js/modules/es.typed-array.find-index":272,"core-js/modules/es.typed-array.for-each":274,"core-js/modules/es.typed-array.includes":275,"core-js/modules/es.typed-array.index-of":276,"core-js/modules/es.typed-array.iterator":277,"core-js/modules/es.typed-array.join":278,"core-js/modules/es.typed-array.last-index-of":279,"core-js/modules/es.typed-array.map":280,"core-js/modules/es.typed-array.reduce":282,"core-js/modules/es.typed-array.reduce-right":281,"core-js/modules/es.typed-array.reverse":283,"core-js/modules/es.typed-array.set":284,"core-js/modules/es.typed-array.slice":285,"core-js/modules/es.typed-array.some":286,"core-js/modules/es.typed-array.sort":287,"core-js/modules/es.typed-array.subarray":288,"core-js/modules/es.typed-array.to-locale-string":289,"core-js/modules/es.typed-array.to-string":290,"core-js/modules/es.typed-array.uint8-array":291,"mime":313,"path":316,"regenerator-runtime/runtime":337,"stream":340,"util":346}],4:[function(require,module,exports){
  1031. "use strict";
  1032. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  1033. require("core-js/modules/es.array.for-each");
  1034. require("core-js/modules/es.array.map");
  1035. require("core-js/modules/es.function.name");
  1036. require("core-js/modules/es.number.constructor");
  1037. require("core-js/modules/es.object.assign");
  1038. require("core-js/modules/es.object.keys");
  1039. require("core-js/modules/es.object.to-string");
  1040. require("core-js/modules/es.promise");
  1041. require("core-js/modules/es.regexp.exec");
  1042. require("core-js/modules/es.regexp.to-string");
  1043. require("core-js/modules/es.string.replace");
  1044. require("core-js/modules/web.dom-collections.for-each");
  1045. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  1046. require("regenerator-runtime/runtime");
  1047. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  1048. // const debug = require('debug')('ali-oss:object');
  1049. var fs = require('fs');
  1050. var copy = require('copy-to');
  1051. var path = require('path');
  1052. var mime = require('mime');
  1053. var callback = require('../common/callback');
  1054. var merge = require('merge-descriptors');
  1055. var _require = require('../common/utils/isBlob'),
  1056. isBlob = _require.isBlob;
  1057. var _require2 = require('../common/utils/isFile'),
  1058. isFile = _require2.isFile;
  1059. var _require3 = require('../common/utils/isBuffer'),
  1060. isBuffer = _require3.isBuffer; // var assert = require('assert');
  1061. var proto = exports;
  1062. /**
  1063. * Object operations
  1064. */
  1065. /**
  1066. * append an object from String(file path)/Buffer/ReadableStream
  1067. * @param {String} name the object key
  1068. * @param {Mixed} file String(file path)/Buffer/ReadableStream
  1069. * @param {Object} options
  1070. * @return {Object}
  1071. */
  1072. proto.append = /*#__PURE__*/function () {
  1073. var _append = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, file, options) {
  1074. var result;
  1075. return _regenerator.default.wrap(function _callee$(_context) {
  1076. while (1) {
  1077. switch (_context.prev = _context.next) {
  1078. case 0:
  1079. options = options || {};
  1080. if (options.position === undefined) options.position = '0';
  1081. options.subres = {
  1082. append: '',
  1083. position: options.position
  1084. };
  1085. options.method = 'POST';
  1086. _context.next = 6;
  1087. return this.put(name, file, options);
  1088. case 6:
  1089. result = _context.sent;
  1090. result.nextAppendPosition = result.res.headers['x-oss-next-append-position'];
  1091. return _context.abrupt("return", result);
  1092. case 9:
  1093. case "end":
  1094. return _context.stop();
  1095. }
  1096. }
  1097. }, _callee, this);
  1098. }));
  1099. function append(_x, _x2, _x3) {
  1100. return _append.apply(this, arguments);
  1101. }
  1102. return append;
  1103. }();
  1104. /**
  1105. * put an object from String(file path)/Buffer/ReadableStream
  1106. * @param {String} name the object key
  1107. * @param {Mixed} file String(file path)/Buffer/ReadableStream
  1108. * @param {Object} options
  1109. * {Object} options.callback The callback parameter is composed of a JSON string encoded in Base64
  1110. * {String} options.callback.url the OSS sends a callback request to this URL
  1111. * {String} options.callback.host The host header value for initiating callback requests
  1112. * {String} options.callback.body The value of the request body when a callback is initiated
  1113. * {String} options.callback.contentType The Content-Type of the callback requests initiatiated
  1114. * {Object} options.callback.customValue Custom parameters are a map of key-values, e.g:
  1115. * customValue = {
  1116. * key1: 'value1',
  1117. * key2: 'value2'
  1118. * }
  1119. * @return {Object}
  1120. */
  1121. proto.put = /*#__PURE__*/function () {
  1122. var _put = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(name, file, options) {
  1123. var content, stream, _result, method, params, result, ret;
  1124. return _regenerator.default.wrap(function _callee2$(_context2) {
  1125. while (1) {
  1126. switch (_context2.prev = _context2.next) {
  1127. case 0:
  1128. options = options || {};
  1129. name = this._objectName(name);
  1130. if (!isBuffer(file)) {
  1131. _context2.next = 6;
  1132. break;
  1133. }
  1134. content = file;
  1135. _context2.next = 32;
  1136. break;
  1137. case 6:
  1138. if (!(isBlob(file) || isFile(file))) {
  1139. _context2.next = 31;
  1140. break;
  1141. }
  1142. if (!options.mime) {
  1143. if (isFile(file)) {
  1144. options.mime = mime.getType(path.extname(file.name));
  1145. } else {
  1146. options.mime = file.type;
  1147. }
  1148. }
  1149. stream = this._createStream(file, 0, file.size);
  1150. _context2.next = 11;
  1151. return this._getFileSize(file);
  1152. case 11:
  1153. options.contentLength = _context2.sent;
  1154. _context2.prev = 12;
  1155. _context2.next = 15;
  1156. return this.putStream(name, stream, options);
  1157. case 15:
  1158. _result = _context2.sent;
  1159. return _context2.abrupt("return", _result);
  1160. case 19:
  1161. _context2.prev = 19;
  1162. _context2.t0 = _context2["catch"](12);
  1163. if (!(_context2.t0.code === 'RequestTimeTooSkewed')) {
  1164. _context2.next = 28;
  1165. break;
  1166. }
  1167. this.options.amendTimeSkewed = +new Date(_context2.t0.serverTime) - new Date();
  1168. _context2.next = 25;
  1169. return this.put(name, file, options);
  1170. case 25:
  1171. return _context2.abrupt("return", _context2.sent);
  1172. case 28:
  1173. throw _context2.t0;
  1174. case 29:
  1175. _context2.next = 32;
  1176. break;
  1177. case 31:
  1178. throw new TypeError('Must provide Buffer/Blob/File for put.');
  1179. case 32:
  1180. options.headers = options.headers || {};
  1181. this._convertMetaToHeaders(options.meta, options.headers);
  1182. method = options.method || 'PUT';
  1183. params = this._objectRequestParams(method, name, options);
  1184. callback.encodeCallback(params, options);
  1185. params.mime = options.mime;
  1186. params.content = content;
  1187. params.successStatuses = [200];
  1188. _context2.next = 42;
  1189. return this.request(params);
  1190. case 42:
  1191. result = _context2.sent;
  1192. ret = {
  1193. name: name,
  1194. url: this._objectUrl(name),
  1195. res: result.res
  1196. };
  1197. if (params.headers && params.headers['x-oss-callback']) {
  1198. ret.data = JSON.parse(result.data.toString());
  1199. }
  1200. return _context2.abrupt("return", ret);
  1201. case 46:
  1202. case "end":
  1203. return _context2.stop();
  1204. }
  1205. }
  1206. }, _callee2, this, [[12, 19]]);
  1207. }));
  1208. function put(_x4, _x5, _x6) {
  1209. return _put.apply(this, arguments);
  1210. }
  1211. return put;
  1212. }();
  1213. /**
  1214. * put an object from ReadableStream. If `options.contentLength` is
  1215. * not provided, chunked encoding is used.
  1216. * @param {String} name the object key
  1217. * @param {Readable} stream the ReadableStream
  1218. * @param {Object} options
  1219. * @return {Object}
  1220. */
  1221. proto.putStream = /*#__PURE__*/function () {
  1222. var _putStream = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(name, stream, options) {
  1223. var method, params, result, ret;
  1224. return _regenerator.default.wrap(function _callee3$(_context3) {
  1225. while (1) {
  1226. switch (_context3.prev = _context3.next) {
  1227. case 0:
  1228. options = options || {};
  1229. options.headers = options.headers || {};
  1230. name = this._objectName(name);
  1231. if (options.contentLength) {
  1232. options.headers['Content-Length'] = options.contentLength;
  1233. } else {
  1234. options.headers['Transfer-Encoding'] = 'chunked';
  1235. }
  1236. this._convertMetaToHeaders(options.meta, options.headers);
  1237. method = options.method || 'PUT';
  1238. params = this._objectRequestParams(method, name, options);
  1239. callback.encodeCallback(params, options);
  1240. params.mime = options.mime;
  1241. params.stream = stream;
  1242. params.successStatuses = [200];
  1243. _context3.next = 13;
  1244. return this.request(params);
  1245. case 13:
  1246. result = _context3.sent;
  1247. ret = {
  1248. name: name,
  1249. url: this._objectUrl(name),
  1250. res: result.res
  1251. };
  1252. if (params.headers && params.headers['x-oss-callback']) {
  1253. ret.data = JSON.parse(result.data.toString());
  1254. }
  1255. return _context3.abrupt("return", ret);
  1256. case 17:
  1257. case "end":
  1258. return _context3.stop();
  1259. }
  1260. }
  1261. }, _callee3, this);
  1262. }));
  1263. function putStream(_x7, _x8, _x9) {
  1264. return _putStream.apply(this, arguments);
  1265. }
  1266. return putStream;
  1267. }();
  1268. merge(proto, require('../common/object/copyObject'));
  1269. merge(proto, require('../common/object/getObjectTagging'));
  1270. merge(proto, require('../common/object/putObjectTagging'));
  1271. merge(proto, require('../common/object/deleteObjectTagging'));
  1272. merge(proto, require('../common/image'));
  1273. merge(proto, require('../common/object/getBucketVersions'));
  1274. merge(proto, require('../common/object/getACL'));
  1275. merge(proto, require('../common/object/putACL'));
  1276. merge(proto, require('../common/object/head'));
  1277. merge(proto, require('../common/object/delete'));
  1278. merge(proto, require('../common/object/get'));
  1279. merge(proto, require('../common/object/putSymlink'));
  1280. merge(proto, require('../common/object/getSymlink'));
  1281. merge(proto, require('../common/object/deleteMulti'));
  1282. merge(proto, require('../common/object/getObjectMeta'));
  1283. merge(proto, require('../common/object/getObjectUrl'));
  1284. merge(proto, require('../common/object/generateObjectUrl'));
  1285. merge(proto, require('../common/object/signatureUrl'));
  1286. proto.putMeta = /*#__PURE__*/function () {
  1287. var _putMeta = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(name, meta, options) {
  1288. var copyResult;
  1289. return _regenerator.default.wrap(function _callee4$(_context4) {
  1290. while (1) {
  1291. switch (_context4.prev = _context4.next) {
  1292. case 0:
  1293. _context4.next = 2;
  1294. return this.copy(name, name, {
  1295. meta: meta || {},
  1296. timeout: options && options.timeout,
  1297. ctx: options && options.ctx
  1298. });
  1299. case 2:
  1300. copyResult = _context4.sent;
  1301. return _context4.abrupt("return", copyResult);
  1302. case 4:
  1303. case "end":
  1304. return _context4.stop();
  1305. }
  1306. }
  1307. }, _callee4, this);
  1308. }));
  1309. function putMeta(_x10, _x11, _x12) {
  1310. return _putMeta.apply(this, arguments);
  1311. }
  1312. return putMeta;
  1313. }();
  1314. proto.list = /*#__PURE__*/function () {
  1315. var _list = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(query, options) {
  1316. var params, result, objects, that, prefixes;
  1317. return _regenerator.default.wrap(function _callee5$(_context5) {
  1318. while (1) {
  1319. switch (_context5.prev = _context5.next) {
  1320. case 0:
  1321. // prefix, marker, max-keys, delimiter
  1322. params = this._objectRequestParams('GET', '', options);
  1323. params.query = query;
  1324. params.xmlResponse = true;
  1325. params.successStatuses = [200];
  1326. _context5.next = 6;
  1327. return this.request(params);
  1328. case 6:
  1329. result = _context5.sent;
  1330. objects = result.data.Contents;
  1331. that = this;
  1332. if (objects) {
  1333. if (!Array.isArray(objects)) {
  1334. objects = [objects];
  1335. }
  1336. objects = objects.map(function (obj) {
  1337. return {
  1338. name: obj.Key,
  1339. url: that._objectUrl(obj.Key),
  1340. lastModified: obj.LastModified,
  1341. etag: obj.ETag,
  1342. type: obj.Type,
  1343. size: Number(obj.Size),
  1344. storageClass: obj.StorageClass,
  1345. owner: {
  1346. id: obj.Owner.ID,
  1347. displayName: obj.Owner.DisplayName
  1348. }
  1349. };
  1350. });
  1351. }
  1352. prefixes = result.data.CommonPrefixes || null;
  1353. if (prefixes) {
  1354. if (!Array.isArray(prefixes)) {
  1355. prefixes = [prefixes];
  1356. }
  1357. prefixes = prefixes.map(function (item) {
  1358. return item.Prefix;
  1359. });
  1360. }
  1361. return _context5.abrupt("return", {
  1362. res: result.res,
  1363. objects: objects,
  1364. prefixes: prefixes,
  1365. nextMarker: result.data.NextMarker || null,
  1366. isTruncated: result.data.IsTruncated === 'true'
  1367. });
  1368. case 13:
  1369. case "end":
  1370. return _context5.stop();
  1371. }
  1372. }
  1373. }, _callee5, this);
  1374. }));
  1375. function list(_x13, _x14) {
  1376. return _list.apply(this, arguments);
  1377. }
  1378. return list;
  1379. }();
  1380. proto.listV2 = /*#__PURE__*/function () {
  1381. var _listV = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(query) {
  1382. var options,
  1383. continuation_token,
  1384. params,
  1385. result,
  1386. objects,
  1387. that,
  1388. prefixes,
  1389. _args6 = arguments;
  1390. return _regenerator.default.wrap(function _callee6$(_context6) {
  1391. while (1) {
  1392. switch (_context6.prev = _context6.next) {
  1393. case 0:
  1394. options = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : {};
  1395. continuation_token = query['continuation-token'] || query.continuationToken;
  1396. delete query['continuation-token'];
  1397. delete query.continuationToken;
  1398. if (continuation_token) {
  1399. options.subres = Object.assign({
  1400. 'continuation-token': continuation_token
  1401. }, options.subres);
  1402. }
  1403. params = this._objectRequestParams('GET', '', options);
  1404. params.query = Object.assign({
  1405. 'list-type': 2
  1406. }, query);
  1407. params.xmlResponse = true;
  1408. params.successStatuses = [200];
  1409. _context6.next = 11;
  1410. return this.request(params);
  1411. case 11:
  1412. result = _context6.sent;
  1413. objects = result.data.Contents;
  1414. that = this;
  1415. if (objects) {
  1416. if (!Array.isArray(objects)) {
  1417. objects = [objects];
  1418. }
  1419. objects = objects.map(function (obj) {
  1420. return {
  1421. name: obj.Key,
  1422. url: that._objectUrl(obj.Key),
  1423. lastModified: obj.LastModified,
  1424. etag: obj.ETag,
  1425. type: obj.Type,
  1426. size: Number(obj.Size),
  1427. storageClass: obj.StorageClass,
  1428. owner: obj.Owner ? {
  1429. id: obj.Owner.ID,
  1430. displayName: obj.Owner.DisplayName
  1431. } : null
  1432. };
  1433. });
  1434. }
  1435. prefixes = result.data.CommonPrefixes || null;
  1436. if (prefixes) {
  1437. if (!Array.isArray(prefixes)) {
  1438. prefixes = [prefixes];
  1439. }
  1440. prefixes = prefixes.map(function (item) {
  1441. return item.Prefix;
  1442. });
  1443. }
  1444. return _context6.abrupt("return", {
  1445. res: result.res,
  1446. objects: objects,
  1447. prefixes: prefixes,
  1448. isTruncated: result.data.IsTruncated === 'true',
  1449. keyCount: +result.data.KeyCount,
  1450. continuationToken: result.data.ContinuationToken || null,
  1451. nextContinuationToken: result.data.NextContinuationToken || null
  1452. });
  1453. case 18:
  1454. case "end":
  1455. return _context6.stop();
  1456. }
  1457. }
  1458. }, _callee6, this);
  1459. }));
  1460. function listV2(_x15) {
  1461. return _listV.apply(this, arguments);
  1462. }
  1463. return listV2;
  1464. }();
  1465. /**
  1466. * Restore Object
  1467. * @param {String} name the object key
  1468. * @param {Object} options
  1469. * @returns {{res}}
  1470. */
  1471. proto.restore = /*#__PURE__*/function () {
  1472. var _restore = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(name, options) {
  1473. var params, result;
  1474. return _regenerator.default.wrap(function _callee7$(_context7) {
  1475. while (1) {
  1476. switch (_context7.prev = _context7.next) {
  1477. case 0:
  1478. options = options || {};
  1479. options.subres = Object.assign({
  1480. restore: ''
  1481. }, options.subres);
  1482. if (options.versionId) {
  1483. options.subres.versionId = options.versionId;
  1484. }
  1485. params = this._objectRequestParams('POST', name, options);
  1486. params.successStatuses = [202];
  1487. _context7.next = 7;
  1488. return this.request(params);
  1489. case 7:
  1490. result = _context7.sent;
  1491. return _context7.abrupt("return", {
  1492. res: result.res
  1493. });
  1494. case 9:
  1495. case "end":
  1496. return _context7.stop();
  1497. }
  1498. }
  1499. }, _callee7, this);
  1500. }));
  1501. function restore(_x16, _x17) {
  1502. return _restore.apply(this, arguments);
  1503. }
  1504. return restore;
  1505. }();
  1506. proto._objectUrl = function _objectUrl(name) {
  1507. return this._getReqUrl({
  1508. bucket: this.options.bucket,
  1509. object: name
  1510. });
  1511. };
  1512. /**
  1513. * generator request params
  1514. * @return {Object} params
  1515. *
  1516. * @api private
  1517. */
  1518. proto._objectRequestParams = function _objectRequestParams(method, name, options) {
  1519. if (!this.options.bucket && !this.options.cname) {
  1520. throw new Error('Please create a bucket first');
  1521. }
  1522. options = options || {};
  1523. name = this._objectName(name);
  1524. var params = {
  1525. object: name,
  1526. bucket: this.options.bucket,
  1527. method: method,
  1528. subres: options && options.subres,
  1529. timeout: options && options.timeout,
  1530. ctx: options && options.ctx
  1531. };
  1532. if (options.headers) {
  1533. params.headers = {};
  1534. copy(options.headers).to(params.headers);
  1535. }
  1536. return params;
  1537. };
  1538. proto._objectName = function _objectName(name) {
  1539. return name.replace(/^\/+/, '');
  1540. };
  1541. proto._convertMetaToHeaders = function _convertMetaToHeaders(meta, headers) {
  1542. if (!meta) {
  1543. return;
  1544. }
  1545. Object.keys(meta).forEach(function (k) {
  1546. headers["x-oss-meta-".concat(k)] = meta[k];
  1547. });
  1548. };
  1549. proto._deleteFileSafe = function _deleteFileSafe(filepath) {
  1550. var _this = this;
  1551. return new Promise(function (resolve) {
  1552. fs.exists(filepath, function (exists) {
  1553. if (!exists) {
  1554. resolve();
  1555. } else {
  1556. fs.unlink(filepath, function (err) {
  1557. if (err) {
  1558. _this.debug('unlink %j error: %s', filepath, err, 'error');
  1559. }
  1560. resolve();
  1561. });
  1562. }
  1563. });
  1564. });
  1565. };
  1566. },{"../common/callback":23,"../common/image":26,"../common/object/copyObject":29,"../common/object/delete":30,"../common/object/deleteMulti":31,"../common/object/deleteObjectTagging":32,"../common/object/generateObjectUrl":33,"../common/object/get":34,"../common/object/getACL":35,"../common/object/getBucketVersions":36,"../common/object/getObjectMeta":37,"../common/object/getObjectTagging":38,"../common/object/getObjectUrl":39,"../common/object/getSymlink":40,"../common/object/head":41,"../common/object/putACL":42,"../common/object/putObjectTagging":43,"../common/object/putSymlink":44,"../common/object/signatureUrl":45,"../common/utils/isBlob":60,"../common/utils/isBuffer":61,"../common/utils/isFile":62,"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"copy-to":101,"core-js/modules/es.array.for-each":238,"core-js/modules/es.array.map":245,"core-js/modules/es.function.name":249,"core-js/modules/es.number.constructor":250,"core-js/modules/es.object.assign":251,"core-js/modules/es.object.keys":253,"core-js/modules/es.object.to-string":254,"core-js/modules/es.promise":255,"core-js/modules/es.regexp.exec":256,"core-js/modules/es.regexp.to-string":257,"core-js/modules/es.string.replace":261,"core-js/modules/web.dom-collections.for-each":292,"fs":78,"merge-descriptors":311,"mime":313,"path":316,"regenerator-runtime/runtime":337}],5:[function(require,module,exports){
  1567. "use strict";
  1568. exports.version = "6.13.2";
  1569. },{}],6:[function(require,module,exports){
  1570. "use strict";
  1571. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  1572. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  1573. require("regenerator-runtime/runtime");
  1574. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  1575. Object.defineProperty(exports, "__esModule", {
  1576. value: true
  1577. });
  1578. exports.abortBucketWorm = void 0;
  1579. var checkBucketName_1 = require("../utils/checkBucketName");
  1580. function abortBucketWorm(_x, _x2) {
  1581. return _abortBucketWorm.apply(this, arguments);
  1582. }
  1583. function _abortBucketWorm() {
  1584. _abortBucketWorm = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, options) {
  1585. var params, result;
  1586. return _regenerator.default.wrap(function _callee$(_context) {
  1587. while (1) {
  1588. switch (_context.prev = _context.next) {
  1589. case 0:
  1590. checkBucketName_1.checkBucketName(name);
  1591. params = this._bucketRequestParams('DELETE', name, 'worm', options);
  1592. _context.next = 4;
  1593. return this.request(params);
  1594. case 4:
  1595. result = _context.sent;
  1596. return _context.abrupt("return", {
  1597. res: result.res,
  1598. status: result.status
  1599. });
  1600. case 6:
  1601. case "end":
  1602. return _context.stop();
  1603. }
  1604. }
  1605. }, _callee, this);
  1606. }));
  1607. return _abortBucketWorm.apply(this, arguments);
  1608. }
  1609. exports.abortBucketWorm = abortBucketWorm;
  1610. },{"../utils/checkBucketName":48,"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"regenerator-runtime/runtime":337}],7:[function(require,module,exports){
  1611. "use strict";
  1612. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  1613. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  1614. require("regenerator-runtime/runtime");
  1615. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  1616. Object.defineProperty(exports, "__esModule", {
  1617. value: true
  1618. });
  1619. exports.completeBucketWorm = void 0;
  1620. var checkBucketName_1 = require("../utils/checkBucketName");
  1621. function completeBucketWorm(_x, _x2, _x3) {
  1622. return _completeBucketWorm.apply(this, arguments);
  1623. }
  1624. function _completeBucketWorm() {
  1625. _completeBucketWorm = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, wormId, options) {
  1626. var params, result;
  1627. return _regenerator.default.wrap(function _callee$(_context) {
  1628. while (1) {
  1629. switch (_context.prev = _context.next) {
  1630. case 0:
  1631. checkBucketName_1.checkBucketName(name);
  1632. params = this._bucketRequestParams('POST', name, {
  1633. wormId: wormId
  1634. }, options);
  1635. _context.next = 4;
  1636. return this.request(params);
  1637. case 4:
  1638. result = _context.sent;
  1639. return _context.abrupt("return", {
  1640. res: result.res,
  1641. status: result.status
  1642. });
  1643. case 6:
  1644. case "end":
  1645. return _context.stop();
  1646. }
  1647. }
  1648. }, _callee, this);
  1649. }));
  1650. return _completeBucketWorm.apply(this, arguments);
  1651. }
  1652. exports.completeBucketWorm = completeBucketWorm;
  1653. },{"../utils/checkBucketName":48,"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"regenerator-runtime/runtime":337}],8:[function(require,module,exports){
  1654. "use strict";
  1655. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  1656. require("core-js/modules/es.object.assign");
  1657. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  1658. require("regenerator-runtime/runtime");
  1659. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  1660. Object.defineProperty(exports, "__esModule", {
  1661. value: true
  1662. });
  1663. exports.deleteBucketInventory = void 0;
  1664. var checkBucketName_1 = require("../utils/checkBucketName");
  1665. /**
  1666. * deleteBucketInventory
  1667. * @param {String} bucketName - bucket name
  1668. * @param {String} inventoryId
  1669. * @param {Object} options
  1670. */
  1671. function deleteBucketInventory(_x, _x2) {
  1672. return _deleteBucketInventory.apply(this, arguments);
  1673. }
  1674. function _deleteBucketInventory() {
  1675. _deleteBucketInventory = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(bucketName, inventoryId) {
  1676. var options,
  1677. subres,
  1678. params,
  1679. result,
  1680. _args = arguments;
  1681. return _regenerator.default.wrap(function _callee$(_context) {
  1682. while (1) {
  1683. switch (_context.prev = _context.next) {
  1684. case 0:
  1685. options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
  1686. subres = Object.assign({
  1687. inventory: '',
  1688. inventoryId: inventoryId
  1689. }, options.subres);
  1690. checkBucketName_1.checkBucketName(bucketName);
  1691. params = this._bucketRequestParams('DELETE', bucketName, subres, options);
  1692. params.successStatuses = [204];
  1693. _context.next = 7;
  1694. return this.request(params);
  1695. case 7:
  1696. result = _context.sent;
  1697. return _context.abrupt("return", {
  1698. status: result.status,
  1699. res: result.res
  1700. });
  1701. case 9:
  1702. case "end":
  1703. return _context.stop();
  1704. }
  1705. }
  1706. }, _callee, this);
  1707. }));
  1708. return _deleteBucketInventory.apply(this, arguments);
  1709. }
  1710. exports.deleteBucketInventory = deleteBucketInventory;
  1711. },{"../utils/checkBucketName":48,"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"core-js/modules/es.object.assign":251,"regenerator-runtime/runtime":337}],9:[function(require,module,exports){
  1712. "use strict";
  1713. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  1714. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  1715. require("regenerator-runtime/runtime");
  1716. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  1717. var _require = require('../utils/checkBucketName'),
  1718. _checkBucketName = _require.checkBucketName;
  1719. var proto = exports;
  1720. proto.deleteBucketLifecycle = /*#__PURE__*/function () {
  1721. var _deleteBucketLifecycle = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, options) {
  1722. var params, result;
  1723. return _regenerator.default.wrap(function _callee$(_context) {
  1724. while (1) {
  1725. switch (_context.prev = _context.next) {
  1726. case 0:
  1727. _checkBucketName(name);
  1728. params = this._bucketRequestParams('DELETE', name, 'lifecycle', options);
  1729. params.successStatuses = [204];
  1730. _context.next = 5;
  1731. return this.request(params);
  1732. case 5:
  1733. result = _context.sent;
  1734. return _context.abrupt("return", {
  1735. res: result.res
  1736. });
  1737. case 7:
  1738. case "end":
  1739. return _context.stop();
  1740. }
  1741. }
  1742. }, _callee, this);
  1743. }));
  1744. function deleteBucketLifecycle(_x, _x2) {
  1745. return _deleteBucketLifecycle.apply(this, arguments);
  1746. }
  1747. return deleteBucketLifecycle;
  1748. }();
  1749. },{"../utils/checkBucketName":48,"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"regenerator-runtime/runtime":337}],10:[function(require,module,exports){
  1750. "use strict";
  1751. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  1752. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  1753. require("regenerator-runtime/runtime");
  1754. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  1755. var _require = require('../utils/checkBucketName'),
  1756. _checkBucketName = _require.checkBucketName;
  1757. var proto = exports;
  1758. proto.deleteBucketWebsite = /*#__PURE__*/function () {
  1759. var _deleteBucketWebsite = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, options) {
  1760. var params, result;
  1761. return _regenerator.default.wrap(function _callee$(_context) {
  1762. while (1) {
  1763. switch (_context.prev = _context.next) {
  1764. case 0:
  1765. _checkBucketName(name);
  1766. params = this._bucketRequestParams('DELETE', name, 'website', options);
  1767. params.successStatuses = [204];
  1768. _context.next = 5;
  1769. return this.request(params);
  1770. case 5:
  1771. result = _context.sent;
  1772. return _context.abrupt("return", {
  1773. res: result.res
  1774. });
  1775. case 7:
  1776. case "end":
  1777. return _context.stop();
  1778. }
  1779. }
  1780. }, _callee, this);
  1781. }));
  1782. function deleteBucketWebsite(_x, _x2) {
  1783. return _deleteBucketWebsite.apply(this, arguments);
  1784. }
  1785. return deleteBucketWebsite;
  1786. }();
  1787. },{"../utils/checkBucketName":48,"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"regenerator-runtime/runtime":337}],11:[function(require,module,exports){
  1788. "use strict";
  1789. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  1790. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  1791. require("regenerator-runtime/runtime");
  1792. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  1793. Object.defineProperty(exports, "__esModule", {
  1794. value: true
  1795. });
  1796. exports.extendBucketWorm = void 0;
  1797. var checkBucketName_1 = require("../utils/checkBucketName");
  1798. var obj2xml_1 = require("../utils/obj2xml");
  1799. function extendBucketWorm(_x, _x2, _x3, _x4) {
  1800. return _extendBucketWorm.apply(this, arguments);
  1801. }
  1802. function _extendBucketWorm() {
  1803. _extendBucketWorm = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, wormId, days, options) {
  1804. var params, paramlXMLObJ, result;
  1805. return _regenerator.default.wrap(function _callee$(_context) {
  1806. while (1) {
  1807. switch (_context.prev = _context.next) {
  1808. case 0:
  1809. checkBucketName_1.checkBucketName(name);
  1810. params = this._bucketRequestParams('POST', name, {
  1811. wormExtend: '',
  1812. wormId: wormId
  1813. }, options);
  1814. paramlXMLObJ = {
  1815. ExtendWormConfiguration: {
  1816. RetentionPeriodInDays: days
  1817. }
  1818. };
  1819. params.mime = 'xml';
  1820. params.content = obj2xml_1.obj2xml(paramlXMLObJ, {
  1821. headers: true
  1822. });
  1823. params.successStatuses = [200];
  1824. _context.next = 8;
  1825. return this.request(params);
  1826. case 8:
  1827. result = _context.sent;
  1828. return _context.abrupt("return", {
  1829. res: result.res,
  1830. status: result.status
  1831. });
  1832. case 10:
  1833. case "end":
  1834. return _context.stop();
  1835. }
  1836. }
  1837. }, _callee, this);
  1838. }));
  1839. return _extendBucketWorm.apply(this, arguments);
  1840. }
  1841. exports.extendBucketWorm = extendBucketWorm;
  1842. },{"../utils/checkBucketName":48,"../utils/obj2xml":66,"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"regenerator-runtime/runtime":337}],12:[function(require,module,exports){
  1843. "use strict";
  1844. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  1845. require("core-js/modules/es.object.assign");
  1846. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  1847. require("regenerator-runtime/runtime");
  1848. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  1849. Object.defineProperty(exports, "__esModule", {
  1850. value: true
  1851. });
  1852. exports.getBucketInventory = void 0;
  1853. var checkBucketName_1 = require("../utils/checkBucketName");
  1854. var formatInventoryConfig_1 = require("../utils/formatInventoryConfig");
  1855. /**
  1856. * getBucketInventory
  1857. * @param {String} bucketName - bucket name
  1858. * @param {String} inventoryId
  1859. * @param {Object} options
  1860. */
  1861. function getBucketInventory(_x, _x2) {
  1862. return _getBucketInventory.apply(this, arguments);
  1863. }
  1864. function _getBucketInventory() {
  1865. _getBucketInventory = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(bucketName, inventoryId) {
  1866. var options,
  1867. subres,
  1868. params,
  1869. result,
  1870. _args = arguments;
  1871. return _regenerator.default.wrap(function _callee$(_context) {
  1872. while (1) {
  1873. switch (_context.prev = _context.next) {
  1874. case 0:
  1875. options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
  1876. subres = Object.assign({
  1877. inventory: '',
  1878. inventoryId: inventoryId
  1879. }, options.subres);
  1880. checkBucketName_1.checkBucketName(bucketName);
  1881. params = this._bucketRequestParams('GET', bucketName, subres, options);
  1882. params.successStatuses = [200];
  1883. params.xmlResponse = true;
  1884. _context.next = 8;
  1885. return this.request(params);
  1886. case 8:
  1887. result = _context.sent;
  1888. return _context.abrupt("return", {
  1889. status: result.status,
  1890. res: result.res,
  1891. inventory: formatInventoryConfig_1.formatInventoryConfig(result.data)
  1892. });
  1893. case 10:
  1894. case "end":
  1895. return _context.stop();
  1896. }
  1897. }
  1898. }, _callee, this);
  1899. }));
  1900. return _getBucketInventory.apply(this, arguments);
  1901. }
  1902. exports.getBucketInventory = getBucketInventory;
  1903. },{"../utils/checkBucketName":48,"../utils/formatInventoryConfig":56,"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"core-js/modules/es.object.assign":251,"regenerator-runtime/runtime":337}],13:[function(require,module,exports){
  1904. "use strict";
  1905. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  1906. require("core-js/modules/es.array.map");
  1907. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  1908. require("regenerator-runtime/runtime");
  1909. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  1910. var _require = require('../utils/checkBucketName'),
  1911. _checkBucketName = _require.checkBucketName;
  1912. var _require2 = require('../utils/isArray'),
  1913. isArray = _require2.isArray;
  1914. var _require3 = require('../utils/formatObjKey'),
  1915. formatObjKey = _require3.formatObjKey;
  1916. var proto = exports;
  1917. proto.getBucketLifecycle = /*#__PURE__*/function () {
  1918. var _getBucketLifecycle = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, options) {
  1919. var params, result, rules;
  1920. return _regenerator.default.wrap(function _callee$(_context) {
  1921. while (1) {
  1922. switch (_context.prev = _context.next) {
  1923. case 0:
  1924. _checkBucketName(name);
  1925. params = this._bucketRequestParams('GET', name, 'lifecycle', options);
  1926. params.successStatuses = [200];
  1927. params.xmlResponse = true;
  1928. _context.next = 6;
  1929. return this.request(params);
  1930. case 6:
  1931. result = _context.sent;
  1932. rules = result.data.Rule || null;
  1933. if (rules) {
  1934. if (!isArray(rules)) {
  1935. rules = [rules];
  1936. }
  1937. rules = rules.map(function (_) {
  1938. if (_.ID) {
  1939. _.id = _.ID;
  1940. delete _.ID;
  1941. }
  1942. if (_.Tag && !isArray(_.Tag)) {
  1943. _.Tag = [_.Tag];
  1944. }
  1945. return formatObjKey(_, 'firstLowerCase');
  1946. });
  1947. }
  1948. return _context.abrupt("return", {
  1949. rules: rules,
  1950. res: result.res
  1951. });
  1952. case 10:
  1953. case "end":
  1954. return _context.stop();
  1955. }
  1956. }
  1957. }, _callee, this);
  1958. }));
  1959. function getBucketLifecycle(_x, _x2) {
  1960. return _getBucketLifecycle.apply(this, arguments);
  1961. }
  1962. return getBucketLifecycle;
  1963. }();
  1964. },{"../utils/checkBucketName":48,"../utils/formatObjKey":57,"../utils/isArray":59,"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"core-js/modules/es.array.map":245,"regenerator-runtime/runtime":337}],14:[function(require,module,exports){
  1965. "use strict";
  1966. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  1967. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  1968. require("regenerator-runtime/runtime");
  1969. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  1970. var _require = require('../utils/checkBucketName'),
  1971. _checkBucketName = _require.checkBucketName;
  1972. var proto = exports;
  1973. /**
  1974. * getBucketVersioning
  1975. * @param {String} bucketName - bucket name
  1976. */
  1977. proto.getBucketVersioning = /*#__PURE__*/function () {
  1978. var _getBucketVersioning = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(bucketName, options) {
  1979. var params, result, versionStatus;
  1980. return _regenerator.default.wrap(function _callee$(_context) {
  1981. while (1) {
  1982. switch (_context.prev = _context.next) {
  1983. case 0:
  1984. _checkBucketName(bucketName);
  1985. params = this._bucketRequestParams('GET', bucketName, 'versioning', options);
  1986. params.xmlResponse = true;
  1987. params.successStatuses = [200];
  1988. _context.next = 6;
  1989. return this.request(params);
  1990. case 6:
  1991. result = _context.sent;
  1992. versionStatus = result.data.Status;
  1993. return _context.abrupt("return", {
  1994. status: result.status,
  1995. versionStatus: versionStatus,
  1996. res: result.res
  1997. });
  1998. case 9:
  1999. case "end":
  2000. return _context.stop();
  2001. }
  2002. }
  2003. }, _callee, this);
  2004. }));
  2005. function getBucketVersioning(_x, _x2) {
  2006. return _getBucketVersioning.apply(this, arguments);
  2007. }
  2008. return getBucketVersioning;
  2009. }();
  2010. },{"../utils/checkBucketName":48,"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"regenerator-runtime/runtime":337}],15:[function(require,module,exports){
  2011. "use strict";
  2012. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  2013. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  2014. require("regenerator-runtime/runtime");
  2015. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  2016. var _require = require('../utils/checkBucketName'),
  2017. _checkBucketName = _require.checkBucketName;
  2018. var _require2 = require('../utils/isObject'),
  2019. isObject = _require2.isObject;
  2020. var proto = exports;
  2021. proto.getBucketWebsite = /*#__PURE__*/function () {
  2022. var _getBucketWebsite = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, options) {
  2023. var params, result, routingRules;
  2024. return _regenerator.default.wrap(function _callee$(_context) {
  2025. while (1) {
  2026. switch (_context.prev = _context.next) {
  2027. case 0:
  2028. _checkBucketName(name);
  2029. params = this._bucketRequestParams('GET', name, 'website', options);
  2030. params.successStatuses = [200];
  2031. params.xmlResponse = true;
  2032. _context.next = 6;
  2033. return this.request(params);
  2034. case 6:
  2035. result = _context.sent;
  2036. routingRules = [];
  2037. if (result.data.RoutingRules && result.data.RoutingRules.RoutingRule) {
  2038. if (isObject(result.data.RoutingRules.RoutingRule)) {
  2039. routingRules = [result.data.RoutingRules.RoutingRule];
  2040. } else {
  2041. routingRules = result.data.RoutingRules.RoutingRule;
  2042. }
  2043. }
  2044. return _context.abrupt("return", {
  2045. index: result.data.IndexDocument && result.data.IndexDocument.Suffix || '',
  2046. supportSubDir: result.data.IndexDocument && result.data.IndexDocument.SupportSubDir || 'false',
  2047. type: result.data.IndexDocument && result.data.IndexDocument.Type,
  2048. routingRules: routingRules,
  2049. error: result.data.ErrorDocument && result.data.ErrorDocument.Key || null,
  2050. res: result.res
  2051. });
  2052. case 10:
  2053. case "end":
  2054. return _context.stop();
  2055. }
  2056. }
  2057. }, _callee, this);
  2058. }));
  2059. function getBucketWebsite(_x, _x2) {
  2060. return _getBucketWebsite.apply(this, arguments);
  2061. }
  2062. return getBucketWebsite;
  2063. }();
  2064. },{"../utils/checkBucketName":48,"../utils/isObject":64,"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"regenerator-runtime/runtime":337}],16:[function(require,module,exports){
  2065. "use strict";
  2066. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  2067. require("core-js/modules/es.object.assign");
  2068. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  2069. require("regenerator-runtime/runtime");
  2070. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  2071. Object.defineProperty(exports, "__esModule", {
  2072. value: true
  2073. });
  2074. exports.getBucketWorm = void 0;
  2075. var checkBucketName_1 = require("../utils/checkBucketName");
  2076. var dataFix_1 = require("../utils/dataFix");
  2077. function getBucketWorm(_x, _x2) {
  2078. return _getBucketWorm.apply(this, arguments);
  2079. }
  2080. function _getBucketWorm() {
  2081. _getBucketWorm = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, options) {
  2082. var params, result;
  2083. return _regenerator.default.wrap(function _callee$(_context) {
  2084. while (1) {
  2085. switch (_context.prev = _context.next) {
  2086. case 0:
  2087. checkBucketName_1.checkBucketName(name);
  2088. params = this._bucketRequestParams('GET', name, 'worm', options);
  2089. params.successStatuses = [200];
  2090. params.xmlResponse = true;
  2091. _context.next = 6;
  2092. return this.request(params);
  2093. case 6:
  2094. result = _context.sent;
  2095. dataFix_1.dataFix(result.data, {
  2096. lowerFirst: true,
  2097. rename: {
  2098. RetentionPeriodInDays: 'days'
  2099. }
  2100. });
  2101. return _context.abrupt("return", Object.assign(Object.assign({}, result.data), {
  2102. res: result.res,
  2103. status: result.status
  2104. }));
  2105. case 9:
  2106. case "end":
  2107. return _context.stop();
  2108. }
  2109. }
  2110. }, _callee, this);
  2111. }));
  2112. return _getBucketWorm.apply(this, arguments);
  2113. }
  2114. exports.getBucketWorm = getBucketWorm;
  2115. },{"../utils/checkBucketName":48,"../utils/dataFix":53,"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"core-js/modules/es.object.assign":251,"regenerator-runtime/runtime":337}],17:[function(require,module,exports){
  2116. "use strict";
  2117. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  2118. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  2119. require("regenerator-runtime/runtime");
  2120. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  2121. Object.defineProperty(exports, "__esModule", {
  2122. value: true
  2123. });
  2124. exports.initiateBucketWorm = void 0;
  2125. var obj2xml_1 = require("../utils/obj2xml");
  2126. var checkBucketName_1 = require("../utils/checkBucketName");
  2127. function initiateBucketWorm(_x, _x2, _x3) {
  2128. return _initiateBucketWorm.apply(this, arguments);
  2129. }
  2130. function _initiateBucketWorm() {
  2131. _initiateBucketWorm = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, days, options) {
  2132. var params, paramlXMLObJ, result;
  2133. return _regenerator.default.wrap(function _callee$(_context) {
  2134. while (1) {
  2135. switch (_context.prev = _context.next) {
  2136. case 0:
  2137. checkBucketName_1.checkBucketName(name);
  2138. params = this._bucketRequestParams('POST', name, 'worm', options);
  2139. paramlXMLObJ = {
  2140. InitiateWormConfiguration: {
  2141. RetentionPeriodInDays: days
  2142. }
  2143. };
  2144. params.mime = 'xml';
  2145. params.content = obj2xml_1.obj2xml(paramlXMLObJ, {
  2146. headers: true
  2147. });
  2148. params.successStatuses = [200];
  2149. _context.next = 8;
  2150. return this.request(params);
  2151. case 8:
  2152. result = _context.sent;
  2153. return _context.abrupt("return", {
  2154. res: result.res,
  2155. wormId: result.res.headers['x-oss-worm-id'],
  2156. status: result.status
  2157. });
  2158. case 10:
  2159. case "end":
  2160. return _context.stop();
  2161. }
  2162. }
  2163. }, _callee, this);
  2164. }));
  2165. return _initiateBucketWorm.apply(this, arguments);
  2166. }
  2167. exports.initiateBucketWorm = initiateBucketWorm;
  2168. },{"../utils/checkBucketName":48,"../utils/obj2xml":66,"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"regenerator-runtime/runtime":337}],18:[function(require,module,exports){
  2169. "use strict";
  2170. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  2171. require("core-js/modules/es.object.assign");
  2172. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  2173. require("regenerator-runtime/runtime");
  2174. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  2175. Object.defineProperty(exports, "__esModule", {
  2176. value: true
  2177. });
  2178. exports.listBucketInventory = void 0;
  2179. var checkBucketName_1 = require("../utils/checkBucketName");
  2180. var formatInventoryConfig_1 = require("../utils/formatInventoryConfig");
  2181. /**
  2182. * listBucketInventory
  2183. * @param {String} bucketName - bucket name
  2184. * @param {String} inventoryId
  2185. * @param {Object} options
  2186. */
  2187. function listBucketInventory(_x) {
  2188. return _listBucketInventory.apply(this, arguments);
  2189. }
  2190. function _listBucketInventory() {
  2191. _listBucketInventory = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(bucketName) {
  2192. var options,
  2193. continuationToken,
  2194. subres,
  2195. params,
  2196. result,
  2197. data,
  2198. res,
  2199. status,
  2200. _args = arguments;
  2201. return _regenerator.default.wrap(function _callee$(_context) {
  2202. while (1) {
  2203. switch (_context.prev = _context.next) {
  2204. case 0:
  2205. options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
  2206. continuationToken = options.continuationToken;
  2207. subres = Object.assign({
  2208. inventory: ''
  2209. }, continuationToken && {
  2210. 'continuation-token': continuationToken
  2211. }, options.subres);
  2212. checkBucketName_1.checkBucketName(bucketName);
  2213. params = this._bucketRequestParams('GET', bucketName, subres, options);
  2214. params.successStatuses = [200];
  2215. params.xmlResponse = true;
  2216. _context.next = 9;
  2217. return this.request(params);
  2218. case 9:
  2219. result = _context.sent;
  2220. data = result.data, res = result.res, status = result.status;
  2221. return _context.abrupt("return", {
  2222. isTruncated: data.IsTruncated === 'true',
  2223. nextContinuationToken: data.NextContinuationToken,
  2224. inventoryList: formatInventoryConfig_1.formatInventoryConfig(data.InventoryConfiguration, true),
  2225. status: status,
  2226. res: res
  2227. });
  2228. case 12:
  2229. case "end":
  2230. return _context.stop();
  2231. }
  2232. }
  2233. }, _callee, this);
  2234. }));
  2235. return _listBucketInventory.apply(this, arguments);
  2236. }
  2237. exports.listBucketInventory = listBucketInventory;
  2238. },{"../utils/checkBucketName":48,"../utils/formatInventoryConfig":56,"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"core-js/modules/es.object.assign":251,"regenerator-runtime/runtime":337}],19:[function(require,module,exports){
  2239. "use strict";
  2240. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  2241. require("core-js/modules/es.array.concat");
  2242. require("core-js/modules/es.object.assign");
  2243. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  2244. require("regenerator-runtime/runtime");
  2245. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  2246. Object.defineProperty(exports, "__esModule", {
  2247. value: true
  2248. });
  2249. exports.putBucketInventory = void 0;
  2250. var checkBucketName_1 = require("../utils/checkBucketName");
  2251. var obj2xml_1 = require("../utils/obj2xml");
  2252. /**
  2253. * putBucketInventory
  2254. * @param {String} bucketName - bucket name
  2255. * @param {Inventory} inventory
  2256. * @param {Object} options
  2257. */
  2258. function putBucketInventory(_x, _x2) {
  2259. return _putBucketInventory.apply(this, arguments);
  2260. }
  2261. function _putBucketInventory() {
  2262. _putBucketInventory = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(bucketName, inventory) {
  2263. var options,
  2264. subres,
  2265. OSSBucketDestination,
  2266. optionalFields,
  2267. includedObjectVersions,
  2268. destinationBucketPrefix,
  2269. rolePrefix,
  2270. paramXMLObj,
  2271. paramXML,
  2272. params,
  2273. result,
  2274. _args = arguments;
  2275. return _regenerator.default.wrap(function _callee$(_context) {
  2276. while (1) {
  2277. switch (_context.prev = _context.next) {
  2278. case 0:
  2279. options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
  2280. subres = Object.assign({
  2281. inventory: '',
  2282. inventoryId: inventory.id
  2283. }, options.subres);
  2284. checkBucketName_1.checkBucketName(bucketName);
  2285. OSSBucketDestination = inventory.OSSBucketDestination, optionalFields = inventory.optionalFields, includedObjectVersions = inventory.includedObjectVersions;
  2286. destinationBucketPrefix = 'acs:oss:::';
  2287. rolePrefix = "acs:ram::".concat(OSSBucketDestination.accountId, ":role/");
  2288. paramXMLObj = {
  2289. InventoryConfiguration: {
  2290. Id: inventory.id,
  2291. IsEnabled: inventory.isEnabled,
  2292. Filter: {
  2293. Prefix: inventory.prefix || ''
  2294. },
  2295. Destination: {
  2296. OSSBucketDestination: {
  2297. Format: OSSBucketDestination.format,
  2298. AccountId: OSSBucketDestination.accountId,
  2299. RoleArn: "".concat(rolePrefix).concat(OSSBucketDestination.rolename),
  2300. Bucket: "".concat(destinationBucketPrefix).concat(OSSBucketDestination.bucket),
  2301. Prefix: OSSBucketDestination.prefix || '',
  2302. Encryption: OSSBucketDestination.encryption || ''
  2303. }
  2304. },
  2305. Schedule: {
  2306. Frequency: inventory.frequency
  2307. },
  2308. IncludedObjectVersions: includedObjectVersions,
  2309. OptionalFields: {
  2310. Field: (optionalFields === null || optionalFields === void 0 ? void 0 : optionalFields.field) || []
  2311. }
  2312. }
  2313. };
  2314. paramXML = obj2xml_1.obj2xml(paramXMLObj, {
  2315. headers: true,
  2316. firstUpperCase: true
  2317. });
  2318. params = this._bucketRequestParams('PUT', bucketName, subres, options);
  2319. params.successStatuses = [200];
  2320. params.mime = 'xml';
  2321. params.content = paramXML;
  2322. _context.next = 14;
  2323. return this.request(params);
  2324. case 14:
  2325. result = _context.sent;
  2326. return _context.abrupt("return", {
  2327. status: result.status,
  2328. res: result.res
  2329. });
  2330. case 16:
  2331. case "end":
  2332. return _context.stop();
  2333. }
  2334. }
  2335. }, _callee, this);
  2336. }));
  2337. return _putBucketInventory.apply(this, arguments);
  2338. }
  2339. exports.putBucketInventory = putBucketInventory;
  2340. },{"../utils/checkBucketName":48,"../utils/obj2xml":66,"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"core-js/modules/es.array.concat":234,"core-js/modules/es.object.assign":251,"regenerator-runtime/runtime":337}],20:[function(require,module,exports){
  2341. "use strict";
  2342. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  2343. require("core-js/modules/es.array.for-each");
  2344. require("core-js/modules/es.array.includes");
  2345. require("core-js/modules/web.dom-collections.for-each");
  2346. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  2347. require("regenerator-runtime/runtime");
  2348. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  2349. /* eslint-disable no-use-before-define */
  2350. var _require = require('../utils/checkBucketName'),
  2351. _checkBucketName = _require.checkBucketName;
  2352. var _require2 = require('../utils/isArray'),
  2353. isArray = _require2.isArray;
  2354. var _require3 = require('../utils/deepCopy'),
  2355. deepCopy = _require3.deepCopy;
  2356. var _require4 = require('../utils/isObject'),
  2357. isObject = _require4.isObject;
  2358. var _require5 = require('../utils/obj2xml'),
  2359. obj2xml = _require5.obj2xml;
  2360. var _require6 = require('../utils/checkObjectTag'),
  2361. checkObjectTag = _require6.checkObjectTag;
  2362. var _require7 = require('../utils/getStrBytesCount'),
  2363. getStrBytesCount = _require7.getStrBytesCount;
  2364. var proto = exports;
  2365. proto.putBucketLifecycle = /*#__PURE__*/function () {
  2366. var _putBucketLifecycle = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, rules, options) {
  2367. var params, Rule, paramXMLObj, paramXML, result;
  2368. return _regenerator.default.wrap(function _callee$(_context) {
  2369. while (1) {
  2370. switch (_context.prev = _context.next) {
  2371. case 0:
  2372. _checkBucketName(name);
  2373. if (isArray(rules)) {
  2374. _context.next = 3;
  2375. break;
  2376. }
  2377. throw new Error('rules must be Array');
  2378. case 3:
  2379. params = this._bucketRequestParams('PUT', name, 'lifecycle', options);
  2380. Rule = [];
  2381. paramXMLObj = {
  2382. LifecycleConfiguration: {
  2383. Rule: Rule
  2384. }
  2385. };
  2386. rules.forEach(function (_) {
  2387. defaultDaysAndDate2Expiration(_); // todo delete, 兼容旧版本
  2388. checkRule(_);
  2389. if (_.id) {
  2390. _.ID = _.id;
  2391. delete _.id;
  2392. }
  2393. Rule.push(_);
  2394. });
  2395. paramXML = obj2xml(paramXMLObj, {
  2396. headers: true,
  2397. firstUpperCase: true
  2398. });
  2399. params.content = paramXML;
  2400. params.mime = 'xml';
  2401. params.successStatuses = [200];
  2402. _context.next = 13;
  2403. return this.request(params);
  2404. case 13:
  2405. result = _context.sent;
  2406. return _context.abrupt("return", {
  2407. res: result.res
  2408. });
  2409. case 15:
  2410. case "end":
  2411. return _context.stop();
  2412. }
  2413. }
  2414. }, _callee, this);
  2415. }));
  2416. function putBucketLifecycle(_x, _x2, _x3) {
  2417. return _putBucketLifecycle.apply(this, arguments);
  2418. }
  2419. return putBucketLifecycle;
  2420. }(); // todo delete, 兼容旧版本
  2421. function defaultDaysAndDate2Expiration(obj) {
  2422. if (obj.days) {
  2423. obj.expiration = {
  2424. days: obj.days
  2425. };
  2426. }
  2427. if (obj.date) {
  2428. obj.expiration = {
  2429. createdBeforeDate: obj.date
  2430. };
  2431. }
  2432. }
  2433. function checkDaysAndDate(obj, key) {
  2434. var days = obj.days,
  2435. createdBeforeDate = obj.createdBeforeDate;
  2436. if (!days && !createdBeforeDate) {
  2437. throw new Error("".concat(key, " must includes days or createdBeforeDate"));
  2438. } else if (days && !/^[1-9][0-9]*$/.test(days)) {
  2439. throw new Error('days must be a positive integer');
  2440. } else if (createdBeforeDate && !/\d{4}-\d{2}-\d{2}T00:00:00.000Z/.test(createdBeforeDate)) {
  2441. throw new Error('createdBeforeDate must be date and conform to iso8601 format');
  2442. }
  2443. }
  2444. function handleCheckTag(tag) {
  2445. if (!isArray(tag) && !isObject(tag)) {
  2446. throw new Error('tag must be Object or Array');
  2447. }
  2448. tag = isObject(tag) ? [tag] : tag;
  2449. var tagObj = {};
  2450. var tagClone = deepCopy(tag);
  2451. tagClone.forEach(function (v) {
  2452. tagObj[v.key] = v.value;
  2453. });
  2454. checkObjectTag(tagObj);
  2455. }
  2456. function checkRule(rule) {
  2457. if (rule.id && getStrBytesCount(rule.id) > 255) throw new Error('ID is composed of 255 bytes at most');
  2458. if (rule.prefix === undefined) throw new Error('Rule must includes prefix');
  2459. if (!['Enabled', 'Disabled'].includes(rule.status)) throw new Error('Status must be Enabled or Disabled');
  2460. if (rule.transition) {
  2461. if (!['IA', 'Archive'].includes(rule.transition.storageClass)) throw new Error('StorageClass must be IA or Archive');
  2462. checkDaysAndDate(rule.transition, 'Transition');
  2463. }
  2464. if (rule.expiration) {
  2465. if (!rule.expiration.expiredObjectDeleteMarker) {
  2466. checkDaysAndDate(rule.expiration, 'Expiration');
  2467. } else if (rule.expiration.days || rule.expiration.createdBeforeDate) {
  2468. throw new Error('expiredObjectDeleteMarker cannot be used with days or createdBeforeDate');
  2469. }
  2470. }
  2471. if (rule.abortMultipartUpload) {
  2472. checkDaysAndDate(rule.abortMultipartUpload, 'AbortMultipartUpload');
  2473. }
  2474. if (!rule.expiration && !rule.abortMultipartUpload && !rule.transition && !rule.noncurrentVersionTransition) {
  2475. throw new Error('Rule must includes expiration or abortMultipartUpload or transition or noncurrentVersionTransition');
  2476. }
  2477. if (rule.tag) {
  2478. if (rule.abortMultipartUpload) {
  2479. throw new Error('Tag cannot be used with abortMultipartUpload');
  2480. }
  2481. handleCheckTag(rule.tag);
  2482. }
  2483. }
  2484. },{"../utils/checkBucketName":48,"../utils/checkObjectTag":50,"../utils/deepCopy":54,"../utils/getStrBytesCount":58,"../utils/isArray":59,"../utils/isObject":64,"../utils/obj2xml":66,"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"core-js/modules/es.array.for-each":238,"core-js/modules/es.array.includes":240,"core-js/modules/web.dom-collections.for-each":292,"regenerator-runtime/runtime":337}],21:[function(require,module,exports){
  2485. "use strict";
  2486. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  2487. require("core-js/modules/es.array.includes");
  2488. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  2489. require("regenerator-runtime/runtime");
  2490. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  2491. var _require = require('../utils/checkBucketName'),
  2492. _checkBucketName = _require.checkBucketName;
  2493. var _require2 = require('../utils/obj2xml'),
  2494. obj2xml = _require2.obj2xml;
  2495. var proto = exports;
  2496. /**
  2497. * putBucketVersioning
  2498. * @param {String} name - bucket name
  2499. * @param {String} status
  2500. * @param {Object} options
  2501. */
  2502. proto.putBucketVersioning = /*#__PURE__*/function () {
  2503. var _putBucketVersioning = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, status) {
  2504. var options,
  2505. params,
  2506. paramXMLObj,
  2507. result,
  2508. _args = arguments;
  2509. return _regenerator.default.wrap(function _callee$(_context) {
  2510. while (1) {
  2511. switch (_context.prev = _context.next) {
  2512. case 0:
  2513. options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
  2514. _checkBucketName(name);
  2515. if (['Enabled', 'Suspended'].includes(status)) {
  2516. _context.next = 4;
  2517. break;
  2518. }
  2519. throw new Error('status must be Enabled or Suspended');
  2520. case 4:
  2521. params = this._bucketRequestParams('PUT', name, 'versioning', options);
  2522. paramXMLObj = {
  2523. VersioningConfiguration: {
  2524. Status: status
  2525. }
  2526. };
  2527. params.mime = 'xml';
  2528. params.content = obj2xml(paramXMLObj, {
  2529. headers: true
  2530. });
  2531. _context.next = 10;
  2532. return this.request(params);
  2533. case 10:
  2534. result = _context.sent;
  2535. return _context.abrupt("return", {
  2536. res: result.res,
  2537. status: result.status
  2538. });
  2539. case 12:
  2540. case "end":
  2541. return _context.stop();
  2542. }
  2543. }
  2544. }, _callee, this);
  2545. }));
  2546. function putBucketVersioning(_x, _x2) {
  2547. return _putBucketVersioning.apply(this, arguments);
  2548. }
  2549. return putBucketVersioning;
  2550. }();
  2551. },{"../utils/checkBucketName":48,"../utils/obj2xml":66,"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"core-js/modules/es.array.includes":240,"regenerator-runtime/runtime":337}],22:[function(require,module,exports){
  2552. "use strict";
  2553. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  2554. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  2555. require("regenerator-runtime/runtime");
  2556. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  2557. var _require = require('../utils/checkBucketName'),
  2558. _checkBucketName = _require.checkBucketName;
  2559. var _require2 = require('../utils/obj2xml'),
  2560. obj2xml = _require2.obj2xml;
  2561. var _require3 = require('../utils/isArray'),
  2562. isArray = _require3.isArray;
  2563. var proto = exports;
  2564. proto.putBucketWebsite = /*#__PURE__*/function () {
  2565. var _putBucketWebsite = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name) {
  2566. var config,
  2567. options,
  2568. params,
  2569. IndexDocument,
  2570. WebsiteConfiguration,
  2571. website,
  2572. result,
  2573. _args = arguments;
  2574. return _regenerator.default.wrap(function _callee$(_context) {
  2575. while (1) {
  2576. switch (_context.prev = _context.next) {
  2577. case 0:
  2578. config = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
  2579. options = _args.length > 2 ? _args[2] : undefined;
  2580. _checkBucketName(name);
  2581. params = this._bucketRequestParams('PUT', name, 'website', options);
  2582. IndexDocument = {
  2583. Suffix: config.index || 'index.html'
  2584. };
  2585. WebsiteConfiguration = {
  2586. IndexDocument: IndexDocument
  2587. };
  2588. website = {
  2589. WebsiteConfiguration: WebsiteConfiguration
  2590. };
  2591. if (config.supportSubDir) {
  2592. IndexDocument.SupportSubDir = config.supportSubDir;
  2593. }
  2594. if (config.type) {
  2595. IndexDocument.Type = config.type;
  2596. }
  2597. if (config.error) {
  2598. WebsiteConfiguration.ErrorDocument = {
  2599. Key: config.error
  2600. };
  2601. }
  2602. if (!(config.routingRules !== undefined)) {
  2603. _context.next = 14;
  2604. break;
  2605. }
  2606. if (isArray(config.routingRules)) {
  2607. _context.next = 13;
  2608. break;
  2609. }
  2610. throw new Error('RoutingRules must be Array');
  2611. case 13:
  2612. WebsiteConfiguration.RoutingRules = {
  2613. RoutingRule: config.routingRules
  2614. };
  2615. case 14:
  2616. website = obj2xml(website);
  2617. params.content = website;
  2618. params.mime = 'xml';
  2619. params.successStatuses = [200];
  2620. _context.next = 20;
  2621. return this.request(params);
  2622. case 20:
  2623. result = _context.sent;
  2624. return _context.abrupt("return", {
  2625. res: result.res
  2626. });
  2627. case 22:
  2628. case "end":
  2629. return _context.stop();
  2630. }
  2631. }
  2632. }, _callee, this);
  2633. }));
  2634. function putBucketWebsite(_x) {
  2635. return _putBucketWebsite.apply(this, arguments);
  2636. }
  2637. return putBucketWebsite;
  2638. }();
  2639. },{"../utils/checkBucketName":48,"../utils/isArray":59,"../utils/obj2xml":66,"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"regenerator-runtime/runtime":337}],23:[function(require,module,exports){
  2640. (function (Buffer){
  2641. "use strict";
  2642. require("core-js/modules/es.array.for-each");
  2643. require("core-js/modules/es.object.keys");
  2644. require("core-js/modules/es.object.to-string");
  2645. require("core-js/modules/es.regexp.to-string");
  2646. require("core-js/modules/web.dom-collections.for-each");
  2647. exports.encodeCallback = function encodeCallback(reqParams, options) {
  2648. reqParams.headers = reqParams.headers || {};
  2649. if (!Object.prototype.hasOwnProperty.call(reqParams.headers, 'x-oss-callback')) {
  2650. if (options.callback) {
  2651. var json = {
  2652. callbackUrl: encodeURI(options.callback.url),
  2653. callbackBody: options.callback.body
  2654. };
  2655. if (options.callback.host) {
  2656. json.callbackHost = options.callback.host;
  2657. }
  2658. if (options.callback.contentType) {
  2659. json.callbackBodyType = options.callback.contentType;
  2660. }
  2661. var callback = Buffer.from(JSON.stringify(json)).toString('base64');
  2662. reqParams.headers['x-oss-callback'] = callback;
  2663. if (options.callback.customValue) {
  2664. var callbackVar = {};
  2665. Object.keys(options.callback.customValue).forEach(function (key) {
  2666. callbackVar["x:".concat(key)] = options.callback.customValue[key];
  2667. });
  2668. reqParams.headers['x-oss-callback-var'] = Buffer.from(JSON.stringify(callbackVar)).toString('base64');
  2669. }
  2670. }
  2671. }
  2672. };
  2673. }).call(this,require("buffer").Buffer)
  2674. },{"buffer":98,"core-js/modules/es.array.for-each":238,"core-js/modules/es.object.keys":253,"core-js/modules/es.object.to-string":254,"core-js/modules/es.regexp.to-string":257,"core-js/modules/web.dom-collections.for-each":292}],24:[function(require,module,exports){
  2675. "use strict";
  2676. require("core-js/modules/es.array.concat");
  2677. require("core-js/modules/es.array.for-each");
  2678. require("core-js/modules/es.regexp.exec");
  2679. require("core-js/modules/es.string.replace");
  2680. require("core-js/modules/web.dom-collections.for-each");
  2681. var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
  2682. return mod && mod.__esModule ? mod : {
  2683. "default": mod
  2684. };
  2685. };
  2686. Object.defineProperty(exports, "__esModule", {
  2687. value: true
  2688. });
  2689. exports.getReqUrl = void 0;
  2690. var copy_to_1 = __importDefault(require("copy-to"));
  2691. var url_1 = __importDefault(require("url"));
  2692. var merge_descriptors_1 = __importDefault(require("merge-descriptors"));
  2693. var is_type_of_1 = __importDefault(require("is-type-of"));
  2694. var isIP_1 = require("../utils/isIP");
  2695. var checkConfigValid_1 = require("../utils/checkConfigValid");
  2696. function getReqUrl(params) {
  2697. var ep = {};
  2698. var isCname = this.options.cname;
  2699. checkConfigValid_1.checkConfigValid(this.options.endpoint, 'endpoint');
  2700. copy_to_1.default(this.options.endpoint, false).to(ep);
  2701. if (params.bucket && !isCname && !isIP_1.isIP(ep.hostname) && !this.options.sldEnable) {
  2702. ep.host = "".concat(params.bucket, ".").concat(ep.host);
  2703. }
  2704. var resourcePath = '/';
  2705. if (params.bucket && this.options.sldEnable) {
  2706. resourcePath += "".concat(params.bucket, "/");
  2707. }
  2708. if (params.object) {
  2709. // Preserve '/' in result url
  2710. resourcePath += this._escape(params.object).replace(/\+/g, '%2B');
  2711. }
  2712. ep.pathname = resourcePath;
  2713. var query = {};
  2714. if (params.query) {
  2715. merge_descriptors_1.default(query, params.query);
  2716. }
  2717. if (params.subres) {
  2718. var subresAsQuery = {};
  2719. if (is_type_of_1.default.string(params.subres)) {
  2720. subresAsQuery[params.subres] = '';
  2721. } else if (is_type_of_1.default.array(params.subres)) {
  2722. params.subres.forEach(function (k) {
  2723. subresAsQuery[k] = '';
  2724. });
  2725. } else {
  2726. subresAsQuery = params.subres;
  2727. }
  2728. merge_descriptors_1.default(query, subresAsQuery);
  2729. }
  2730. ep.query = query;
  2731. return url_1.default.format(ep);
  2732. }
  2733. exports.getReqUrl = getReqUrl;
  2734. },{"../utils/checkConfigValid":49,"../utils/isIP":63,"copy-to":101,"core-js/modules/es.array.concat":234,"core-js/modules/es.array.for-each":238,"core-js/modules/es.regexp.exec":256,"core-js/modules/es.string.replace":261,"core-js/modules/web.dom-collections.for-each":292,"is-type-of":392,"merge-descriptors":311,"url":394}],25:[function(require,module,exports){
  2735. "use strict";
  2736. require("core-js/modules/es.array.concat");
  2737. require("core-js/modules/es.object.assign");
  2738. require("core-js/modules/es.string.trim");
  2739. var ms = require('humanize-ms');
  2740. var urlutil = require('url');
  2741. var _require = require('../utils/checkBucketName'),
  2742. _checkBucketName = _require.checkBucketName;
  2743. var _require2 = require('../utils/setRegion'),
  2744. setRegion = _require2.setRegion;
  2745. var _require3 = require('../utils/checkConfigValid'),
  2746. checkConfigValid = _require3.checkConfigValid;
  2747. function setEndpoint(endpoint, secure) {
  2748. checkConfigValid(endpoint, 'endpoint');
  2749. var url = urlutil.parse(endpoint);
  2750. if (!url.protocol) {
  2751. url = urlutil.parse("http".concat(secure ? 's' : '', "://").concat(endpoint));
  2752. }
  2753. if (url.protocol !== 'http:' && url.protocol !== 'https:') {
  2754. throw new Error('Endpoint protocol must be http or https.');
  2755. }
  2756. return url;
  2757. }
  2758. module.exports = function (options) {
  2759. if (!options || !options.accessKeyId || !options.accessKeySecret) {
  2760. throw new Error('require accessKeyId, accessKeySecret');
  2761. }
  2762. if (options.bucket) {
  2763. _checkBucketName(options.bucket);
  2764. }
  2765. var opts = Object.assign({
  2766. region: 'oss-cn-hangzhou',
  2767. internal: false,
  2768. secure: false,
  2769. timeout: 60000,
  2770. bucket: null,
  2771. endpoint: null,
  2772. cname: false,
  2773. isRequestPay: false,
  2774. sldEnable: false,
  2775. headerEncoding: 'utf-8',
  2776. refreshSTSToken: null
  2777. }, options);
  2778. opts.accessKeyId = opts.accessKeyId.trim();
  2779. opts.accessKeySecret = opts.accessKeySecret.trim();
  2780. if (opts.timeout) {
  2781. opts.timeout = ms(opts.timeout);
  2782. }
  2783. if (opts.endpoint) {
  2784. opts.endpoint = setEndpoint(opts.endpoint, opts.secure);
  2785. } else if (opts.region) {
  2786. opts.endpoint = setRegion(opts.region, opts.internal, opts.secure);
  2787. } else {
  2788. throw new Error('require options.endpoint or options.region');
  2789. }
  2790. opts.inited = true;
  2791. return opts;
  2792. };
  2793. },{"../utils/checkBucketName":48,"../utils/checkConfigValid":49,"../utils/setRegion":68,"core-js/modules/es.array.concat":234,"core-js/modules/es.object.assign":251,"core-js/modules/es.string.trim":265,"humanize-ms":299,"url":394}],26:[function(require,module,exports){
  2794. "use strict";
  2795. var merge = require('merge-descriptors');
  2796. var proto = exports;
  2797. merge(proto, require('./processObjectSave'));
  2798. },{"./processObjectSave":27,"merge-descriptors":311}],27:[function(require,module,exports){
  2799. "use strict";
  2800. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  2801. require("core-js/modules/es.array.concat");
  2802. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  2803. require("regenerator-runtime/runtime");
  2804. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  2805. /* eslint-disable no-use-before-define */
  2806. var _require = require('../utils/checkBucketName'),
  2807. _checkBucketName = _require.checkBucketName;
  2808. var querystring = require('querystring');
  2809. var _require2 = require('js-base64'),
  2810. str2Base64 = _require2.Base64.encode;
  2811. var proto = exports;
  2812. proto.processObjectSave = /*#__PURE__*/function () {
  2813. var _processObjectSave = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(sourceObject, targetObject, process, targetBucket) {
  2814. var params, bucketParam, content, result;
  2815. return _regenerator.default.wrap(function _callee$(_context) {
  2816. while (1) {
  2817. switch (_context.prev = _context.next) {
  2818. case 0:
  2819. checkArgs(sourceObject, 'sourceObject');
  2820. checkArgs(targetObject, 'targetObject');
  2821. checkArgs(process, 'process');
  2822. targetObject = this._objectName(targetObject);
  2823. if (targetBucket) {
  2824. _checkBucketName(targetBucket);
  2825. }
  2826. params = this._objectRequestParams('POST', sourceObject, {
  2827. subres: 'x-oss-process'
  2828. });
  2829. bucketParam = targetBucket ? ",b_".concat(str2Base64(targetBucket)) : '';
  2830. targetObject = str2Base64(targetObject);
  2831. content = {
  2832. 'x-oss-process': "".concat(process, "|sys/saveas,o_").concat(targetObject).concat(bucketParam)
  2833. };
  2834. params.content = querystring.stringify(content);
  2835. _context.next = 12;
  2836. return this.request(params);
  2837. case 12:
  2838. result = _context.sent;
  2839. return _context.abrupt("return", {
  2840. res: result.res,
  2841. status: result.res.status
  2842. });
  2843. case 14:
  2844. case "end":
  2845. return _context.stop();
  2846. }
  2847. }
  2848. }, _callee, this);
  2849. }));
  2850. function processObjectSave(_x, _x2, _x3, _x4) {
  2851. return _processObjectSave.apply(this, arguments);
  2852. }
  2853. return processObjectSave;
  2854. }();
  2855. function checkArgs(name, key) {
  2856. if (!name) {
  2857. throw new Error("".concat(key, " is required"));
  2858. }
  2859. if (typeof name !== 'string') {
  2860. throw new Error("".concat(key, " must be String"));
  2861. }
  2862. }
  2863. },{"../utils/checkBucketName":48,"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"core-js/modules/es.array.concat":234,"js-base64":310,"querystring":323,"regenerator-runtime/runtime":337}],28:[function(require,module,exports){
  2864. "use strict";
  2865. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  2866. require("core-js/modules/es.array.concat");
  2867. require("core-js/modules/es.array.filter");
  2868. require("core-js/modules/es.array.map");
  2869. require("core-js/modules/es.array.sort");
  2870. require("core-js/modules/es.object.to-string");
  2871. require("core-js/modules/es.regexp.to-string");
  2872. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  2873. require("regenerator-runtime/runtime");
  2874. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  2875. var copy = require('copy-to');
  2876. var callback = require('./callback');
  2877. var _require = require('./utils/deepCopy'),
  2878. deepCopyWith = _require.deepCopyWith;
  2879. var _require2 = require('./utils/isBuffer'),
  2880. isBuffer = _require2.isBuffer;
  2881. var proto = exports;
  2882. /**
  2883. * List the on-going multipart uploads
  2884. * https://help.aliyun.com/document_detail/31997.html
  2885. * @param {Object} options
  2886. * @return {Array} the multipart uploads
  2887. */
  2888. proto.listUploads = /*#__PURE__*/function () {
  2889. var _listUploads = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(query, options) {
  2890. var opt, params, result, uploads;
  2891. return _regenerator.default.wrap(function _callee$(_context) {
  2892. while (1) {
  2893. switch (_context.prev = _context.next) {
  2894. case 0:
  2895. options = options || {};
  2896. opt = {};
  2897. copy(options).to(opt);
  2898. opt.subres = 'uploads';
  2899. params = this._objectRequestParams('GET', '', opt);
  2900. params.query = query;
  2901. params.xmlResponse = true;
  2902. params.successStatuses = [200];
  2903. _context.next = 10;
  2904. return this.request(params);
  2905. case 10:
  2906. result = _context.sent;
  2907. uploads = result.data.Upload || [];
  2908. if (!Array.isArray(uploads)) {
  2909. uploads = [uploads];
  2910. }
  2911. uploads = uploads.map(function (up) {
  2912. return {
  2913. name: up.Key,
  2914. uploadId: up.UploadId,
  2915. initiated: up.Initiated
  2916. };
  2917. });
  2918. return _context.abrupt("return", {
  2919. res: result.res,
  2920. uploads: uploads,
  2921. bucket: result.data.Bucket,
  2922. nextKeyMarker: result.data.NextKeyMarker,
  2923. nextUploadIdMarker: result.data.NextUploadIdMarker,
  2924. isTruncated: result.data.IsTruncated === 'true'
  2925. });
  2926. case 15:
  2927. case "end":
  2928. return _context.stop();
  2929. }
  2930. }
  2931. }, _callee, this);
  2932. }));
  2933. function listUploads(_x, _x2) {
  2934. return _listUploads.apply(this, arguments);
  2935. }
  2936. return listUploads;
  2937. }();
  2938. /**
  2939. * List the done uploadPart parts
  2940. * @param {String} name object name
  2941. * @param {String} uploadId multipart upload id
  2942. * @param {Object} query
  2943. * {Number} query.max-parts The maximum part number in the response of the OSS. Default value: 1000
  2944. * {Number} query.part-number-marker Starting position of a specific list.
  2945. * {String} query.encoding-type Specify the encoding of the returned content and the encoding type.
  2946. * @param {Object} options
  2947. * @return {Object} result
  2948. */
  2949. proto.listParts = /*#__PURE__*/function () {
  2950. var _listParts = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(name, uploadId, query, options) {
  2951. var opt, params, result;
  2952. return _regenerator.default.wrap(function _callee2$(_context2) {
  2953. while (1) {
  2954. switch (_context2.prev = _context2.next) {
  2955. case 0:
  2956. options = options || {};
  2957. opt = {};
  2958. copy(options).to(opt);
  2959. opt.subres = {
  2960. uploadId: uploadId
  2961. };
  2962. params = this._objectRequestParams('GET', name, opt);
  2963. params.query = query;
  2964. params.xmlResponse = true;
  2965. params.successStatuses = [200];
  2966. _context2.next = 10;
  2967. return this.request(params);
  2968. case 10:
  2969. result = _context2.sent;
  2970. return _context2.abrupt("return", {
  2971. res: result.res,
  2972. uploadId: result.data.UploadId,
  2973. bucket: result.data.Bucket,
  2974. name: result.data.Key,
  2975. partNumberMarker: result.data.PartNumberMarker,
  2976. nextPartNumberMarker: result.data.NextPartNumberMarker,
  2977. maxParts: result.data.MaxParts,
  2978. isTruncated: result.data.IsTruncated,
  2979. parts: result.data.Part || []
  2980. });
  2981. case 12:
  2982. case "end":
  2983. return _context2.stop();
  2984. }
  2985. }
  2986. }, _callee2, this);
  2987. }));
  2988. function listParts(_x3, _x4, _x5, _x6) {
  2989. return _listParts.apply(this, arguments);
  2990. }
  2991. return listParts;
  2992. }();
  2993. /**
  2994. * Abort a multipart upload transaction
  2995. * @param {String} name the object name
  2996. * @param {String} uploadId the upload id
  2997. * @param {Object} options
  2998. */
  2999. proto.abortMultipartUpload = /*#__PURE__*/function () {
  3000. var _abortMultipartUpload = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(name, uploadId, options) {
  3001. var opt, params, result;
  3002. return _regenerator.default.wrap(function _callee3$(_context3) {
  3003. while (1) {
  3004. switch (_context3.prev = _context3.next) {
  3005. case 0:
  3006. this._stop();
  3007. options = options || {};
  3008. opt = {};
  3009. copy(options).to(opt);
  3010. opt.subres = {
  3011. uploadId: uploadId
  3012. };
  3013. params = this._objectRequestParams('DELETE', name, opt);
  3014. params.successStatuses = [204];
  3015. _context3.next = 9;
  3016. return this.request(params);
  3017. case 9:
  3018. result = _context3.sent;
  3019. return _context3.abrupt("return", {
  3020. res: result.res
  3021. });
  3022. case 11:
  3023. case "end":
  3024. return _context3.stop();
  3025. }
  3026. }
  3027. }, _callee3, this);
  3028. }));
  3029. function abortMultipartUpload(_x7, _x8, _x9) {
  3030. return _abortMultipartUpload.apply(this, arguments);
  3031. }
  3032. return abortMultipartUpload;
  3033. }();
  3034. /**
  3035. * Initiate a multipart upload transaction
  3036. * @param {String} name the object name
  3037. * @param {Object} options
  3038. * @return {String} upload id
  3039. */
  3040. proto.initMultipartUpload = /*#__PURE__*/function () {
  3041. var _initMultipartUpload = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(name, options) {
  3042. var opt, params, result;
  3043. return _regenerator.default.wrap(function _callee4$(_context4) {
  3044. while (1) {
  3045. switch (_context4.prev = _context4.next) {
  3046. case 0:
  3047. options = options || {};
  3048. opt = {};
  3049. copy(options).to(opt);
  3050. opt.headers = opt.headers || {};
  3051. this._convertMetaToHeaders(options.meta, opt.headers);
  3052. opt.subres = 'uploads';
  3053. params = this._objectRequestParams('POST', name, opt);
  3054. params.mime = options.mime;
  3055. params.xmlResponse = true;
  3056. params.successStatuses = [200];
  3057. _context4.next = 12;
  3058. return this.request(params);
  3059. case 12:
  3060. result = _context4.sent;
  3061. return _context4.abrupt("return", {
  3062. res: result.res,
  3063. bucket: result.data.Bucket,
  3064. name: result.data.Key,
  3065. uploadId: result.data.UploadId
  3066. });
  3067. case 14:
  3068. case "end":
  3069. return _context4.stop();
  3070. }
  3071. }
  3072. }, _callee4, this);
  3073. }));
  3074. function initMultipartUpload(_x10, _x11) {
  3075. return _initMultipartUpload.apply(this, arguments);
  3076. }
  3077. return initMultipartUpload;
  3078. }();
  3079. /**
  3080. * Upload a part in a multipart upload transaction
  3081. * @param {String} name the object name
  3082. * @param {String} uploadId the upload id
  3083. * @param {Integer} partNo the part number
  3084. * @param {File} file upload File, whole File
  3085. * @param {Integer} start part start bytes e.g: 102400
  3086. * @param {Integer} end part end bytes e.g: 204800
  3087. * @param {Object} options
  3088. */
  3089. proto.uploadPart = /*#__PURE__*/function () {
  3090. var _uploadPart2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(name, uploadId, partNo, file, start, end, options) {
  3091. var data;
  3092. return _regenerator.default.wrap(function _callee5$(_context5) {
  3093. while (1) {
  3094. switch (_context5.prev = _context5.next) {
  3095. case 0:
  3096. data = {
  3097. stream: this._createStream(file, start, end),
  3098. size: end - start
  3099. };
  3100. _context5.next = 3;
  3101. return this._uploadPart(name, uploadId, partNo, data, options);
  3102. case 3:
  3103. return _context5.abrupt("return", _context5.sent);
  3104. case 4:
  3105. case "end":
  3106. return _context5.stop();
  3107. }
  3108. }
  3109. }, _callee5, this);
  3110. }));
  3111. function uploadPart(_x12, _x13, _x14, _x15, _x16, _x17, _x18) {
  3112. return _uploadPart2.apply(this, arguments);
  3113. }
  3114. return uploadPart;
  3115. }();
  3116. /**
  3117. * Complete a multipart upload transaction
  3118. * @param {String} name the object name
  3119. * @param {String} uploadId the upload id
  3120. * @param {Array} parts the uploaded parts, each in the structure:
  3121. * {Integer} number partNo
  3122. * {String} etag part etag uploadPartCopy result.res.header.etag
  3123. * @param {Object} options
  3124. * {Object} options.callback The callback parameter is composed of a JSON string encoded in Base64
  3125. * {String} options.callback.url the OSS sends a callback request to this URL
  3126. * {String} options.callback.host The host header value for initiating callback requests
  3127. * {String} options.callback.body The value of the request body when a callback is initiated
  3128. * {String} options.callback.contentType The Content-Type of the callback requests initiatiated
  3129. * {Object} options.callback.customValue Custom parameters are a map of key-values, e.g:
  3130. * customValue = {
  3131. * key1: 'value1',
  3132. * key2: 'value2'
  3133. * }
  3134. */
  3135. proto.completeMultipartUpload = /*#__PURE__*/function () {
  3136. var _completeMultipartUpload = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(name, uploadId, parts, options) {
  3137. var completeParts, xml, i, p, opt, params, result, ret;
  3138. return _regenerator.default.wrap(function _callee6$(_context6) {
  3139. while (1) {
  3140. switch (_context6.prev = _context6.next) {
  3141. case 0:
  3142. completeParts = parts.concat().sort(function (a, b) {
  3143. return a.number - b.number;
  3144. }).filter(function (item, index, arr) {
  3145. return !index || item.number !== arr[index - 1].number;
  3146. });
  3147. xml = '<?xml version="1.0" encoding="UTF-8"?>\n<CompleteMultipartUpload>\n';
  3148. for (i = 0; i < completeParts.length; i++) {
  3149. p = completeParts[i];
  3150. xml += '<Part>\n';
  3151. xml += "<PartNumber>".concat(p.number, "</PartNumber>\n");
  3152. xml += "<ETag>".concat(p.etag, "</ETag>\n");
  3153. xml += '</Part>\n';
  3154. }
  3155. xml += '</CompleteMultipartUpload>';
  3156. options = options || {};
  3157. opt = {};
  3158. opt = deepCopyWith(options, function (_) {
  3159. if (isBuffer(_)) return null;
  3160. });
  3161. if (opt.headers) delete opt.headers['x-oss-server-side-encryption'];
  3162. opt.subres = {
  3163. uploadId: uploadId
  3164. };
  3165. params = this._objectRequestParams('POST', name, opt);
  3166. callback.encodeCallback(params, opt);
  3167. params.mime = 'xml';
  3168. params.content = xml;
  3169. if (!(params.headers && params.headers['x-oss-callback'])) {
  3170. params.xmlResponse = true;
  3171. }
  3172. params.successStatuses = [200];
  3173. _context6.next = 17;
  3174. return this.request(params);
  3175. case 17:
  3176. result = _context6.sent;
  3177. ret = {
  3178. res: result.res,
  3179. bucket: params.bucket,
  3180. name: name,
  3181. etag: result.res.headers.etag
  3182. };
  3183. if (params.headers && params.headers['x-oss-callback']) {
  3184. ret.data = JSON.parse(result.data.toString());
  3185. }
  3186. return _context6.abrupt("return", ret);
  3187. case 21:
  3188. case "end":
  3189. return _context6.stop();
  3190. }
  3191. }
  3192. }, _callee6, this);
  3193. }));
  3194. function completeMultipartUpload(_x19, _x20, _x21, _x22) {
  3195. return _completeMultipartUpload.apply(this, arguments);
  3196. }
  3197. return completeMultipartUpload;
  3198. }();
  3199. /**
  3200. * Upload a part in a multipart upload transaction
  3201. * @param {String} name the object name
  3202. * @param {String} uploadId the upload id
  3203. * @param {Integer} partNo the part number
  3204. * @param {Object} data the body data
  3205. * @param {Object} options
  3206. */
  3207. proto._uploadPart = /*#__PURE__*/function () {
  3208. var _uploadPart3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(name, uploadId, partNo, data, options) {
  3209. var opt, params, result;
  3210. return _regenerator.default.wrap(function _callee7$(_context7) {
  3211. while (1) {
  3212. switch (_context7.prev = _context7.next) {
  3213. case 0:
  3214. options = options || {};
  3215. opt = {};
  3216. copy(options).to(opt);
  3217. opt.headers = {
  3218. 'Content-Length': data.size
  3219. };
  3220. opt.subres = {
  3221. partNumber: partNo,
  3222. uploadId: uploadId
  3223. };
  3224. params = this._objectRequestParams('PUT', name, opt);
  3225. params.mime = opt.mime;
  3226. params.stream = data.stream;
  3227. params.successStatuses = [200];
  3228. _context7.next = 11;
  3229. return this.request(params);
  3230. case 11:
  3231. result = _context7.sent;
  3232. if (result.res.headers.etag) {
  3233. _context7.next = 14;
  3234. break;
  3235. }
  3236. throw new Error('Please set the etag of expose-headers in OSS \n https://help.aliyun.com/document_detail/32069.html');
  3237. case 14:
  3238. data.stream = null;
  3239. params.stream = null;
  3240. return _context7.abrupt("return", {
  3241. name: name,
  3242. etag: result.res.headers.etag,
  3243. res: result.res
  3244. });
  3245. case 17:
  3246. case "end":
  3247. return _context7.stop();
  3248. }
  3249. }
  3250. }, _callee7, this);
  3251. }));
  3252. function _uploadPart(_x23, _x24, _x25, _x26, _x27) {
  3253. return _uploadPart3.apply(this, arguments);
  3254. }
  3255. return _uploadPart;
  3256. }();
  3257. },{"./callback":23,"./utils/deepCopy":54,"./utils/isBuffer":61,"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"copy-to":101,"core-js/modules/es.array.concat":234,"core-js/modules/es.array.filter":236,"core-js/modules/es.array.map":245,"core-js/modules/es.array.sort":247,"core-js/modules/es.object.to-string":254,"core-js/modules/es.regexp.to-string":257,"regenerator-runtime/runtime":337}],29:[function(require,module,exports){
  3258. "use strict";
  3259. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3260. require("core-js/modules/es.array.concat");
  3261. require("core-js/modules/es.array.find");
  3262. require("core-js/modules/es.array.for-each");
  3263. require("core-js/modules/es.array.includes");
  3264. require("core-js/modules/es.object.keys");
  3265. require("core-js/modules/es.regexp.exec");
  3266. require("core-js/modules/es.string.replace");
  3267. require("core-js/modules/web.dom-collections.for-each");
  3268. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  3269. var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
  3270. require("regenerator-runtime/runtime");
  3271. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  3272. var _require = require('../utils/checkBucketName'),
  3273. _checkBucketName = _require.checkBucketName;
  3274. var proto = exports;
  3275. var REPLACE_HEDERS = ['content-type', 'content-encoding', 'content-language', 'content-disposition', 'cache-control', 'expires'];
  3276. proto.copy = /*#__PURE__*/function () {
  3277. var _copy = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, sourceName, bucketName, options) {
  3278. var params, result, data;
  3279. return _regenerator.default.wrap(function _callee$(_context) {
  3280. while (1) {
  3281. switch (_context.prev = _context.next) {
  3282. case 0:
  3283. if ((0, _typeof2.default)(bucketName) === 'object') {
  3284. options = bucketName; // 兼容旧版本,旧版本第三个参数为options
  3285. }
  3286. options = options || {};
  3287. options.headers = options.headers || {};
  3288. Object.keys(options.headers).forEach(function (key) {
  3289. options.headers["x-oss-copy-source-".concat(key.toLowerCase())] = options.headers[key];
  3290. });
  3291. if (options.meta || Object.keys(options.headers).find(function (_) {
  3292. return REPLACE_HEDERS.includes(_.toLowerCase());
  3293. })) {
  3294. options.headers['x-oss-metadata-directive'] = 'REPLACE';
  3295. }
  3296. this._convertMetaToHeaders(options.meta, options.headers);
  3297. sourceName = this._getSourceName(sourceName, bucketName);
  3298. if (options.versionId) {
  3299. sourceName = "".concat(sourceName, "?versionId=").concat(options.versionId);
  3300. }
  3301. options.headers['x-oss-copy-source'] = sourceName;
  3302. params = this._objectRequestParams('PUT', name, options);
  3303. params.xmlResponse = true;
  3304. params.successStatuses = [200, 304];
  3305. _context.next = 14;
  3306. return this.request(params);
  3307. case 14:
  3308. result = _context.sent;
  3309. data = result.data;
  3310. if (data) {
  3311. data = {
  3312. etag: data.ETag,
  3313. lastModified: data.LastModified
  3314. };
  3315. }
  3316. return _context.abrupt("return", {
  3317. data: data,
  3318. res: result.res
  3319. });
  3320. case 18:
  3321. case "end":
  3322. return _context.stop();
  3323. }
  3324. }
  3325. }, _callee, this);
  3326. }));
  3327. function copy(_x, _x2, _x3, _x4) {
  3328. return _copy.apply(this, arguments);
  3329. }
  3330. return copy;
  3331. }(); // todo delete
  3332. proto._getSourceName = function _getSourceName(sourceName, bucketName) {
  3333. if (typeof bucketName === 'string') {
  3334. sourceName = this._objectName(sourceName);
  3335. } else if (sourceName[0] !== '/') {
  3336. bucketName = this.options.bucket;
  3337. } else {
  3338. bucketName = sourceName.replace(/\/(.+?)(\/.*)/, '$1');
  3339. sourceName = sourceName.replace(/(\/.+?\/)(.*)/, '$2');
  3340. }
  3341. _checkBucketName(bucketName);
  3342. sourceName = encodeURIComponent(sourceName);
  3343. sourceName = "/".concat(bucketName, "/").concat(sourceName);
  3344. return sourceName;
  3345. };
  3346. },{"../utils/checkBucketName":48,"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/helpers/typeof":72,"@babel/runtime/regenerator":74,"core-js/modules/es.array.concat":234,"core-js/modules/es.array.find":237,"core-js/modules/es.array.for-each":238,"core-js/modules/es.array.includes":240,"core-js/modules/es.object.keys":253,"core-js/modules/es.regexp.exec":256,"core-js/modules/es.string.replace":261,"core-js/modules/web.dom-collections.for-each":292,"regenerator-runtime/runtime":337}],30:[function(require,module,exports){
  3347. "use strict";
  3348. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3349. require("core-js/modules/es.object.assign");
  3350. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  3351. require("regenerator-runtime/runtime");
  3352. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  3353. var proto = exports;
  3354. /**
  3355. * delete
  3356. * @param {String} name - object name
  3357. * @param {Object} options
  3358. * @param {{res}}
  3359. */
  3360. proto.delete = /*#__PURE__*/function () {
  3361. var _delete2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name) {
  3362. var options,
  3363. params,
  3364. result,
  3365. _args = arguments;
  3366. return _regenerator.default.wrap(function _callee$(_context) {
  3367. while (1) {
  3368. switch (_context.prev = _context.next) {
  3369. case 0:
  3370. options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
  3371. options.subres = Object.assign({}, options.subres);
  3372. if (options.versionId) {
  3373. options.subres.versionId = options.versionId;
  3374. }
  3375. params = this._objectRequestParams('DELETE', name, options);
  3376. params.successStatuses = [204];
  3377. _context.next = 7;
  3378. return this.request(params);
  3379. case 7:
  3380. result = _context.sent;
  3381. return _context.abrupt("return", {
  3382. res: result.res
  3383. });
  3384. case 9:
  3385. case "end":
  3386. return _context.stop();
  3387. }
  3388. }
  3389. }, _callee, this);
  3390. }));
  3391. function _delete(_x) {
  3392. return _delete2.apply(this, arguments);
  3393. }
  3394. return _delete;
  3395. }();
  3396. },{"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"core-js/modules/es.object.assign":251,"regenerator-runtime/runtime":337}],31:[function(require,module,exports){
  3397. "use strict";
  3398. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3399. require("core-js/modules/es.object.assign");
  3400. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  3401. require("regenerator-runtime/runtime");
  3402. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  3403. /* eslint-disable object-curly-newline */
  3404. var utility = require('utility');
  3405. var _require = require('../utils/obj2xml'),
  3406. obj2xml = _require.obj2xml;
  3407. var proto = exports;
  3408. proto.deleteMulti = /*#__PURE__*/function () {
  3409. var _deleteMulti = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(names) {
  3410. var options,
  3411. objects,
  3412. i,
  3413. object,
  3414. _names$i,
  3415. key,
  3416. versionId,
  3417. paramXMLObj,
  3418. paramXML,
  3419. params,
  3420. result,
  3421. r,
  3422. deleted,
  3423. _args = arguments;
  3424. return _regenerator.default.wrap(function _callee$(_context) {
  3425. while (1) {
  3426. switch (_context.prev = _context.next) {
  3427. case 0:
  3428. options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
  3429. objects = [];
  3430. if (!(!names || !names.length)) {
  3431. _context.next = 4;
  3432. break;
  3433. }
  3434. throw new Error('names is required');
  3435. case 4:
  3436. for (i = 0; i < names.length; i++) {
  3437. object = {};
  3438. if (typeof names[i] === 'string') {
  3439. object.Key = utility.escape(this._objectName(names[i]));
  3440. } else {
  3441. _names$i = names[i], key = _names$i.key, versionId = _names$i.versionId;
  3442. object.Key = utility.escape(this._objectName(key));
  3443. object.VersionId = versionId;
  3444. }
  3445. objects.push(object);
  3446. }
  3447. paramXMLObj = {
  3448. Delete: {
  3449. Quiet: !!options.quiet,
  3450. Object: objects
  3451. }
  3452. };
  3453. paramXML = obj2xml(paramXMLObj, {
  3454. headers: true
  3455. });
  3456. options.subres = Object.assign({
  3457. delete: ''
  3458. }, options.subres);
  3459. if (options.versionId) {
  3460. options.subres.versionId = options.versionId;
  3461. }
  3462. params = this._objectRequestParams('POST', '', options);
  3463. params.mime = 'xml';
  3464. params.content = paramXML;
  3465. params.xmlResponse = true;
  3466. params.successStatuses = [200];
  3467. _context.next = 16;
  3468. return this.request(params);
  3469. case 16:
  3470. result = _context.sent;
  3471. r = result.data;
  3472. deleted = r && r.Deleted || null;
  3473. if (deleted) {
  3474. if (!Array.isArray(deleted)) {
  3475. deleted = [deleted];
  3476. }
  3477. }
  3478. return _context.abrupt("return", {
  3479. res: result.res,
  3480. deleted: deleted || []
  3481. });
  3482. case 21:
  3483. case "end":
  3484. return _context.stop();
  3485. }
  3486. }
  3487. }, _callee, this);
  3488. }));
  3489. function deleteMulti(_x) {
  3490. return _deleteMulti.apply(this, arguments);
  3491. }
  3492. return deleteMulti;
  3493. }();
  3494. },{"../utils/obj2xml":66,"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"core-js/modules/es.object.assign":251,"regenerator-runtime/runtime":337,"utility":396}],32:[function(require,module,exports){
  3495. "use strict";
  3496. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3497. require("core-js/modules/es.object.assign");
  3498. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  3499. require("regenerator-runtime/runtime");
  3500. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  3501. var proto = exports;
  3502. /**
  3503. * deleteObjectTagging
  3504. * @param {String} name - object name
  3505. * @param {Object} options
  3506. */
  3507. proto.deleteObjectTagging = /*#__PURE__*/function () {
  3508. var _deleteObjectTagging = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name) {
  3509. var options,
  3510. params,
  3511. result,
  3512. _args = arguments;
  3513. return _regenerator.default.wrap(function _callee$(_context) {
  3514. while (1) {
  3515. switch (_context.prev = _context.next) {
  3516. case 0:
  3517. options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
  3518. options.subres = Object.assign({
  3519. tagging: ''
  3520. }, options.subres);
  3521. if (options.versionId) {
  3522. options.subres.versionId = options.versionId;
  3523. }
  3524. name = this._objectName(name);
  3525. params = this._objectRequestParams('DELETE', name, options);
  3526. params.successStatuses = [204];
  3527. _context.next = 8;
  3528. return this.request(params);
  3529. case 8:
  3530. result = _context.sent;
  3531. return _context.abrupt("return", {
  3532. status: result.status,
  3533. res: result.res
  3534. });
  3535. case 10:
  3536. case "end":
  3537. return _context.stop();
  3538. }
  3539. }
  3540. }, _callee, this);
  3541. }));
  3542. function deleteObjectTagging(_x) {
  3543. return _deleteObjectTagging.apply(this, arguments);
  3544. }
  3545. return deleteObjectTagging;
  3546. }();
  3547. },{"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"core-js/modules/es.object.assign":251,"regenerator-runtime/runtime":337}],33:[function(require,module,exports){
  3548. "use strict";
  3549. require("core-js/modules/es.array.concat");
  3550. var urlutil = require('url');
  3551. var _require = require('../utils/isIP'),
  3552. isIP = _require.isIP;
  3553. var proto = exports;
  3554. /**
  3555. * Get Object url by name
  3556. * @param {String} name - object name
  3557. * @param {String} [baseUrl] - If provide `baseUrl`, will use `baseUrl` instead the default `endpoint and bucket`.
  3558. * @return {String} object url include bucket
  3559. */
  3560. proto.generateObjectUrl = function generateObjectUrl(name, baseUrl) {
  3561. if (isIP(this.options.endpoint.hostname)) {
  3562. throw new Error('can not get the object URL when endpoint is IP');
  3563. }
  3564. if (!baseUrl) {
  3565. baseUrl = this.options.endpoint.format();
  3566. var copyUrl = urlutil.parse(baseUrl);
  3567. var bucket = this.options.bucket;
  3568. copyUrl.hostname = "".concat(bucket, ".").concat(copyUrl.hostname);
  3569. copyUrl.host = "".concat(bucket, ".").concat(copyUrl.host);
  3570. baseUrl = copyUrl.format();
  3571. } else if (baseUrl[baseUrl.length - 1] !== '/') {
  3572. baseUrl += '/';
  3573. }
  3574. return baseUrl + this._escape(this._objectName(name));
  3575. };
  3576. },{"../utils/isIP":63,"core-js/modules/es.array.concat":234,"url":394}],34:[function(require,module,exports){
  3577. (function (process){
  3578. "use strict";
  3579. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3580. require("core-js/modules/es.object.assign");
  3581. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  3582. require("regenerator-runtime/runtime");
  3583. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  3584. var fs = require('fs');
  3585. var is = require('is-type-of');
  3586. var proto = exports;
  3587. /**
  3588. * get
  3589. * @param {String} name - object name
  3590. * @param {String | Stream} file
  3591. * @param {Object} options
  3592. * @param {{res}}
  3593. */
  3594. proto.get = /*#__PURE__*/function () {
  3595. var _get = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, file) {
  3596. var options,
  3597. writeStream,
  3598. needDestroy,
  3599. isBrowserEnv,
  3600. responseCacheControl,
  3601. defaultSubresOptions,
  3602. result,
  3603. params,
  3604. _args = arguments;
  3605. return _regenerator.default.wrap(function _callee$(_context) {
  3606. while (1) {
  3607. switch (_context.prev = _context.next) {
  3608. case 0:
  3609. options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
  3610. writeStream = null;
  3611. needDestroy = false;
  3612. if (is.writableStream(file)) {
  3613. writeStream = file;
  3614. } else if (is.string(file)) {
  3615. writeStream = fs.createWriteStream(file);
  3616. needDestroy = true;
  3617. } else {
  3618. // get(name, options)
  3619. options = file;
  3620. }
  3621. options = options || {};
  3622. isBrowserEnv = process && process.browser;
  3623. responseCacheControl = options.responseCacheControl === null ? '' : 'no-cache';
  3624. defaultSubresOptions = isBrowserEnv && responseCacheControl ? {
  3625. 'response-cache-control': responseCacheControl
  3626. } : {};
  3627. options.subres = Object.assign(defaultSubresOptions, options.subres);
  3628. if (options.versionId) {
  3629. options.subres.versionId = options.versionId;
  3630. }
  3631. if (options.process) {
  3632. options.subres['x-oss-process'] = options.process;
  3633. }
  3634. _context.prev = 11;
  3635. params = this._objectRequestParams('GET', name, options);
  3636. params.writeStream = writeStream;
  3637. params.successStatuses = [200, 206, 304];
  3638. _context.next = 17;
  3639. return this.request(params);
  3640. case 17:
  3641. result = _context.sent;
  3642. if (needDestroy) {
  3643. writeStream.destroy();
  3644. }
  3645. _context.next = 28;
  3646. break;
  3647. case 21:
  3648. _context.prev = 21;
  3649. _context.t0 = _context["catch"](11);
  3650. if (!needDestroy) {
  3651. _context.next = 27;
  3652. break;
  3653. }
  3654. writeStream.destroy(); // should delete the exists file before throw error
  3655. _context.next = 27;
  3656. return this._deleteFileSafe(file);
  3657. case 27:
  3658. throw _context.t0;
  3659. case 28:
  3660. return _context.abrupt("return", {
  3661. res: result.res,
  3662. content: result.data
  3663. });
  3664. case 29:
  3665. case "end":
  3666. return _context.stop();
  3667. }
  3668. }
  3669. }, _callee, this, [[11, 21]]);
  3670. }));
  3671. function get(_x, _x2) {
  3672. return _get.apply(this, arguments);
  3673. }
  3674. return get;
  3675. }();
  3676. }).call(this,require('_process'))
  3677. },{"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"_process":393,"core-js/modules/es.object.assign":251,"fs":78,"is-type-of":392,"regenerator-runtime/runtime":337}],35:[function(require,module,exports){
  3678. "use strict";
  3679. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3680. require("core-js/modules/es.object.assign");
  3681. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  3682. require("regenerator-runtime/runtime");
  3683. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  3684. var proto = exports;
  3685. /*
  3686. * Get object's ACL
  3687. * @param {String} name the object key
  3688. * @param {Object} options
  3689. * @return {Object}
  3690. */
  3691. proto.getACL = /*#__PURE__*/function () {
  3692. var _getACL = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name) {
  3693. var options,
  3694. params,
  3695. result,
  3696. _args = arguments;
  3697. return _regenerator.default.wrap(function _callee$(_context) {
  3698. while (1) {
  3699. switch (_context.prev = _context.next) {
  3700. case 0:
  3701. options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
  3702. options.subres = Object.assign({
  3703. acl: ''
  3704. }, options.subres);
  3705. if (options.versionId) {
  3706. options.subres.versionId = options.versionId;
  3707. }
  3708. name = this._objectName(name);
  3709. params = this._objectRequestParams('GET', name, options);
  3710. params.successStatuses = [200];
  3711. params.xmlResponse = true;
  3712. _context.next = 9;
  3713. return this.request(params);
  3714. case 9:
  3715. result = _context.sent;
  3716. return _context.abrupt("return", {
  3717. acl: result.data.AccessControlList.Grant,
  3718. owner: {
  3719. id: result.data.Owner.ID,
  3720. displayName: result.data.Owner.DisplayName
  3721. },
  3722. res: result.res
  3723. });
  3724. case 11:
  3725. case "end":
  3726. return _context.stop();
  3727. }
  3728. }
  3729. }, _callee, this);
  3730. }));
  3731. function getACL(_x) {
  3732. return _getACL.apply(this, arguments);
  3733. }
  3734. return getACL;
  3735. }();
  3736. },{"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"core-js/modules/es.object.assign":251,"regenerator-runtime/runtime":337}],36:[function(require,module,exports){
  3737. "use strict";
  3738. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3739. require("core-js/modules/es.array.for-each");
  3740. require("core-js/modules/es.array.map");
  3741. require("core-js/modules/es.number.constructor");
  3742. require("core-js/modules/es.object.assign");
  3743. require("core-js/modules/es.object.keys");
  3744. require("core-js/modules/es.regexp.exec");
  3745. require("core-js/modules/es.string.replace");
  3746. require("core-js/modules/web.dom-collections.for-each");
  3747. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  3748. require("regenerator-runtime/runtime");
  3749. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  3750. /* eslint-disable no-use-before-define */
  3751. var proto = exports;
  3752. var _require = require('../utils/isObject'),
  3753. isObject = _require.isObject;
  3754. var _require2 = require('../utils/isArray'),
  3755. isArray = _require2.isArray;
  3756. proto.getBucketVersions = getBucketVersions;
  3757. proto.listObjectVersions = getBucketVersions;
  3758. function getBucketVersions() {
  3759. return _getBucketVersions.apply(this, arguments);
  3760. }
  3761. function _getBucketVersions() {
  3762. _getBucketVersions = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
  3763. var query,
  3764. options,
  3765. params,
  3766. result,
  3767. objects,
  3768. deleteMarker,
  3769. that,
  3770. prefixes,
  3771. _args = arguments;
  3772. return _regenerator.default.wrap(function _callee$(_context) {
  3773. while (1) {
  3774. switch (_context.prev = _context.next) {
  3775. case 0:
  3776. query = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
  3777. options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
  3778. if (!(query.versionIdMarker && query.keyMarker === undefined)) {
  3779. _context.next = 4;
  3780. break;
  3781. }
  3782. throw new Error('A version-id marker cannot be specified without a key marker');
  3783. case 4:
  3784. options.subres = Object.assign({
  3785. versions: ''
  3786. }, options.subres);
  3787. if (options.versionId) {
  3788. options.subres.versionId = options.versionId;
  3789. }
  3790. params = this._objectRequestParams('GET', '', options);
  3791. params.xmlResponse = true;
  3792. params.successStatuses = [200];
  3793. params.query = formatQuery(query);
  3794. _context.next = 12;
  3795. return this.request(params);
  3796. case 12:
  3797. result = _context.sent;
  3798. objects = result.data.Version || [];
  3799. deleteMarker = result.data.DeleteMarker || [];
  3800. that = this;
  3801. if (objects) {
  3802. if (!Array.isArray(objects)) {
  3803. objects = [objects];
  3804. }
  3805. objects = objects.map(function (obj) {
  3806. return {
  3807. name: obj.Key,
  3808. url: that._objectUrl(obj.Key),
  3809. lastModified: obj.LastModified,
  3810. isLatest: obj.IsLatest === 'true',
  3811. versionId: obj.VersionId,
  3812. etag: obj.ETag,
  3813. type: obj.Type,
  3814. size: Number(obj.Size),
  3815. storageClass: obj.StorageClass,
  3816. owner: {
  3817. id: obj.Owner.ID,
  3818. displayName: obj.Owner.DisplayName
  3819. }
  3820. };
  3821. });
  3822. }
  3823. if (deleteMarker) {
  3824. if (!isArray(deleteMarker)) {
  3825. deleteMarker = [deleteMarker];
  3826. }
  3827. deleteMarker = deleteMarker.map(function (obj) {
  3828. return {
  3829. name: obj.Key,
  3830. lastModified: obj.LastModified,
  3831. versionId: obj.VersionId,
  3832. owner: {
  3833. id: obj.Owner.ID,
  3834. displayName: obj.Owner.DisplayName
  3835. }
  3836. };
  3837. });
  3838. }
  3839. prefixes = result.data.CommonPrefixes || null;
  3840. if (prefixes) {
  3841. if (!isArray(prefixes)) {
  3842. prefixes = [prefixes];
  3843. }
  3844. prefixes = prefixes.map(function (item) {
  3845. return item.Prefix;
  3846. });
  3847. }
  3848. return _context.abrupt("return", {
  3849. res: result.res,
  3850. objects: objects,
  3851. deleteMarker: deleteMarker,
  3852. prefixes: prefixes,
  3853. // attirbute of legacy error
  3854. nextMarker: result.data.NextKeyMarker || null,
  3855. // attirbute of legacy error
  3856. NextVersionIdMarker: result.data.NextVersionIdMarker || null,
  3857. nextKeyMarker: result.data.NextKeyMarker || null,
  3858. nextVersionIdMarker: result.data.NextVersionIdMarker || null,
  3859. isTruncated: result.data.IsTruncated === 'true'
  3860. });
  3861. case 21:
  3862. case "end":
  3863. return _context.stop();
  3864. }
  3865. }
  3866. }, _callee, this);
  3867. }));
  3868. return _getBucketVersions.apply(this, arguments);
  3869. }
  3870. function camel2Line(name) {
  3871. return name.replace(/([A-Z])/g, '-$1').toLowerCase();
  3872. }
  3873. function formatQuery() {
  3874. var query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  3875. var obj = {};
  3876. if (isObject(query)) {
  3877. Object.keys(query).forEach(function (key) {
  3878. obj[camel2Line(key)] = query[key];
  3879. });
  3880. }
  3881. return obj;
  3882. }
  3883. },{"../utils/isArray":59,"../utils/isObject":64,"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"core-js/modules/es.array.for-each":238,"core-js/modules/es.array.map":245,"core-js/modules/es.number.constructor":250,"core-js/modules/es.object.assign":251,"core-js/modules/es.object.keys":253,"core-js/modules/es.regexp.exec":256,"core-js/modules/es.string.replace":261,"core-js/modules/web.dom-collections.for-each":292,"regenerator-runtime/runtime":337}],37:[function(require,module,exports){
  3884. "use strict";
  3885. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3886. require("core-js/modules/es.object.assign");
  3887. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  3888. require("regenerator-runtime/runtime");
  3889. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  3890. var proto = exports;
  3891. /**
  3892. * getObjectMeta
  3893. * @param {String} name - object name
  3894. * @param {Object} options
  3895. * @param {{res}}
  3896. */
  3897. proto.getObjectMeta = /*#__PURE__*/function () {
  3898. var _getObjectMeta = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, options) {
  3899. var params, result;
  3900. return _regenerator.default.wrap(function _callee$(_context) {
  3901. while (1) {
  3902. switch (_context.prev = _context.next) {
  3903. case 0:
  3904. options = options || {};
  3905. name = this._objectName(name);
  3906. options.subres = Object.assign({
  3907. objectMeta: ''
  3908. }, options.subres);
  3909. if (options.versionId) {
  3910. options.subres.versionId = options.versionId;
  3911. }
  3912. params = this._objectRequestParams('HEAD', name, options);
  3913. params.successStatuses = [200];
  3914. _context.next = 8;
  3915. return this.request(params);
  3916. case 8:
  3917. result = _context.sent;
  3918. return _context.abrupt("return", {
  3919. status: result.status,
  3920. res: result.res
  3921. });
  3922. case 10:
  3923. case "end":
  3924. return _context.stop();
  3925. }
  3926. }
  3927. }, _callee, this);
  3928. }));
  3929. function getObjectMeta(_x, _x2) {
  3930. return _getObjectMeta.apply(this, arguments);
  3931. }
  3932. return getObjectMeta;
  3933. }();
  3934. },{"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"core-js/modules/es.object.assign":251,"regenerator-runtime/runtime":337}],38:[function(require,module,exports){
  3935. "use strict";
  3936. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3937. require("core-js/modules/es.array.for-each");
  3938. require("core-js/modules/es.object.assign");
  3939. require("core-js/modules/web.dom-collections.for-each");
  3940. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  3941. require("regenerator-runtime/runtime");
  3942. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  3943. var proto = exports;
  3944. var _require = require('../utils/isObject'),
  3945. isObject = _require.isObject;
  3946. /**
  3947. * getObjectTagging
  3948. * @param {String} name - object name
  3949. * @param {Object} options
  3950. * @return {Object}
  3951. */
  3952. proto.getObjectTagging = /*#__PURE__*/function () {
  3953. var _getObjectTagging = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name) {
  3954. var options,
  3955. params,
  3956. result,
  3957. Tagging,
  3958. Tag,
  3959. tag,
  3960. _args = arguments;
  3961. return _regenerator.default.wrap(function _callee$(_context) {
  3962. while (1) {
  3963. switch (_context.prev = _context.next) {
  3964. case 0:
  3965. options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
  3966. options.subres = Object.assign({
  3967. tagging: ''
  3968. }, options.subres);
  3969. if (options.versionId) {
  3970. options.subres.versionId = options.versionId;
  3971. }
  3972. name = this._objectName(name);
  3973. params = this._objectRequestParams('GET', name, options);
  3974. params.successStatuses = [200];
  3975. _context.next = 8;
  3976. return this.request(params);
  3977. case 8:
  3978. result = _context.sent;
  3979. _context.next = 11;
  3980. return this.parseXML(result.data);
  3981. case 11:
  3982. Tagging = _context.sent;
  3983. Tag = Tagging.TagSet.Tag;
  3984. Tag = Tag && isObject(Tag) ? [Tag] : Tag || [];
  3985. tag = {};
  3986. Tag.forEach(function (item) {
  3987. tag[item.Key] = item.Value;
  3988. });
  3989. return _context.abrupt("return", {
  3990. status: result.status,
  3991. res: result.res,
  3992. tag: tag
  3993. });
  3994. case 17:
  3995. case "end":
  3996. return _context.stop();
  3997. }
  3998. }
  3999. }, _callee, this);
  4000. }));
  4001. function getObjectTagging(_x) {
  4002. return _getObjectTagging.apply(this, arguments);
  4003. }
  4004. return getObjectTagging;
  4005. }();
  4006. },{"../utils/isObject":64,"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"core-js/modules/es.array.for-each":238,"core-js/modules/es.object.assign":251,"core-js/modules/web.dom-collections.for-each":292,"regenerator-runtime/runtime":337}],39:[function(require,module,exports){
  4007. "use strict";
  4008. var _require = require('../utils/isIP'),
  4009. isIP = _require.isIP;
  4010. var proto = exports;
  4011. /**
  4012. * Get Object url by name
  4013. * @param {String} name - object name
  4014. * @param {String} [baseUrl] - If provide `baseUrl`,
  4015. * will use `baseUrl` instead the default `endpoint`.
  4016. * @return {String} object url
  4017. */
  4018. proto.getObjectUrl = function getObjectUrl(name, baseUrl) {
  4019. if (isIP(this.options.endpoint.hostname)) {
  4020. throw new Error('can not get the object URL when endpoint is IP');
  4021. }
  4022. if (!baseUrl) {
  4023. baseUrl = this.options.endpoint.format();
  4024. } else if (baseUrl[baseUrl.length - 1] !== '/') {
  4025. baseUrl += '/';
  4026. }
  4027. return baseUrl + this._escape(this._objectName(name));
  4028. };
  4029. },{"../utils/isIP":63}],40:[function(require,module,exports){
  4030. "use strict";
  4031. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  4032. require("core-js/modules/es.object.assign");
  4033. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  4034. require("regenerator-runtime/runtime");
  4035. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  4036. var proto = exports;
  4037. /**
  4038. * getSymlink
  4039. * @param {String} name - object name
  4040. * @param {Object} options
  4041. * @param {{res}}
  4042. */
  4043. proto.getSymlink = /*#__PURE__*/function () {
  4044. var _getSymlink = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name) {
  4045. var options,
  4046. params,
  4047. result,
  4048. target,
  4049. _args = arguments;
  4050. return _regenerator.default.wrap(function _callee$(_context) {
  4051. while (1) {
  4052. switch (_context.prev = _context.next) {
  4053. case 0:
  4054. options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
  4055. options.subres = Object.assign({
  4056. symlink: ''
  4057. }, options.subres);
  4058. if (options.versionId) {
  4059. options.subres.versionId = options.versionId;
  4060. }
  4061. name = this._objectName(name);
  4062. params = this._objectRequestParams('GET', name, options);
  4063. params.successStatuses = [200];
  4064. _context.next = 8;
  4065. return this.request(params);
  4066. case 8:
  4067. result = _context.sent;
  4068. target = result.res.headers['x-oss-symlink-target'];
  4069. return _context.abrupt("return", {
  4070. targetName: decodeURIComponent(target),
  4071. res: result.res
  4072. });
  4073. case 11:
  4074. case "end":
  4075. return _context.stop();
  4076. }
  4077. }
  4078. }, _callee, this);
  4079. }));
  4080. function getSymlink(_x) {
  4081. return _getSymlink.apply(this, arguments);
  4082. }
  4083. return getSymlink;
  4084. }();
  4085. },{"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"core-js/modules/es.object.assign":251,"regenerator-runtime/runtime":337}],41:[function(require,module,exports){
  4086. "use strict";
  4087. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  4088. require("core-js/modules/es.array.for-each");
  4089. require("core-js/modules/es.array.index-of");
  4090. require("core-js/modules/es.object.assign");
  4091. require("core-js/modules/es.object.keys");
  4092. require("core-js/modules/web.dom-collections.for-each");
  4093. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  4094. require("regenerator-runtime/runtime");
  4095. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  4096. var proto = exports;
  4097. /**
  4098. * head
  4099. * @param {String} name - object name
  4100. * @param {Object} options
  4101. * @param {{res}}
  4102. */
  4103. proto.head = /*#__PURE__*/function () {
  4104. var _head = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name) {
  4105. var options,
  4106. params,
  4107. result,
  4108. data,
  4109. _args = arguments;
  4110. return _regenerator.default.wrap(function _callee$(_context) {
  4111. while (1) {
  4112. switch (_context.prev = _context.next) {
  4113. case 0:
  4114. options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
  4115. options.subres = Object.assign({}, options.subres);
  4116. if (options.versionId) {
  4117. options.subres.versionId = options.versionId;
  4118. }
  4119. params = this._objectRequestParams('HEAD', name, options);
  4120. params.successStatuses = [200, 304];
  4121. _context.next = 7;
  4122. return this.request(params);
  4123. case 7:
  4124. result = _context.sent;
  4125. data = {
  4126. meta: null,
  4127. res: result.res,
  4128. status: result.status
  4129. };
  4130. if (result.status === 200) {
  4131. Object.keys(result.headers).forEach(function (k) {
  4132. if (k.indexOf('x-oss-meta-') === 0) {
  4133. if (!data.meta) {
  4134. data.meta = {};
  4135. }
  4136. data.meta[k.substring(11)] = result.headers[k];
  4137. }
  4138. });
  4139. }
  4140. return _context.abrupt("return", data);
  4141. case 11:
  4142. case "end":
  4143. return _context.stop();
  4144. }
  4145. }
  4146. }, _callee, this);
  4147. }));
  4148. function head(_x) {
  4149. return _head.apply(this, arguments);
  4150. }
  4151. return head;
  4152. }();
  4153. },{"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"core-js/modules/es.array.for-each":238,"core-js/modules/es.array.index-of":241,"core-js/modules/es.object.assign":251,"core-js/modules/es.object.keys":253,"core-js/modules/web.dom-collections.for-each":292,"regenerator-runtime/runtime":337}],42:[function(require,module,exports){
  4154. "use strict";
  4155. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  4156. require("core-js/modules/es.object.assign");
  4157. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  4158. require("regenerator-runtime/runtime");
  4159. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  4160. var proto = exports;
  4161. /*
  4162. * Set object's ACL
  4163. * @param {String} name the object key
  4164. * @param {String} acl the object ACL
  4165. * @param {Object} options
  4166. */
  4167. proto.putACL = /*#__PURE__*/function () {
  4168. var _putACL = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, acl, options) {
  4169. var params, result;
  4170. return _regenerator.default.wrap(function _callee$(_context) {
  4171. while (1) {
  4172. switch (_context.prev = _context.next) {
  4173. case 0:
  4174. options = options || {};
  4175. options.subres = Object.assign({
  4176. acl: ''
  4177. }, options.subres);
  4178. if (options.versionId) {
  4179. options.subres.versionId = options.versionId;
  4180. }
  4181. options.headers = options.headers || {};
  4182. options.headers['x-oss-object-acl'] = acl;
  4183. name = this._objectName(name);
  4184. params = this._objectRequestParams('PUT', name, options);
  4185. params.successStatuses = [200];
  4186. _context.next = 10;
  4187. return this.request(params);
  4188. case 10:
  4189. result = _context.sent;
  4190. return _context.abrupt("return", {
  4191. res: result.res
  4192. });
  4193. case 12:
  4194. case "end":
  4195. return _context.stop();
  4196. }
  4197. }
  4198. }, _callee, this);
  4199. }));
  4200. function putACL(_x, _x2, _x3) {
  4201. return _putACL.apply(this, arguments);
  4202. }
  4203. return putACL;
  4204. }();
  4205. },{"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"core-js/modules/es.object.assign":251,"regenerator-runtime/runtime":337}],43:[function(require,module,exports){
  4206. "use strict";
  4207. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  4208. require("core-js/modules/es.array.map");
  4209. require("core-js/modules/es.object.assign");
  4210. require("core-js/modules/es.object.keys");
  4211. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  4212. require("regenerator-runtime/runtime");
  4213. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  4214. var _require = require('../utils/obj2xml'),
  4215. obj2xml = _require.obj2xml;
  4216. var _require2 = require('../utils/checkObjectTag'),
  4217. checkObjectTag = _require2.checkObjectTag;
  4218. var proto = exports;
  4219. /**
  4220. * putObjectTagging
  4221. * @param {String} name - object name
  4222. * @param {Object} tag - object tag, eg: `{a: "1", b: "2"}`
  4223. * @param {Object} options
  4224. */
  4225. proto.putObjectTagging = /*#__PURE__*/function () {
  4226. var _putObjectTagging = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, tag) {
  4227. var options,
  4228. params,
  4229. paramXMLObj,
  4230. result,
  4231. _args = arguments;
  4232. return _regenerator.default.wrap(function _callee$(_context) {
  4233. while (1) {
  4234. switch (_context.prev = _context.next) {
  4235. case 0:
  4236. options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
  4237. checkObjectTag(tag);
  4238. options.subres = Object.assign({
  4239. tagging: ''
  4240. }, options.subres);
  4241. if (options.versionId) {
  4242. options.subres.versionId = options.versionId;
  4243. }
  4244. name = this._objectName(name);
  4245. params = this._objectRequestParams('PUT', name, options);
  4246. params.successStatuses = [200];
  4247. tag = Object.keys(tag).map(function (key) {
  4248. return {
  4249. Key: key,
  4250. Value: tag[key]
  4251. };
  4252. });
  4253. paramXMLObj = {
  4254. Tagging: {
  4255. TagSet: {
  4256. Tag: tag
  4257. }
  4258. }
  4259. };
  4260. params.mime = 'xml';
  4261. params.content = obj2xml(paramXMLObj);
  4262. _context.next = 13;
  4263. return this.request(params);
  4264. case 13:
  4265. result = _context.sent;
  4266. return _context.abrupt("return", {
  4267. res: result.res,
  4268. status: result.status
  4269. });
  4270. case 15:
  4271. case "end":
  4272. return _context.stop();
  4273. }
  4274. }
  4275. }, _callee, this);
  4276. }));
  4277. function putObjectTagging(_x, _x2) {
  4278. return _putObjectTagging.apply(this, arguments);
  4279. }
  4280. return putObjectTagging;
  4281. }();
  4282. },{"../utils/checkObjectTag":50,"../utils/obj2xml":66,"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"core-js/modules/es.array.map":245,"core-js/modules/es.object.assign":251,"core-js/modules/es.object.keys":253,"regenerator-runtime/runtime":337}],44:[function(require,module,exports){
  4283. "use strict";
  4284. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  4285. require("core-js/modules/es.object.assign");
  4286. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  4287. require("regenerator-runtime/runtime");
  4288. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  4289. var proto = exports;
  4290. /**
  4291. * putSymlink
  4292. * @param {String} name - object name
  4293. * @param {String} targetName - target name
  4294. * @param {Object} options
  4295. * @param {{res}}
  4296. */
  4297. proto.putSymlink = /*#__PURE__*/function () {
  4298. var _putSymlink = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, targetName, options) {
  4299. var params, result;
  4300. return _regenerator.default.wrap(function _callee$(_context) {
  4301. while (1) {
  4302. switch (_context.prev = _context.next) {
  4303. case 0:
  4304. options = options || {};
  4305. options.headers = options.headers || {};
  4306. targetName = this._escape(this._objectName(targetName));
  4307. this._convertMetaToHeaders(options.meta, options.headers);
  4308. options.headers['x-oss-symlink-target'] = targetName;
  4309. options.subres = Object.assign({
  4310. symlink: ''
  4311. }, options.subres);
  4312. if (options.versionId) {
  4313. options.subres.versionId = options.versionId;
  4314. }
  4315. if (options.storageClass) {
  4316. options.headers['x-oss-storage-class'] = options.storageClass;
  4317. }
  4318. name = this._objectName(name);
  4319. params = this._objectRequestParams('PUT', name, options);
  4320. params.successStatuses = [200];
  4321. _context.next = 13;
  4322. return this.request(params);
  4323. case 13:
  4324. result = _context.sent;
  4325. return _context.abrupt("return", {
  4326. res: result.res
  4327. });
  4328. case 15:
  4329. case "end":
  4330. return _context.stop();
  4331. }
  4332. }
  4333. }, _callee, this);
  4334. }));
  4335. function putSymlink(_x, _x2, _x3) {
  4336. return _putSymlink.apply(this, arguments);
  4337. }
  4338. return putSymlink;
  4339. }();
  4340. },{"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"core-js/modules/es.object.assign":251,"regenerator-runtime/runtime":337}],45:[function(require,module,exports){
  4341. "use strict";
  4342. var urlutil = require('url');
  4343. var utility = require('utility');
  4344. var copy = require('copy-to');
  4345. var signHelper = require('../../common/signUtils');
  4346. var _require = require('../utils/isIP'),
  4347. isIP = _require.isIP;
  4348. var proto = exports;
  4349. proto.signatureUrl = function signatureUrl(name, options) {
  4350. if (isIP(this.options.endpoint.hostname)) {
  4351. throw new Error('can not get the object URL when endpoint is IP');
  4352. }
  4353. options = options || {};
  4354. name = this._objectName(name);
  4355. options.method = options.method || 'GET';
  4356. var expires = utility.timestamp() + (options.expires || 1800);
  4357. var params = {
  4358. bucket: this.options.bucket,
  4359. object: name
  4360. };
  4361. var resource = this._getResource(params);
  4362. if (this.options.stsToken) {
  4363. options['security-token'] = this.options.stsToken;
  4364. }
  4365. var signRes = signHelper._signatureForURL(this.options.accessKeySecret, options, resource, expires);
  4366. var url = urlutil.parse(this._getReqUrl(params));
  4367. url.query = {
  4368. OSSAccessKeyId: this.options.accessKeyId,
  4369. Expires: expires,
  4370. Signature: signRes.Signature
  4371. };
  4372. copy(signRes.subResource).to(url.query);
  4373. return url.format();
  4374. };
  4375. },{"../../common/signUtils":47,"../utils/isIP":63,"copy-to":101,"url":394,"utility":396}],46:[function(require,module,exports){
  4376. "use strict";
  4377. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  4378. require("core-js/modules/es.array.for-each");
  4379. require("core-js/modules/es.array.iterator");
  4380. require("core-js/modules/es.function.name");
  4381. require("core-js/modules/es.object.to-string");
  4382. require("core-js/modules/es.promise");
  4383. require("core-js/modules/es.string.iterator");
  4384. require("core-js/modules/web.dom-collections.for-each");
  4385. require("core-js/modules/web.dom-collections.iterator");
  4386. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  4387. require("regenerator-runtime/runtime");
  4388. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  4389. var _require = require("./utils/isArray"),
  4390. isArray = _require.isArray;
  4391. var proto = exports;
  4392. proto._parallelNode = /*#__PURE__*/function () {
  4393. var _parallelNode2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(todo, parallel, fn, sourceData) {
  4394. var that, jobErr, jobs, tempBatch, remainder, batch, taskIndex, i;
  4395. return _regenerator.default.wrap(function _callee$(_context) {
  4396. while (1) {
  4397. switch (_context.prev = _context.next) {
  4398. case 0:
  4399. that = this; // upload in parallel
  4400. jobErr = [];
  4401. jobs = [];
  4402. tempBatch = todo.length / parallel;
  4403. remainder = todo.length % parallel;
  4404. batch = remainder === 0 ? tempBatch : (todo.length - remainder) / parallel + 1;
  4405. taskIndex = 1;
  4406. i = 0;
  4407. case 8:
  4408. if (!(i < todo.length)) {
  4409. _context.next = 26;
  4410. break;
  4411. }
  4412. if (!that.isCancel()) {
  4413. _context.next = 11;
  4414. break;
  4415. }
  4416. return _context.abrupt("break", 26);
  4417. case 11:
  4418. if (sourceData) {
  4419. jobs.push(fn(that, todo[i], sourceData));
  4420. } else {
  4421. jobs.push(fn(that, todo[i]));
  4422. }
  4423. if (!(jobs.length === parallel || taskIndex === batch && i === todo.length - 1)) {
  4424. _context.next = 23;
  4425. break;
  4426. }
  4427. _context.prev = 13;
  4428. taskIndex += 1;
  4429. /* eslint no-await-in-loop: [0] */
  4430. _context.next = 17;
  4431. return Promise.all(jobs);
  4432. case 17:
  4433. _context.next = 22;
  4434. break;
  4435. case 19:
  4436. _context.prev = 19;
  4437. _context.t0 = _context["catch"](13);
  4438. jobErr.push(_context.t0);
  4439. case 22:
  4440. jobs = [];
  4441. case 23:
  4442. i++;
  4443. _context.next = 8;
  4444. break;
  4445. case 26:
  4446. return _context.abrupt("return", jobErr);
  4447. case 27:
  4448. case "end":
  4449. return _context.stop();
  4450. }
  4451. }
  4452. }, _callee, this, [[13, 19]]);
  4453. }));
  4454. function _parallelNode(_x, _x2, _x3, _x4) {
  4455. return _parallelNode2.apply(this, arguments);
  4456. }
  4457. return _parallelNode;
  4458. }();
  4459. proto._parallel = function _parallel(todo, parallel, jobPromise) {
  4460. var that = this;
  4461. return new Promise(function (resolve) {
  4462. var _jobErr = [];
  4463. if (parallel <= 0 || !todo) {
  4464. resolve(_jobErr);
  4465. return;
  4466. }
  4467. function onlyOnce(fn) {
  4468. return function () {
  4469. if (fn === null) throw new Error('Callback was already called.');
  4470. var callFn = fn;
  4471. fn = null;
  4472. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  4473. args[_key] = arguments[_key];
  4474. }
  4475. callFn.apply(this, args);
  4476. };
  4477. }
  4478. function createArrayIterator(coll) {
  4479. var i = -1;
  4480. var len = coll.length;
  4481. return function next() {
  4482. return ++i < len && !that.isCancel() ? {
  4483. value: coll[i],
  4484. key: i
  4485. } : null;
  4486. };
  4487. }
  4488. var nextElem = createArrayIterator(todo);
  4489. var done = false;
  4490. var running = 0;
  4491. var looping = false;
  4492. function iterateeCallback(err, value) {
  4493. running -= 1;
  4494. if (err) {
  4495. done = true;
  4496. _jobErr.push(err);
  4497. resolve(_jobErr);
  4498. } else if (value === {} || done && running <= 0) {
  4499. done = true;
  4500. resolve(_jobErr);
  4501. } else if (!looping) {
  4502. /* eslint no-use-before-define: [0] */
  4503. if (that.isCancel()) {
  4504. resolve(_jobErr);
  4505. } else {
  4506. replenish();
  4507. }
  4508. }
  4509. }
  4510. function iteratee(value, callback) {
  4511. jobPromise(value).then(function (result) {
  4512. callback(null, result);
  4513. }).catch(function (err) {
  4514. callback(err);
  4515. });
  4516. }
  4517. function replenish() {
  4518. looping = true;
  4519. while (running < parallel && !done && !that.isCancel()) {
  4520. var elem = nextElem();
  4521. if (elem === null || _jobErr.length > 0) {
  4522. done = true;
  4523. if (running <= 0) {
  4524. resolve(_jobErr);
  4525. }
  4526. return;
  4527. }
  4528. running += 1;
  4529. iteratee(elem.value, onlyOnce(iterateeCallback));
  4530. }
  4531. looping = false;
  4532. }
  4533. replenish();
  4534. });
  4535. };
  4536. /**
  4537. * cancel operation, now can use with multipartUpload
  4538. * @param {Object} abort
  4539. * {String} anort.name object key
  4540. * {String} anort.uploadId upload id
  4541. * {String} anort.options timeout
  4542. */
  4543. proto.cancel = function cancel(abort) {
  4544. this.options.cancelFlag = true;
  4545. if (isArray(this.multipartUploadStreams)) {
  4546. this.multipartUploadStreams.forEach(function (_) {
  4547. if (_.destroyed === false) {
  4548. var err = {
  4549. name: 'cancel',
  4550. message: 'cancel'
  4551. };
  4552. _.destroy(err);
  4553. }
  4554. });
  4555. }
  4556. this.multipartUploadStreams = [];
  4557. if (abort) {
  4558. this.abortMultipartUpload(abort.name, abort.uploadId, abort.options);
  4559. }
  4560. };
  4561. proto.isCancel = function isCancel() {
  4562. return this.options.cancelFlag;
  4563. };
  4564. proto.resetCancelFlag = function resetCancelFlag() {
  4565. this.options.cancelFlag = false;
  4566. };
  4567. proto._stop = function _stop() {
  4568. this.options.cancelFlag = true;
  4569. }; // cancel is not error , so create an object
  4570. proto._makeCancelEvent = function _makeCancelEvent() {
  4571. var cancelEvent = {
  4572. status: 0,
  4573. name: 'cancel'
  4574. };
  4575. return cancelEvent;
  4576. }; // abort is not error , so create an object
  4577. proto._makeAbortEvent = function _makeAbortEvent() {
  4578. var abortEvent = {
  4579. status: 0,
  4580. name: 'abort',
  4581. message: 'upload task has been abort'
  4582. };
  4583. return abortEvent;
  4584. };
  4585. },{"./utils/isArray":59,"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"core-js/modules/es.array.for-each":238,"core-js/modules/es.array.iterator":242,"core-js/modules/es.function.name":249,"core-js/modules/es.object.to-string":254,"core-js/modules/es.promise":255,"core-js/modules/es.string.iterator":259,"core-js/modules/web.dom-collections.for-each":292,"core-js/modules/web.dom-collections.iterator":293,"regenerator-runtime/runtime":337}],47:[function(require,module,exports){
  4586. (function (Buffer){
  4587. "use strict";
  4588. require("core-js/modules/es.array.concat");
  4589. require("core-js/modules/es.array.for-each");
  4590. require("core-js/modules/es.array.index-of");
  4591. require("core-js/modules/es.array.join");
  4592. require("core-js/modules/es.array.sort");
  4593. require("core-js/modules/es.object.keys");
  4594. require("core-js/modules/es.object.to-string");
  4595. require("core-js/modules/es.regexp.to-string");
  4596. require("core-js/modules/es.string.trim");
  4597. require("core-js/modules/web.dom-collections.for-each");
  4598. var crypto = require('./../../shims/crypto/crypto.js');
  4599. var is = require('is-type-of');
  4600. var _require = require('./utils/lowercaseKeyHeader'),
  4601. lowercaseKeyHeader = _require.lowercaseKeyHeader;
  4602. /**
  4603. *
  4604. * @param {String} resourcePath
  4605. * @param {Object} parameters
  4606. * @return
  4607. */
  4608. exports.buildCanonicalizedResource = function buildCanonicalizedResource(resourcePath, parameters) {
  4609. var canonicalizedResource = "".concat(resourcePath);
  4610. var separatorString = '?';
  4611. if (is.string(parameters) && parameters.trim() !== '') {
  4612. canonicalizedResource += separatorString + parameters;
  4613. } else if (is.array(parameters)) {
  4614. parameters.sort();
  4615. canonicalizedResource += separatorString + parameters.join('&');
  4616. } else if (parameters) {
  4617. var compareFunc = function compareFunc(entry1, entry2) {
  4618. if (entry1[0] > entry2[0]) {
  4619. return 1;
  4620. } else if (entry1[0] < entry2[0]) {
  4621. return -1;
  4622. }
  4623. return 0;
  4624. };
  4625. var processFunc = function processFunc(key) {
  4626. canonicalizedResource += separatorString + key;
  4627. if (parameters[key]) {
  4628. canonicalizedResource += "=".concat(parameters[key]);
  4629. }
  4630. separatorString = '&';
  4631. };
  4632. Object.keys(parameters).sort(compareFunc).forEach(processFunc);
  4633. }
  4634. return canonicalizedResource;
  4635. };
  4636. /**
  4637. * @param {String} method
  4638. * @param {String} resourcePath
  4639. * @param {Object} request
  4640. * @param {String} expires
  4641. * @return {String} canonicalString
  4642. */
  4643. exports.buildCanonicalString = function canonicalString(method, resourcePath, request, expires) {
  4644. request = request || {};
  4645. var headers = lowercaseKeyHeader(request.headers);
  4646. var OSS_PREFIX = 'x-oss-';
  4647. var ossHeaders = [];
  4648. var headersToSign = {};
  4649. var signContent = [method.toUpperCase(), headers['content-md5'] || '', headers['content-type'], expires || headers['x-oss-date']];
  4650. Object.keys(headers).forEach(function (key) {
  4651. var lowerKey = key.toLowerCase();
  4652. if (lowerKey.indexOf(OSS_PREFIX) === 0) {
  4653. headersToSign[lowerKey] = String(headers[key]).trim();
  4654. }
  4655. });
  4656. Object.keys(headersToSign).sort().forEach(function (key) {
  4657. ossHeaders.push("".concat(key, ":").concat(headersToSign[key]));
  4658. });
  4659. signContent = signContent.concat(ossHeaders);
  4660. signContent.push(this.buildCanonicalizedResource(resourcePath, request.parameters));
  4661. return signContent.join('\n');
  4662. };
  4663. /**
  4664. * @param {String} accessKeySecret
  4665. * @param {String} canonicalString
  4666. */
  4667. exports.computeSignature = function computeSignature(accessKeySecret, canonicalString) {
  4668. var headerEncoding = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'utf-8';
  4669. var signature = crypto.createHmac('sha1', accessKeySecret);
  4670. return signature.update(Buffer.from(canonicalString, headerEncoding)).digest('base64');
  4671. };
  4672. /**
  4673. * @param {String} accessKeyId
  4674. * @param {String} accessKeySecret
  4675. * @param {String} canonicalString
  4676. */
  4677. exports.authorization = function authorization(accessKeyId, accessKeySecret, canonicalString, headerEncoding) {
  4678. return "OSS ".concat(accessKeyId, ":").concat(this.computeSignature(accessKeySecret, canonicalString, headerEncoding));
  4679. };
  4680. /**
  4681. *
  4682. * @param {String} accessKeySecret
  4683. * @param {Object} options
  4684. * @param {String} resource
  4685. * @param {Number} expires
  4686. */
  4687. exports._signatureForURL = function _signatureForURL(accessKeySecret) {
  4688. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  4689. var resource = arguments.length > 2 ? arguments[2] : undefined;
  4690. var expires = arguments.length > 3 ? arguments[3] : undefined;
  4691. var headerEncoding = arguments.length > 4 ? arguments[4] : undefined;
  4692. var headers = {};
  4693. var _options$subResource = options.subResource,
  4694. subResource = _options$subResource === void 0 ? {} : _options$subResource;
  4695. if (options.process) {
  4696. var processKeyword = 'x-oss-process';
  4697. subResource[processKeyword] = options.process;
  4698. }
  4699. if (options.trafficLimit) {
  4700. var trafficLimitKey = 'x-oss-traffic-limit';
  4701. subResource[trafficLimitKey] = options.trafficLimit;
  4702. }
  4703. if (options.response) {
  4704. Object.keys(options.response).forEach(function (k) {
  4705. var key = "response-".concat(k.toLowerCase());
  4706. subResource[key] = options.response[k];
  4707. });
  4708. }
  4709. Object.keys(options).forEach(function (key) {
  4710. var lowerKey = key.toLowerCase();
  4711. var value = options[key];
  4712. if (lowerKey.indexOf('x-oss-') === 0) {
  4713. headers[lowerKey] = value;
  4714. } else if (lowerKey.indexOf('content-md5') === 0) {
  4715. headers[key] = value;
  4716. } else if (lowerKey.indexOf('content-type') === 0) {
  4717. headers[key] = value;
  4718. }
  4719. });
  4720. if (Object.prototype.hasOwnProperty.call(options, 'security-token')) {
  4721. subResource['security-token'] = options['security-token'];
  4722. }
  4723. if (Object.prototype.hasOwnProperty.call(options, 'callback')) {
  4724. var json = {
  4725. callbackUrl: encodeURI(options.callback.url),
  4726. callbackBody: options.callback.body
  4727. };
  4728. if (options.callback.host) {
  4729. json.callbackHost = options.callback.host;
  4730. }
  4731. if (options.callback.contentType) {
  4732. json.callbackBodyType = options.callback.contentType;
  4733. }
  4734. subResource.callback = Buffer.from(JSON.stringify(json)).toString('base64');
  4735. if (options.callback.customValue) {
  4736. var callbackVar = {};
  4737. Object.keys(options.callback.customValue).forEach(function (key) {
  4738. callbackVar["x:".concat(key)] = options.callback.customValue[key];
  4739. });
  4740. subResource['callback-var'] = Buffer.from(JSON.stringify(callbackVar)).toString('base64');
  4741. }
  4742. }
  4743. var canonicalString = this.buildCanonicalString(options.method, resource, {
  4744. headers: headers,
  4745. parameters: subResource
  4746. }, expires.toString());
  4747. return {
  4748. Signature: this.computeSignature(accessKeySecret, canonicalString, headerEncoding),
  4749. subResource: subResource
  4750. };
  4751. };
  4752. }).call(this,require("buffer").Buffer)
  4753. },{"./../../shims/crypto/crypto.js":387,"./utils/lowercaseKeyHeader":65,"buffer":98,"core-js/modules/es.array.concat":234,"core-js/modules/es.array.for-each":238,"core-js/modules/es.array.index-of":241,"core-js/modules/es.array.join":243,"core-js/modules/es.array.sort":247,"core-js/modules/es.object.keys":253,"core-js/modules/es.object.to-string":254,"core-js/modules/es.regexp.to-string":257,"core-js/modules/es.string.trim":265,"core-js/modules/web.dom-collections.for-each":292,"is-type-of":392}],48:[function(require,module,exports){
  4754. "use strict";
  4755. Object.defineProperty(exports, "__esModule", {
  4756. value: true
  4757. });
  4758. exports.checkBucketName = void 0;
  4759. exports.checkBucketName = function (name) {
  4760. var createBucket = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4761. var bucketRegex = createBucket ? /^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$/ : /^[a-z0-9_][a-z0-9-_]{1,61}[a-z0-9_]$/;
  4762. if (!bucketRegex.test(name)) {
  4763. throw new Error('The bucket must be conform to the specifications');
  4764. }
  4765. };
  4766. },{}],49:[function(require,module,exports){
  4767. "use strict";
  4768. Object.defineProperty(exports, "__esModule", {
  4769. value: true
  4770. });
  4771. exports.checkConfigValid = void 0;
  4772. var checkConfigMap = {
  4773. endpoint: checkEndpoint,
  4774. region: /^[a-zA-Z0-9\-_]+$/
  4775. };
  4776. function checkEndpoint(endpoint) {
  4777. if (typeof endpoint === 'string') {
  4778. return /^[a-zA-Z0-9._:/-]+$/.test(endpoint);
  4779. } else if (endpoint.host) {
  4780. return /^[a-zA-Z0-9._:/-]+$/.test(endpoint.host);
  4781. }
  4782. return false;
  4783. }
  4784. exports.checkConfigValid = function (conf, key) {
  4785. if (checkConfigMap[key]) {
  4786. var isConfigValid = true;
  4787. if (checkConfigMap[key] instanceof Function) {
  4788. isConfigValid = checkConfigMap[key](conf);
  4789. } else {
  4790. isConfigValid = checkConfigMap[key].test(conf);
  4791. }
  4792. if (!isConfigValid) {
  4793. throw new Error("The ".concat(key, " must be conform to the specifications"));
  4794. }
  4795. }
  4796. };
  4797. },{}],50:[function(require,module,exports){
  4798. "use strict";
  4799. require("core-js/modules/es.array.concat");
  4800. require("core-js/modules/es.array.for-each");
  4801. require("core-js/modules/es.object.entries");
  4802. require("core-js/modules/web.dom-collections.for-each");
  4803. Object.defineProperty(exports, "__esModule", {
  4804. value: true
  4805. });
  4806. exports.checkObjectTag = void 0;
  4807. var _require = require('./checkValid'),
  4808. checkValid = _require.checkValid;
  4809. var _require2 = require('./isObject'),
  4810. isObject = _require2.isObject;
  4811. var commonRules = [{
  4812. validator: function validator(value) {
  4813. if (typeof value !== 'string') {
  4814. throw new Error('the key and value of the tag must be String');
  4815. }
  4816. }
  4817. }, {
  4818. pattern: /^[a-zA-Z0-9 +-=._:/]+$/,
  4819. msg: 'tag can contain letters, numbers, spaces, and the following symbols: plus sign (+), hyphen (-), equal sign (=), period (.), underscore (_), colon (:), and forward slash (/)'
  4820. }];
  4821. var rules = {
  4822. key: [].concat(commonRules, [{
  4823. pattern: /^.{1,128}$/,
  4824. msg: 'tag key can be a maximum of 128 bytes in length'
  4825. }]),
  4826. value: [].concat(commonRules, [{
  4827. pattern: /^.{0,256}$/,
  4828. msg: 'tag value can be a maximum of 256 bytes in length'
  4829. }])
  4830. };
  4831. function checkObjectTag(tag) {
  4832. if (!isObject(tag)) {
  4833. throw new Error('tag must be Object');
  4834. }
  4835. var entries = Object.entries(tag);
  4836. if (entries.length > 10) {
  4837. throw new Error('maximum of 10 tags for a object');
  4838. }
  4839. var rulesIndexKey = ['key', 'value'];
  4840. entries.forEach(function (keyValue) {
  4841. keyValue.forEach(function (item, index) {
  4842. checkValid(item, rules[rulesIndexKey[index]]);
  4843. });
  4844. });
  4845. }
  4846. exports.checkObjectTag = checkObjectTag;
  4847. },{"./checkValid":51,"./isObject":64,"core-js/modules/es.array.concat":234,"core-js/modules/es.array.for-each":238,"core-js/modules/es.object.entries":252,"core-js/modules/web.dom-collections.for-each":292}],51:[function(require,module,exports){
  4848. "use strict";
  4849. require("core-js/modules/es.array.for-each");
  4850. require("core-js/modules/web.dom-collections.for-each");
  4851. Object.defineProperty(exports, "__esModule", {
  4852. value: true
  4853. });
  4854. exports.checkValid = void 0;
  4855. function checkValid(_value, _rules) {
  4856. _rules.forEach(function (rule) {
  4857. if (rule.validator) {
  4858. rule.validator(_value);
  4859. } else if (rule.pattern && !rule.pattern.test(_value)) {
  4860. throw new Error(rule.msg);
  4861. }
  4862. });
  4863. }
  4864. exports.checkValid = checkValid;
  4865. },{"core-js/modules/es.array.for-each":238,"core-js/modules/web.dom-collections.for-each":292}],52:[function(require,module,exports){
  4866. (function (Buffer){
  4867. "use strict";
  4868. require("core-js/modules/es.array.concat");
  4869. require("core-js/modules/es.array.includes");
  4870. require("core-js/modules/es.array.index-of");
  4871. require("core-js/modules/es.object.assign");
  4872. require("core-js/modules/es.string.includes");
  4873. Object.defineProperty(exports, "__esModule", {
  4874. value: true
  4875. });
  4876. exports.createRequest = void 0;
  4877. var crypto = require('./../../../shims/crypto/crypto.js');
  4878. var debug = require('debug')('ali-oss');
  4879. var mime = require('mime');
  4880. var dateFormat = require('dateformat');
  4881. var copy = require('copy-to');
  4882. var path = require('path');
  4883. var _require = require('./encoder'),
  4884. encoder = _require.encoder;
  4885. var _require2 = require('./isIP'),
  4886. isIP = _require2.isIP;
  4887. var _require3 = require('./setRegion'),
  4888. setRegion = _require3.setRegion;
  4889. var _require4 = require('../client/getReqUrl'),
  4890. getReqUrl = _require4.getReqUrl;
  4891. function getHeader(headers, name) {
  4892. return headers[name] || headers[name.toLowerCase()];
  4893. }
  4894. function delHeader(headers, name) {
  4895. delete headers[name];
  4896. delete headers[name.toLowerCase()];
  4897. }
  4898. function createRequest(params) {
  4899. var date = new Date();
  4900. if (this.options.amendTimeSkewed) {
  4901. date = +new Date() + this.options.amendTimeSkewed;
  4902. }
  4903. var headers = {
  4904. 'x-oss-date': dateFormat(date, 'UTC:ddd, dd mmm yyyy HH:MM:ss \'GMT\''),
  4905. 'x-oss-user-agent': this.userAgent
  4906. };
  4907. if (this.userAgent.includes('nodejs')) {
  4908. headers['User-Agent'] = this.userAgent;
  4909. }
  4910. if (this.options.isRequestPay) {
  4911. Object.assign(headers, {
  4912. 'x-oss-request-payer': 'requester'
  4913. });
  4914. }
  4915. if (this.options.stsToken) {
  4916. headers['x-oss-security-token'] = this.options.stsToken;
  4917. }
  4918. copy(params.headers).to(headers);
  4919. if (!getHeader(headers, 'Content-Type')) {
  4920. if (params.mime && params.mime.indexOf('/') > 0) {
  4921. headers['Content-Type'] = params.mime;
  4922. } else {
  4923. headers['Content-Type'] = mime.getType(params.mime || path.extname(params.object || ''));
  4924. }
  4925. }
  4926. if (!getHeader(headers, 'Content-Type')) {
  4927. delHeader(headers, 'Content-Type');
  4928. }
  4929. if (params.content) {
  4930. headers['Content-MD5'] = crypto.createHash('md5').update(Buffer.from(params.content, 'utf8')).digest('base64');
  4931. if (!headers['Content-Length']) {
  4932. headers['Content-Length'] = params.content.length;
  4933. }
  4934. }
  4935. var hasOwnProperty = Object.prototype.hasOwnProperty;
  4936. for (var k in headers) {
  4937. if (headers[k] && hasOwnProperty.call(headers, k)) {
  4938. headers[k] = encoder(String(headers[k]), this.options.headerEncoding);
  4939. }
  4940. }
  4941. var authResource = this._getResource(params);
  4942. headers.authorization = this.authorization(params.method, authResource, params.subres, headers, this.options.headerEncoding); // const url = this._getReqUrl(params);
  4943. if (isIP(this.options.endpoint.hostname)) {
  4944. var _this$options = this.options,
  4945. region = _this$options.region,
  4946. internal = _this$options.internal,
  4947. secure = _this$options.secure;
  4948. var hostInfo = setRegion(region, internal, secure);
  4949. headers.host = "".concat(params.bucket, ".").concat(hostInfo.host);
  4950. }
  4951. var url = getReqUrl.bind(this)(params);
  4952. debug('request %s %s, with headers %j, !!stream: %s', params.method, url, headers, !!params.stream);
  4953. var timeout = params.timeout || this.options.timeout;
  4954. var reqParams = {
  4955. method: params.method,
  4956. content: params.content,
  4957. stream: params.stream,
  4958. headers: headers,
  4959. timeout: timeout,
  4960. writeStream: params.writeStream,
  4961. customResponse: params.customResponse,
  4962. ctx: params.ctx || this.ctx
  4963. };
  4964. if (this.agent) {
  4965. reqParams.agent = this.agent;
  4966. }
  4967. if (this.httpsAgent) {
  4968. reqParams.httpsAgent = this.httpsAgent;
  4969. }
  4970. reqParams.enableProxy = !!this.options.enableProxy;
  4971. reqParams.proxy = this.options.proxy ? this.options.proxy : null;
  4972. return {
  4973. url: url,
  4974. params: reqParams
  4975. };
  4976. }
  4977. exports.createRequest = createRequest;
  4978. }).call(this,require("buffer").Buffer)
  4979. },{"../client/getReqUrl":24,"./../../../shims/crypto/crypto.js":387,"./encoder":55,"./isIP":63,"./setRegion":68,"buffer":98,"copy-to":101,"core-js/modules/es.array.concat":234,"core-js/modules/es.array.includes":240,"core-js/modules/es.array.index-of":241,"core-js/modules/es.object.assign":251,"core-js/modules/es.string.includes":258,"dateformat":295,"debug":391,"mime":313,"path":316}],53:[function(require,module,exports){
  4980. "use strict";
  4981. require("core-js/modules/es.array.for-each");
  4982. require("core-js/modules/es.array.includes");
  4983. require("core-js/modules/es.object.entries");
  4984. require("core-js/modules/es.object.keys");
  4985. require("core-js/modules/es.regexp.exec");
  4986. require("core-js/modules/es.string.replace");
  4987. require("core-js/modules/web.dom-collections.for-each");
  4988. Object.defineProperty(exports, "__esModule", {
  4989. value: true
  4990. });
  4991. exports.dataFix = void 0;
  4992. var isObject_1 = require("./isObject");
  4993. var TRUE = ['true', 'TRUE', '1', 1];
  4994. var FALSE = ['false', 'FALSE', '0', 0];
  4995. function dataFix(o, conf, finalKill) {
  4996. if (!isObject_1.isObject(o)) return;
  4997. var _conf$remove = conf.remove,
  4998. remove = _conf$remove === void 0 ? [] : _conf$remove,
  4999. _conf$rename = conf.rename,
  5000. rename = _conf$rename === void 0 ? {} : _conf$rename,
  5001. _conf$camel = conf.camel,
  5002. camel = _conf$camel === void 0 ? [] : _conf$camel,
  5003. _conf$bool = conf.bool,
  5004. bool = _conf$bool === void 0 ? [] : _conf$bool,
  5005. _conf$lowerFirst = conf.lowerFirst,
  5006. lowerFirst = _conf$lowerFirst === void 0 ? false : _conf$lowerFirst; // 删除不需要的数据
  5007. remove.forEach(function (v) {
  5008. return delete o[v];
  5009. }); // 重命名
  5010. Object.entries(rename).forEach(function (v) {
  5011. if (!o[v[0]]) return;
  5012. if (o[v[1]]) return;
  5013. o[v[1]] = o[v[0]];
  5014. delete o[v[0]];
  5015. }); // 驼峰化
  5016. camel.forEach(function (v) {
  5017. if (!o[v]) return;
  5018. var afterKey = v.replace(/^(.)/, function ($0) {
  5019. return $0.toLowerCase();
  5020. }).replace(/-(\w)/g, function (_, $1) {
  5021. return $1.toUpperCase();
  5022. });
  5023. if (o[afterKey]) return;
  5024. o[afterKey] = o[v]; // todo 暂时兼容以前数据,不做删除
  5025. // delete o[v];
  5026. }); // 转换值为布尔值
  5027. bool.forEach(function (v) {
  5028. o[v] = fixBool(o[v]);
  5029. }); // finalKill
  5030. if (typeof finalKill === 'function') {
  5031. finalKill(o);
  5032. } // 首字母转小写
  5033. fixLowerFirst(o, lowerFirst);
  5034. return dataFix;
  5035. }
  5036. exports.dataFix = dataFix;
  5037. function fixBool(value) {
  5038. if (!value) return false;
  5039. if (TRUE.includes(value)) return true;
  5040. return FALSE.includes(value) ? false : value;
  5041. }
  5042. function fixLowerFirst(o, lowerFirst) {
  5043. if (lowerFirst) {
  5044. Object.keys(o).forEach(function (key) {
  5045. var lowerK = key.replace(/^\w/, function (match) {
  5046. return match.toLowerCase();
  5047. });
  5048. if (typeof o[lowerK] === 'undefined') {
  5049. o[lowerK] = o[key];
  5050. delete o[key];
  5051. }
  5052. });
  5053. }
  5054. }
  5055. },{"./isObject":64,"core-js/modules/es.array.for-each":238,"core-js/modules/es.array.includes":240,"core-js/modules/es.object.entries":252,"core-js/modules/es.object.keys":253,"core-js/modules/es.regexp.exec":256,"core-js/modules/es.string.replace":261,"core-js/modules/web.dom-collections.for-each":292}],54:[function(require,module,exports){
  5056. "use strict";
  5057. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  5058. require("core-js/modules/es.array.for-each");
  5059. require("core-js/modules/es.array.slice");
  5060. require("core-js/modules/es.object.keys");
  5061. require("core-js/modules/web.dom-collections.for-each");
  5062. var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
  5063. Object.defineProperty(exports, "__esModule", {
  5064. value: true
  5065. });
  5066. exports.deepCopyWith = exports.deepCopy = void 0;
  5067. var isBuffer_1 = require("./isBuffer");
  5068. exports.deepCopy = function (obj) {
  5069. if (obj === null || (0, _typeof2.default)(obj) !== 'object') {
  5070. return obj;
  5071. }
  5072. if (isBuffer_1.isBuffer(obj)) {
  5073. return obj.slice();
  5074. }
  5075. var copy = Array.isArray(obj) ? [] : {};
  5076. Object.keys(obj).forEach(function (key) {
  5077. copy[key] = exports.deepCopy(obj[key]);
  5078. });
  5079. return copy;
  5080. };
  5081. exports.deepCopyWith = function (obj, customizer) {
  5082. function deepCopyWithHelper(value, innerKey, innerObject) {
  5083. var result = customizer(value, innerKey, innerObject);
  5084. if (result !== undefined) return result;
  5085. if (value === null || (0, _typeof2.default)(value) !== 'object') {
  5086. return value;
  5087. }
  5088. if (isBuffer_1.isBuffer(value)) {
  5089. return value.slice();
  5090. }
  5091. var copy = Array.isArray(value) ? [] : {};
  5092. Object.keys(value).forEach(function (k) {
  5093. copy[k] = deepCopyWithHelper(value[k], k, value);
  5094. });
  5095. return copy;
  5096. }
  5097. if (customizer) {
  5098. return deepCopyWithHelper(obj, '', null);
  5099. } else {
  5100. return exports.deepCopy(obj);
  5101. }
  5102. };
  5103. },{"./isBuffer":61,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/helpers/typeof":72,"core-js/modules/es.array.for-each":238,"core-js/modules/es.array.slice":246,"core-js/modules/es.object.keys":253,"core-js/modules/web.dom-collections.for-each":292}],55:[function(require,module,exports){
  5104. (function (Buffer){
  5105. "use strict";
  5106. require("core-js/modules/es.object.to-string");
  5107. require("core-js/modules/es.regexp.to-string");
  5108. Object.defineProperty(exports, "__esModule", {
  5109. value: true
  5110. });
  5111. exports.encoder = void 0;
  5112. function encoder(str) {
  5113. var encoding = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'utf-8';
  5114. if (encoding === 'utf-8') return str;
  5115. return Buffer.from(str).toString('latin1');
  5116. }
  5117. exports.encoder = encoder;
  5118. }).call(this,require("buffer").Buffer)
  5119. },{"buffer":98,"core-js/modules/es.object.to-string":254,"core-js/modules/es.regexp.to-string":257}],56:[function(require,module,exports){
  5120. "use strict";
  5121. require("core-js/modules/es.array.map");
  5122. require("core-js/modules/es.regexp.exec");
  5123. require("core-js/modules/es.string.replace");
  5124. Object.defineProperty(exports, "__esModule", {
  5125. value: true
  5126. });
  5127. exports.formatInventoryConfig = void 0;
  5128. var dataFix_1 = require("../utils/dataFix");
  5129. var isObject_1 = require("../utils/isObject");
  5130. var isArray_1 = require("../utils/isArray");
  5131. var formatObjKey_1 = require("../utils/formatObjKey");
  5132. function formatInventoryConfig(inventoryConfig) {
  5133. var toArray = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  5134. if (toArray && isObject_1.isObject(inventoryConfig)) inventoryConfig = [inventoryConfig];
  5135. if (isArray_1.isArray(inventoryConfig)) {
  5136. inventoryConfig = inventoryConfig.map(formatFn);
  5137. } else {
  5138. inventoryConfig = formatFn(inventoryConfig);
  5139. }
  5140. return inventoryConfig;
  5141. }
  5142. exports.formatInventoryConfig = formatInventoryConfig;
  5143. function formatFn(_) {
  5144. dataFix_1.dataFix(_, {
  5145. bool: ['IsEnabled']
  5146. }, function (conf) {
  5147. var _a, _b; // prefix
  5148. conf.prefix = conf.Filter.Prefix;
  5149. delete conf.Filter; // OSSBucketDestination
  5150. conf.OSSBucketDestination = conf.Destination.OSSBucketDestination; // OSSBucketDestination.rolename
  5151. conf.OSSBucketDestination.rolename = conf.OSSBucketDestination.RoleArn.replace(/.*\//, '');
  5152. delete conf.OSSBucketDestination.RoleArn; // OSSBucketDestination.bucket
  5153. conf.OSSBucketDestination.bucket = conf.OSSBucketDestination.Bucket.replace(/.*:::/, '');
  5154. delete conf.OSSBucketDestination.Bucket;
  5155. delete conf.Destination; // frequency
  5156. conf.frequency = conf.Schedule.Frequency;
  5157. delete conf.Schedule.Frequency; // optionalFields
  5158. if (((_a = conf === null || conf === void 0 ? void 0 : conf.OptionalFields) === null || _a === void 0 ? void 0 : _a.Field) && !isArray_1.isArray((_b = conf.OptionalFields) === null || _b === void 0 ? void 0 : _b.Field)) conf.OptionalFields.Field = [conf.OptionalFields.Field];
  5159. }); // firstLowerCase
  5160. _ = formatObjKey_1.formatObjKey(_, 'firstLowerCase', {
  5161. exclude: ['OSSBucketDestination', 'SSE-OSS', 'SSE-KMS']
  5162. });
  5163. return _;
  5164. }
  5165. },{"../utils/dataFix":53,"../utils/formatObjKey":57,"../utils/isArray":59,"../utils/isObject":64,"core-js/modules/es.array.map":245,"core-js/modules/es.regexp.exec":256,"core-js/modules/es.string.replace":261}],57:[function(require,module,exports){
  5166. "use strict";
  5167. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  5168. require("core-js/modules/es.array.for-each");
  5169. require("core-js/modules/es.array.includes");
  5170. require("core-js/modules/es.object.keys");
  5171. require("core-js/modules/es.regexp.exec");
  5172. require("core-js/modules/es.string.includes");
  5173. require("core-js/modules/es.string.replace");
  5174. require("core-js/modules/web.dom-collections.for-each");
  5175. var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
  5176. Object.defineProperty(exports, "__esModule", {
  5177. value: true
  5178. });
  5179. exports.formatObjKey = void 0;
  5180. function formatObjKey(obj, type, options) {
  5181. if (obj === null || (0, _typeof2.default)(obj) !== 'object') {
  5182. return obj;
  5183. }
  5184. var o;
  5185. if (Array.isArray(obj)) {
  5186. o = [];
  5187. for (var i = 0; i < obj.length; i++) {
  5188. o.push(formatObjKey(obj[i], type, options));
  5189. }
  5190. } else {
  5191. o = {};
  5192. Object.keys(obj).forEach(function (key) {
  5193. o[handelFormat(key, type, options)] = formatObjKey(obj[key], type, options);
  5194. });
  5195. }
  5196. return o;
  5197. }
  5198. exports.formatObjKey = formatObjKey;
  5199. function handelFormat(key, type, options) {
  5200. var _a;
  5201. if (options && ((_a = options.exclude) === null || _a === void 0 ? void 0 : _a.includes(key))) return key;
  5202. if (type === 'firstUpperCase') {
  5203. key = key.replace(/^./, function (_) {
  5204. return _.toUpperCase();
  5205. });
  5206. } else if (type === 'firstLowerCase') {
  5207. key = key.replace(/^./, function (_) {
  5208. return _.toLowerCase();
  5209. });
  5210. }
  5211. return key;
  5212. }
  5213. },{"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/helpers/typeof":72,"core-js/modules/es.array.for-each":238,"core-js/modules/es.array.includes":240,"core-js/modules/es.object.keys":253,"core-js/modules/es.regexp.exec":256,"core-js/modules/es.string.includes":258,"core-js/modules/es.string.replace":261,"core-js/modules/web.dom-collections.for-each":292}],58:[function(require,module,exports){
  5214. "use strict";
  5215. Object.defineProperty(exports, "__esModule", {
  5216. value: true
  5217. });
  5218. exports.getStrBytesCount = void 0;
  5219. function getStrBytesCount(str) {
  5220. var bytesCount = 0;
  5221. for (var i = 0; i < str.length; i++) {
  5222. var c = str.charAt(i);
  5223. if (/^[\u00-\uff]$/.test(c)) {
  5224. bytesCount += 1;
  5225. } else {
  5226. bytesCount += 2;
  5227. }
  5228. }
  5229. return bytesCount;
  5230. }
  5231. exports.getStrBytesCount = getStrBytesCount;
  5232. },{}],59:[function(require,module,exports){
  5233. "use strict";
  5234. require("core-js/modules/es.object.to-string");
  5235. require("core-js/modules/es.regexp.to-string");
  5236. Object.defineProperty(exports, "__esModule", {
  5237. value: true
  5238. });
  5239. exports.isArray = void 0;
  5240. exports.isArray = function (obj) {
  5241. return Object.prototype.toString.call(obj) === '[object Array]';
  5242. };
  5243. },{"core-js/modules/es.object.to-string":254,"core-js/modules/es.regexp.to-string":257}],60:[function(require,module,exports){
  5244. "use strict";
  5245. Object.defineProperty(exports, "__esModule", {
  5246. value: true
  5247. });
  5248. exports.isBlob = void 0;
  5249. function isBlob(blob) {
  5250. return typeof Blob !== 'undefined' && blob instanceof Blob;
  5251. }
  5252. exports.isBlob = isBlob;
  5253. },{}],61:[function(require,module,exports){
  5254. (function (Buffer){
  5255. "use strict";
  5256. Object.defineProperty(exports, "__esModule", {
  5257. value: true
  5258. });
  5259. exports.isBuffer = void 0;
  5260. function isBuffer(obj) {
  5261. return Buffer.isBuffer(obj);
  5262. }
  5263. exports.isBuffer = isBuffer;
  5264. }).call(this,{"isBuffer":require("../../../node_modules/is-buffer/index.js")})
  5265. },{"../../../node_modules/is-buffer/index.js":308}],62:[function(require,module,exports){
  5266. "use strict";
  5267. Object.defineProperty(exports, "__esModule", {
  5268. value: true
  5269. });
  5270. exports.isFile = void 0;
  5271. exports.isFile = function (obj) {
  5272. return typeof File !== 'undefined' && obj instanceof File;
  5273. };
  5274. },{}],63:[function(require,module,exports){
  5275. "use strict";
  5276. Object.defineProperty(exports, "__esModule", {
  5277. value: true
  5278. });
  5279. exports.isIP = void 0; // it provide commont methods for node and browser , we will add more solutions later in this file
  5280. /**
  5281. * Judge isIP include ipv4 or ipv6
  5282. * @param {String} options
  5283. * @return {Array} the multipart uploads
  5284. */
  5285. exports.isIP = function (host) {
  5286. var ipv4Regex = /^(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}$/;
  5287. var ipv6Regex = /^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/;
  5288. return ipv4Regex.test(host) || ipv6Regex.test(host);
  5289. };
  5290. },{}],64:[function(require,module,exports){
  5291. "use strict";
  5292. require("core-js/modules/es.object.to-string");
  5293. require("core-js/modules/es.regexp.to-string");
  5294. Object.defineProperty(exports, "__esModule", {
  5295. value: true
  5296. });
  5297. exports.isObject = void 0;
  5298. exports.isObject = function (obj) {
  5299. return Object.prototype.toString.call(obj) === '[object Object]';
  5300. };
  5301. },{"core-js/modules/es.object.to-string":254,"core-js/modules/es.regexp.to-string":257}],65:[function(require,module,exports){
  5302. "use strict";
  5303. require("core-js/modules/es.array.for-each");
  5304. require("core-js/modules/es.object.keys");
  5305. require("core-js/modules/web.dom-collections.for-each");
  5306. Object.defineProperty(exports, "__esModule", {
  5307. value: true
  5308. });
  5309. exports.lowercaseKeyHeader = void 0;
  5310. var isObject_1 = require("./isObject");
  5311. function lowercaseKeyHeader(headers) {
  5312. var lowercaseHeader = {};
  5313. if (isObject_1.isObject(headers)) {
  5314. Object.keys(headers).forEach(function (key) {
  5315. lowercaseHeader[key.toLowerCase()] = headers[key];
  5316. });
  5317. }
  5318. return lowercaseHeader;
  5319. }
  5320. exports.lowercaseKeyHeader = lowercaseKeyHeader;
  5321. },{"./isObject":64,"core-js/modules/es.array.for-each":238,"core-js/modules/es.object.keys":253,"core-js/modules/web.dom-collections.for-each":292}],66:[function(require,module,exports){
  5322. "use strict";
  5323. require("core-js/modules/es.array.concat");
  5324. require("core-js/modules/es.array.for-each");
  5325. require("core-js/modules/es.array.join");
  5326. require("core-js/modules/es.array.map");
  5327. require("core-js/modules/es.object.keys");
  5328. require("core-js/modules/es.object.to-string");
  5329. require("core-js/modules/es.regexp.exec");
  5330. require("core-js/modules/es.regexp.to-string");
  5331. require("core-js/modules/es.string.replace");
  5332. require("core-js/modules/web.dom-collections.for-each");
  5333. Object.defineProperty(exports, "__esModule", {
  5334. value: true
  5335. });
  5336. exports.obj2xml = void 0;
  5337. var formatObjKey_1 = require("./formatObjKey");
  5338. function type(params) {
  5339. return Object.prototype.toString.call(params).replace(/(.*? |])/g, '').toLowerCase();
  5340. }
  5341. function obj2xml(obj, options) {
  5342. var s = '';
  5343. if (options && options.headers) {
  5344. s = '<?xml version="1.0" encoding="UTF-8"?>\n';
  5345. }
  5346. if (options && options.firstUpperCase) {
  5347. obj = formatObjKey_1.formatObjKey(obj, 'firstUpperCase');
  5348. }
  5349. if (type(obj) === 'object') {
  5350. Object.keys(obj).forEach(function (key) {
  5351. // filter undefined or null
  5352. if (type(obj[key]) !== 'undefined' && type(obj[key]) !== 'null') {
  5353. if (type(obj[key]) === 'string' || type(obj[key]) === 'number') {
  5354. s += "<".concat(key, ">").concat(obj[key], "</").concat(key, ">");
  5355. } else if (type(obj[key]) === 'object') {
  5356. s += "<".concat(key, ">").concat(obj2xml(obj[key]), "</").concat(key, ">");
  5357. } else if (type(obj[key]) === 'array') {
  5358. s += obj[key].map(function (keyChild) {
  5359. return "<".concat(key, ">").concat(obj2xml(keyChild), "</").concat(key, ">");
  5360. }).join('');
  5361. } else {
  5362. s += "<".concat(key, ">").concat(obj[key].toString(), "</").concat(key, ">");
  5363. }
  5364. }
  5365. });
  5366. } else {
  5367. s += obj.toString();
  5368. }
  5369. return s;
  5370. }
  5371. exports.obj2xml = obj2xml;
  5372. },{"./formatObjKey":57,"core-js/modules/es.array.concat":234,"core-js/modules/es.array.for-each":238,"core-js/modules/es.array.join":243,"core-js/modules/es.array.map":245,"core-js/modules/es.object.keys":253,"core-js/modules/es.object.to-string":254,"core-js/modules/es.regexp.exec":256,"core-js/modules/es.regexp.to-string":257,"core-js/modules/es.string.replace":261,"core-js/modules/web.dom-collections.for-each":292}],67:[function(require,module,exports){
  5373. "use strict";
  5374. require("core-js/modules/es.object.to-string");
  5375. require("core-js/modules/es.promise");
  5376. Object.defineProperty(exports, "__esModule", {
  5377. value: true
  5378. });
  5379. exports.retry = void 0;
  5380. function retry(func, retryMax) {
  5381. var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  5382. var retryNum = 0;
  5383. var _config$retryDelay = config.retryDelay,
  5384. retryDelay = _config$retryDelay === void 0 ? 500 : _config$retryDelay,
  5385. _config$errorHandler = config.errorHandler,
  5386. errorHandler = _config$errorHandler === void 0 ? function () {
  5387. return true;
  5388. } : _config$errorHandler;
  5389. var funcR = function funcR() {
  5390. for (var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++) {
  5391. arg[_key] = arguments[_key];
  5392. }
  5393. return new Promise(function (resolve, reject) {
  5394. func.apply(void 0, arg).then(function (result) {
  5395. retryNum = 0;
  5396. resolve(result);
  5397. }).catch(function (err) {
  5398. if (retryNum < retryMax && errorHandler(err)) {
  5399. retryNum++;
  5400. setTimeout(function () {
  5401. resolve(funcR.apply(void 0, arg));
  5402. }, retryDelay);
  5403. } else {
  5404. retryNum = 0;
  5405. reject(err);
  5406. }
  5407. });
  5408. });
  5409. };
  5410. return funcR;
  5411. }
  5412. exports.retry = retry;
  5413. },{"core-js/modules/es.object.to-string":254,"core-js/modules/es.promise":255}],68:[function(require,module,exports){
  5414. "use strict";
  5415. var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
  5416. return mod && mod.__esModule ? mod : {
  5417. "default": mod
  5418. };
  5419. };
  5420. Object.defineProperty(exports, "__esModule", {
  5421. value: true
  5422. });
  5423. exports.setRegion = void 0;
  5424. var url_1 = __importDefault(require("url"));
  5425. var checkConfigValid_1 = require("./checkConfigValid");
  5426. function setRegion(region) {
  5427. var internal = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  5428. var secure = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  5429. checkConfigValid_1.checkConfigValid(region, 'region');
  5430. var protocol = secure ? 'https://' : 'http://';
  5431. var suffix = internal ? '-internal.aliyuncs.com' : '.aliyuncs.com';
  5432. var prefix = 'vpc100-oss-cn-'; // aliyun VPC region: https://help.aliyun.com/knowledge_detail/38740.html
  5433. if (region.substr(0, prefix.length) === prefix) {
  5434. suffix = '.aliyuncs.com';
  5435. }
  5436. return url_1.default.parse(protocol + region + suffix);
  5437. }
  5438. exports.setRegion = setRegion;
  5439. },{"./checkConfigValid":49,"url":394}],69:[function(require,module,exports){
  5440. "use strict";
  5441. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  5442. require("core-js/modules/es.array.find");
  5443. require("core-js/modules/es.array.for-each");
  5444. require("core-js/modules/es.object.assign");
  5445. require("core-js/modules/es.object.keys");
  5446. var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
  5447. require("regenerator-runtime/runtime");
  5448. var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
  5449. Object.defineProperty(exports, "__esModule", {
  5450. value: true
  5451. });
  5452. exports.setSTSToken = void 0;
  5453. var formatObjKey_1 = require("./formatObjKey");
  5454. function setSTSToken() {
  5455. return _setSTSToken.apply(this, arguments);
  5456. }
  5457. function _setSTSToken() {
  5458. _setSTSToken = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
  5459. var credentials;
  5460. return _regenerator.default.wrap(function _callee$(_context) {
  5461. while (1) {
  5462. switch (_context.prev = _context.next) {
  5463. case 0:
  5464. if (!this.options) this.options = {};
  5465. _context.next = 3;
  5466. return this.options.refreshSTSToken();
  5467. case 3:
  5468. credentials = _context.sent;
  5469. credentials = formatObjKey_1.formatObjKey(credentials, 'firstLowerCase');
  5470. if (credentials.securityToken) {
  5471. credentials.stsToken = credentials.securityToken;
  5472. }
  5473. checkCredentials(credentials);
  5474. Object.assign(this.options, credentials);
  5475. case 8:
  5476. case "end":
  5477. return _context.stop();
  5478. }
  5479. }
  5480. }, _callee, this);
  5481. }));
  5482. return _setSTSToken.apply(this, arguments);
  5483. }
  5484. exports.setSTSToken = setSTSToken;
  5485. function checkCredentials(obj) {
  5486. var stsTokenKey = ['accessKeySecret', 'accessKeyId', 'stsToken'];
  5487. var objKeys = Object.keys(obj);
  5488. stsTokenKey.forEach(function (_) {
  5489. if (!objKeys.find(function (key) {
  5490. return key === _;
  5491. })) {
  5492. throw Error("refreshSTSToken must return contains ".concat(_));
  5493. }
  5494. });
  5495. }
  5496. },{"./formatObjKey":57,"@babel/runtime/helpers/asyncToGenerator":70,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/regenerator":74,"core-js/modules/es.array.find":237,"core-js/modules/es.array.for-each":238,"core-js/modules/es.object.assign":251,"core-js/modules/es.object.keys":253,"regenerator-runtime/runtime":337}],70:[function(require,module,exports){
  5497. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  5498. try {
  5499. var info = gen[key](arg);
  5500. var value = info.value;
  5501. } catch (error) {
  5502. reject(error);
  5503. return;
  5504. }
  5505. if (info.done) {
  5506. resolve(value);
  5507. } else {
  5508. Promise.resolve(value).then(_next, _throw);
  5509. }
  5510. }
  5511. function _asyncToGenerator(fn) {
  5512. return function () {
  5513. var self = this,
  5514. args = arguments;
  5515. return new Promise(function (resolve, reject) {
  5516. var gen = fn.apply(self, args);
  5517. function _next(value) {
  5518. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  5519. }
  5520. function _throw(err) {
  5521. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  5522. }
  5523. _next(undefined);
  5524. });
  5525. };
  5526. }
  5527. module.exports = _asyncToGenerator;
  5528. },{}],71:[function(require,module,exports){
  5529. function _interopRequireDefault(obj) {
  5530. return obj && obj.__esModule ? obj : {
  5531. "default": obj
  5532. };
  5533. }
  5534. module.exports = _interopRequireDefault;
  5535. },{}],72:[function(require,module,exports){
  5536. function _typeof(obj) {
  5537. "@babel/helpers - typeof";
  5538. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  5539. module.exports = _typeof = function _typeof(obj) {
  5540. return typeof obj;
  5541. };
  5542. } else {
  5543. module.exports = _typeof = function _typeof(obj) {
  5544. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  5545. };
  5546. }
  5547. return _typeof(obj);
  5548. }
  5549. module.exports = _typeof;
  5550. },{}],73:[function(require,module,exports){
  5551. /**
  5552. * Copyright (c) 2014-present, Facebook, Inc.
  5553. *
  5554. * This source code is licensed under the MIT license found in the
  5555. * LICENSE file in the root directory of this source tree.
  5556. */
  5557. var runtime = (function (exports) {
  5558. "use strict";
  5559. var Op = Object.prototype;
  5560. var hasOwn = Op.hasOwnProperty;
  5561. var undefined; // More compressible than void 0.
  5562. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  5563. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  5564. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  5565. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  5566. function define(obj, key, value) {
  5567. Object.defineProperty(obj, key, {
  5568. value: value,
  5569. enumerable: true,
  5570. configurable: true,
  5571. writable: true
  5572. });
  5573. return obj[key];
  5574. }
  5575. try {
  5576. // IE 8 has a broken Object.defineProperty that only works on DOM objects.
  5577. define({}, "");
  5578. } catch (err) {
  5579. define = function(obj, key, value) {
  5580. return obj[key] = value;
  5581. };
  5582. }
  5583. function wrap(innerFn, outerFn, self, tryLocsList) {
  5584. // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
  5585. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  5586. var generator = Object.create(protoGenerator.prototype);
  5587. var context = new Context(tryLocsList || []);
  5588. // The ._invoke method unifies the implementations of the .next,
  5589. // .throw, and .return methods.
  5590. generator._invoke = makeInvokeMethod(innerFn, self, context);
  5591. return generator;
  5592. }
  5593. exports.wrap = wrap;
  5594. // Try/catch helper to minimize deoptimizations. Returns a completion
  5595. // record like context.tryEntries[i].completion. This interface could
  5596. // have been (and was previously) designed to take a closure to be
  5597. // invoked without arguments, but in all the cases we care about we
  5598. // already have an existing method we want to call, so there's no need
  5599. // to create a new function object. We can even get away with assuming
  5600. // the method takes exactly one argument, since that happens to be true
  5601. // in every case, so we don't have to touch the arguments object. The
  5602. // only additional allocation required is the completion record, which
  5603. // has a stable shape and so hopefully should be cheap to allocate.
  5604. function tryCatch(fn, obj, arg) {
  5605. try {
  5606. return { type: "normal", arg: fn.call(obj, arg) };
  5607. } catch (err) {
  5608. return { type: "throw", arg: err };
  5609. }
  5610. }
  5611. var GenStateSuspendedStart = "suspendedStart";
  5612. var GenStateSuspendedYield = "suspendedYield";
  5613. var GenStateExecuting = "executing";
  5614. var GenStateCompleted = "completed";
  5615. // Returning this object from the innerFn has the same effect as
  5616. // breaking out of the dispatch switch statement.
  5617. var ContinueSentinel = {};
  5618. // Dummy constructor functions that we use as the .constructor and
  5619. // .constructor.prototype properties for functions that return Generator
  5620. // objects. For full spec compliance, you may wish to configure your
  5621. // minifier not to mangle the names of these two functions.
  5622. function Generator() {}
  5623. function GeneratorFunction() {}
  5624. function GeneratorFunctionPrototype() {}
  5625. // This is a polyfill for %IteratorPrototype% for environments that
  5626. // don't natively support it.
  5627. var IteratorPrototype = {};
  5628. IteratorPrototype[iteratorSymbol] = function () {
  5629. return this;
  5630. };
  5631. var getProto = Object.getPrototypeOf;
  5632. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  5633. if (NativeIteratorPrototype &&
  5634. NativeIteratorPrototype !== Op &&
  5635. hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  5636. // This environment has a native %IteratorPrototype%; use it instead
  5637. // of the polyfill.
  5638. IteratorPrototype = NativeIteratorPrototype;
  5639. }
  5640. var Gp = GeneratorFunctionPrototype.prototype =
  5641. Generator.prototype = Object.create(IteratorPrototype);
  5642. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  5643. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  5644. GeneratorFunction.displayName = define(
  5645. GeneratorFunctionPrototype,
  5646. toStringTagSymbol,
  5647. "GeneratorFunction"
  5648. );
  5649. // Helper for defining the .next, .throw, and .return methods of the
  5650. // Iterator interface in terms of a single ._invoke method.
  5651. function defineIteratorMethods(prototype) {
  5652. ["next", "throw", "return"].forEach(function(method) {
  5653. define(prototype, method, function(arg) {
  5654. return this._invoke(method, arg);
  5655. });
  5656. });
  5657. }
  5658. exports.isGeneratorFunction = function(genFun) {
  5659. var ctor = typeof genFun === "function" && genFun.constructor;
  5660. return ctor
  5661. ? ctor === GeneratorFunction ||
  5662. // For the native GeneratorFunction constructor, the best we can
  5663. // do is to check its .name property.
  5664. (ctor.displayName || ctor.name) === "GeneratorFunction"
  5665. : false;
  5666. };
  5667. exports.mark = function(genFun) {
  5668. if (Object.setPrototypeOf) {
  5669. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  5670. } else {
  5671. genFun.__proto__ = GeneratorFunctionPrototype;
  5672. define(genFun, toStringTagSymbol, "GeneratorFunction");
  5673. }
  5674. genFun.prototype = Object.create(Gp);
  5675. return genFun;
  5676. };
  5677. // Within the body of any async function, `await x` is transformed to
  5678. // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
  5679. // `hasOwn.call(value, "__await")` to determine if the yielded value is
  5680. // meant to be awaited.
  5681. exports.awrap = function(arg) {
  5682. return { __await: arg };
  5683. };
  5684. function AsyncIterator(generator, PromiseImpl) {
  5685. function invoke(method, arg, resolve, reject) {
  5686. var record = tryCatch(generator[method], generator, arg);
  5687. if (record.type === "throw") {
  5688. reject(record.arg);
  5689. } else {
  5690. var result = record.arg;
  5691. var value = result.value;
  5692. if (value &&
  5693. typeof value === "object" &&
  5694. hasOwn.call(value, "__await")) {
  5695. return PromiseImpl.resolve(value.__await).then(function(value) {
  5696. invoke("next", value, resolve, reject);
  5697. }, function(err) {
  5698. invoke("throw", err, resolve, reject);
  5699. });
  5700. }
  5701. return PromiseImpl.resolve(value).then(function(unwrapped) {
  5702. // When a yielded Promise is resolved, its final value becomes
  5703. // the .value of the Promise<{value,done}> result for the
  5704. // current iteration.
  5705. result.value = unwrapped;
  5706. resolve(result);
  5707. }, function(error) {
  5708. // If a rejected Promise was yielded, throw the rejection back
  5709. // into the async generator function so it can be handled there.
  5710. return invoke("throw", error, resolve, reject);
  5711. });
  5712. }
  5713. }
  5714. var previousPromise;
  5715. function enqueue(method, arg) {
  5716. function callInvokeWithMethodAndArg() {
  5717. return new PromiseImpl(function(resolve, reject) {
  5718. invoke(method, arg, resolve, reject);
  5719. });
  5720. }
  5721. return previousPromise =
  5722. // If enqueue has been called before, then we want to wait until
  5723. // all previous Promises have been resolved before calling invoke,
  5724. // so that results are always delivered in the correct order. If
  5725. // enqueue has not been called before, then it is important to
  5726. // call invoke immediately, without waiting on a callback to fire,
  5727. // so that the async generator function has the opportunity to do
  5728. // any necessary setup in a predictable way. This predictability
  5729. // is why the Promise constructor synchronously invokes its
  5730. // executor callback, and why async functions synchronously
  5731. // execute code before the first await. Since we implement simple
  5732. // async functions in terms of async generators, it is especially
  5733. // important to get this right, even though it requires care.
  5734. previousPromise ? previousPromise.then(
  5735. callInvokeWithMethodAndArg,
  5736. // Avoid propagating failures to Promises returned by later
  5737. // invocations of the iterator.
  5738. callInvokeWithMethodAndArg
  5739. ) : callInvokeWithMethodAndArg();
  5740. }
  5741. // Define the unified helper method that is used to implement .next,
  5742. // .throw, and .return (see defineIteratorMethods).
  5743. this._invoke = enqueue;
  5744. }
  5745. defineIteratorMethods(AsyncIterator.prototype);
  5746. AsyncIterator.prototype[asyncIteratorSymbol] = function () {
  5747. return this;
  5748. };
  5749. exports.AsyncIterator = AsyncIterator;
  5750. // Note that simple async functions are implemented on top of
  5751. // AsyncIterator objects; they just return a Promise for the value of
  5752. // the final result produced by the iterator.
  5753. exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  5754. if (PromiseImpl === void 0) PromiseImpl = Promise;
  5755. var iter = new AsyncIterator(
  5756. wrap(innerFn, outerFn, self, tryLocsList),
  5757. PromiseImpl
  5758. );
  5759. return exports.isGeneratorFunction(outerFn)
  5760. ? iter // If outerFn is a generator, return the full iterator.
  5761. : iter.next().then(function(result) {
  5762. return result.done ? result.value : iter.next();
  5763. });
  5764. };
  5765. function makeInvokeMethod(innerFn, self, context) {
  5766. var state = GenStateSuspendedStart;
  5767. return function invoke(method, arg) {
  5768. if (state === GenStateExecuting) {
  5769. throw new Error("Generator is already running");
  5770. }
  5771. if (state === GenStateCompleted) {
  5772. if (method === "throw") {
  5773. throw arg;
  5774. }
  5775. // Be forgiving, per 25.3.3.3.3 of the spec:
  5776. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
  5777. return doneResult();
  5778. }
  5779. context.method = method;
  5780. context.arg = arg;
  5781. while (true) {
  5782. var delegate = context.delegate;
  5783. if (delegate) {
  5784. var delegateResult = maybeInvokeDelegate(delegate, context);
  5785. if (delegateResult) {
  5786. if (delegateResult === ContinueSentinel) continue;
  5787. return delegateResult;
  5788. }
  5789. }
  5790. if (context.method === "next") {
  5791. // Setting context._sent for legacy support of Babel's
  5792. // function.sent implementation.
  5793. context.sent = context._sent = context.arg;
  5794. } else if (context.method === "throw") {
  5795. if (state === GenStateSuspendedStart) {
  5796. state = GenStateCompleted;
  5797. throw context.arg;
  5798. }
  5799. context.dispatchException(context.arg);
  5800. } else if (context.method === "return") {
  5801. context.abrupt("return", context.arg);
  5802. }
  5803. state = GenStateExecuting;
  5804. var record = tryCatch(innerFn, self, context);
  5805. if (record.type === "normal") {
  5806. // If an exception is thrown from innerFn, we leave state ===
  5807. // GenStateExecuting and loop back for another invocation.
  5808. state = context.done
  5809. ? GenStateCompleted
  5810. : GenStateSuspendedYield;
  5811. if (record.arg === ContinueSentinel) {
  5812. continue;
  5813. }
  5814. return {
  5815. value: record.arg,
  5816. done: context.done
  5817. };
  5818. } else if (record.type === "throw") {
  5819. state = GenStateCompleted;
  5820. // Dispatch the exception by looping back around to the
  5821. // context.dispatchException(context.arg) call above.
  5822. context.method = "throw";
  5823. context.arg = record.arg;
  5824. }
  5825. }
  5826. };
  5827. }
  5828. // Call delegate.iterator[context.method](context.arg) and handle the
  5829. // result, either by returning a { value, done } result from the
  5830. // delegate iterator, or by modifying context.method and context.arg,
  5831. // setting context.delegate to null, and returning the ContinueSentinel.
  5832. function maybeInvokeDelegate(delegate, context) {
  5833. var method = delegate.iterator[context.method];
  5834. if (method === undefined) {
  5835. // A .throw or .return when the delegate iterator has no .throw
  5836. // method always terminates the yield* loop.
  5837. context.delegate = null;
  5838. if (context.method === "throw") {
  5839. // Note: ["return"] must be used for ES3 parsing compatibility.
  5840. if (delegate.iterator["return"]) {
  5841. // If the delegate iterator has a return method, give it a
  5842. // chance to clean up.
  5843. context.method = "return";
  5844. context.arg = undefined;
  5845. maybeInvokeDelegate(delegate, context);
  5846. if (context.method === "throw") {
  5847. // If maybeInvokeDelegate(context) changed context.method from
  5848. // "return" to "throw", let that override the TypeError below.
  5849. return ContinueSentinel;
  5850. }
  5851. }
  5852. context.method = "throw";
  5853. context.arg = new TypeError(
  5854. "The iterator does not provide a 'throw' method");
  5855. }
  5856. return ContinueSentinel;
  5857. }
  5858. var record = tryCatch(method, delegate.iterator, context.arg);
  5859. if (record.type === "throw") {
  5860. context.method = "throw";
  5861. context.arg = record.arg;
  5862. context.delegate = null;
  5863. return ContinueSentinel;
  5864. }
  5865. var info = record.arg;
  5866. if (! info) {
  5867. context.method = "throw";
  5868. context.arg = new TypeError("iterator result is not an object");
  5869. context.delegate = null;
  5870. return ContinueSentinel;
  5871. }
  5872. if (info.done) {
  5873. // Assign the result of the finished delegate to the temporary
  5874. // variable specified by delegate.resultName (see delegateYield).
  5875. context[delegate.resultName] = info.value;
  5876. // Resume execution at the desired location (see delegateYield).
  5877. context.next = delegate.nextLoc;
  5878. // If context.method was "throw" but the delegate handled the
  5879. // exception, let the outer generator proceed normally. If
  5880. // context.method was "next", forget context.arg since it has been
  5881. // "consumed" by the delegate iterator. If context.method was
  5882. // "return", allow the original .return call to continue in the
  5883. // outer generator.
  5884. if (context.method !== "return") {
  5885. context.method = "next";
  5886. context.arg = undefined;
  5887. }
  5888. } else {
  5889. // Re-yield the result returned by the delegate method.
  5890. return info;
  5891. }
  5892. // The delegate iterator is finished, so forget it and continue with
  5893. // the outer generator.
  5894. context.delegate = null;
  5895. return ContinueSentinel;
  5896. }
  5897. // Define Generator.prototype.{next,throw,return} in terms of the
  5898. // unified ._invoke helper method.
  5899. defineIteratorMethods(Gp);
  5900. define(Gp, toStringTagSymbol, "Generator");
  5901. // A Generator should always return itself as the iterator object when the
  5902. // @@iterator function is called on it. Some browsers' implementations of the
  5903. // iterator prototype chain incorrectly implement this, causing the Generator
  5904. // object to not be returned from this call. This ensures that doesn't happen.
  5905. // See https://github.com/facebook/regenerator/issues/274 for more details.
  5906. Gp[iteratorSymbol] = function() {
  5907. return this;
  5908. };
  5909. Gp.toString = function() {
  5910. return "[object Generator]";
  5911. };
  5912. function pushTryEntry(locs) {
  5913. var entry = { tryLoc: locs[0] };
  5914. if (1 in locs) {
  5915. entry.catchLoc = locs[1];
  5916. }
  5917. if (2 in locs) {
  5918. entry.finallyLoc = locs[2];
  5919. entry.afterLoc = locs[3];
  5920. }
  5921. this.tryEntries.push(entry);
  5922. }
  5923. function resetTryEntry(entry) {
  5924. var record = entry.completion || {};
  5925. record.type = "normal";
  5926. delete record.arg;
  5927. entry.completion = record;
  5928. }
  5929. function Context(tryLocsList) {
  5930. // The root entry object (effectively a try statement without a catch
  5931. // or a finally block) gives us a place to store values thrown from
  5932. // locations where there is no enclosing try statement.
  5933. this.tryEntries = [{ tryLoc: "root" }];
  5934. tryLocsList.forEach(pushTryEntry, this);
  5935. this.reset(true);
  5936. }
  5937. exports.keys = function(object) {
  5938. var keys = [];
  5939. for (var key in object) {
  5940. keys.push(key);
  5941. }
  5942. keys.reverse();
  5943. // Rather than returning an object with a next method, we keep
  5944. // things simple and return the next function itself.
  5945. return function next() {
  5946. while (keys.length) {
  5947. var key = keys.pop();
  5948. if (key in object) {
  5949. next.value = key;
  5950. next.done = false;
  5951. return next;
  5952. }
  5953. }
  5954. // To avoid creating an additional object, we just hang the .value
  5955. // and .done properties off the next function object itself. This
  5956. // also ensures that the minifier will not anonymize the function.
  5957. next.done = true;
  5958. return next;
  5959. };
  5960. };
  5961. function values(iterable) {
  5962. if (iterable) {
  5963. var iteratorMethod = iterable[iteratorSymbol];
  5964. if (iteratorMethod) {
  5965. return iteratorMethod.call(iterable);
  5966. }
  5967. if (typeof iterable.next === "function") {
  5968. return iterable;
  5969. }
  5970. if (!isNaN(iterable.length)) {
  5971. var i = -1, next = function next() {
  5972. while (++i < iterable.length) {
  5973. if (hasOwn.call(iterable, i)) {
  5974. next.value = iterable[i];
  5975. next.done = false;
  5976. return next;
  5977. }
  5978. }
  5979. next.value = undefined;
  5980. next.done = true;
  5981. return next;
  5982. };
  5983. return next.next = next;
  5984. }
  5985. }
  5986. // Return an iterator with no values.
  5987. return { next: doneResult };
  5988. }
  5989. exports.values = values;
  5990. function doneResult() {
  5991. return { value: undefined, done: true };
  5992. }
  5993. Context.prototype = {
  5994. constructor: Context,
  5995. reset: function(skipTempReset) {
  5996. this.prev = 0;
  5997. this.next = 0;
  5998. // Resetting context._sent for legacy support of Babel's
  5999. // function.sent implementation.
  6000. this.sent = this._sent = undefined;
  6001. this.done = false;
  6002. this.delegate = null;
  6003. this.method = "next";
  6004. this.arg = undefined;
  6005. this.tryEntries.forEach(resetTryEntry);
  6006. if (!skipTempReset) {
  6007. for (var name in this) {
  6008. // Not sure about the optimal order of these conditions:
  6009. if (name.charAt(0) === "t" &&
  6010. hasOwn.call(this, name) &&
  6011. !isNaN(+name.slice(1))) {
  6012. this[name] = undefined;
  6013. }
  6014. }
  6015. }
  6016. },
  6017. stop: function() {
  6018. this.done = true;
  6019. var rootEntry = this.tryEntries[0];
  6020. var rootRecord = rootEntry.completion;
  6021. if (rootRecord.type === "throw") {
  6022. throw rootRecord.arg;
  6023. }
  6024. return this.rval;
  6025. },
  6026. dispatchException: function(exception) {
  6027. if (this.done) {
  6028. throw exception;
  6029. }
  6030. var context = this;
  6031. function handle(loc, caught) {
  6032. record.type = "throw";
  6033. record.arg = exception;
  6034. context.next = loc;
  6035. if (caught) {
  6036. // If the dispatched exception was caught by a catch block,
  6037. // then let that catch block handle the exception normally.
  6038. context.method = "next";
  6039. context.arg = undefined;
  6040. }
  6041. return !! caught;
  6042. }
  6043. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  6044. var entry = this.tryEntries[i];
  6045. var record = entry.completion;
  6046. if (entry.tryLoc === "root") {
  6047. // Exception thrown outside of any try block that could handle
  6048. // it, so set the completion value of the entire function to
  6049. // throw the exception.
  6050. return handle("end");
  6051. }
  6052. if (entry.tryLoc <= this.prev) {
  6053. var hasCatch = hasOwn.call(entry, "catchLoc");
  6054. var hasFinally = hasOwn.call(entry, "finallyLoc");
  6055. if (hasCatch && hasFinally) {
  6056. if (this.prev < entry.catchLoc) {
  6057. return handle(entry.catchLoc, true);
  6058. } else if (this.prev < entry.finallyLoc) {
  6059. return handle(entry.finallyLoc);
  6060. }
  6061. } else if (hasCatch) {
  6062. if (this.prev < entry.catchLoc) {
  6063. return handle(entry.catchLoc, true);
  6064. }
  6065. } else if (hasFinally) {
  6066. if (this.prev < entry.finallyLoc) {
  6067. return handle(entry.finallyLoc);
  6068. }
  6069. } else {
  6070. throw new Error("try statement without catch or finally");
  6071. }
  6072. }
  6073. }
  6074. },
  6075. abrupt: function(type, arg) {
  6076. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  6077. var entry = this.tryEntries[i];
  6078. if (entry.tryLoc <= this.prev &&
  6079. hasOwn.call(entry, "finallyLoc") &&
  6080. this.prev < entry.finallyLoc) {
  6081. var finallyEntry = entry;
  6082. break;
  6083. }
  6084. }
  6085. if (finallyEntry &&
  6086. (type === "break" ||
  6087. type === "continue") &&
  6088. finallyEntry.tryLoc <= arg &&
  6089. arg <= finallyEntry.finallyLoc) {
  6090. // Ignore the finally entry if control is not jumping to a
  6091. // location outside the try/catch block.
  6092. finallyEntry = null;
  6093. }
  6094. var record = finallyEntry ? finallyEntry.completion : {};
  6095. record.type = type;
  6096. record.arg = arg;
  6097. if (finallyEntry) {
  6098. this.method = "next";
  6099. this.next = finallyEntry.finallyLoc;
  6100. return ContinueSentinel;
  6101. }
  6102. return this.complete(record);
  6103. },
  6104. complete: function(record, afterLoc) {
  6105. if (record.type === "throw") {
  6106. throw record.arg;
  6107. }
  6108. if (record.type === "break" ||
  6109. record.type === "continue") {
  6110. this.next = record.arg;
  6111. } else if (record.type === "return") {
  6112. this.rval = this.arg = record.arg;
  6113. this.method = "return";
  6114. this.next = "end";
  6115. } else if (record.type === "normal" && afterLoc) {
  6116. this.next = afterLoc;
  6117. }
  6118. return ContinueSentinel;
  6119. },
  6120. finish: function(finallyLoc) {
  6121. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  6122. var entry = this.tryEntries[i];
  6123. if (entry.finallyLoc === finallyLoc) {
  6124. this.complete(entry.completion, entry.afterLoc);
  6125. resetTryEntry(entry);
  6126. return ContinueSentinel;
  6127. }
  6128. }
  6129. },
  6130. "catch": function(tryLoc) {
  6131. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  6132. var entry = this.tryEntries[i];
  6133. if (entry.tryLoc === tryLoc) {
  6134. var record = entry.completion;
  6135. if (record.type === "throw") {
  6136. var thrown = record.arg;
  6137. resetTryEntry(entry);
  6138. }
  6139. return thrown;
  6140. }
  6141. }
  6142. // The context.catch method must only be called with a location
  6143. // argument that corresponds to a known catch block.
  6144. throw new Error("illegal catch attempt");
  6145. },
  6146. delegateYield: function(iterable, resultName, nextLoc) {
  6147. this.delegate = {
  6148. iterator: values(iterable),
  6149. resultName: resultName,
  6150. nextLoc: nextLoc
  6151. };
  6152. if (this.method === "next") {
  6153. // Deliberately forget the last sent value so that we don't
  6154. // accidentally pass it on to the delegate.
  6155. this.arg = undefined;
  6156. }
  6157. return ContinueSentinel;
  6158. }
  6159. };
  6160. // Regardless of whether this script is executing as a CommonJS module
  6161. // or not, return the runtime object so that we can declare the variable
  6162. // regeneratorRuntime in the outer scope, which allows this module to be
  6163. // injected easily by `bin/regenerator --include-runtime script.js`.
  6164. return exports;
  6165. }(
  6166. // If this script is executing as a CommonJS module, use module.exports
  6167. // as the regeneratorRuntime namespace. Otherwise create a new empty
  6168. // object. Either way, the resulting object will be used to initialize
  6169. // the regeneratorRuntime variable at the top of this file.
  6170. typeof module === "object" ? module.exports : {}
  6171. ));
  6172. try {
  6173. regeneratorRuntime = runtime;
  6174. } catch (accidentalStrictMode) {
  6175. // This module should not be running in strict mode, so the above
  6176. // assignment should always work unless something is misconfigured. Just
  6177. // in case runtime.js accidentally runs in strict mode, we can escape
  6178. // strict mode using a global Function call. This could conceivably fail
  6179. // if a Content Security Policy forbids using Function, but in that case
  6180. // the proper solution is to fix the accidental strict mode problem. If
  6181. // you've misconfigured your bundler to force strict mode and applied a
  6182. // CSP to forbid Function, and you're not willing to fix either of those
  6183. // problems, please detail your unique predicament in a GitHub issue.
  6184. Function("r", "regeneratorRuntime = r")(runtime);
  6185. }
  6186. },{}],74:[function(require,module,exports){
  6187. module.exports = require("regenerator-runtime");
  6188. },{"regenerator-runtime":73}],75:[function(require,module,exports){
  6189. module.exports = noop;
  6190. module.exports.HttpsAgent = noop;
  6191. // Noop function for browser since native api's don't use agents.
  6192. function noop () {}
  6193. },{}],76:[function(require,module,exports){
  6194. 'use strict'
  6195. exports.byteLength = byteLength
  6196. exports.toByteArray = toByteArray
  6197. exports.fromByteArray = fromByteArray
  6198. var lookup = []
  6199. var revLookup = []
  6200. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  6201. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  6202. for (var i = 0, len = code.length; i < len; ++i) {
  6203. lookup[i] = code[i]
  6204. revLookup[code.charCodeAt(i)] = i
  6205. }
  6206. // Support decoding URL-safe base64 strings, as Node.js does.
  6207. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  6208. revLookup['-'.charCodeAt(0)] = 62
  6209. revLookup['_'.charCodeAt(0)] = 63
  6210. function getLens (b64) {
  6211. var len = b64.length
  6212. if (len % 4 > 0) {
  6213. throw new Error('Invalid string. Length must be a multiple of 4')
  6214. }
  6215. // Trim off extra bytes after placeholder bytes are found
  6216. // See: https://github.com/beatgammit/base64-js/issues/42
  6217. var validLen = b64.indexOf('=')
  6218. if (validLen === -1) validLen = len
  6219. var placeHoldersLen = validLen === len
  6220. ? 0
  6221. : 4 - (validLen % 4)
  6222. return [validLen, placeHoldersLen]
  6223. }
  6224. // base64 is 4/3 + up to two characters of the original data
  6225. function byteLength (b64) {
  6226. var lens = getLens(b64)
  6227. var validLen = lens[0]
  6228. var placeHoldersLen = lens[1]
  6229. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  6230. }
  6231. function _byteLength (b64, validLen, placeHoldersLen) {
  6232. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  6233. }
  6234. function toByteArray (b64) {
  6235. var tmp
  6236. var lens = getLens(b64)
  6237. var validLen = lens[0]
  6238. var placeHoldersLen = lens[1]
  6239. var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
  6240. var curByte = 0
  6241. // if there are placeholders, only get up to the last complete 4 chars
  6242. var len = placeHoldersLen > 0
  6243. ? validLen - 4
  6244. : validLen
  6245. var i
  6246. for (i = 0; i < len; i += 4) {
  6247. tmp =
  6248. (revLookup[b64.charCodeAt(i)] << 18) |
  6249. (revLookup[b64.charCodeAt(i + 1)] << 12) |
  6250. (revLookup[b64.charCodeAt(i + 2)] << 6) |
  6251. revLookup[b64.charCodeAt(i + 3)]
  6252. arr[curByte++] = (tmp >> 16) & 0xFF
  6253. arr[curByte++] = (tmp >> 8) & 0xFF
  6254. arr[curByte++] = tmp & 0xFF
  6255. }
  6256. if (placeHoldersLen === 2) {
  6257. tmp =
  6258. (revLookup[b64.charCodeAt(i)] << 2) |
  6259. (revLookup[b64.charCodeAt(i + 1)] >> 4)
  6260. arr[curByte++] = tmp & 0xFF
  6261. }
  6262. if (placeHoldersLen === 1) {
  6263. tmp =
  6264. (revLookup[b64.charCodeAt(i)] << 10) |
  6265. (revLookup[b64.charCodeAt(i + 1)] << 4) |
  6266. (revLookup[b64.charCodeAt(i + 2)] >> 2)
  6267. arr[curByte++] = (tmp >> 8) & 0xFF
  6268. arr[curByte++] = tmp & 0xFF
  6269. }
  6270. return arr
  6271. }
  6272. function tripletToBase64 (num) {
  6273. return lookup[num >> 18 & 0x3F] +
  6274. lookup[num >> 12 & 0x3F] +
  6275. lookup[num >> 6 & 0x3F] +
  6276. lookup[num & 0x3F]
  6277. }
  6278. function encodeChunk (uint8, start, end) {
  6279. var tmp
  6280. var output = []
  6281. for (var i = start; i < end; i += 3) {
  6282. tmp =
  6283. ((uint8[i] << 16) & 0xFF0000) +
  6284. ((uint8[i + 1] << 8) & 0xFF00) +
  6285. (uint8[i + 2] & 0xFF)
  6286. output.push(tripletToBase64(tmp))
  6287. }
  6288. return output.join('')
  6289. }
  6290. function fromByteArray (uint8) {
  6291. var tmp
  6292. var len = uint8.length
  6293. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  6294. var parts = []
  6295. var maxChunkLength = 16383 // must be multiple of 3
  6296. // go through the array every three bytes, we'll deal with trailing stuff later
  6297. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  6298. parts.push(encodeChunk(
  6299. uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
  6300. ))
  6301. }
  6302. // pad the end with zeros, but make sure to not forget the extra bytes
  6303. if (extraBytes === 1) {
  6304. tmp = uint8[len - 1]
  6305. parts.push(
  6306. lookup[tmp >> 2] +
  6307. lookup[(tmp << 4) & 0x3F] +
  6308. '=='
  6309. )
  6310. } else if (extraBytes === 2) {
  6311. tmp = (uint8[len - 2] << 8) + uint8[len - 1]
  6312. parts.push(
  6313. lookup[tmp >> 10] +
  6314. lookup[(tmp >> 4) & 0x3F] +
  6315. lookup[(tmp << 2) & 0x3F] +
  6316. '='
  6317. )
  6318. }
  6319. return parts.join('')
  6320. }
  6321. },{}],77:[function(require,module,exports){
  6322. /*!
  6323. * Bowser - a browser detector
  6324. * https://github.com/ded/bowser
  6325. * MIT License | (c) Dustin Diaz 2015
  6326. */
  6327. !function (root, name, definition) {
  6328. if (typeof module != 'undefined' && module.exports) module.exports = definition()
  6329. else if (typeof define == 'function' && define.amd) define(name, definition)
  6330. else root[name] = definition()
  6331. }(this, 'bowser', function () {
  6332. /**
  6333. * See useragents.js for examples of navigator.userAgent
  6334. */
  6335. var t = true
  6336. function detect(ua) {
  6337. function getFirstMatch(regex) {
  6338. var match = ua.match(regex);
  6339. return (match && match.length > 1 && match[1]) || '';
  6340. }
  6341. function getSecondMatch(regex) {
  6342. var match = ua.match(regex);
  6343. return (match && match.length > 1 && match[2]) || '';
  6344. }
  6345. var iosdevice = getFirstMatch(/(ipod|iphone|ipad)/i).toLowerCase()
  6346. , likeAndroid = /like android/i.test(ua)
  6347. , android = !likeAndroid && /android/i.test(ua)
  6348. , nexusMobile = /nexus\s*[0-6]\s*/i.test(ua)
  6349. , nexusTablet = !nexusMobile && /nexus\s*[0-9]+/i.test(ua)
  6350. , chromeos = /CrOS/.test(ua)
  6351. , silk = /silk/i.test(ua)
  6352. , sailfish = /sailfish/i.test(ua)
  6353. , tizen = /tizen/i.test(ua)
  6354. , webos = /(web|hpw)(o|0)s/i.test(ua)
  6355. , windowsphone = /windows phone/i.test(ua)
  6356. , samsungBrowser = /SamsungBrowser/i.test(ua)
  6357. , windows = !windowsphone && /windows/i.test(ua)
  6358. , mac = !iosdevice && !silk && /macintosh/i.test(ua)
  6359. , linux = !android && !sailfish && !tizen && !webos && /linux/i.test(ua)
  6360. , edgeVersion = getSecondMatch(/edg([ea]|ios)\/(\d+(\.\d+)?)/i)
  6361. , versionIdentifier = getFirstMatch(/version\/(\d+(\.\d+)?)/i)
  6362. , tablet = /tablet/i.test(ua) && !/tablet pc/i.test(ua)
  6363. , mobile = !tablet && /[^-]mobi/i.test(ua)
  6364. , xbox = /xbox/i.test(ua)
  6365. , result
  6366. if (/opera/i.test(ua)) {
  6367. // an old Opera
  6368. result = {
  6369. name: 'Opera'
  6370. , opera: t
  6371. , version: versionIdentifier || getFirstMatch(/(?:opera|opr|opios)[\s\/](\d+(\.\d+)?)/i)
  6372. }
  6373. } else if (/opr\/|opios/i.test(ua)) {
  6374. // a new Opera
  6375. result = {
  6376. name: 'Opera'
  6377. , opera: t
  6378. , version: getFirstMatch(/(?:opr|opios)[\s\/](\d+(\.\d+)?)/i) || versionIdentifier
  6379. }
  6380. }
  6381. else if (/SamsungBrowser/i.test(ua)) {
  6382. result = {
  6383. name: 'Samsung Internet for Android'
  6384. , samsungBrowser: t
  6385. , version: versionIdentifier || getFirstMatch(/(?:SamsungBrowser)[\s\/](\d+(\.\d+)?)/i)
  6386. }
  6387. }
  6388. else if (/Whale/i.test(ua)) {
  6389. result = {
  6390. name: 'NAVER Whale browser'
  6391. , whale: t
  6392. , version: getFirstMatch(/(?:whale)[\s\/](\d+(?:\.\d+)+)/i)
  6393. }
  6394. }
  6395. else if (/MZBrowser/i.test(ua)) {
  6396. result = {
  6397. name: 'MZ Browser'
  6398. , mzbrowser: t
  6399. , version: getFirstMatch(/(?:MZBrowser)[\s\/](\d+(?:\.\d+)+)/i)
  6400. }
  6401. }
  6402. else if (/coast/i.test(ua)) {
  6403. result = {
  6404. name: 'Opera Coast'
  6405. , coast: t
  6406. , version: versionIdentifier || getFirstMatch(/(?:coast)[\s\/](\d+(\.\d+)?)/i)
  6407. }
  6408. }
  6409. else if (/focus/i.test(ua)) {
  6410. result = {
  6411. name: 'Focus'
  6412. , focus: t
  6413. , version: getFirstMatch(/(?:focus)[\s\/](\d+(?:\.\d+)+)/i)
  6414. }
  6415. }
  6416. else if (/yabrowser/i.test(ua)) {
  6417. result = {
  6418. name: 'Yandex Browser'
  6419. , yandexbrowser: t
  6420. , version: versionIdentifier || getFirstMatch(/(?:yabrowser)[\s\/](\d+(\.\d+)?)/i)
  6421. }
  6422. }
  6423. else if (/ucbrowser/i.test(ua)) {
  6424. result = {
  6425. name: 'UC Browser'
  6426. , ucbrowser: t
  6427. , version: getFirstMatch(/(?:ucbrowser)[\s\/](\d+(?:\.\d+)+)/i)
  6428. }
  6429. }
  6430. else if (/mxios/i.test(ua)) {
  6431. result = {
  6432. name: 'Maxthon'
  6433. , maxthon: t
  6434. , version: getFirstMatch(/(?:mxios)[\s\/](\d+(?:\.\d+)+)/i)
  6435. }
  6436. }
  6437. else if (/epiphany/i.test(ua)) {
  6438. result = {
  6439. name: 'Epiphany'
  6440. , epiphany: t
  6441. , version: getFirstMatch(/(?:epiphany)[\s\/](\d+(?:\.\d+)+)/i)
  6442. }
  6443. }
  6444. else if (/puffin/i.test(ua)) {
  6445. result = {
  6446. name: 'Puffin'
  6447. , puffin: t
  6448. , version: getFirstMatch(/(?:puffin)[\s\/](\d+(?:\.\d+)?)/i)
  6449. }
  6450. }
  6451. else if (/sleipnir/i.test(ua)) {
  6452. result = {
  6453. name: 'Sleipnir'
  6454. , sleipnir: t
  6455. , version: getFirstMatch(/(?:sleipnir)[\s\/](\d+(?:\.\d+)+)/i)
  6456. }
  6457. }
  6458. else if (/k-meleon/i.test(ua)) {
  6459. result = {
  6460. name: 'K-Meleon'
  6461. , kMeleon: t
  6462. , version: getFirstMatch(/(?:k-meleon)[\s\/](\d+(?:\.\d+)+)/i)
  6463. }
  6464. }
  6465. else if (windowsphone) {
  6466. result = {
  6467. name: 'Windows Phone'
  6468. , osname: 'Windows Phone'
  6469. , windowsphone: t
  6470. }
  6471. if (edgeVersion) {
  6472. result.msedge = t
  6473. result.version = edgeVersion
  6474. }
  6475. else {
  6476. result.msie = t
  6477. result.version = getFirstMatch(/iemobile\/(\d+(\.\d+)?)/i)
  6478. }
  6479. }
  6480. else if (/msie|trident/i.test(ua)) {
  6481. result = {
  6482. name: 'Internet Explorer'
  6483. , msie: t
  6484. , version: getFirstMatch(/(?:msie |rv:)(\d+(\.\d+)?)/i)
  6485. }
  6486. } else if (chromeos) {
  6487. result = {
  6488. name: 'Chrome'
  6489. , osname: 'Chrome OS'
  6490. , chromeos: t
  6491. , chromeBook: t
  6492. , chrome: t
  6493. , version: getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)
  6494. }
  6495. } else if (/edg([ea]|ios)/i.test(ua)) {
  6496. result = {
  6497. name: 'Microsoft Edge'
  6498. , msedge: t
  6499. , version: edgeVersion
  6500. }
  6501. }
  6502. else if (/vivaldi/i.test(ua)) {
  6503. result = {
  6504. name: 'Vivaldi'
  6505. , vivaldi: t
  6506. , version: getFirstMatch(/vivaldi\/(\d+(\.\d+)?)/i) || versionIdentifier
  6507. }
  6508. }
  6509. else if (sailfish) {
  6510. result = {
  6511. name: 'Sailfish'
  6512. , osname: 'Sailfish OS'
  6513. , sailfish: t
  6514. , version: getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i)
  6515. }
  6516. }
  6517. else if (/seamonkey\//i.test(ua)) {
  6518. result = {
  6519. name: 'SeaMonkey'
  6520. , seamonkey: t
  6521. , version: getFirstMatch(/seamonkey\/(\d+(\.\d+)?)/i)
  6522. }
  6523. }
  6524. else if (/firefox|iceweasel|fxios/i.test(ua)) {
  6525. result = {
  6526. name: 'Firefox'
  6527. , firefox: t
  6528. , version: getFirstMatch(/(?:firefox|iceweasel|fxios)[ \/](\d+(\.\d+)?)/i)
  6529. }
  6530. if (/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(ua)) {
  6531. result.firefoxos = t
  6532. result.osname = 'Firefox OS'
  6533. }
  6534. }
  6535. else if (silk) {
  6536. result = {
  6537. name: 'Amazon Silk'
  6538. , silk: t
  6539. , version : getFirstMatch(/silk\/(\d+(\.\d+)?)/i)
  6540. }
  6541. }
  6542. else if (/phantom/i.test(ua)) {
  6543. result = {
  6544. name: 'PhantomJS'
  6545. , phantom: t
  6546. , version: getFirstMatch(/phantomjs\/(\d+(\.\d+)?)/i)
  6547. }
  6548. }
  6549. else if (/slimerjs/i.test(ua)) {
  6550. result = {
  6551. name: 'SlimerJS'
  6552. , slimer: t
  6553. , version: getFirstMatch(/slimerjs\/(\d+(\.\d+)?)/i)
  6554. }
  6555. }
  6556. else if (/blackberry|\bbb\d+/i.test(ua) || /rim\stablet/i.test(ua)) {
  6557. result = {
  6558. name: 'BlackBerry'
  6559. , osname: 'BlackBerry OS'
  6560. , blackberry: t
  6561. , version: versionIdentifier || getFirstMatch(/blackberry[\d]+\/(\d+(\.\d+)?)/i)
  6562. }
  6563. }
  6564. else if (webos) {
  6565. result = {
  6566. name: 'WebOS'
  6567. , osname: 'WebOS'
  6568. , webos: t
  6569. , version: versionIdentifier || getFirstMatch(/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i)
  6570. };
  6571. /touchpad\//i.test(ua) && (result.touchpad = t)
  6572. }
  6573. else if (/bada/i.test(ua)) {
  6574. result = {
  6575. name: 'Bada'
  6576. , osname: 'Bada'
  6577. , bada: t
  6578. , version: getFirstMatch(/dolfin\/(\d+(\.\d+)?)/i)
  6579. };
  6580. }
  6581. else if (tizen) {
  6582. result = {
  6583. name: 'Tizen'
  6584. , osname: 'Tizen'
  6585. , tizen: t
  6586. , version: getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i) || versionIdentifier
  6587. };
  6588. }
  6589. else if (/qupzilla/i.test(ua)) {
  6590. result = {
  6591. name: 'QupZilla'
  6592. , qupzilla: t
  6593. , version: getFirstMatch(/(?:qupzilla)[\s\/](\d+(?:\.\d+)+)/i) || versionIdentifier
  6594. }
  6595. }
  6596. else if (/chromium/i.test(ua)) {
  6597. result = {
  6598. name: 'Chromium'
  6599. , chromium: t
  6600. , version: getFirstMatch(/(?:chromium)[\s\/](\d+(?:\.\d+)?)/i) || versionIdentifier
  6601. }
  6602. }
  6603. else if (/chrome|crios|crmo/i.test(ua)) {
  6604. result = {
  6605. name: 'Chrome'
  6606. , chrome: t
  6607. , version: getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)
  6608. }
  6609. }
  6610. else if (android) {
  6611. result = {
  6612. name: 'Android'
  6613. , version: versionIdentifier
  6614. }
  6615. }
  6616. else if (/safari|applewebkit/i.test(ua)) {
  6617. result = {
  6618. name: 'Safari'
  6619. , safari: t
  6620. }
  6621. if (versionIdentifier) {
  6622. result.version = versionIdentifier
  6623. }
  6624. }
  6625. else if (iosdevice) {
  6626. result = {
  6627. name : iosdevice == 'iphone' ? 'iPhone' : iosdevice == 'ipad' ? 'iPad' : 'iPod'
  6628. }
  6629. // WTF: version is not part of user agent in web apps
  6630. if (versionIdentifier) {
  6631. result.version = versionIdentifier
  6632. }
  6633. }
  6634. else if(/googlebot/i.test(ua)) {
  6635. result = {
  6636. name: 'Googlebot'
  6637. , googlebot: t
  6638. , version: getFirstMatch(/googlebot\/(\d+(\.\d+))/i) || versionIdentifier
  6639. }
  6640. }
  6641. else {
  6642. result = {
  6643. name: getFirstMatch(/^(.*)\/(.*) /),
  6644. version: getSecondMatch(/^(.*)\/(.*) /)
  6645. };
  6646. }
  6647. // set webkit or gecko flag for browsers based on these engines
  6648. if (!result.msedge && /(apple)?webkit/i.test(ua)) {
  6649. if (/(apple)?webkit\/537\.36/i.test(ua)) {
  6650. result.name = result.name || "Blink"
  6651. result.blink = t
  6652. } else {
  6653. result.name = result.name || "Webkit"
  6654. result.webkit = t
  6655. }
  6656. if (!result.version && versionIdentifier) {
  6657. result.version = versionIdentifier
  6658. }
  6659. } else if (!result.opera && /gecko\//i.test(ua)) {
  6660. result.name = result.name || "Gecko"
  6661. result.gecko = t
  6662. result.version = result.version || getFirstMatch(/gecko\/(\d+(\.\d+)?)/i)
  6663. }
  6664. // set OS flags for platforms that have multiple browsers
  6665. if (!result.windowsphone && (android || result.silk)) {
  6666. result.android = t
  6667. result.osname = 'Android'
  6668. } else if (!result.windowsphone && iosdevice) {
  6669. result[iosdevice] = t
  6670. result.ios = t
  6671. result.osname = 'iOS'
  6672. } else if (mac) {
  6673. result.mac = t
  6674. result.osname = 'macOS'
  6675. } else if (xbox) {
  6676. result.xbox = t
  6677. result.osname = 'Xbox'
  6678. } else if (windows) {
  6679. result.windows = t
  6680. result.osname = 'Windows'
  6681. } else if (linux) {
  6682. result.linux = t
  6683. result.osname = 'Linux'
  6684. }
  6685. function getWindowsVersion (s) {
  6686. switch (s) {
  6687. case 'NT': return 'NT'
  6688. case 'XP': return 'XP'
  6689. case 'NT 5.0': return '2000'
  6690. case 'NT 5.1': return 'XP'
  6691. case 'NT 5.2': return '2003'
  6692. case 'NT 6.0': return 'Vista'
  6693. case 'NT 6.1': return '7'
  6694. case 'NT 6.2': return '8'
  6695. case 'NT 6.3': return '8.1'
  6696. case 'NT 10.0': return '10'
  6697. default: return undefined
  6698. }
  6699. }
  6700. // OS version extraction
  6701. var osVersion = '';
  6702. if (result.windows) {
  6703. osVersion = getWindowsVersion(getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i))
  6704. } else if (result.windowsphone) {
  6705. osVersion = getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i);
  6706. } else if (result.mac) {
  6707. osVersion = getFirstMatch(/Mac OS X (\d+([_\.\s]\d+)*)/i);
  6708. osVersion = osVersion.replace(/[_\s]/g, '.');
  6709. } else if (iosdevice) {
  6710. osVersion = getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i);
  6711. osVersion = osVersion.replace(/[_\s]/g, '.');
  6712. } else if (android) {
  6713. osVersion = getFirstMatch(/android[ \/-](\d+(\.\d+)*)/i);
  6714. } else if (result.webos) {
  6715. osVersion = getFirstMatch(/(?:web|hpw)os\/(\d+(\.\d+)*)/i);
  6716. } else if (result.blackberry) {
  6717. osVersion = getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i);
  6718. } else if (result.bada) {
  6719. osVersion = getFirstMatch(/bada\/(\d+(\.\d+)*)/i);
  6720. } else if (result.tizen) {
  6721. osVersion = getFirstMatch(/tizen[\/\s](\d+(\.\d+)*)/i);
  6722. }
  6723. if (osVersion) {
  6724. result.osversion = osVersion;
  6725. }
  6726. // device type extraction
  6727. var osMajorVersion = !result.windows && osVersion.split('.')[0];
  6728. if (
  6729. tablet
  6730. || nexusTablet
  6731. || iosdevice == 'ipad'
  6732. || (android && (osMajorVersion == 3 || (osMajorVersion >= 4 && !mobile)))
  6733. || result.silk
  6734. ) {
  6735. result.tablet = t
  6736. } else if (
  6737. mobile
  6738. || iosdevice == 'iphone'
  6739. || iosdevice == 'ipod'
  6740. || android
  6741. || nexusMobile
  6742. || result.blackberry
  6743. || result.webos
  6744. || result.bada
  6745. ) {
  6746. result.mobile = t
  6747. }
  6748. // Graded Browser Support
  6749. // http://developer.yahoo.com/yui/articles/gbs
  6750. if (result.msedge ||
  6751. (result.msie && result.version >= 10) ||
  6752. (result.yandexbrowser && result.version >= 15) ||
  6753. (result.vivaldi && result.version >= 1.0) ||
  6754. (result.chrome && result.version >= 20) ||
  6755. (result.samsungBrowser && result.version >= 4) ||
  6756. (result.whale && compareVersions([result.version, '1.0']) === 1) ||
  6757. (result.mzbrowser && compareVersions([result.version, '6.0']) === 1) ||
  6758. (result.focus && compareVersions([result.version, '1.0']) === 1) ||
  6759. (result.firefox && result.version >= 20.0) ||
  6760. (result.safari && result.version >= 6) ||
  6761. (result.opera && result.version >= 10.0) ||
  6762. (result.ios && result.osversion && result.osversion.split(".")[0] >= 6) ||
  6763. (result.blackberry && result.version >= 10.1)
  6764. || (result.chromium && result.version >= 20)
  6765. ) {
  6766. result.a = t;
  6767. }
  6768. else if ((result.msie && result.version < 10) ||
  6769. (result.chrome && result.version < 20) ||
  6770. (result.firefox && result.version < 20.0) ||
  6771. (result.safari && result.version < 6) ||
  6772. (result.opera && result.version < 10.0) ||
  6773. (result.ios && result.osversion && result.osversion.split(".")[0] < 6)
  6774. || (result.chromium && result.version < 20)
  6775. ) {
  6776. result.c = t
  6777. } else result.x = t
  6778. return result
  6779. }
  6780. var bowser = detect(typeof navigator !== 'undefined' ? navigator.userAgent || '' : '')
  6781. bowser.test = function (browserList) {
  6782. for (var i = 0; i < browserList.length; ++i) {
  6783. var browserItem = browserList[i];
  6784. if (typeof browserItem=== 'string') {
  6785. if (browserItem in bowser) {
  6786. return true;
  6787. }
  6788. }
  6789. }
  6790. return false;
  6791. }
  6792. /**
  6793. * Get version precisions count
  6794. *
  6795. * @example
  6796. * getVersionPrecision("1.10.3") // 3
  6797. *
  6798. * @param {string} version
  6799. * @return {number}
  6800. */
  6801. function getVersionPrecision(version) {
  6802. return version.split(".").length;
  6803. }
  6804. /**
  6805. * Array::map polyfill
  6806. *
  6807. * @param {Array} arr
  6808. * @param {Function} iterator
  6809. * @return {Array}
  6810. */
  6811. function map(arr, iterator) {
  6812. var result = [], i;
  6813. if (Array.prototype.map) {
  6814. return Array.prototype.map.call(arr, iterator);
  6815. }
  6816. for (i = 0; i < arr.length; i++) {
  6817. result.push(iterator(arr[i]));
  6818. }
  6819. return result;
  6820. }
  6821. /**
  6822. * Calculate browser version weight
  6823. *
  6824. * @example
  6825. * compareVersions(['1.10.2.1', '1.8.2.1.90']) // 1
  6826. * compareVersions(['1.010.2.1', '1.09.2.1.90']); // 1
  6827. * compareVersions(['1.10.2.1', '1.10.2.1']); // 0
  6828. * compareVersions(['1.10.2.1', '1.0800.2']); // -1
  6829. *
  6830. * @param {Array<String>} versions versions to compare
  6831. * @return {Number} comparison result
  6832. */
  6833. function compareVersions(versions) {
  6834. // 1) get common precision for both versions, for example for "10.0" and "9" it should be 2
  6835. var precision = Math.max(getVersionPrecision(versions[0]), getVersionPrecision(versions[1]));
  6836. var chunks = map(versions, function (version) {
  6837. var delta = precision - getVersionPrecision(version);
  6838. // 2) "9" -> "9.0" (for precision = 2)
  6839. version = version + new Array(delta + 1).join(".0");
  6840. // 3) "9.0" -> ["000000000"", "000000009"]
  6841. return map(version.split("."), function (chunk) {
  6842. return new Array(20 - chunk.length).join("0") + chunk;
  6843. }).reverse();
  6844. });
  6845. // iterate in reverse order by reversed chunks array
  6846. while (--precision >= 0) {
  6847. // 4) compare: "000000009" > "000000010" = false (but "9" > "10" = true)
  6848. if (chunks[0][precision] > chunks[1][precision]) {
  6849. return 1;
  6850. }
  6851. else if (chunks[0][precision] === chunks[1][precision]) {
  6852. if (precision === 0) {
  6853. // all version chunks are same
  6854. return 0;
  6855. }
  6856. }
  6857. else {
  6858. return -1;
  6859. }
  6860. }
  6861. }
  6862. /**
  6863. * Check if browser is unsupported
  6864. *
  6865. * @example
  6866. * bowser.isUnsupportedBrowser({
  6867. * msie: "10",
  6868. * firefox: "23",
  6869. * chrome: "29",
  6870. * safari: "5.1",
  6871. * opera: "16",
  6872. * phantom: "534"
  6873. * });
  6874. *
  6875. * @param {Object} minVersions map of minimal version to browser
  6876. * @param {Boolean} [strictMode = false] flag to return false if browser wasn't found in map
  6877. * @param {String} [ua] user agent string
  6878. * @return {Boolean}
  6879. */
  6880. function isUnsupportedBrowser(minVersions, strictMode, ua) {
  6881. var _bowser = bowser;
  6882. // make strictMode param optional with ua param usage
  6883. if (typeof strictMode === 'string') {
  6884. ua = strictMode;
  6885. strictMode = void(0);
  6886. }
  6887. if (strictMode === void(0)) {
  6888. strictMode = false;
  6889. }
  6890. if (ua) {
  6891. _bowser = detect(ua);
  6892. }
  6893. var version = "" + _bowser.version;
  6894. for (var browser in minVersions) {
  6895. if (minVersions.hasOwnProperty(browser)) {
  6896. if (_bowser[browser]) {
  6897. if (typeof minVersions[browser] !== 'string') {
  6898. throw new Error('Browser version in the minVersion map should be a string: ' + browser + ': ' + String(minVersions));
  6899. }
  6900. // browser version and min supported version.
  6901. return compareVersions([version, minVersions[browser]]) < 0;
  6902. }
  6903. }
  6904. }
  6905. return strictMode; // not found
  6906. }
  6907. /**
  6908. * Check if browser is supported
  6909. *
  6910. * @param {Object} minVersions map of minimal version to browser
  6911. * @param {Boolean} [strictMode = false] flag to return false if browser wasn't found in map
  6912. * @param {String} [ua] user agent string
  6913. * @return {Boolean}
  6914. */
  6915. function check(minVersions, strictMode, ua) {
  6916. return !isUnsupportedBrowser(minVersions, strictMode, ua);
  6917. }
  6918. bowser.isUnsupportedBrowser = isUnsupportedBrowser;
  6919. bowser.compareVersions = compareVersions;
  6920. bowser.check = check;
  6921. /*
  6922. * Set our detect method to the main bowser object so we can
  6923. * reuse it to test other user agents.
  6924. * This is needed to implement future tests.
  6925. */
  6926. bowser._detect = detect;
  6927. /*
  6928. * Set our detect public method to the main bowser object
  6929. * This is needed to implement bowser in server side
  6930. */
  6931. bowser.detect = detect;
  6932. return bowser
  6933. });
  6934. },{}],78:[function(require,module,exports){
  6935. },{}],79:[function(require,module,exports){
  6936. (function (global){
  6937. var ClientRequest = require('./lib/request')
  6938. var response = require('./lib/response')
  6939. var extend = require('xtend')
  6940. var statusCodes = require('builtin-status-codes')
  6941. var url = require('url')
  6942. var http = exports
  6943. http.request = function (opts, cb) {
  6944. if (typeof opts === 'string')
  6945. opts = url.parse(opts)
  6946. else
  6947. opts = extend(opts)
  6948. // Normally, the page is loaded from http or https, so not specifying a protocol
  6949. // will result in a (valid) protocol-relative url. However, this won't work if
  6950. // the protocol is something else, like 'file:'
  6951. var defaultProtocol = global.location.protocol.search(/^https?:$/) === -1 ? 'http:' : ''
  6952. var protocol = opts.protocol || defaultProtocol
  6953. var host = opts.hostname || opts.host
  6954. var port = opts.port
  6955. var path = opts.path || '/'
  6956. // Necessary for IPv6 addresses
  6957. if (host && host.indexOf(':') !== -1)
  6958. host = '[' + host + ']'
  6959. // This may be a relative url. The browser should always be able to interpret it correctly.
  6960. opts.url = (host ? (protocol + '//' + host) : '') + (port ? ':' + port : '') + path
  6961. opts.method = (opts.method || 'GET').toUpperCase()
  6962. opts.headers = opts.headers || {}
  6963. // Also valid opts.auth, opts.mode
  6964. var req = new ClientRequest(opts)
  6965. if (cb)
  6966. req.on('response', cb)
  6967. return req
  6968. }
  6969. http.get = function get (opts, cb) {
  6970. var req = http.request(opts, cb)
  6971. req.end()
  6972. return req
  6973. }
  6974. http.ClientRequest = ClientRequest
  6975. http.IncomingMessage = response.IncomingMessage
  6976. http.Agent = function () {}
  6977. http.Agent.defaultMaxSockets = 4
  6978. http.globalAgent = new http.Agent()
  6979. http.STATUS_CODES = statusCodes
  6980. http.METHODS = [
  6981. 'CHECKOUT',
  6982. 'CONNECT',
  6983. 'COPY',
  6984. 'DELETE',
  6985. 'GET',
  6986. 'HEAD',
  6987. 'LOCK',
  6988. 'M-SEARCH',
  6989. 'MERGE',
  6990. 'MKACTIVITY',
  6991. 'MKCOL',
  6992. 'MOVE',
  6993. 'NOTIFY',
  6994. 'OPTIONS',
  6995. 'PATCH',
  6996. 'POST',
  6997. 'PROPFIND',
  6998. 'PROPPATCH',
  6999. 'PURGE',
  7000. 'PUT',
  7001. 'REPORT',
  7002. 'SEARCH',
  7003. 'SUBSCRIBE',
  7004. 'TRACE',
  7005. 'UNLOCK',
  7006. 'UNSUBSCRIBE'
  7007. ]
  7008. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  7009. },{"./lib/request":81,"./lib/response":82,"builtin-status-codes":99,"url":394,"xtend":386}],80:[function(require,module,exports){
  7010. (function (global){
  7011. exports.fetch = isFunction(global.fetch) && isFunction(global.ReadableStream)
  7012. exports.writableStream = isFunction(global.WritableStream)
  7013. exports.abortController = isFunction(global.AbortController)
  7014. // The xhr request to example.com may violate some restrictive CSP configurations,
  7015. // so if we're running in a browser that supports `fetch`, avoid calling getXHR()
  7016. // and assume support for certain features below.
  7017. var xhr
  7018. function getXHR () {
  7019. // Cache the xhr value
  7020. if (xhr !== undefined) return xhr
  7021. if (global.XMLHttpRequest) {
  7022. xhr = new global.XMLHttpRequest()
  7023. // If XDomainRequest is available (ie only, where xhr might not work
  7024. // cross domain), use the page location. Otherwise use example.com
  7025. // Note: this doesn't actually make an http request.
  7026. try {
  7027. xhr.open('GET', global.XDomainRequest ? '/' : 'https://example.com')
  7028. } catch(e) {
  7029. xhr = null
  7030. }
  7031. } else {
  7032. // Service workers don't have XHR
  7033. xhr = null
  7034. }
  7035. return xhr
  7036. }
  7037. function checkTypeSupport (type) {
  7038. var xhr = getXHR()
  7039. if (!xhr) return false
  7040. try {
  7041. xhr.responseType = type
  7042. return xhr.responseType === type
  7043. } catch (e) {}
  7044. return false
  7045. }
  7046. // If fetch is supported, then arraybuffer will be supported too. Skip calling
  7047. // checkTypeSupport(), since that calls getXHR().
  7048. exports.arraybuffer = exports.fetch || checkTypeSupport('arraybuffer')
  7049. // These next two tests unavoidably show warnings in Chrome. Since fetch will always
  7050. // be used if it's available, just return false for these to avoid the warnings.
  7051. exports.msstream = !exports.fetch && checkTypeSupport('ms-stream')
  7052. exports.mozchunkedarraybuffer = !exports.fetch && checkTypeSupport('moz-chunked-arraybuffer')
  7053. // If fetch is supported, then overrideMimeType will be supported too. Skip calling
  7054. // getXHR().
  7055. exports.overrideMimeType = exports.fetch || (getXHR() ? isFunction(getXHR().overrideMimeType) : false)
  7056. function isFunction (value) {
  7057. return typeof value === 'function'
  7058. }
  7059. xhr = null // Help gc
  7060. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  7061. },{}],81:[function(require,module,exports){
  7062. (function (process,global,Buffer){
  7063. var capability = require('./capability')
  7064. var inherits = require('inherits')
  7065. var response = require('./response')
  7066. var stream = require('readable-stream')
  7067. var IncomingMessage = response.IncomingMessage
  7068. var rStates = response.readyStates
  7069. function decideMode (preferBinary, useFetch) {
  7070. if (capability.fetch && useFetch) {
  7071. return 'fetch'
  7072. } else if (capability.mozchunkedarraybuffer) {
  7073. return 'moz-chunked-arraybuffer'
  7074. } else if (capability.msstream) {
  7075. return 'ms-stream'
  7076. } else if (capability.arraybuffer && preferBinary) {
  7077. return 'arraybuffer'
  7078. } else {
  7079. return 'text'
  7080. }
  7081. }
  7082. var ClientRequest = module.exports = function (opts) {
  7083. var self = this
  7084. stream.Writable.call(self)
  7085. self._opts = opts
  7086. self._body = []
  7087. self._headers = {}
  7088. if (opts.auth)
  7089. self.setHeader('Authorization', 'Basic ' + Buffer.from(opts.auth).toString('base64'))
  7090. Object.keys(opts.headers).forEach(function (name) {
  7091. self.setHeader(name, opts.headers[name])
  7092. })
  7093. var preferBinary
  7094. var useFetch = true
  7095. if (opts.mode === 'disable-fetch' || ('requestTimeout' in opts && !capability.abortController)) {
  7096. // If the use of XHR should be preferred. Not typically needed.
  7097. useFetch = false
  7098. preferBinary = true
  7099. } else if (opts.mode === 'prefer-streaming') {
  7100. // If streaming is a high priority but binary compatibility and
  7101. // the accuracy of the 'content-type' header aren't
  7102. preferBinary = false
  7103. } else if (opts.mode === 'allow-wrong-content-type') {
  7104. // If streaming is more important than preserving the 'content-type' header
  7105. preferBinary = !capability.overrideMimeType
  7106. } else if (!opts.mode || opts.mode === 'default' || opts.mode === 'prefer-fast') {
  7107. // Use binary if text streaming may corrupt data or the content-type header, or for speed
  7108. preferBinary = true
  7109. } else {
  7110. throw new Error('Invalid value for opts.mode')
  7111. }
  7112. self._mode = decideMode(preferBinary, useFetch)
  7113. self._fetchTimer = null
  7114. self.on('finish', function () {
  7115. self._onFinish()
  7116. })
  7117. }
  7118. inherits(ClientRequest, stream.Writable)
  7119. ClientRequest.prototype.setHeader = function (name, value) {
  7120. var self = this
  7121. var lowerName = name.toLowerCase()
  7122. // This check is not necessary, but it prevents warnings from browsers about setting unsafe
  7123. // headers. To be honest I'm not entirely sure hiding these warnings is a good thing, but
  7124. // http-browserify did it, so I will too.
  7125. if (unsafeHeaders.indexOf(lowerName) !== -1)
  7126. return
  7127. self._headers[lowerName] = {
  7128. name: name,
  7129. value: value
  7130. }
  7131. }
  7132. ClientRequest.prototype.getHeader = function (name) {
  7133. var header = this._headers[name.toLowerCase()]
  7134. if (header)
  7135. return header.value
  7136. return null
  7137. }
  7138. ClientRequest.prototype.removeHeader = function (name) {
  7139. var self = this
  7140. delete self._headers[name.toLowerCase()]
  7141. }
  7142. ClientRequest.prototype._onFinish = function () {
  7143. var self = this
  7144. if (self._destroyed)
  7145. return
  7146. var opts = self._opts
  7147. var headersObj = self._headers
  7148. var body = null
  7149. if (opts.method !== 'GET' && opts.method !== 'HEAD') {
  7150. body = new Blob(self._body, {
  7151. type: (headersObj['content-type'] || {}).value || ''
  7152. });
  7153. }
  7154. // create flattened list of headers
  7155. var headersList = []
  7156. Object.keys(headersObj).forEach(function (keyName) {
  7157. var name = headersObj[keyName].name
  7158. var value = headersObj[keyName].value
  7159. if (Array.isArray(value)) {
  7160. value.forEach(function (v) {
  7161. headersList.push([name, v])
  7162. })
  7163. } else {
  7164. headersList.push([name, value])
  7165. }
  7166. })
  7167. if (self._mode === 'fetch') {
  7168. var signal = null
  7169. if (capability.abortController) {
  7170. var controller = new AbortController()
  7171. signal = controller.signal
  7172. self._fetchAbortController = controller
  7173. if ('requestTimeout' in opts && opts.requestTimeout !== 0) {
  7174. self._fetchTimer = global.setTimeout(function () {
  7175. self.emit('requestTimeout')
  7176. if (self._fetchAbortController)
  7177. self._fetchAbortController.abort()
  7178. }, opts.requestTimeout)
  7179. }
  7180. }
  7181. global.fetch(self._opts.url, {
  7182. method: self._opts.method,
  7183. headers: headersList,
  7184. body: body || undefined,
  7185. mode: 'cors',
  7186. credentials: opts.withCredentials ? 'include' : 'same-origin',
  7187. signal: signal
  7188. }).then(function (response) {
  7189. self._fetchResponse = response
  7190. self._connect()
  7191. }, function (reason) {
  7192. global.clearTimeout(self._fetchTimer)
  7193. if (!self._destroyed)
  7194. self.emit('error', reason)
  7195. })
  7196. } else {
  7197. var xhr = self._xhr = new global.XMLHttpRequest()
  7198. try {
  7199. xhr.open(self._opts.method, self._opts.url, true)
  7200. } catch (err) {
  7201. process.nextTick(function () {
  7202. self.emit('error', err)
  7203. })
  7204. return
  7205. }
  7206. // Can't set responseType on really old browsers
  7207. if ('responseType' in xhr)
  7208. xhr.responseType = self._mode
  7209. if ('withCredentials' in xhr)
  7210. xhr.withCredentials = !!opts.withCredentials
  7211. if (self._mode === 'text' && 'overrideMimeType' in xhr)
  7212. xhr.overrideMimeType('text/plain; charset=x-user-defined')
  7213. if ('requestTimeout' in opts) {
  7214. xhr.timeout = opts.requestTimeout
  7215. xhr.ontimeout = function () {
  7216. self.emit('requestTimeout')
  7217. }
  7218. }
  7219. headersList.forEach(function (header) {
  7220. xhr.setRequestHeader(header[0], header[1])
  7221. })
  7222. self._response = null
  7223. xhr.onreadystatechange = function () {
  7224. switch (xhr.readyState) {
  7225. case rStates.LOADING:
  7226. case rStates.DONE:
  7227. self._onXHRProgress()
  7228. break
  7229. }
  7230. }
  7231. // Necessary for streaming in Firefox, since xhr.response is ONLY defined
  7232. // in onprogress, not in onreadystatechange with xhr.readyState = 3
  7233. if (self._mode === 'moz-chunked-arraybuffer') {
  7234. xhr.onprogress = function () {
  7235. self._onXHRProgress()
  7236. }
  7237. }
  7238. xhr.onerror = function () {
  7239. if (self._destroyed)
  7240. return
  7241. self.emit('error', new Error('XHR error'))
  7242. }
  7243. try {
  7244. xhr.send(body)
  7245. } catch (err) {
  7246. process.nextTick(function () {
  7247. self.emit('error', err)
  7248. })
  7249. return
  7250. }
  7251. }
  7252. }
  7253. /**
  7254. * Checks if xhr.status is readable and non-zero, indicating no error.
  7255. * Even though the spec says it should be available in readyState 3,
  7256. * accessing it throws an exception in IE8
  7257. */
  7258. function statusValid (xhr) {
  7259. try {
  7260. var status = xhr.status
  7261. return (status !== null && status !== 0)
  7262. } catch (e) {
  7263. return false
  7264. }
  7265. }
  7266. ClientRequest.prototype._onXHRProgress = function () {
  7267. var self = this
  7268. if (!statusValid(self._xhr) || self._destroyed)
  7269. return
  7270. if (!self._response)
  7271. self._connect()
  7272. self._response._onXHRProgress()
  7273. }
  7274. ClientRequest.prototype._connect = function () {
  7275. var self = this
  7276. if (self._destroyed)
  7277. return
  7278. self._response = new IncomingMessage(self._xhr, self._fetchResponse, self._mode, self._fetchTimer)
  7279. self._response.on('error', function(err) {
  7280. self.emit('error', err)
  7281. })
  7282. self.emit('response', self._response)
  7283. }
  7284. ClientRequest.prototype._write = function (chunk, encoding, cb) {
  7285. var self = this
  7286. self._body.push(chunk)
  7287. cb()
  7288. }
  7289. ClientRequest.prototype.abort = ClientRequest.prototype.destroy = function () {
  7290. var self = this
  7291. self._destroyed = true
  7292. global.clearTimeout(self._fetchTimer)
  7293. if (self._response)
  7294. self._response._destroyed = true
  7295. if (self._xhr)
  7296. self._xhr.abort()
  7297. else if (self._fetchAbortController)
  7298. self._fetchAbortController.abort()
  7299. }
  7300. ClientRequest.prototype.end = function (data, encoding, cb) {
  7301. var self = this
  7302. if (typeof data === 'function') {
  7303. cb = data
  7304. data = undefined
  7305. }
  7306. stream.Writable.prototype.end.call(self, data, encoding, cb)
  7307. }
  7308. ClientRequest.prototype.flushHeaders = function () {}
  7309. ClientRequest.prototype.setTimeout = function () {}
  7310. ClientRequest.prototype.setNoDelay = function () {}
  7311. ClientRequest.prototype.setSocketKeepAlive = function () {}
  7312. // Taken from http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader%28%29-method
  7313. var unsafeHeaders = [
  7314. 'accept-charset',
  7315. 'accept-encoding',
  7316. 'access-control-request-headers',
  7317. 'access-control-request-method',
  7318. 'connection',
  7319. 'content-length',
  7320. 'cookie',
  7321. 'cookie2',
  7322. 'date',
  7323. 'dnt',
  7324. 'expect',
  7325. 'host',
  7326. 'keep-alive',
  7327. 'origin',
  7328. 'referer',
  7329. 'te',
  7330. 'trailer',
  7331. 'transfer-encoding',
  7332. 'upgrade',
  7333. 'via'
  7334. ]
  7335. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer)
  7336. },{"./capability":80,"./response":82,"_process":393,"buffer":98,"inherits":307,"readable-stream":97}],82:[function(require,module,exports){
  7337. (function (process,global,Buffer){
  7338. var capability = require('./capability')
  7339. var inherits = require('inherits')
  7340. var stream = require('readable-stream')
  7341. var rStates = exports.readyStates = {
  7342. UNSENT: 0,
  7343. OPENED: 1,
  7344. HEADERS_RECEIVED: 2,
  7345. LOADING: 3,
  7346. DONE: 4
  7347. }
  7348. var IncomingMessage = exports.IncomingMessage = function (xhr, response, mode, fetchTimer) {
  7349. var self = this
  7350. stream.Readable.call(self)
  7351. self._mode = mode
  7352. self.headers = {}
  7353. self.rawHeaders = []
  7354. self.trailers = {}
  7355. self.rawTrailers = []
  7356. // Fake the 'close' event, but only once 'end' fires
  7357. self.on('end', function () {
  7358. // The nextTick is necessary to prevent the 'request' module from causing an infinite loop
  7359. process.nextTick(function () {
  7360. self.emit('close')
  7361. })
  7362. })
  7363. if (mode === 'fetch') {
  7364. self._fetchResponse = response
  7365. self.url = response.url
  7366. self.statusCode = response.status
  7367. self.statusMessage = response.statusText
  7368. response.headers.forEach(function (header, key){
  7369. self.headers[key.toLowerCase()] = header
  7370. self.rawHeaders.push(key, header)
  7371. })
  7372. if (capability.writableStream) {
  7373. var writable = new WritableStream({
  7374. write: function (chunk) {
  7375. return new Promise(function (resolve, reject) {
  7376. if (self._destroyed) {
  7377. reject()
  7378. } else if(self.push(Buffer.from(chunk))) {
  7379. resolve()
  7380. } else {
  7381. self._resumeFetch = resolve
  7382. }
  7383. })
  7384. },
  7385. close: function () {
  7386. global.clearTimeout(fetchTimer)
  7387. if (!self._destroyed)
  7388. self.push(null)
  7389. },
  7390. abort: function (err) {
  7391. if (!self._destroyed)
  7392. self.emit('error', err)
  7393. }
  7394. })
  7395. try {
  7396. response.body.pipeTo(writable).catch(function (err) {
  7397. global.clearTimeout(fetchTimer)
  7398. if (!self._destroyed)
  7399. self.emit('error', err)
  7400. })
  7401. return
  7402. } catch (e) {} // pipeTo method isn't defined. Can't find a better way to feature test this
  7403. }
  7404. // fallback for when writableStream or pipeTo aren't available
  7405. var reader = response.body.getReader()
  7406. function read () {
  7407. reader.read().then(function (result) {
  7408. if (self._destroyed)
  7409. return
  7410. if (result.done) {
  7411. global.clearTimeout(fetchTimer)
  7412. self.push(null)
  7413. return
  7414. }
  7415. self.push(Buffer.from(result.value))
  7416. read()
  7417. }).catch(function (err) {
  7418. global.clearTimeout(fetchTimer)
  7419. if (!self._destroyed)
  7420. self.emit('error', err)
  7421. })
  7422. }
  7423. read()
  7424. } else {
  7425. self._xhr = xhr
  7426. self._pos = 0
  7427. self.url = xhr.responseURL
  7428. self.statusCode = xhr.status
  7429. self.statusMessage = xhr.statusText
  7430. var headers = xhr.getAllResponseHeaders().split(/\r?\n/)
  7431. headers.forEach(function (header) {
  7432. var matches = header.match(/^([^:]+):\s*(.*)/)
  7433. if (matches) {
  7434. var key = matches[1].toLowerCase()
  7435. if (key === 'set-cookie') {
  7436. if (self.headers[key] === undefined) {
  7437. self.headers[key] = []
  7438. }
  7439. self.headers[key].push(matches[2])
  7440. } else if (self.headers[key] !== undefined) {
  7441. self.headers[key] += ', ' + matches[2]
  7442. } else {
  7443. self.headers[key] = matches[2]
  7444. }
  7445. self.rawHeaders.push(matches[1], matches[2])
  7446. }
  7447. })
  7448. self._charset = 'x-user-defined'
  7449. if (!capability.overrideMimeType) {
  7450. var mimeType = self.rawHeaders['mime-type']
  7451. if (mimeType) {
  7452. var charsetMatch = mimeType.match(/;\s*charset=([^;])(;|$)/)
  7453. if (charsetMatch) {
  7454. self._charset = charsetMatch[1].toLowerCase()
  7455. }
  7456. }
  7457. if (!self._charset)
  7458. self._charset = 'utf-8' // best guess
  7459. }
  7460. }
  7461. }
  7462. inherits(IncomingMessage, stream.Readable)
  7463. IncomingMessage.prototype._read = function () {
  7464. var self = this
  7465. var resolve = self._resumeFetch
  7466. if (resolve) {
  7467. self._resumeFetch = null
  7468. resolve()
  7469. }
  7470. }
  7471. IncomingMessage.prototype._onXHRProgress = function () {
  7472. var self = this
  7473. var xhr = self._xhr
  7474. var response = null
  7475. switch (self._mode) {
  7476. case 'text':
  7477. response = xhr.responseText
  7478. if (response.length > self._pos) {
  7479. var newData = response.substr(self._pos)
  7480. if (self._charset === 'x-user-defined') {
  7481. var buffer = Buffer.alloc(newData.length)
  7482. for (var i = 0; i < newData.length; i++)
  7483. buffer[i] = newData.charCodeAt(i) & 0xff
  7484. self.push(buffer)
  7485. } else {
  7486. self.push(newData, self._charset)
  7487. }
  7488. self._pos = response.length
  7489. }
  7490. break
  7491. case 'arraybuffer':
  7492. if (xhr.readyState !== rStates.DONE || !xhr.response)
  7493. break
  7494. response = xhr.response
  7495. self.push(Buffer.from(new Uint8Array(response)))
  7496. break
  7497. case 'moz-chunked-arraybuffer': // take whole
  7498. response = xhr.response
  7499. if (xhr.readyState !== rStates.LOADING || !response)
  7500. break
  7501. self.push(Buffer.from(new Uint8Array(response)))
  7502. break
  7503. case 'ms-stream':
  7504. response = xhr.response
  7505. if (xhr.readyState !== rStates.LOADING)
  7506. break
  7507. var reader = new global.MSStreamReader()
  7508. reader.onprogress = function () {
  7509. if (reader.result.byteLength > self._pos) {
  7510. self.push(Buffer.from(new Uint8Array(reader.result.slice(self._pos))))
  7511. self._pos = reader.result.byteLength
  7512. }
  7513. }
  7514. reader.onload = function () {
  7515. self.push(null)
  7516. }
  7517. // reader.onerror = ??? // TODO: this
  7518. reader.readAsArrayBuffer(response)
  7519. break
  7520. }
  7521. // The ms-stream case handles end separately in reader.onload()
  7522. if (self._xhr.readyState === rStates.DONE && self._mode !== 'ms-stream') {
  7523. self.push(null)
  7524. }
  7525. }
  7526. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer)
  7527. },{"./capability":80,"_process":393,"buffer":98,"inherits":307,"readable-stream":97}],83:[function(require,module,exports){
  7528. 'use strict';
  7529. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  7530. var codes = {};
  7531. function createErrorType(code, message, Base) {
  7532. if (!Base) {
  7533. Base = Error;
  7534. }
  7535. function getMessage(arg1, arg2, arg3) {
  7536. if (typeof message === 'string') {
  7537. return message;
  7538. } else {
  7539. return message(arg1, arg2, arg3);
  7540. }
  7541. }
  7542. var NodeError =
  7543. /*#__PURE__*/
  7544. function (_Base) {
  7545. _inheritsLoose(NodeError, _Base);
  7546. function NodeError(arg1, arg2, arg3) {
  7547. return _Base.call(this, getMessage(arg1, arg2, arg3)) || this;
  7548. }
  7549. return NodeError;
  7550. }(Base);
  7551. NodeError.prototype.name = Base.name;
  7552. NodeError.prototype.code = code;
  7553. codes[code] = NodeError;
  7554. } // https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js
  7555. function oneOf(expected, thing) {
  7556. if (Array.isArray(expected)) {
  7557. var len = expected.length;
  7558. expected = expected.map(function (i) {
  7559. return String(i);
  7560. });
  7561. if (len > 2) {
  7562. return "one of ".concat(thing, " ").concat(expected.slice(0, len - 1).join(', '), ", or ") + expected[len - 1];
  7563. } else if (len === 2) {
  7564. return "one of ".concat(thing, " ").concat(expected[0], " or ").concat(expected[1]);
  7565. } else {
  7566. return "of ".concat(thing, " ").concat(expected[0]);
  7567. }
  7568. } else {
  7569. return "of ".concat(thing, " ").concat(String(expected));
  7570. }
  7571. } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
  7572. function startsWith(str, search, pos) {
  7573. return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
  7574. } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
  7575. function endsWith(str, search, this_len) {
  7576. if (this_len === undefined || this_len > str.length) {
  7577. this_len = str.length;
  7578. }
  7579. return str.substring(this_len - search.length, this_len) === search;
  7580. } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
  7581. function includes(str, search, start) {
  7582. if (typeof start !== 'number') {
  7583. start = 0;
  7584. }
  7585. if (start + search.length > str.length) {
  7586. return false;
  7587. } else {
  7588. return str.indexOf(search, start) !== -1;
  7589. }
  7590. }
  7591. createErrorType('ERR_INVALID_OPT_VALUE', function (name, value) {
  7592. return 'The value "' + value + '" is invalid for option "' + name + '"';
  7593. }, TypeError);
  7594. createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) {
  7595. // determiner: 'must be' or 'must not be'
  7596. var determiner;
  7597. if (typeof expected === 'string' && startsWith(expected, 'not ')) {
  7598. determiner = 'must not be';
  7599. expected = expected.replace(/^not /, '');
  7600. } else {
  7601. determiner = 'must be';
  7602. }
  7603. var msg;
  7604. if (endsWith(name, ' argument')) {
  7605. // For cases like 'first argument'
  7606. msg = "The ".concat(name, " ").concat(determiner, " ").concat(oneOf(expected, 'type'));
  7607. } else {
  7608. var type = includes(name, '.') ? 'property' : 'argument';
  7609. msg = "The \"".concat(name, "\" ").concat(type, " ").concat(determiner, " ").concat(oneOf(expected, 'type'));
  7610. }
  7611. msg += ". Received type ".concat(typeof actual);
  7612. return msg;
  7613. }, TypeError);
  7614. createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF');
  7615. createErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) {
  7616. return 'The ' + name + ' method is not implemented';
  7617. });
  7618. createErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close');
  7619. createErrorType('ERR_STREAM_DESTROYED', function (name) {
  7620. return 'Cannot call ' + name + ' after a stream was destroyed';
  7621. });
  7622. createErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times');
  7623. createErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable');
  7624. createErrorType('ERR_STREAM_WRITE_AFTER_END', 'write after end');
  7625. createErrorType('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError);
  7626. createErrorType('ERR_UNKNOWN_ENCODING', function (arg) {
  7627. return 'Unknown encoding: ' + arg;
  7628. }, TypeError);
  7629. createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event');
  7630. module.exports.codes = codes;
  7631. },{}],84:[function(require,module,exports){
  7632. (function (process){
  7633. // Copyright Joyent, Inc. and other Node contributors.
  7634. //
  7635. // Permission is hereby granted, free of charge, to any person obtaining a
  7636. // copy of this software and associated documentation files (the
  7637. // "Software"), to deal in the Software without restriction, including
  7638. // without limitation the rights to use, copy, modify, merge, publish,
  7639. // distribute, sublicense, and/or sell copies of the Software, and to permit
  7640. // persons to whom the Software is furnished to do so, subject to the
  7641. // following conditions:
  7642. //
  7643. // The above copyright notice and this permission notice shall be included
  7644. // in all copies or substantial portions of the Software.
  7645. //
  7646. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  7647. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  7648. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  7649. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  7650. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  7651. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  7652. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  7653. // a duplex stream is just a stream that is both readable and writable.
  7654. // Since JS doesn't have multiple prototypal inheritance, this class
  7655. // prototypally inherits from Readable, and then parasitically from
  7656. // Writable.
  7657. 'use strict';
  7658. /*<replacement>*/
  7659. var objectKeys = Object.keys || function (obj) {
  7660. var keys = [];
  7661. for (var key in obj) {
  7662. keys.push(key);
  7663. }
  7664. return keys;
  7665. };
  7666. /*</replacement>*/
  7667. module.exports = Duplex;
  7668. var Readable = require('./_stream_readable');
  7669. var Writable = require('./_stream_writable');
  7670. require('inherits')(Duplex, Readable);
  7671. {
  7672. // Allow the keys array to be GC'ed.
  7673. var keys = objectKeys(Writable.prototype);
  7674. for (var v = 0; v < keys.length; v++) {
  7675. var method = keys[v];
  7676. if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
  7677. }
  7678. }
  7679. function Duplex(options) {
  7680. if (!(this instanceof Duplex)) return new Duplex(options);
  7681. Readable.call(this, options);
  7682. Writable.call(this, options);
  7683. this.allowHalfOpen = true;
  7684. if (options) {
  7685. if (options.readable === false) this.readable = false;
  7686. if (options.writable === false) this.writable = false;
  7687. if (options.allowHalfOpen === false) {
  7688. this.allowHalfOpen = false;
  7689. this.once('end', onend);
  7690. }
  7691. }
  7692. }
  7693. Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
  7694. // making it explicit this property is not enumerable
  7695. // because otherwise some prototype manipulation in
  7696. // userland will fail
  7697. enumerable: false,
  7698. get: function get() {
  7699. return this._writableState.highWaterMark;
  7700. }
  7701. });
  7702. Object.defineProperty(Duplex.prototype, 'writableBuffer', {
  7703. // making it explicit this property is not enumerable
  7704. // because otherwise some prototype manipulation in
  7705. // userland will fail
  7706. enumerable: false,
  7707. get: function get() {
  7708. return this._writableState && this._writableState.getBuffer();
  7709. }
  7710. });
  7711. Object.defineProperty(Duplex.prototype, 'writableLength', {
  7712. // making it explicit this property is not enumerable
  7713. // because otherwise some prototype manipulation in
  7714. // userland will fail
  7715. enumerable: false,
  7716. get: function get() {
  7717. return this._writableState.length;
  7718. }
  7719. }); // the no-half-open enforcer
  7720. function onend() {
  7721. // If the writable side ended, then we're ok.
  7722. if (this._writableState.ended) return; // no more data can be written.
  7723. // But allow more writes to happen in this tick.
  7724. process.nextTick(onEndNT, this);
  7725. }
  7726. function onEndNT(self) {
  7727. self.end();
  7728. }
  7729. Object.defineProperty(Duplex.prototype, 'destroyed', {
  7730. // making it explicit this property is not enumerable
  7731. // because otherwise some prototype manipulation in
  7732. // userland will fail
  7733. enumerable: false,
  7734. get: function get() {
  7735. if (this._readableState === undefined || this._writableState === undefined) {
  7736. return false;
  7737. }
  7738. return this._readableState.destroyed && this._writableState.destroyed;
  7739. },
  7740. set: function set(value) {
  7741. // we ignore the value if the stream
  7742. // has not been initialized yet
  7743. if (this._readableState === undefined || this._writableState === undefined) {
  7744. return;
  7745. } // backward compatibility, the user is explicitly
  7746. // managing destroyed
  7747. this._readableState.destroyed = value;
  7748. this._writableState.destroyed = value;
  7749. }
  7750. });
  7751. }).call(this,require('_process'))
  7752. },{"./_stream_readable":86,"./_stream_writable":88,"_process":393,"inherits":307}],85:[function(require,module,exports){
  7753. // Copyright Joyent, Inc. and other Node contributors.
  7754. //
  7755. // Permission is hereby granted, free of charge, to any person obtaining a
  7756. // copy of this software and associated documentation files (the
  7757. // "Software"), to deal in the Software without restriction, including
  7758. // without limitation the rights to use, copy, modify, merge, publish,
  7759. // distribute, sublicense, and/or sell copies of the Software, and to permit
  7760. // persons to whom the Software is furnished to do so, subject to the
  7761. // following conditions:
  7762. //
  7763. // The above copyright notice and this permission notice shall be included
  7764. // in all copies or substantial portions of the Software.
  7765. //
  7766. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  7767. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  7768. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  7769. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  7770. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  7771. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  7772. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  7773. // a passthrough stream.
  7774. // basically just the most minimal sort of Transform stream.
  7775. // Every written chunk gets output as-is.
  7776. 'use strict';
  7777. module.exports = PassThrough;
  7778. var Transform = require('./_stream_transform');
  7779. require('inherits')(PassThrough, Transform);
  7780. function PassThrough(options) {
  7781. if (!(this instanceof PassThrough)) return new PassThrough(options);
  7782. Transform.call(this, options);
  7783. }
  7784. PassThrough.prototype._transform = function (chunk, encoding, cb) {
  7785. cb(null, chunk);
  7786. };
  7787. },{"./_stream_transform":87,"inherits":307}],86:[function(require,module,exports){
  7788. (function (process,global){
  7789. // Copyright Joyent, Inc. and other Node contributors.
  7790. //
  7791. // Permission is hereby granted, free of charge, to any person obtaining a
  7792. // copy of this software and associated documentation files (the
  7793. // "Software"), to deal in the Software without restriction, including
  7794. // without limitation the rights to use, copy, modify, merge, publish,
  7795. // distribute, sublicense, and/or sell copies of the Software, and to permit
  7796. // persons to whom the Software is furnished to do so, subject to the
  7797. // following conditions:
  7798. //
  7799. // The above copyright notice and this permission notice shall be included
  7800. // in all copies or substantial portions of the Software.
  7801. //
  7802. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  7803. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  7804. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  7805. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  7806. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  7807. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  7808. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  7809. 'use strict';
  7810. module.exports = Readable;
  7811. /*<replacement>*/
  7812. var Duplex;
  7813. /*</replacement>*/
  7814. Readable.ReadableState = ReadableState;
  7815. /*<replacement>*/
  7816. var EE = require('events').EventEmitter;
  7817. var EElistenerCount = function EElistenerCount(emitter, type) {
  7818. return emitter.listeners(type).length;
  7819. };
  7820. /*</replacement>*/
  7821. /*<replacement>*/
  7822. var Stream = require('./internal/streams/stream');
  7823. /*</replacement>*/
  7824. var Buffer = require('buffer').Buffer;
  7825. var OurUint8Array = global.Uint8Array || function () {};
  7826. function _uint8ArrayToBuffer(chunk) {
  7827. return Buffer.from(chunk);
  7828. }
  7829. function _isUint8Array(obj) {
  7830. return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
  7831. }
  7832. /*<replacement>*/
  7833. var debugUtil = require('util');
  7834. var debug;
  7835. if (debugUtil && debugUtil.debuglog) {
  7836. debug = debugUtil.debuglog('stream');
  7837. } else {
  7838. debug = function debug() {};
  7839. }
  7840. /*</replacement>*/
  7841. var BufferList = require('./internal/streams/buffer_list');
  7842. var destroyImpl = require('./internal/streams/destroy');
  7843. var _require = require('./internal/streams/state'),
  7844. getHighWaterMark = _require.getHighWaterMark;
  7845. var _require$codes = require('../errors').codes,
  7846. ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
  7847. ERR_STREAM_PUSH_AFTER_EOF = _require$codes.ERR_STREAM_PUSH_AFTER_EOF,
  7848. ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
  7849. ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT; // Lazy loaded to improve the startup performance.
  7850. var StringDecoder;
  7851. var createReadableStreamAsyncIterator;
  7852. var from;
  7853. require('inherits')(Readable, Stream);
  7854. var errorOrDestroy = destroyImpl.errorOrDestroy;
  7855. var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
  7856. function prependListener(emitter, event, fn) {
  7857. // Sadly this is not cacheable as some libraries bundle their own
  7858. // event emitter implementation with them.
  7859. if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); // This is a hack to make sure that our error handler is attached before any
  7860. // userland ones. NEVER DO THIS. This is here only because this code needs
  7861. // to continue to work with older versions of Node.js that do not include
  7862. // the prependListener() method. The goal is to eventually remove this hack.
  7863. if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
  7864. }
  7865. function ReadableState(options, stream, isDuplex) {
  7866. Duplex = Duplex || require('./_stream_duplex');
  7867. options = options || {}; // Duplex streams are both readable and writable, but share
  7868. // the same options object.
  7869. // However, some cases require setting options to different
  7870. // values for the readable and the writable sides of the duplex stream.
  7871. // These options can be provided separately as readableXXX and writableXXX.
  7872. if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag. Used to make read(n) ignore n and to
  7873. // make all the buffer merging and length checks go away
  7874. this.objectMode = !!options.objectMode;
  7875. if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; // the point at which it stops calling _read() to fill the buffer
  7876. // Note: 0 is a valid value, means "don't call _read preemptively ever"
  7877. this.highWaterMark = getHighWaterMark(this, options, 'readableHighWaterMark', isDuplex); // A linked list is used to store data chunks instead of an array because the
  7878. // linked list can remove elements from the beginning faster than
  7879. // array.shift()
  7880. this.buffer = new BufferList();
  7881. this.length = 0;
  7882. this.pipes = null;
  7883. this.pipesCount = 0;
  7884. this.flowing = null;
  7885. this.ended = false;
  7886. this.endEmitted = false;
  7887. this.reading = false; // a flag to be able to tell if the event 'readable'/'data' is emitted
  7888. // immediately, or on a later tick. We set this to true at first, because
  7889. // any actions that shouldn't happen until "later" should generally also
  7890. // not happen before the first read call.
  7891. this.sync = true; // whenever we return null, then we set a flag to say
  7892. // that we're awaiting a 'readable' event emission.
  7893. this.needReadable = false;
  7894. this.emittedReadable = false;
  7895. this.readableListening = false;
  7896. this.resumeScheduled = false;
  7897. this.paused = true; // Should close be emitted on destroy. Defaults to true.
  7898. this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'end' (and potentially 'finish')
  7899. this.autoDestroy = !!options.autoDestroy; // has it been destroyed
  7900. this.destroyed = false; // Crypto is kind of old and crusty. Historically, its default string
  7901. // encoding is 'binary' so we have to make this configurable.
  7902. // Everything else in the universe uses 'utf8', though.
  7903. this.defaultEncoding = options.defaultEncoding || 'utf8'; // the number of writers that are awaiting a drain event in .pipe()s
  7904. this.awaitDrain = 0; // if true, a maybeReadMore has been scheduled
  7905. this.readingMore = false;
  7906. this.decoder = null;
  7907. this.encoding = null;
  7908. if (options.encoding) {
  7909. if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
  7910. this.decoder = new StringDecoder(options.encoding);
  7911. this.encoding = options.encoding;
  7912. }
  7913. }
  7914. function Readable(options) {
  7915. Duplex = Duplex || require('./_stream_duplex');
  7916. if (!(this instanceof Readable)) return new Readable(options); // Checking for a Stream.Duplex instance is faster here instead of inside
  7917. // the ReadableState constructor, at least with V8 6.5
  7918. var isDuplex = this instanceof Duplex;
  7919. this._readableState = new ReadableState(options, this, isDuplex); // legacy
  7920. this.readable = true;
  7921. if (options) {
  7922. if (typeof options.read === 'function') this._read = options.read;
  7923. if (typeof options.destroy === 'function') this._destroy = options.destroy;
  7924. }
  7925. Stream.call(this);
  7926. }
  7927. Object.defineProperty(Readable.prototype, 'destroyed', {
  7928. // making it explicit this property is not enumerable
  7929. // because otherwise some prototype manipulation in
  7930. // userland will fail
  7931. enumerable: false,
  7932. get: function get() {
  7933. if (this._readableState === undefined) {
  7934. return false;
  7935. }
  7936. return this._readableState.destroyed;
  7937. },
  7938. set: function set(value) {
  7939. // we ignore the value if the stream
  7940. // has not been initialized yet
  7941. if (!this._readableState) {
  7942. return;
  7943. } // backward compatibility, the user is explicitly
  7944. // managing destroyed
  7945. this._readableState.destroyed = value;
  7946. }
  7947. });
  7948. Readable.prototype.destroy = destroyImpl.destroy;
  7949. Readable.prototype._undestroy = destroyImpl.undestroy;
  7950. Readable.prototype._destroy = function (err, cb) {
  7951. cb(err);
  7952. }; // Manually shove something into the read() buffer.
  7953. // This returns true if the highWaterMark has not been hit yet,
  7954. // similar to how Writable.write() returns true if you should
  7955. // write() some more.
  7956. Readable.prototype.push = function (chunk, encoding) {
  7957. var state = this._readableState;
  7958. var skipChunkCheck;
  7959. if (!state.objectMode) {
  7960. if (typeof chunk === 'string') {
  7961. encoding = encoding || state.defaultEncoding;
  7962. if (encoding !== state.encoding) {
  7963. chunk = Buffer.from(chunk, encoding);
  7964. encoding = '';
  7965. }
  7966. skipChunkCheck = true;
  7967. }
  7968. } else {
  7969. skipChunkCheck = true;
  7970. }
  7971. return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
  7972. }; // Unshift should *always* be something directly out of read()
  7973. Readable.prototype.unshift = function (chunk) {
  7974. return readableAddChunk(this, chunk, null, true, false);
  7975. };
  7976. function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
  7977. debug('readableAddChunk', chunk);
  7978. var state = stream._readableState;
  7979. if (chunk === null) {
  7980. state.reading = false;
  7981. onEofChunk(stream, state);
  7982. } else {
  7983. var er;
  7984. if (!skipChunkCheck) er = chunkInvalid(state, chunk);
  7985. if (er) {
  7986. errorOrDestroy(stream, er);
  7987. } else if (state.objectMode || chunk && chunk.length > 0) {
  7988. if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
  7989. chunk = _uint8ArrayToBuffer(chunk);
  7990. }
  7991. if (addToFront) {
  7992. if (state.endEmitted) errorOrDestroy(stream, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT());else addChunk(stream, state, chunk, true);
  7993. } else if (state.ended) {
  7994. errorOrDestroy(stream, new ERR_STREAM_PUSH_AFTER_EOF());
  7995. } else if (state.destroyed) {
  7996. return false;
  7997. } else {
  7998. state.reading = false;
  7999. if (state.decoder && !encoding) {
  8000. chunk = state.decoder.write(chunk);
  8001. if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
  8002. } else {
  8003. addChunk(stream, state, chunk, false);
  8004. }
  8005. }
  8006. } else if (!addToFront) {
  8007. state.reading = false;
  8008. maybeReadMore(stream, state);
  8009. }
  8010. } // We can push more data if we are below the highWaterMark.
  8011. // Also, if we have no data yet, we can stand some more bytes.
  8012. // This is to work around cases where hwm=0, such as the repl.
  8013. return !state.ended && (state.length < state.highWaterMark || state.length === 0);
  8014. }
  8015. function addChunk(stream, state, chunk, addToFront) {
  8016. if (state.flowing && state.length === 0 && !state.sync) {
  8017. state.awaitDrain = 0;
  8018. stream.emit('data', chunk);
  8019. } else {
  8020. // update the buffer info.
  8021. state.length += state.objectMode ? 1 : chunk.length;
  8022. if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
  8023. if (state.needReadable) emitReadable(stream);
  8024. }
  8025. maybeReadMore(stream, state);
  8026. }
  8027. function chunkInvalid(state, chunk) {
  8028. var er;
  8029. if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
  8030. er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer', 'Uint8Array'], chunk);
  8031. }
  8032. return er;
  8033. }
  8034. Readable.prototype.isPaused = function () {
  8035. return this._readableState.flowing === false;
  8036. }; // backwards compatibility.
  8037. Readable.prototype.setEncoding = function (enc) {
  8038. if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
  8039. var decoder = new StringDecoder(enc);
  8040. this._readableState.decoder = decoder; // If setEncoding(null), decoder.encoding equals utf8
  8041. this._readableState.encoding = this._readableState.decoder.encoding; // Iterate over current buffer to convert already stored Buffers:
  8042. var p = this._readableState.buffer.head;
  8043. var content = '';
  8044. while (p !== null) {
  8045. content += decoder.write(p.data);
  8046. p = p.next;
  8047. }
  8048. this._readableState.buffer.clear();
  8049. if (content !== '') this._readableState.buffer.push(content);
  8050. this._readableState.length = content.length;
  8051. return this;
  8052. }; // Don't raise the hwm > 1GB
  8053. var MAX_HWM = 0x40000000;
  8054. function computeNewHighWaterMark(n) {
  8055. if (n >= MAX_HWM) {
  8056. // TODO(ronag): Throw ERR_VALUE_OUT_OF_RANGE.
  8057. n = MAX_HWM;
  8058. } else {
  8059. // Get the next highest power of 2 to prevent increasing hwm excessively in
  8060. // tiny amounts
  8061. n--;
  8062. n |= n >>> 1;
  8063. n |= n >>> 2;
  8064. n |= n >>> 4;
  8065. n |= n >>> 8;
  8066. n |= n >>> 16;
  8067. n++;
  8068. }
  8069. return n;
  8070. } // This function is designed to be inlinable, so please take care when making
  8071. // changes to the function body.
  8072. function howMuchToRead(n, state) {
  8073. if (n <= 0 || state.length === 0 && state.ended) return 0;
  8074. if (state.objectMode) return 1;
  8075. if (n !== n) {
  8076. // Only flow one buffer at a time
  8077. if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
  8078. } // If we're asking for more than the current hwm, then raise the hwm.
  8079. if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
  8080. if (n <= state.length) return n; // Don't have enough
  8081. if (!state.ended) {
  8082. state.needReadable = true;
  8083. return 0;
  8084. }
  8085. return state.length;
  8086. } // you can override either this method, or the async _read(n) below.
  8087. Readable.prototype.read = function (n) {
  8088. debug('read', n);
  8089. n = parseInt(n, 10);
  8090. var state = this._readableState;
  8091. var nOrig = n;
  8092. if (n !== 0) state.emittedReadable = false; // if we're doing read(0) to trigger a readable event, but we
  8093. // already have a bunch of data in the buffer, then just trigger
  8094. // the 'readable' event and move on.
  8095. if (n === 0 && state.needReadable && ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)) {
  8096. debug('read: emitReadable', state.length, state.ended);
  8097. if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
  8098. return null;
  8099. }
  8100. n = howMuchToRead(n, state); // if we've ended, and we're now clear, then finish it up.
  8101. if (n === 0 && state.ended) {
  8102. if (state.length === 0) endReadable(this);
  8103. return null;
  8104. } // All the actual chunk generation logic needs to be
  8105. // *below* the call to _read. The reason is that in certain
  8106. // synthetic stream cases, such as passthrough streams, _read
  8107. // may be a completely synchronous operation which may change
  8108. // the state of the read buffer, providing enough data when
  8109. // before there was *not* enough.
  8110. //
  8111. // So, the steps are:
  8112. // 1. Figure out what the state of things will be after we do
  8113. // a read from the buffer.
  8114. //
  8115. // 2. If that resulting state will trigger a _read, then call _read.
  8116. // Note that this may be asynchronous, or synchronous. Yes, it is
  8117. // deeply ugly to write APIs this way, but that still doesn't mean
  8118. // that the Readable class should behave improperly, as streams are
  8119. // designed to be sync/async agnostic.
  8120. // Take note if the _read call is sync or async (ie, if the read call
  8121. // has returned yet), so that we know whether or not it's safe to emit
  8122. // 'readable' etc.
  8123. //
  8124. // 3. Actually pull the requested chunks out of the buffer and return.
  8125. // if we need a readable event, then we need to do some reading.
  8126. var doRead = state.needReadable;
  8127. debug('need readable', doRead); // if we currently have less than the highWaterMark, then also read some
  8128. if (state.length === 0 || state.length - n < state.highWaterMark) {
  8129. doRead = true;
  8130. debug('length less than watermark', doRead);
  8131. } // however, if we've ended, then there's no point, and if we're already
  8132. // reading, then it's unnecessary.
  8133. if (state.ended || state.reading) {
  8134. doRead = false;
  8135. debug('reading or ended', doRead);
  8136. } else if (doRead) {
  8137. debug('do read');
  8138. state.reading = true;
  8139. state.sync = true; // if the length is currently zero, then we *need* a readable event.
  8140. if (state.length === 0) state.needReadable = true; // call internal read method
  8141. this._read(state.highWaterMark);
  8142. state.sync = false; // If _read pushed data synchronously, then `reading` will be false,
  8143. // and we need to re-evaluate how much data we can return to the user.
  8144. if (!state.reading) n = howMuchToRead(nOrig, state);
  8145. }
  8146. var ret;
  8147. if (n > 0) ret = fromList(n, state);else ret = null;
  8148. if (ret === null) {
  8149. state.needReadable = state.length <= state.highWaterMark;
  8150. n = 0;
  8151. } else {
  8152. state.length -= n;
  8153. state.awaitDrain = 0;
  8154. }
  8155. if (state.length === 0) {
  8156. // If we have nothing in the buffer, then we want to know
  8157. // as soon as we *do* get something into the buffer.
  8158. if (!state.ended) state.needReadable = true; // If we tried to read() past the EOF, then emit end on the next tick.
  8159. if (nOrig !== n && state.ended) endReadable(this);
  8160. }
  8161. if (ret !== null) this.emit('data', ret);
  8162. return ret;
  8163. };
  8164. function onEofChunk(stream, state) {
  8165. debug('onEofChunk');
  8166. if (state.ended) return;
  8167. if (state.decoder) {
  8168. var chunk = state.decoder.end();
  8169. if (chunk && chunk.length) {
  8170. state.buffer.push(chunk);
  8171. state.length += state.objectMode ? 1 : chunk.length;
  8172. }
  8173. }
  8174. state.ended = true;
  8175. if (state.sync) {
  8176. // if we are sync, wait until next tick to emit the data.
  8177. // Otherwise we risk emitting data in the flow()
  8178. // the readable code triggers during a read() call
  8179. emitReadable(stream);
  8180. } else {
  8181. // emit 'readable' now to make sure it gets picked up.
  8182. state.needReadable = false;
  8183. if (!state.emittedReadable) {
  8184. state.emittedReadable = true;
  8185. emitReadable_(stream);
  8186. }
  8187. }
  8188. } // Don't emit readable right away in sync mode, because this can trigger
  8189. // another read() call => stack overflow. This way, it might trigger
  8190. // a nextTick recursion warning, but that's not so bad.
  8191. function emitReadable(stream) {
  8192. var state = stream._readableState;
  8193. debug('emitReadable', state.needReadable, state.emittedReadable);
  8194. state.needReadable = false;
  8195. if (!state.emittedReadable) {
  8196. debug('emitReadable', state.flowing);
  8197. state.emittedReadable = true;
  8198. process.nextTick(emitReadable_, stream);
  8199. }
  8200. }
  8201. function emitReadable_(stream) {
  8202. var state = stream._readableState;
  8203. debug('emitReadable_', state.destroyed, state.length, state.ended);
  8204. if (!state.destroyed && (state.length || state.ended)) {
  8205. stream.emit('readable');
  8206. state.emittedReadable = false;
  8207. } // The stream needs another readable event if
  8208. // 1. It is not flowing, as the flow mechanism will take
  8209. // care of it.
  8210. // 2. It is not ended.
  8211. // 3. It is below the highWaterMark, so we can schedule
  8212. // another readable later.
  8213. state.needReadable = !state.flowing && !state.ended && state.length <= state.highWaterMark;
  8214. flow(stream);
  8215. } // at this point, the user has presumably seen the 'readable' event,
  8216. // and called read() to consume some data. that may have triggered
  8217. // in turn another _read(n) call, in which case reading = true if
  8218. // it's in progress.
  8219. // However, if we're not ended, or reading, and the length < hwm,
  8220. // then go ahead and try to read some more preemptively.
  8221. function maybeReadMore(stream, state) {
  8222. if (!state.readingMore) {
  8223. state.readingMore = true;
  8224. process.nextTick(maybeReadMore_, stream, state);
  8225. }
  8226. }
  8227. function maybeReadMore_(stream, state) {
  8228. // Attempt to read more data if we should.
  8229. //
  8230. // The conditions for reading more data are (one of):
  8231. // - Not enough data buffered (state.length < state.highWaterMark). The loop
  8232. // is responsible for filling the buffer with enough data if such data
  8233. // is available. If highWaterMark is 0 and we are not in the flowing mode
  8234. // we should _not_ attempt to buffer any extra data. We'll get more data
  8235. // when the stream consumer calls read() instead.
  8236. // - No data in the buffer, and the stream is in flowing mode. In this mode
  8237. // the loop below is responsible for ensuring read() is called. Failing to
  8238. // call read here would abort the flow and there's no other mechanism for
  8239. // continuing the flow if the stream consumer has just subscribed to the
  8240. // 'data' event.
  8241. //
  8242. // In addition to the above conditions to keep reading data, the following
  8243. // conditions prevent the data from being read:
  8244. // - The stream has ended (state.ended).
  8245. // - There is already a pending 'read' operation (state.reading). This is a
  8246. // case where the the stream has called the implementation defined _read()
  8247. // method, but they are processing the call asynchronously and have _not_
  8248. // called push() with new data. In this case we skip performing more
  8249. // read()s. The execution ends in this method again after the _read() ends
  8250. // up calling push() with more data.
  8251. while (!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)) {
  8252. var len = state.length;
  8253. debug('maybeReadMore read 0');
  8254. stream.read(0);
  8255. if (len === state.length) // didn't get any data, stop spinning.
  8256. break;
  8257. }
  8258. state.readingMore = false;
  8259. } // abstract method. to be overridden in specific implementation classes.
  8260. // call cb(er, data) where data is <= n in length.
  8261. // for virtual (non-string, non-buffer) streams, "length" is somewhat
  8262. // arbitrary, and perhaps not very meaningful.
  8263. Readable.prototype._read = function (n) {
  8264. errorOrDestroy(this, new ERR_METHOD_NOT_IMPLEMENTED('_read()'));
  8265. };
  8266. Readable.prototype.pipe = function (dest, pipeOpts) {
  8267. var src = this;
  8268. var state = this._readableState;
  8269. switch (state.pipesCount) {
  8270. case 0:
  8271. state.pipes = dest;
  8272. break;
  8273. case 1:
  8274. state.pipes = [state.pipes, dest];
  8275. break;
  8276. default:
  8277. state.pipes.push(dest);
  8278. break;
  8279. }
  8280. state.pipesCount += 1;
  8281. debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
  8282. var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
  8283. var endFn = doEnd ? onend : unpipe;
  8284. if (state.endEmitted) process.nextTick(endFn);else src.once('end', endFn);
  8285. dest.on('unpipe', onunpipe);
  8286. function onunpipe(readable, unpipeInfo) {
  8287. debug('onunpipe');
  8288. if (readable === src) {
  8289. if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
  8290. unpipeInfo.hasUnpiped = true;
  8291. cleanup();
  8292. }
  8293. }
  8294. }
  8295. function onend() {
  8296. debug('onend');
  8297. dest.end();
  8298. } // when the dest drains, it reduces the awaitDrain counter
  8299. // on the source. This would be more elegant with a .once()
  8300. // handler in flow(), but adding and removing repeatedly is
  8301. // too slow.
  8302. var ondrain = pipeOnDrain(src);
  8303. dest.on('drain', ondrain);
  8304. var cleanedUp = false;
  8305. function cleanup() {
  8306. debug('cleanup'); // cleanup event handlers once the pipe is broken
  8307. dest.removeListener('close', onclose);
  8308. dest.removeListener('finish', onfinish);
  8309. dest.removeListener('drain', ondrain);
  8310. dest.removeListener('error', onerror);
  8311. dest.removeListener('unpipe', onunpipe);
  8312. src.removeListener('end', onend);
  8313. src.removeListener('end', unpipe);
  8314. src.removeListener('data', ondata);
  8315. cleanedUp = true; // if the reader is waiting for a drain event from this
  8316. // specific writer, then it would cause it to never start
  8317. // flowing again.
  8318. // So, if this is awaiting a drain, then we just call it now.
  8319. // If we don't know, then assume that we are waiting for one.
  8320. if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
  8321. }
  8322. src.on('data', ondata);
  8323. function ondata(chunk) {
  8324. debug('ondata');
  8325. var ret = dest.write(chunk);
  8326. debug('dest.write', ret);
  8327. if (ret === false) {
  8328. // If the user unpiped during `dest.write()`, it is possible
  8329. // to get stuck in a permanently paused state if that write
  8330. // also returned false.
  8331. // => Check whether `dest` is still a piping destination.
  8332. if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
  8333. debug('false write response, pause', state.awaitDrain);
  8334. state.awaitDrain++;
  8335. }
  8336. src.pause();
  8337. }
  8338. } // if the dest has an error, then stop piping into it.
  8339. // however, don't suppress the throwing behavior for this.
  8340. function onerror(er) {
  8341. debug('onerror', er);
  8342. unpipe();
  8343. dest.removeListener('error', onerror);
  8344. if (EElistenerCount(dest, 'error') === 0) errorOrDestroy(dest, er);
  8345. } // Make sure our error handler is attached before userland ones.
  8346. prependListener(dest, 'error', onerror); // Both close and finish should trigger unpipe, but only once.
  8347. function onclose() {
  8348. dest.removeListener('finish', onfinish);
  8349. unpipe();
  8350. }
  8351. dest.once('close', onclose);
  8352. function onfinish() {
  8353. debug('onfinish');
  8354. dest.removeListener('close', onclose);
  8355. unpipe();
  8356. }
  8357. dest.once('finish', onfinish);
  8358. function unpipe() {
  8359. debug('unpipe');
  8360. src.unpipe(dest);
  8361. } // tell the dest that it's being piped to
  8362. dest.emit('pipe', src); // start the flow if it hasn't been started already.
  8363. if (!state.flowing) {
  8364. debug('pipe resume');
  8365. src.resume();
  8366. }
  8367. return dest;
  8368. };
  8369. function pipeOnDrain(src) {
  8370. return function pipeOnDrainFunctionResult() {
  8371. var state = src._readableState;
  8372. debug('pipeOnDrain', state.awaitDrain);
  8373. if (state.awaitDrain) state.awaitDrain--;
  8374. if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
  8375. state.flowing = true;
  8376. flow(src);
  8377. }
  8378. };
  8379. }
  8380. Readable.prototype.unpipe = function (dest) {
  8381. var state = this._readableState;
  8382. var unpipeInfo = {
  8383. hasUnpiped: false
  8384. }; // if we're not piping anywhere, then do nothing.
  8385. if (state.pipesCount === 0) return this; // just one destination. most common case.
  8386. if (state.pipesCount === 1) {
  8387. // passed in one, but it's not the right one.
  8388. if (dest && dest !== state.pipes) return this;
  8389. if (!dest) dest = state.pipes; // got a match.
  8390. state.pipes = null;
  8391. state.pipesCount = 0;
  8392. state.flowing = false;
  8393. if (dest) dest.emit('unpipe', this, unpipeInfo);
  8394. return this;
  8395. } // slow case. multiple pipe destinations.
  8396. if (!dest) {
  8397. // remove all.
  8398. var dests = state.pipes;
  8399. var len = state.pipesCount;
  8400. state.pipes = null;
  8401. state.pipesCount = 0;
  8402. state.flowing = false;
  8403. for (var i = 0; i < len; i++) {
  8404. dests[i].emit('unpipe', this, {
  8405. hasUnpiped: false
  8406. });
  8407. }
  8408. return this;
  8409. } // try to find the right one.
  8410. var index = indexOf(state.pipes, dest);
  8411. if (index === -1) return this;
  8412. state.pipes.splice(index, 1);
  8413. state.pipesCount -= 1;
  8414. if (state.pipesCount === 1) state.pipes = state.pipes[0];
  8415. dest.emit('unpipe', this, unpipeInfo);
  8416. return this;
  8417. }; // set up data events if they are asked for
  8418. // Ensure readable listeners eventually get something
  8419. Readable.prototype.on = function (ev, fn) {
  8420. var res = Stream.prototype.on.call(this, ev, fn);
  8421. var state = this._readableState;
  8422. if (ev === 'data') {
  8423. // update readableListening so that resume() may be a no-op
  8424. // a few lines down. This is needed to support once('readable').
  8425. state.readableListening = this.listenerCount('readable') > 0; // Try start flowing on next tick if stream isn't explicitly paused
  8426. if (state.flowing !== false) this.resume();
  8427. } else if (ev === 'readable') {
  8428. if (!state.endEmitted && !state.readableListening) {
  8429. state.readableListening = state.needReadable = true;
  8430. state.flowing = false;
  8431. state.emittedReadable = false;
  8432. debug('on readable', state.length, state.reading);
  8433. if (state.length) {
  8434. emitReadable(this);
  8435. } else if (!state.reading) {
  8436. process.nextTick(nReadingNextTick, this);
  8437. }
  8438. }
  8439. }
  8440. return res;
  8441. };
  8442. Readable.prototype.addListener = Readable.prototype.on;
  8443. Readable.prototype.removeListener = function (ev, fn) {
  8444. var res = Stream.prototype.removeListener.call(this, ev, fn);
  8445. if (ev === 'readable') {
  8446. // We need to check if there is someone still listening to
  8447. // readable and reset the state. However this needs to happen
  8448. // after readable has been emitted but before I/O (nextTick) to
  8449. // support once('readable', fn) cycles. This means that calling
  8450. // resume within the same tick will have no
  8451. // effect.
  8452. process.nextTick(updateReadableListening, this);
  8453. }
  8454. return res;
  8455. };
  8456. Readable.prototype.removeAllListeners = function (ev) {
  8457. var res = Stream.prototype.removeAllListeners.apply(this, arguments);
  8458. if (ev === 'readable' || ev === undefined) {
  8459. // We need to check if there is someone still listening to
  8460. // readable and reset the state. However this needs to happen
  8461. // after readable has been emitted but before I/O (nextTick) to
  8462. // support once('readable', fn) cycles. This means that calling
  8463. // resume within the same tick will have no
  8464. // effect.
  8465. process.nextTick(updateReadableListening, this);
  8466. }
  8467. return res;
  8468. };
  8469. function updateReadableListening(self) {
  8470. var state = self._readableState;
  8471. state.readableListening = self.listenerCount('readable') > 0;
  8472. if (state.resumeScheduled && !state.paused) {
  8473. // flowing needs to be set to true now, otherwise
  8474. // the upcoming resume will not flow.
  8475. state.flowing = true; // crude way to check if we should resume
  8476. } else if (self.listenerCount('data') > 0) {
  8477. self.resume();
  8478. }
  8479. }
  8480. function nReadingNextTick(self) {
  8481. debug('readable nexttick read 0');
  8482. self.read(0);
  8483. } // pause() and resume() are remnants of the legacy readable stream API
  8484. // If the user uses them, then switch into old mode.
  8485. Readable.prototype.resume = function () {
  8486. var state = this._readableState;
  8487. if (!state.flowing) {
  8488. debug('resume'); // we flow only if there is no one listening
  8489. // for readable, but we still have to call
  8490. // resume()
  8491. state.flowing = !state.readableListening;
  8492. resume(this, state);
  8493. }
  8494. state.paused = false;
  8495. return this;
  8496. };
  8497. function resume(stream, state) {
  8498. if (!state.resumeScheduled) {
  8499. state.resumeScheduled = true;
  8500. process.nextTick(resume_, stream, state);
  8501. }
  8502. }
  8503. function resume_(stream, state) {
  8504. debug('resume', state.reading);
  8505. if (!state.reading) {
  8506. stream.read(0);
  8507. }
  8508. state.resumeScheduled = false;
  8509. stream.emit('resume');
  8510. flow(stream);
  8511. if (state.flowing && !state.reading) stream.read(0);
  8512. }
  8513. Readable.prototype.pause = function () {
  8514. debug('call pause flowing=%j', this._readableState.flowing);
  8515. if (this._readableState.flowing !== false) {
  8516. debug('pause');
  8517. this._readableState.flowing = false;
  8518. this.emit('pause');
  8519. }
  8520. this._readableState.paused = true;
  8521. return this;
  8522. };
  8523. function flow(stream) {
  8524. var state = stream._readableState;
  8525. debug('flow', state.flowing);
  8526. while (state.flowing && stream.read() !== null) {
  8527. ;
  8528. }
  8529. } // wrap an old-style stream as the async data source.
  8530. // This is *not* part of the readable stream interface.
  8531. // It is an ugly unfortunate mess of history.
  8532. Readable.prototype.wrap = function (stream) {
  8533. var _this = this;
  8534. var state = this._readableState;
  8535. var paused = false;
  8536. stream.on('end', function () {
  8537. debug('wrapped end');
  8538. if (state.decoder && !state.ended) {
  8539. var chunk = state.decoder.end();
  8540. if (chunk && chunk.length) _this.push(chunk);
  8541. }
  8542. _this.push(null);
  8543. });
  8544. stream.on('data', function (chunk) {
  8545. debug('wrapped data');
  8546. if (state.decoder) chunk = state.decoder.write(chunk); // don't skip over falsy values in objectMode
  8547. if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
  8548. var ret = _this.push(chunk);
  8549. if (!ret) {
  8550. paused = true;
  8551. stream.pause();
  8552. }
  8553. }); // proxy all the other methods.
  8554. // important when wrapping filters and duplexes.
  8555. for (var i in stream) {
  8556. if (this[i] === undefined && typeof stream[i] === 'function') {
  8557. this[i] = function methodWrap(method) {
  8558. return function methodWrapReturnFunction() {
  8559. return stream[method].apply(stream, arguments);
  8560. };
  8561. }(i);
  8562. }
  8563. } // proxy certain important events.
  8564. for (var n = 0; n < kProxyEvents.length; n++) {
  8565. stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
  8566. } // when we try to consume some more bytes, simply unpause the
  8567. // underlying stream.
  8568. this._read = function (n) {
  8569. debug('wrapped _read', n);
  8570. if (paused) {
  8571. paused = false;
  8572. stream.resume();
  8573. }
  8574. };
  8575. return this;
  8576. };
  8577. if (typeof Symbol === 'function') {
  8578. Readable.prototype[Symbol.asyncIterator] = function () {
  8579. if (createReadableStreamAsyncIterator === undefined) {
  8580. createReadableStreamAsyncIterator = require('./internal/streams/async_iterator');
  8581. }
  8582. return createReadableStreamAsyncIterator(this);
  8583. };
  8584. }
  8585. Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
  8586. // making it explicit this property is not enumerable
  8587. // because otherwise some prototype manipulation in
  8588. // userland will fail
  8589. enumerable: false,
  8590. get: function get() {
  8591. return this._readableState.highWaterMark;
  8592. }
  8593. });
  8594. Object.defineProperty(Readable.prototype, 'readableBuffer', {
  8595. // making it explicit this property is not enumerable
  8596. // because otherwise some prototype manipulation in
  8597. // userland will fail
  8598. enumerable: false,
  8599. get: function get() {
  8600. return this._readableState && this._readableState.buffer;
  8601. }
  8602. });
  8603. Object.defineProperty(Readable.prototype, 'readableFlowing', {
  8604. // making it explicit this property is not enumerable
  8605. // because otherwise some prototype manipulation in
  8606. // userland will fail
  8607. enumerable: false,
  8608. get: function get() {
  8609. return this._readableState.flowing;
  8610. },
  8611. set: function set(state) {
  8612. if (this._readableState) {
  8613. this._readableState.flowing = state;
  8614. }
  8615. }
  8616. }); // exposed for testing purposes only.
  8617. Readable._fromList = fromList;
  8618. Object.defineProperty(Readable.prototype, 'readableLength', {
  8619. // making it explicit this property is not enumerable
  8620. // because otherwise some prototype manipulation in
  8621. // userland will fail
  8622. enumerable: false,
  8623. get: function get() {
  8624. return this._readableState.length;
  8625. }
  8626. }); // Pluck off n bytes from an array of buffers.
  8627. // Length is the combined lengths of all the buffers in the list.
  8628. // This function is designed to be inlinable, so please take care when making
  8629. // changes to the function body.
  8630. function fromList(n, state) {
  8631. // nothing buffered
  8632. if (state.length === 0) return null;
  8633. var ret;
  8634. if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
  8635. // read it all, truncate the list
  8636. if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.first();else ret = state.buffer.concat(state.length);
  8637. state.buffer.clear();
  8638. } else {
  8639. // read part of list
  8640. ret = state.buffer.consume(n, state.decoder);
  8641. }
  8642. return ret;
  8643. }
  8644. function endReadable(stream) {
  8645. var state = stream._readableState;
  8646. debug('endReadable', state.endEmitted);
  8647. if (!state.endEmitted) {
  8648. state.ended = true;
  8649. process.nextTick(endReadableNT, state, stream);
  8650. }
  8651. }
  8652. function endReadableNT(state, stream) {
  8653. debug('endReadableNT', state.endEmitted, state.length); // Check that we didn't get one last unshift.
  8654. if (!state.endEmitted && state.length === 0) {
  8655. state.endEmitted = true;
  8656. stream.readable = false;
  8657. stream.emit('end');
  8658. if (state.autoDestroy) {
  8659. // In case of duplex streams we need a way to detect
  8660. // if the writable side is ready for autoDestroy as well
  8661. var wState = stream._writableState;
  8662. if (!wState || wState.autoDestroy && wState.finished) {
  8663. stream.destroy();
  8664. }
  8665. }
  8666. }
  8667. }
  8668. if (typeof Symbol === 'function') {
  8669. Readable.from = function (iterable, opts) {
  8670. if (from === undefined) {
  8671. from = require('./internal/streams/from');
  8672. }
  8673. return from(Readable, iterable, opts);
  8674. };
  8675. }
  8676. function indexOf(xs, x) {
  8677. for (var i = 0, l = xs.length; i < l; i++) {
  8678. if (xs[i] === x) return i;
  8679. }
  8680. return -1;
  8681. }
  8682. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  8683. },{"../errors":83,"./_stream_duplex":84,"./internal/streams/async_iterator":89,"./internal/streams/buffer_list":90,"./internal/streams/destroy":91,"./internal/streams/from":93,"./internal/streams/state":95,"./internal/streams/stream":96,"_process":393,"buffer":98,"events":297,"inherits":307,"string_decoder/":341,"util":78}],87:[function(require,module,exports){
  8684. // Copyright Joyent, Inc. and other Node contributors.
  8685. //
  8686. // Permission is hereby granted, free of charge, to any person obtaining a
  8687. // copy of this software and associated documentation files (the
  8688. // "Software"), to deal in the Software without restriction, including
  8689. // without limitation the rights to use, copy, modify, merge, publish,
  8690. // distribute, sublicense, and/or sell copies of the Software, and to permit
  8691. // persons to whom the Software is furnished to do so, subject to the
  8692. // following conditions:
  8693. //
  8694. // The above copyright notice and this permission notice shall be included
  8695. // in all copies or substantial portions of the Software.
  8696. //
  8697. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  8698. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  8699. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  8700. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  8701. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  8702. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  8703. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  8704. // a transform stream is a readable/writable stream where you do
  8705. // something with the data. Sometimes it's called a "filter",
  8706. // but that's not a great name for it, since that implies a thing where
  8707. // some bits pass through, and others are simply ignored. (That would
  8708. // be a valid example of a transform, of course.)
  8709. //
  8710. // While the output is causally related to the input, it's not a
  8711. // necessarily symmetric or synchronous transformation. For example,
  8712. // a zlib stream might take multiple plain-text writes(), and then
  8713. // emit a single compressed chunk some time in the future.
  8714. //
  8715. // Here's how this works:
  8716. //
  8717. // The Transform stream has all the aspects of the readable and writable
  8718. // stream classes. When you write(chunk), that calls _write(chunk,cb)
  8719. // internally, and returns false if there's a lot of pending writes
  8720. // buffered up. When you call read(), that calls _read(n) until
  8721. // there's enough pending readable data buffered up.
  8722. //
  8723. // In a transform stream, the written data is placed in a buffer. When
  8724. // _read(n) is called, it transforms the queued up data, calling the
  8725. // buffered _write cb's as it consumes chunks. If consuming a single
  8726. // written chunk would result in multiple output chunks, then the first
  8727. // outputted bit calls the readcb, and subsequent chunks just go into
  8728. // the read buffer, and will cause it to emit 'readable' if necessary.
  8729. //
  8730. // This way, back-pressure is actually determined by the reading side,
  8731. // since _read has to be called to start processing a new chunk. However,
  8732. // a pathological inflate type of transform can cause excessive buffering
  8733. // here. For example, imagine a stream where every byte of input is
  8734. // interpreted as an integer from 0-255, and then results in that many
  8735. // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
  8736. // 1kb of data being output. In this case, you could write a very small
  8737. // amount of input, and end up with a very large amount of output. In
  8738. // such a pathological inflating mechanism, there'd be no way to tell
  8739. // the system to stop doing the transform. A single 4MB write could
  8740. // cause the system to run out of memory.
  8741. //
  8742. // However, even in such a pathological case, only a single written chunk
  8743. // would be consumed, and then the rest would wait (un-transformed) until
  8744. // the results of the previous transformed chunk were consumed.
  8745. 'use strict';
  8746. module.exports = Transform;
  8747. var _require$codes = require('../errors').codes,
  8748. ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
  8749. ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,
  8750. ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING,
  8751. ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0;
  8752. var Duplex = require('./_stream_duplex');
  8753. require('inherits')(Transform, Duplex);
  8754. function afterTransform(er, data) {
  8755. var ts = this._transformState;
  8756. ts.transforming = false;
  8757. var cb = ts.writecb;
  8758. if (cb === null) {
  8759. return this.emit('error', new ERR_MULTIPLE_CALLBACK());
  8760. }
  8761. ts.writechunk = null;
  8762. ts.writecb = null;
  8763. if (data != null) // single equals check for both `null` and `undefined`
  8764. this.push(data);
  8765. cb(er);
  8766. var rs = this._readableState;
  8767. rs.reading = false;
  8768. if (rs.needReadable || rs.length < rs.highWaterMark) {
  8769. this._read(rs.highWaterMark);
  8770. }
  8771. }
  8772. function Transform(options) {
  8773. if (!(this instanceof Transform)) return new Transform(options);
  8774. Duplex.call(this, options);
  8775. this._transformState = {
  8776. afterTransform: afterTransform.bind(this),
  8777. needTransform: false,
  8778. transforming: false,
  8779. writecb: null,
  8780. writechunk: null,
  8781. writeencoding: null
  8782. }; // start out asking for a readable event once data is transformed.
  8783. this._readableState.needReadable = true; // we have implemented the _read method, and done the other things
  8784. // that Readable wants before the first _read call, so unset the
  8785. // sync guard flag.
  8786. this._readableState.sync = false;
  8787. if (options) {
  8788. if (typeof options.transform === 'function') this._transform = options.transform;
  8789. if (typeof options.flush === 'function') this._flush = options.flush;
  8790. } // When the writable side finishes, then flush out anything remaining.
  8791. this.on('prefinish', prefinish);
  8792. }
  8793. function prefinish() {
  8794. var _this = this;
  8795. if (typeof this._flush === 'function' && !this._readableState.destroyed) {
  8796. this._flush(function (er, data) {
  8797. done(_this, er, data);
  8798. });
  8799. } else {
  8800. done(this, null, null);
  8801. }
  8802. }
  8803. Transform.prototype.push = function (chunk, encoding) {
  8804. this._transformState.needTransform = false;
  8805. return Duplex.prototype.push.call(this, chunk, encoding);
  8806. }; // This is the part where you do stuff!
  8807. // override this function in implementation classes.
  8808. // 'chunk' is an input chunk.
  8809. //
  8810. // Call `push(newChunk)` to pass along transformed output
  8811. // to the readable side. You may call 'push' zero or more times.
  8812. //
  8813. // Call `cb(err)` when you are done with this chunk. If you pass
  8814. // an error, then that'll put the hurt on the whole operation. If you
  8815. // never call cb(), then you'll never get another chunk.
  8816. Transform.prototype._transform = function (chunk, encoding, cb) {
  8817. cb(new ERR_METHOD_NOT_IMPLEMENTED('_transform()'));
  8818. };
  8819. Transform.prototype._write = function (chunk, encoding, cb) {
  8820. var ts = this._transformState;
  8821. ts.writecb = cb;
  8822. ts.writechunk = chunk;
  8823. ts.writeencoding = encoding;
  8824. if (!ts.transforming) {
  8825. var rs = this._readableState;
  8826. if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
  8827. }
  8828. }; // Doesn't matter what the args are here.
  8829. // _transform does all the work.
  8830. // That we got here means that the readable side wants more data.
  8831. Transform.prototype._read = function (n) {
  8832. var ts = this._transformState;
  8833. if (ts.writechunk !== null && !ts.transforming) {
  8834. ts.transforming = true;
  8835. this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
  8836. } else {
  8837. // mark that we need a transform, so that any data that comes in
  8838. // will get processed, now that we've asked for it.
  8839. ts.needTransform = true;
  8840. }
  8841. };
  8842. Transform.prototype._destroy = function (err, cb) {
  8843. Duplex.prototype._destroy.call(this, err, function (err2) {
  8844. cb(err2);
  8845. });
  8846. };
  8847. function done(stream, er, data) {
  8848. if (er) return stream.emit('error', er);
  8849. if (data != null) // single equals check for both `null` and `undefined`
  8850. stream.push(data); // TODO(BridgeAR): Write a test for these two error cases
  8851. // if there's nothing in the write buffer, then that means
  8852. // that nothing more will ever be provided
  8853. if (stream._writableState.length) throw new ERR_TRANSFORM_WITH_LENGTH_0();
  8854. if (stream._transformState.transforming) throw new ERR_TRANSFORM_ALREADY_TRANSFORMING();
  8855. return stream.push(null);
  8856. }
  8857. },{"../errors":83,"./_stream_duplex":84,"inherits":307}],88:[function(require,module,exports){
  8858. (function (process,global){
  8859. // Copyright Joyent, Inc. and other Node contributors.
  8860. //
  8861. // Permission is hereby granted, free of charge, to any person obtaining a
  8862. // copy of this software and associated documentation files (the
  8863. // "Software"), to deal in the Software without restriction, including
  8864. // without limitation the rights to use, copy, modify, merge, publish,
  8865. // distribute, sublicense, and/or sell copies of the Software, and to permit
  8866. // persons to whom the Software is furnished to do so, subject to the
  8867. // following conditions:
  8868. //
  8869. // The above copyright notice and this permission notice shall be included
  8870. // in all copies or substantial portions of the Software.
  8871. //
  8872. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  8873. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  8874. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  8875. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  8876. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  8877. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  8878. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  8879. // A bit simpler than readable streams.
  8880. // Implement an async ._write(chunk, encoding, cb), and it'll handle all
  8881. // the drain event emission and buffering.
  8882. 'use strict';
  8883. module.exports = Writable;
  8884. /* <replacement> */
  8885. function WriteReq(chunk, encoding, cb) {
  8886. this.chunk = chunk;
  8887. this.encoding = encoding;
  8888. this.callback = cb;
  8889. this.next = null;
  8890. } // It seems a linked list but it is not
  8891. // there will be only 2 of these for each stream
  8892. function CorkedRequest(state) {
  8893. var _this = this;
  8894. this.next = null;
  8895. this.entry = null;
  8896. this.finish = function () {
  8897. onCorkedFinish(_this, state);
  8898. };
  8899. }
  8900. /* </replacement> */
  8901. /*<replacement>*/
  8902. var Duplex;
  8903. /*</replacement>*/
  8904. Writable.WritableState = WritableState;
  8905. /*<replacement>*/
  8906. var internalUtil = {
  8907. deprecate: require('util-deprecate')
  8908. };
  8909. /*</replacement>*/
  8910. /*<replacement>*/
  8911. var Stream = require('./internal/streams/stream');
  8912. /*</replacement>*/
  8913. var Buffer = require('buffer').Buffer;
  8914. var OurUint8Array = global.Uint8Array || function () {};
  8915. function _uint8ArrayToBuffer(chunk) {
  8916. return Buffer.from(chunk);
  8917. }
  8918. function _isUint8Array(obj) {
  8919. return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
  8920. }
  8921. var destroyImpl = require('./internal/streams/destroy');
  8922. var _require = require('./internal/streams/state'),
  8923. getHighWaterMark = _require.getHighWaterMark;
  8924. var _require$codes = require('../errors').codes,
  8925. ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
  8926. ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
  8927. ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,
  8928. ERR_STREAM_CANNOT_PIPE = _require$codes.ERR_STREAM_CANNOT_PIPE,
  8929. ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED,
  8930. ERR_STREAM_NULL_VALUES = _require$codes.ERR_STREAM_NULL_VALUES,
  8931. ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END,
  8932. ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING;
  8933. var errorOrDestroy = destroyImpl.errorOrDestroy;
  8934. require('inherits')(Writable, Stream);
  8935. function nop() {}
  8936. function WritableState(options, stream, isDuplex) {
  8937. Duplex = Duplex || require('./_stream_duplex');
  8938. options = options || {}; // Duplex streams are both readable and writable, but share
  8939. // the same options object.
  8940. // However, some cases require setting options to different
  8941. // values for the readable and the writable sides of the duplex stream,
  8942. // e.g. options.readableObjectMode vs. options.writableObjectMode, etc.
  8943. if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag to indicate whether or not this stream
  8944. // contains buffers or objects.
  8945. this.objectMode = !!options.objectMode;
  8946. if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; // the point at which write() starts returning false
  8947. // Note: 0 is a valid value, means that we always return false if
  8948. // the entire buffer is not flushed immediately on write()
  8949. this.highWaterMark = getHighWaterMark(this, options, 'writableHighWaterMark', isDuplex); // if _final has been called
  8950. this.finalCalled = false; // drain event flag.
  8951. this.needDrain = false; // at the start of calling end()
  8952. this.ending = false; // when end() has been called, and returned
  8953. this.ended = false; // when 'finish' is emitted
  8954. this.finished = false; // has it been destroyed
  8955. this.destroyed = false; // should we decode strings into buffers before passing to _write?
  8956. // this is here so that some node-core streams can optimize string
  8957. // handling at a lower level.
  8958. var noDecode = options.decodeStrings === false;
  8959. this.decodeStrings = !noDecode; // Crypto is kind of old and crusty. Historically, its default string
  8960. // encoding is 'binary' so we have to make this configurable.
  8961. // Everything else in the universe uses 'utf8', though.
  8962. this.defaultEncoding = options.defaultEncoding || 'utf8'; // not an actual buffer we keep track of, but a measurement
  8963. // of how much we're waiting to get pushed to some underlying
  8964. // socket or file.
  8965. this.length = 0; // a flag to see when we're in the middle of a write.
  8966. this.writing = false; // when true all writes will be buffered until .uncork() call
  8967. this.corked = 0; // a flag to be able to tell if the onwrite cb is called immediately,
  8968. // or on a later tick. We set this to true at first, because any
  8969. // actions that shouldn't happen until "later" should generally also
  8970. // not happen before the first write call.
  8971. this.sync = true; // a flag to know if we're processing previously buffered items, which
  8972. // may call the _write() callback in the same tick, so that we don't
  8973. // end up in an overlapped onwrite situation.
  8974. this.bufferProcessing = false; // the callback that's passed to _write(chunk,cb)
  8975. this.onwrite = function (er) {
  8976. onwrite(stream, er);
  8977. }; // the callback that the user supplies to write(chunk,encoding,cb)
  8978. this.writecb = null; // the amount that is being written when _write is called.
  8979. this.writelen = 0;
  8980. this.bufferedRequest = null;
  8981. this.lastBufferedRequest = null; // number of pending user-supplied write callbacks
  8982. // this must be 0 before 'finish' can be emitted
  8983. this.pendingcb = 0; // emit prefinish if the only thing we're waiting for is _write cbs
  8984. // This is relevant for synchronous Transform streams
  8985. this.prefinished = false; // True if the error was already emitted and should not be thrown again
  8986. this.errorEmitted = false; // Should close be emitted on destroy. Defaults to true.
  8987. this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'finish' (and potentially 'end')
  8988. this.autoDestroy = !!options.autoDestroy; // count buffered requests
  8989. this.bufferedRequestCount = 0; // allocate the first CorkedRequest, there is always
  8990. // one allocated and free to use, and we maintain at most two
  8991. this.corkedRequestsFree = new CorkedRequest(this);
  8992. }
  8993. WritableState.prototype.getBuffer = function getBuffer() {
  8994. var current = this.bufferedRequest;
  8995. var out = [];
  8996. while (current) {
  8997. out.push(current);
  8998. current = current.next;
  8999. }
  9000. return out;
  9001. };
  9002. (function () {
  9003. try {
  9004. Object.defineProperty(WritableState.prototype, 'buffer', {
  9005. get: internalUtil.deprecate(function writableStateBufferGetter() {
  9006. return this.getBuffer();
  9007. }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
  9008. });
  9009. } catch (_) {}
  9010. })(); // Test _writableState for inheritance to account for Duplex streams,
  9011. // whose prototype chain only points to Readable.
  9012. var realHasInstance;
  9013. if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
  9014. realHasInstance = Function.prototype[Symbol.hasInstance];
  9015. Object.defineProperty(Writable, Symbol.hasInstance, {
  9016. value: function value(object) {
  9017. if (realHasInstance.call(this, object)) return true;
  9018. if (this !== Writable) return false;
  9019. return object && object._writableState instanceof WritableState;
  9020. }
  9021. });
  9022. } else {
  9023. realHasInstance = function realHasInstance(object) {
  9024. return object instanceof this;
  9025. };
  9026. }
  9027. function Writable(options) {
  9028. Duplex = Duplex || require('./_stream_duplex'); // Writable ctor is applied to Duplexes, too.
  9029. // `realHasInstance` is necessary because using plain `instanceof`
  9030. // would return false, as no `_writableState` property is attached.
  9031. // Trying to use the custom `instanceof` for Writable here will also break the
  9032. // Node.js LazyTransform implementation, which has a non-trivial getter for
  9033. // `_writableState` that would lead to infinite recursion.
  9034. // Checking for a Stream.Duplex instance is faster here instead of inside
  9035. // the WritableState constructor, at least with V8 6.5
  9036. var isDuplex = this instanceof Duplex;
  9037. if (!isDuplex && !realHasInstance.call(Writable, this)) return new Writable(options);
  9038. this._writableState = new WritableState(options, this, isDuplex); // legacy.
  9039. this.writable = true;
  9040. if (options) {
  9041. if (typeof options.write === 'function') this._write = options.write;
  9042. if (typeof options.writev === 'function') this._writev = options.writev;
  9043. if (typeof options.destroy === 'function') this._destroy = options.destroy;
  9044. if (typeof options.final === 'function') this._final = options.final;
  9045. }
  9046. Stream.call(this);
  9047. } // Otherwise people can pipe Writable streams, which is just wrong.
  9048. Writable.prototype.pipe = function () {
  9049. errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE());
  9050. };
  9051. function writeAfterEnd(stream, cb) {
  9052. var er = new ERR_STREAM_WRITE_AFTER_END(); // TODO: defer error events consistently everywhere, not just the cb
  9053. errorOrDestroy(stream, er);
  9054. process.nextTick(cb, er);
  9055. } // Checks that a user-supplied chunk is valid, especially for the particular
  9056. // mode the stream is in. Currently this means that `null` is never accepted
  9057. // and undefined/non-string values are only allowed in object mode.
  9058. function validChunk(stream, state, chunk, cb) {
  9059. var er;
  9060. if (chunk === null) {
  9061. er = new ERR_STREAM_NULL_VALUES();
  9062. } else if (typeof chunk !== 'string' && !state.objectMode) {
  9063. er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer'], chunk);
  9064. }
  9065. if (er) {
  9066. errorOrDestroy(stream, er);
  9067. process.nextTick(cb, er);
  9068. return false;
  9069. }
  9070. return true;
  9071. }
  9072. Writable.prototype.write = function (chunk, encoding, cb) {
  9073. var state = this._writableState;
  9074. var ret = false;
  9075. var isBuf = !state.objectMode && _isUint8Array(chunk);
  9076. if (isBuf && !Buffer.isBuffer(chunk)) {
  9077. chunk = _uint8ArrayToBuffer(chunk);
  9078. }
  9079. if (typeof encoding === 'function') {
  9080. cb = encoding;
  9081. encoding = null;
  9082. }
  9083. if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
  9084. if (typeof cb !== 'function') cb = nop;
  9085. if (state.ending) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
  9086. state.pendingcb++;
  9087. ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
  9088. }
  9089. return ret;
  9090. };
  9091. Writable.prototype.cork = function () {
  9092. this._writableState.corked++;
  9093. };
  9094. Writable.prototype.uncork = function () {
  9095. var state = this._writableState;
  9096. if (state.corked) {
  9097. state.corked--;
  9098. if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
  9099. }
  9100. };
  9101. Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
  9102. // node::ParseEncoding() requires lower case.
  9103. if (typeof encoding === 'string') encoding = encoding.toLowerCase();
  9104. if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new ERR_UNKNOWN_ENCODING(encoding);
  9105. this._writableState.defaultEncoding = encoding;
  9106. return this;
  9107. };
  9108. Object.defineProperty(Writable.prototype, 'writableBuffer', {
  9109. // making it explicit this property is not enumerable
  9110. // because otherwise some prototype manipulation in
  9111. // userland will fail
  9112. enumerable: false,
  9113. get: function get() {
  9114. return this._writableState && this._writableState.getBuffer();
  9115. }
  9116. });
  9117. function decodeChunk(state, chunk, encoding) {
  9118. if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
  9119. chunk = Buffer.from(chunk, encoding);
  9120. }
  9121. return chunk;
  9122. }
  9123. Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
  9124. // making it explicit this property is not enumerable
  9125. // because otherwise some prototype manipulation in
  9126. // userland will fail
  9127. enumerable: false,
  9128. get: function get() {
  9129. return this._writableState.highWaterMark;
  9130. }
  9131. }); // if we're already writing something, then just put this
  9132. // in the queue, and wait our turn. Otherwise, call _write
  9133. // If we return false, then we need a drain event, so set that flag.
  9134. function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
  9135. if (!isBuf) {
  9136. var newChunk = decodeChunk(state, chunk, encoding);
  9137. if (chunk !== newChunk) {
  9138. isBuf = true;
  9139. encoding = 'buffer';
  9140. chunk = newChunk;
  9141. }
  9142. }
  9143. var len = state.objectMode ? 1 : chunk.length;
  9144. state.length += len;
  9145. var ret = state.length < state.highWaterMark; // we must ensure that previous needDrain will not be reset to false.
  9146. if (!ret) state.needDrain = true;
  9147. if (state.writing || state.corked) {
  9148. var last = state.lastBufferedRequest;
  9149. state.lastBufferedRequest = {
  9150. chunk: chunk,
  9151. encoding: encoding,
  9152. isBuf: isBuf,
  9153. callback: cb,
  9154. next: null
  9155. };
  9156. if (last) {
  9157. last.next = state.lastBufferedRequest;
  9158. } else {
  9159. state.bufferedRequest = state.lastBufferedRequest;
  9160. }
  9161. state.bufferedRequestCount += 1;
  9162. } else {
  9163. doWrite(stream, state, false, len, chunk, encoding, cb);
  9164. }
  9165. return ret;
  9166. }
  9167. function doWrite(stream, state, writev, len, chunk, encoding, cb) {
  9168. state.writelen = len;
  9169. state.writecb = cb;
  9170. state.writing = true;
  9171. state.sync = true;
  9172. if (state.destroyed) state.onwrite(new ERR_STREAM_DESTROYED('write'));else if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
  9173. state.sync = false;
  9174. }
  9175. function onwriteError(stream, state, sync, er, cb) {
  9176. --state.pendingcb;
  9177. if (sync) {
  9178. // defer the callback if we are being called synchronously
  9179. // to avoid piling up things on the stack
  9180. process.nextTick(cb, er); // this can emit finish, and it will always happen
  9181. // after error
  9182. process.nextTick(finishMaybe, stream, state);
  9183. stream._writableState.errorEmitted = true;
  9184. errorOrDestroy(stream, er);
  9185. } else {
  9186. // the caller expect this to happen before if
  9187. // it is async
  9188. cb(er);
  9189. stream._writableState.errorEmitted = true;
  9190. errorOrDestroy(stream, er); // this can emit finish, but finish must
  9191. // always follow error
  9192. finishMaybe(stream, state);
  9193. }
  9194. }
  9195. function onwriteStateUpdate(state) {
  9196. state.writing = false;
  9197. state.writecb = null;
  9198. state.length -= state.writelen;
  9199. state.writelen = 0;
  9200. }
  9201. function onwrite(stream, er) {
  9202. var state = stream._writableState;
  9203. var sync = state.sync;
  9204. var cb = state.writecb;
  9205. if (typeof cb !== 'function') throw new ERR_MULTIPLE_CALLBACK();
  9206. onwriteStateUpdate(state);
  9207. if (er) onwriteError(stream, state, sync, er, cb);else {
  9208. // Check if we're actually ready to finish, but don't emit yet
  9209. var finished = needFinish(state) || stream.destroyed;
  9210. if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
  9211. clearBuffer(stream, state);
  9212. }
  9213. if (sync) {
  9214. process.nextTick(afterWrite, stream, state, finished, cb);
  9215. } else {
  9216. afterWrite(stream, state, finished, cb);
  9217. }
  9218. }
  9219. }
  9220. function afterWrite(stream, state, finished, cb) {
  9221. if (!finished) onwriteDrain(stream, state);
  9222. state.pendingcb--;
  9223. cb();
  9224. finishMaybe(stream, state);
  9225. } // Must force callback to be called on nextTick, so that we don't
  9226. // emit 'drain' before the write() consumer gets the 'false' return
  9227. // value, and has a chance to attach a 'drain' listener.
  9228. function onwriteDrain(stream, state) {
  9229. if (state.length === 0 && state.needDrain) {
  9230. state.needDrain = false;
  9231. stream.emit('drain');
  9232. }
  9233. } // if there's something in the buffer waiting, then process it
  9234. function clearBuffer(stream, state) {
  9235. state.bufferProcessing = true;
  9236. var entry = state.bufferedRequest;
  9237. if (stream._writev && entry && entry.next) {
  9238. // Fast case, write everything using _writev()
  9239. var l = state.bufferedRequestCount;
  9240. var buffer = new Array(l);
  9241. var holder = state.corkedRequestsFree;
  9242. holder.entry = entry;
  9243. var count = 0;
  9244. var allBuffers = true;
  9245. while (entry) {
  9246. buffer[count] = entry;
  9247. if (!entry.isBuf) allBuffers = false;
  9248. entry = entry.next;
  9249. count += 1;
  9250. }
  9251. buffer.allBuffers = allBuffers;
  9252. doWrite(stream, state, true, state.length, buffer, '', holder.finish); // doWrite is almost always async, defer these to save a bit of time
  9253. // as the hot path ends with doWrite
  9254. state.pendingcb++;
  9255. state.lastBufferedRequest = null;
  9256. if (holder.next) {
  9257. state.corkedRequestsFree = holder.next;
  9258. holder.next = null;
  9259. } else {
  9260. state.corkedRequestsFree = new CorkedRequest(state);
  9261. }
  9262. state.bufferedRequestCount = 0;
  9263. } else {
  9264. // Slow case, write chunks one-by-one
  9265. while (entry) {
  9266. var chunk = entry.chunk;
  9267. var encoding = entry.encoding;
  9268. var cb = entry.callback;
  9269. var len = state.objectMode ? 1 : chunk.length;
  9270. doWrite(stream, state, false, len, chunk, encoding, cb);
  9271. entry = entry.next;
  9272. state.bufferedRequestCount--; // if we didn't call the onwrite immediately, then
  9273. // it means that we need to wait until it does.
  9274. // also, that means that the chunk and cb are currently
  9275. // being processed, so move the buffer counter past them.
  9276. if (state.writing) {
  9277. break;
  9278. }
  9279. }
  9280. if (entry === null) state.lastBufferedRequest = null;
  9281. }
  9282. state.bufferedRequest = entry;
  9283. state.bufferProcessing = false;
  9284. }
  9285. Writable.prototype._write = function (chunk, encoding, cb) {
  9286. cb(new ERR_METHOD_NOT_IMPLEMENTED('_write()'));
  9287. };
  9288. Writable.prototype._writev = null;
  9289. Writable.prototype.end = function (chunk, encoding, cb) {
  9290. var state = this._writableState;
  9291. if (typeof chunk === 'function') {
  9292. cb = chunk;
  9293. chunk = null;
  9294. encoding = null;
  9295. } else if (typeof encoding === 'function') {
  9296. cb = encoding;
  9297. encoding = null;
  9298. }
  9299. if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); // .end() fully uncorks
  9300. if (state.corked) {
  9301. state.corked = 1;
  9302. this.uncork();
  9303. } // ignore unnecessary end() calls.
  9304. if (!state.ending) endWritable(this, state, cb);
  9305. return this;
  9306. };
  9307. Object.defineProperty(Writable.prototype, 'writableLength', {
  9308. // making it explicit this property is not enumerable
  9309. // because otherwise some prototype manipulation in
  9310. // userland will fail
  9311. enumerable: false,
  9312. get: function get() {
  9313. return this._writableState.length;
  9314. }
  9315. });
  9316. function needFinish(state) {
  9317. return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
  9318. }
  9319. function callFinal(stream, state) {
  9320. stream._final(function (err) {
  9321. state.pendingcb--;
  9322. if (err) {
  9323. errorOrDestroy(stream, err);
  9324. }
  9325. state.prefinished = true;
  9326. stream.emit('prefinish');
  9327. finishMaybe(stream, state);
  9328. });
  9329. }
  9330. function prefinish(stream, state) {
  9331. if (!state.prefinished && !state.finalCalled) {
  9332. if (typeof stream._final === 'function' && !state.destroyed) {
  9333. state.pendingcb++;
  9334. state.finalCalled = true;
  9335. process.nextTick(callFinal, stream, state);
  9336. } else {
  9337. state.prefinished = true;
  9338. stream.emit('prefinish');
  9339. }
  9340. }
  9341. }
  9342. function finishMaybe(stream, state) {
  9343. var need = needFinish(state);
  9344. if (need) {
  9345. prefinish(stream, state);
  9346. if (state.pendingcb === 0) {
  9347. state.finished = true;
  9348. stream.emit('finish');
  9349. if (state.autoDestroy) {
  9350. // In case of duplex streams we need a way to detect
  9351. // if the readable side is ready for autoDestroy as well
  9352. var rState = stream._readableState;
  9353. if (!rState || rState.autoDestroy && rState.endEmitted) {
  9354. stream.destroy();
  9355. }
  9356. }
  9357. }
  9358. }
  9359. return need;
  9360. }
  9361. function endWritable(stream, state, cb) {
  9362. state.ending = true;
  9363. finishMaybe(stream, state);
  9364. if (cb) {
  9365. if (state.finished) process.nextTick(cb);else stream.once('finish', cb);
  9366. }
  9367. state.ended = true;
  9368. stream.writable = false;
  9369. }
  9370. function onCorkedFinish(corkReq, state, err) {
  9371. var entry = corkReq.entry;
  9372. corkReq.entry = null;
  9373. while (entry) {
  9374. var cb = entry.callback;
  9375. state.pendingcb--;
  9376. cb(err);
  9377. entry = entry.next;
  9378. } // reuse the free corkReq.
  9379. state.corkedRequestsFree.next = corkReq;
  9380. }
  9381. Object.defineProperty(Writable.prototype, 'destroyed', {
  9382. // making it explicit this property is not enumerable
  9383. // because otherwise some prototype manipulation in
  9384. // userland will fail
  9385. enumerable: false,
  9386. get: function get() {
  9387. if (this._writableState === undefined) {
  9388. return false;
  9389. }
  9390. return this._writableState.destroyed;
  9391. },
  9392. set: function set(value) {
  9393. // we ignore the value if the stream
  9394. // has not been initialized yet
  9395. if (!this._writableState) {
  9396. return;
  9397. } // backward compatibility, the user is explicitly
  9398. // managing destroyed
  9399. this._writableState.destroyed = value;
  9400. }
  9401. });
  9402. Writable.prototype.destroy = destroyImpl.destroy;
  9403. Writable.prototype._undestroy = destroyImpl.undestroy;
  9404. Writable.prototype._destroy = function (err, cb) {
  9405. cb(err);
  9406. };
  9407. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  9408. },{"../errors":83,"./_stream_duplex":84,"./internal/streams/destroy":91,"./internal/streams/state":95,"./internal/streams/stream":96,"_process":393,"buffer":98,"inherits":307,"util-deprecate":343}],89:[function(require,module,exports){
  9409. (function (process){
  9410. 'use strict';
  9411. var _Object$setPrototypeO;
  9412. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  9413. var finished = require('./end-of-stream');
  9414. var kLastResolve = Symbol('lastResolve');
  9415. var kLastReject = Symbol('lastReject');
  9416. var kError = Symbol('error');
  9417. var kEnded = Symbol('ended');
  9418. var kLastPromise = Symbol('lastPromise');
  9419. var kHandlePromise = Symbol('handlePromise');
  9420. var kStream = Symbol('stream');
  9421. function createIterResult(value, done) {
  9422. return {
  9423. value: value,
  9424. done: done
  9425. };
  9426. }
  9427. function readAndResolve(iter) {
  9428. var resolve = iter[kLastResolve];
  9429. if (resolve !== null) {
  9430. var data = iter[kStream].read(); // we defer if data is null
  9431. // we can be expecting either 'end' or
  9432. // 'error'
  9433. if (data !== null) {
  9434. iter[kLastPromise] = null;
  9435. iter[kLastResolve] = null;
  9436. iter[kLastReject] = null;
  9437. resolve(createIterResult(data, false));
  9438. }
  9439. }
  9440. }
  9441. function onReadable(iter) {
  9442. // we wait for the next tick, because it might
  9443. // emit an error with process.nextTick
  9444. process.nextTick(readAndResolve, iter);
  9445. }
  9446. function wrapForNext(lastPromise, iter) {
  9447. return function (resolve, reject) {
  9448. lastPromise.then(function () {
  9449. if (iter[kEnded]) {
  9450. resolve(createIterResult(undefined, true));
  9451. return;
  9452. }
  9453. iter[kHandlePromise](resolve, reject);
  9454. }, reject);
  9455. };
  9456. }
  9457. var AsyncIteratorPrototype = Object.getPrototypeOf(function () {});
  9458. var ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf((_Object$setPrototypeO = {
  9459. get stream() {
  9460. return this[kStream];
  9461. },
  9462. next: function next() {
  9463. var _this = this;
  9464. // if we have detected an error in the meanwhile
  9465. // reject straight away
  9466. var error = this[kError];
  9467. if (error !== null) {
  9468. return Promise.reject(error);
  9469. }
  9470. if (this[kEnded]) {
  9471. return Promise.resolve(createIterResult(undefined, true));
  9472. }
  9473. if (this[kStream].destroyed) {
  9474. // We need to defer via nextTick because if .destroy(err) is
  9475. // called, the error will be emitted via nextTick, and
  9476. // we cannot guarantee that there is no error lingering around
  9477. // waiting to be emitted.
  9478. return new Promise(function (resolve, reject) {
  9479. process.nextTick(function () {
  9480. if (_this[kError]) {
  9481. reject(_this[kError]);
  9482. } else {
  9483. resolve(createIterResult(undefined, true));
  9484. }
  9485. });
  9486. });
  9487. } // if we have multiple next() calls
  9488. // we will wait for the previous Promise to finish
  9489. // this logic is optimized to support for await loops,
  9490. // where next() is only called once at a time
  9491. var lastPromise = this[kLastPromise];
  9492. var promise;
  9493. if (lastPromise) {
  9494. promise = new Promise(wrapForNext(lastPromise, this));
  9495. } else {
  9496. // fast path needed to support multiple this.push()
  9497. // without triggering the next() queue
  9498. var data = this[kStream].read();
  9499. if (data !== null) {
  9500. return Promise.resolve(createIterResult(data, false));
  9501. }
  9502. promise = new Promise(this[kHandlePromise]);
  9503. }
  9504. this[kLastPromise] = promise;
  9505. return promise;
  9506. }
  9507. }, _defineProperty(_Object$setPrototypeO, Symbol.asyncIterator, function () {
  9508. return this;
  9509. }), _defineProperty(_Object$setPrototypeO, "return", function _return() {
  9510. var _this2 = this;
  9511. // destroy(err, cb) is a private API
  9512. // we can guarantee we have that here, because we control the
  9513. // Readable class this is attached to
  9514. return new Promise(function (resolve, reject) {
  9515. _this2[kStream].destroy(null, function (err) {
  9516. if (err) {
  9517. reject(err);
  9518. return;
  9519. }
  9520. resolve(createIterResult(undefined, true));
  9521. });
  9522. });
  9523. }), _Object$setPrototypeO), AsyncIteratorPrototype);
  9524. var createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator(stream) {
  9525. var _Object$create;
  9526. var iterator = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, {
  9527. value: stream,
  9528. writable: true
  9529. }), _defineProperty(_Object$create, kLastResolve, {
  9530. value: null,
  9531. writable: true
  9532. }), _defineProperty(_Object$create, kLastReject, {
  9533. value: null,
  9534. writable: true
  9535. }), _defineProperty(_Object$create, kError, {
  9536. value: null,
  9537. writable: true
  9538. }), _defineProperty(_Object$create, kEnded, {
  9539. value: stream._readableState.endEmitted,
  9540. writable: true
  9541. }), _defineProperty(_Object$create, kHandlePromise, {
  9542. value: function value(resolve, reject) {
  9543. var data = iterator[kStream].read();
  9544. if (data) {
  9545. iterator[kLastPromise] = null;
  9546. iterator[kLastResolve] = null;
  9547. iterator[kLastReject] = null;
  9548. resolve(createIterResult(data, false));
  9549. } else {
  9550. iterator[kLastResolve] = resolve;
  9551. iterator[kLastReject] = reject;
  9552. }
  9553. },
  9554. writable: true
  9555. }), _Object$create));
  9556. iterator[kLastPromise] = null;
  9557. finished(stream, function (err) {
  9558. if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') {
  9559. var reject = iterator[kLastReject]; // reject if we are waiting for data in the Promise
  9560. // returned by next() and store the error
  9561. if (reject !== null) {
  9562. iterator[kLastPromise] = null;
  9563. iterator[kLastResolve] = null;
  9564. iterator[kLastReject] = null;
  9565. reject(err);
  9566. }
  9567. iterator[kError] = err;
  9568. return;
  9569. }
  9570. var resolve = iterator[kLastResolve];
  9571. if (resolve !== null) {
  9572. iterator[kLastPromise] = null;
  9573. iterator[kLastResolve] = null;
  9574. iterator[kLastReject] = null;
  9575. resolve(createIterResult(undefined, true));
  9576. }
  9577. iterator[kEnded] = true;
  9578. });
  9579. stream.on('readable', onReadable.bind(null, iterator));
  9580. return iterator;
  9581. };
  9582. module.exports = createReadableStreamAsyncIterator;
  9583. }).call(this,require('_process'))
  9584. },{"./end-of-stream":92,"_process":393}],90:[function(require,module,exports){
  9585. 'use strict';
  9586. function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
  9587. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
  9588. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  9589. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9590. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  9591. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9592. var _require = require('buffer'),
  9593. Buffer = _require.Buffer;
  9594. var _require2 = require('util'),
  9595. inspect = _require2.inspect;
  9596. var custom = inspect && inspect.custom || 'inspect';
  9597. function copyBuffer(src, target, offset) {
  9598. Buffer.prototype.copy.call(src, target, offset);
  9599. }
  9600. module.exports =
  9601. /*#__PURE__*/
  9602. function () {
  9603. function BufferList() {
  9604. _classCallCheck(this, BufferList);
  9605. this.head = null;
  9606. this.tail = null;
  9607. this.length = 0;
  9608. }
  9609. _createClass(BufferList, [{
  9610. key: "push",
  9611. value: function push(v) {
  9612. var entry = {
  9613. data: v,
  9614. next: null
  9615. };
  9616. if (this.length > 0) this.tail.next = entry;else this.head = entry;
  9617. this.tail = entry;
  9618. ++this.length;
  9619. }
  9620. }, {
  9621. key: "unshift",
  9622. value: function unshift(v) {
  9623. var entry = {
  9624. data: v,
  9625. next: this.head
  9626. };
  9627. if (this.length === 0) this.tail = entry;
  9628. this.head = entry;
  9629. ++this.length;
  9630. }
  9631. }, {
  9632. key: "shift",
  9633. value: function shift() {
  9634. if (this.length === 0) return;
  9635. var ret = this.head.data;
  9636. if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
  9637. --this.length;
  9638. return ret;
  9639. }
  9640. }, {
  9641. key: "clear",
  9642. value: function clear() {
  9643. this.head = this.tail = null;
  9644. this.length = 0;
  9645. }
  9646. }, {
  9647. key: "join",
  9648. value: function join(s) {
  9649. if (this.length === 0) return '';
  9650. var p = this.head;
  9651. var ret = '' + p.data;
  9652. while (p = p.next) {
  9653. ret += s + p.data;
  9654. }
  9655. return ret;
  9656. }
  9657. }, {
  9658. key: "concat",
  9659. value: function concat(n) {
  9660. if (this.length === 0) return Buffer.alloc(0);
  9661. var ret = Buffer.allocUnsafe(n >>> 0);
  9662. var p = this.head;
  9663. var i = 0;
  9664. while (p) {
  9665. copyBuffer(p.data, ret, i);
  9666. i += p.data.length;
  9667. p = p.next;
  9668. }
  9669. return ret;
  9670. } // Consumes a specified amount of bytes or characters from the buffered data.
  9671. }, {
  9672. key: "consume",
  9673. value: function consume(n, hasStrings) {
  9674. var ret;
  9675. if (n < this.head.data.length) {
  9676. // `slice` is the same for buffers and strings.
  9677. ret = this.head.data.slice(0, n);
  9678. this.head.data = this.head.data.slice(n);
  9679. } else if (n === this.head.data.length) {
  9680. // First chunk is a perfect match.
  9681. ret = this.shift();
  9682. } else {
  9683. // Result spans more than one buffer.
  9684. ret = hasStrings ? this._getString(n) : this._getBuffer(n);
  9685. }
  9686. return ret;
  9687. }
  9688. }, {
  9689. key: "first",
  9690. value: function first() {
  9691. return this.head.data;
  9692. } // Consumes a specified amount of characters from the buffered data.
  9693. }, {
  9694. key: "_getString",
  9695. value: function _getString(n) {
  9696. var p = this.head;
  9697. var c = 1;
  9698. var ret = p.data;
  9699. n -= ret.length;
  9700. while (p = p.next) {
  9701. var str = p.data;
  9702. var nb = n > str.length ? str.length : n;
  9703. if (nb === str.length) ret += str;else ret += str.slice(0, n);
  9704. n -= nb;
  9705. if (n === 0) {
  9706. if (nb === str.length) {
  9707. ++c;
  9708. if (p.next) this.head = p.next;else this.head = this.tail = null;
  9709. } else {
  9710. this.head = p;
  9711. p.data = str.slice(nb);
  9712. }
  9713. break;
  9714. }
  9715. ++c;
  9716. }
  9717. this.length -= c;
  9718. return ret;
  9719. } // Consumes a specified amount of bytes from the buffered data.
  9720. }, {
  9721. key: "_getBuffer",
  9722. value: function _getBuffer(n) {
  9723. var ret = Buffer.allocUnsafe(n);
  9724. var p = this.head;
  9725. var c = 1;
  9726. p.data.copy(ret);
  9727. n -= p.data.length;
  9728. while (p = p.next) {
  9729. var buf = p.data;
  9730. var nb = n > buf.length ? buf.length : n;
  9731. buf.copy(ret, ret.length - n, 0, nb);
  9732. n -= nb;
  9733. if (n === 0) {
  9734. if (nb === buf.length) {
  9735. ++c;
  9736. if (p.next) this.head = p.next;else this.head = this.tail = null;
  9737. } else {
  9738. this.head = p;
  9739. p.data = buf.slice(nb);
  9740. }
  9741. break;
  9742. }
  9743. ++c;
  9744. }
  9745. this.length -= c;
  9746. return ret;
  9747. } // Make sure the linked list only shows the minimal necessary information.
  9748. }, {
  9749. key: custom,
  9750. value: function value(_, options) {
  9751. return inspect(this, _objectSpread({}, options, {
  9752. // Only inspect one level.
  9753. depth: 0,
  9754. // It should not recurse.
  9755. customInspect: false
  9756. }));
  9757. }
  9758. }]);
  9759. return BufferList;
  9760. }();
  9761. },{"buffer":98,"util":78}],91:[function(require,module,exports){
  9762. (function (process){
  9763. 'use strict'; // undocumented cb() API, needed for core, not for public API
  9764. function destroy(err, cb) {
  9765. var _this = this;
  9766. var readableDestroyed = this._readableState && this._readableState.destroyed;
  9767. var writableDestroyed = this._writableState && this._writableState.destroyed;
  9768. if (readableDestroyed || writableDestroyed) {
  9769. if (cb) {
  9770. cb(err);
  9771. } else if (err) {
  9772. if (!this._writableState) {
  9773. process.nextTick(emitErrorNT, this, err);
  9774. } else if (!this._writableState.errorEmitted) {
  9775. this._writableState.errorEmitted = true;
  9776. process.nextTick(emitErrorNT, this, err);
  9777. }
  9778. }
  9779. return this;
  9780. } // we set destroyed to true before firing error callbacks in order
  9781. // to make it re-entrance safe in case destroy() is called within callbacks
  9782. if (this._readableState) {
  9783. this._readableState.destroyed = true;
  9784. } // if this is a duplex stream mark the writable part as destroyed as well
  9785. if (this._writableState) {
  9786. this._writableState.destroyed = true;
  9787. }
  9788. this._destroy(err || null, function (err) {
  9789. if (!cb && err) {
  9790. if (!_this._writableState) {
  9791. process.nextTick(emitErrorAndCloseNT, _this, err);
  9792. } else if (!_this._writableState.errorEmitted) {
  9793. _this._writableState.errorEmitted = true;
  9794. process.nextTick(emitErrorAndCloseNT, _this, err);
  9795. } else {
  9796. process.nextTick(emitCloseNT, _this);
  9797. }
  9798. } else if (cb) {
  9799. process.nextTick(emitCloseNT, _this);
  9800. cb(err);
  9801. } else {
  9802. process.nextTick(emitCloseNT, _this);
  9803. }
  9804. });
  9805. return this;
  9806. }
  9807. function emitErrorAndCloseNT(self, err) {
  9808. emitErrorNT(self, err);
  9809. emitCloseNT(self);
  9810. }
  9811. function emitCloseNT(self) {
  9812. if (self._writableState && !self._writableState.emitClose) return;
  9813. if (self._readableState && !self._readableState.emitClose) return;
  9814. self.emit('close');
  9815. }
  9816. function undestroy() {
  9817. if (this._readableState) {
  9818. this._readableState.destroyed = false;
  9819. this._readableState.reading = false;
  9820. this._readableState.ended = false;
  9821. this._readableState.endEmitted = false;
  9822. }
  9823. if (this._writableState) {
  9824. this._writableState.destroyed = false;
  9825. this._writableState.ended = false;
  9826. this._writableState.ending = false;
  9827. this._writableState.finalCalled = false;
  9828. this._writableState.prefinished = false;
  9829. this._writableState.finished = false;
  9830. this._writableState.errorEmitted = false;
  9831. }
  9832. }
  9833. function emitErrorNT(self, err) {
  9834. self.emit('error', err);
  9835. }
  9836. function errorOrDestroy(stream, err) {
  9837. // We have tests that rely on errors being emitted
  9838. // in the same tick, so changing this is semver major.
  9839. // For now when you opt-in to autoDestroy we allow
  9840. // the error to be emitted nextTick. In a future
  9841. // semver major update we should change the default to this.
  9842. var rState = stream._readableState;
  9843. var wState = stream._writableState;
  9844. if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err);
  9845. }
  9846. module.exports = {
  9847. destroy: destroy,
  9848. undestroy: undestroy,
  9849. errorOrDestroy: errorOrDestroy
  9850. };
  9851. }).call(this,require('_process'))
  9852. },{"_process":393}],92:[function(require,module,exports){
  9853. // Ported from https://github.com/mafintosh/end-of-stream with
  9854. // permission from the author, Mathias Buus (@mafintosh).
  9855. 'use strict';
  9856. var ERR_STREAM_PREMATURE_CLOSE = require('../../../errors').codes.ERR_STREAM_PREMATURE_CLOSE;
  9857. function once(callback) {
  9858. var called = false;
  9859. return function () {
  9860. if (called) return;
  9861. called = true;
  9862. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  9863. args[_key] = arguments[_key];
  9864. }
  9865. callback.apply(this, args);
  9866. };
  9867. }
  9868. function noop() {}
  9869. function isRequest(stream) {
  9870. return stream.setHeader && typeof stream.abort === 'function';
  9871. }
  9872. function eos(stream, opts, callback) {
  9873. if (typeof opts === 'function') return eos(stream, null, opts);
  9874. if (!opts) opts = {};
  9875. callback = once(callback || noop);
  9876. var readable = opts.readable || opts.readable !== false && stream.readable;
  9877. var writable = opts.writable || opts.writable !== false && stream.writable;
  9878. var onlegacyfinish = function onlegacyfinish() {
  9879. if (!stream.writable) onfinish();
  9880. };
  9881. var writableEnded = stream._writableState && stream._writableState.finished;
  9882. var onfinish = function onfinish() {
  9883. writable = false;
  9884. writableEnded = true;
  9885. if (!readable) callback.call(stream);
  9886. };
  9887. var readableEnded = stream._readableState && stream._readableState.endEmitted;
  9888. var onend = function onend() {
  9889. readable = false;
  9890. readableEnded = true;
  9891. if (!writable) callback.call(stream);
  9892. };
  9893. var onerror = function onerror(err) {
  9894. callback.call(stream, err);
  9895. };
  9896. var onclose = function onclose() {
  9897. var err;
  9898. if (readable && !readableEnded) {
  9899. if (!stream._readableState || !stream._readableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();
  9900. return callback.call(stream, err);
  9901. }
  9902. if (writable && !writableEnded) {
  9903. if (!stream._writableState || !stream._writableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();
  9904. return callback.call(stream, err);
  9905. }
  9906. };
  9907. var onrequest = function onrequest() {
  9908. stream.req.on('finish', onfinish);
  9909. };
  9910. if (isRequest(stream)) {
  9911. stream.on('complete', onfinish);
  9912. stream.on('abort', onclose);
  9913. if (stream.req) onrequest();else stream.on('request', onrequest);
  9914. } else if (writable && !stream._writableState) {
  9915. // legacy streams
  9916. stream.on('end', onlegacyfinish);
  9917. stream.on('close', onlegacyfinish);
  9918. }
  9919. stream.on('end', onend);
  9920. stream.on('finish', onfinish);
  9921. if (opts.error !== false) stream.on('error', onerror);
  9922. stream.on('close', onclose);
  9923. return function () {
  9924. stream.removeListener('complete', onfinish);
  9925. stream.removeListener('abort', onclose);
  9926. stream.removeListener('request', onrequest);
  9927. if (stream.req) stream.req.removeListener('finish', onfinish);
  9928. stream.removeListener('end', onlegacyfinish);
  9929. stream.removeListener('close', onlegacyfinish);
  9930. stream.removeListener('finish', onfinish);
  9931. stream.removeListener('end', onend);
  9932. stream.removeListener('error', onerror);
  9933. stream.removeListener('close', onclose);
  9934. };
  9935. }
  9936. module.exports = eos;
  9937. },{"../../../errors":83}],93:[function(require,module,exports){
  9938. module.exports = function () {
  9939. throw new Error('Readable.from is not available in the browser')
  9940. };
  9941. },{}],94:[function(require,module,exports){
  9942. // Ported from https://github.com/mafintosh/pump with
  9943. // permission from the author, Mathias Buus (@mafintosh).
  9944. 'use strict';
  9945. var eos;
  9946. function once(callback) {
  9947. var called = false;
  9948. return function () {
  9949. if (called) return;
  9950. called = true;
  9951. callback.apply(void 0, arguments);
  9952. };
  9953. }
  9954. var _require$codes = require('../../../errors').codes,
  9955. ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS,
  9956. ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED;
  9957. function noop(err) {
  9958. // Rethrow the error if it exists to avoid swallowing it
  9959. if (err) throw err;
  9960. }
  9961. function isRequest(stream) {
  9962. return stream.setHeader && typeof stream.abort === 'function';
  9963. }
  9964. function destroyer(stream, reading, writing, callback) {
  9965. callback = once(callback);
  9966. var closed = false;
  9967. stream.on('close', function () {
  9968. closed = true;
  9969. });
  9970. if (eos === undefined) eos = require('./end-of-stream');
  9971. eos(stream, {
  9972. readable: reading,
  9973. writable: writing
  9974. }, function (err) {
  9975. if (err) return callback(err);
  9976. closed = true;
  9977. callback();
  9978. });
  9979. var destroyed = false;
  9980. return function (err) {
  9981. if (closed) return;
  9982. if (destroyed) return;
  9983. destroyed = true; // request.destroy just do .end - .abort is what we want
  9984. if (isRequest(stream)) return stream.abort();
  9985. if (typeof stream.destroy === 'function') return stream.destroy();
  9986. callback(err || new ERR_STREAM_DESTROYED('pipe'));
  9987. };
  9988. }
  9989. function call(fn) {
  9990. fn();
  9991. }
  9992. function pipe(from, to) {
  9993. return from.pipe(to);
  9994. }
  9995. function popCallback(streams) {
  9996. if (!streams.length) return noop;
  9997. if (typeof streams[streams.length - 1] !== 'function') return noop;
  9998. return streams.pop();
  9999. }
  10000. function pipeline() {
  10001. for (var _len = arguments.length, streams = new Array(_len), _key = 0; _key < _len; _key++) {
  10002. streams[_key] = arguments[_key];
  10003. }
  10004. var callback = popCallback(streams);
  10005. if (Array.isArray(streams[0])) streams = streams[0];
  10006. if (streams.length < 2) {
  10007. throw new ERR_MISSING_ARGS('streams');
  10008. }
  10009. var error;
  10010. var destroys = streams.map(function (stream, i) {
  10011. var reading = i < streams.length - 1;
  10012. var writing = i > 0;
  10013. return destroyer(stream, reading, writing, function (err) {
  10014. if (!error) error = err;
  10015. if (err) destroys.forEach(call);
  10016. if (reading) return;
  10017. destroys.forEach(call);
  10018. callback(error);
  10019. });
  10020. });
  10021. return streams.reduce(pipe);
  10022. }
  10023. module.exports = pipeline;
  10024. },{"../../../errors":83,"./end-of-stream":92}],95:[function(require,module,exports){
  10025. 'use strict';
  10026. var ERR_INVALID_OPT_VALUE = require('../../../errors').codes.ERR_INVALID_OPT_VALUE;
  10027. function highWaterMarkFrom(options, isDuplex, duplexKey) {
  10028. return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
  10029. }
  10030. function getHighWaterMark(state, options, duplexKey, isDuplex) {
  10031. var hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
  10032. if (hwm != null) {
  10033. if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
  10034. var name = isDuplex ? duplexKey : 'highWaterMark';
  10035. throw new ERR_INVALID_OPT_VALUE(name, hwm);
  10036. }
  10037. return Math.floor(hwm);
  10038. } // Default value
  10039. return state.objectMode ? 16 : 16 * 1024;
  10040. }
  10041. module.exports = {
  10042. getHighWaterMark: getHighWaterMark
  10043. };
  10044. },{"../../../errors":83}],96:[function(require,module,exports){
  10045. module.exports = require('events').EventEmitter;
  10046. },{"events":297}],97:[function(require,module,exports){
  10047. exports = module.exports = require('./lib/_stream_readable.js');
  10048. exports.Stream = exports;
  10049. exports.Readable = exports;
  10050. exports.Writable = require('./lib/_stream_writable.js');
  10051. exports.Duplex = require('./lib/_stream_duplex.js');
  10052. exports.Transform = require('./lib/_stream_transform.js');
  10053. exports.PassThrough = require('./lib/_stream_passthrough.js');
  10054. exports.finished = require('./lib/internal/streams/end-of-stream.js');
  10055. exports.pipeline = require('./lib/internal/streams/pipeline.js');
  10056. },{"./lib/_stream_duplex.js":84,"./lib/_stream_passthrough.js":85,"./lib/_stream_readable.js":86,"./lib/_stream_transform.js":87,"./lib/_stream_writable.js":88,"./lib/internal/streams/end-of-stream.js":92,"./lib/internal/streams/pipeline.js":94}],98:[function(require,module,exports){
  10057. (function (Buffer){
  10058. /*!
  10059. * The buffer module from node.js, for the browser.
  10060. *
  10061. * @author Feross Aboukhadijeh <https://feross.org>
  10062. * @license MIT
  10063. */
  10064. /* eslint-disable no-proto */
  10065. 'use strict'
  10066. var base64 = require('base64-js')
  10067. var ieee754 = require('ieee754')
  10068. exports.Buffer = Buffer
  10069. exports.SlowBuffer = SlowBuffer
  10070. exports.INSPECT_MAX_BYTES = 50
  10071. var K_MAX_LENGTH = 0x7fffffff
  10072. exports.kMaxLength = K_MAX_LENGTH
  10073. /**
  10074. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  10075. * === true Use Uint8Array implementation (fastest)
  10076. * === false Print warning and recommend using `buffer` v4.x which has an Object
  10077. * implementation (most compatible, even IE6)
  10078. *
  10079. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  10080. * Opera 11.6+, iOS 4.2+.
  10081. *
  10082. * We report that the browser does not support typed arrays if the are not subclassable
  10083. * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
  10084. * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
  10085. * for __proto__ and has a buggy typed array implementation.
  10086. */
  10087. Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
  10088. if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
  10089. typeof console.error === 'function') {
  10090. console.error(
  10091. 'This browser lacks typed array (Uint8Array) support which is required by ' +
  10092. '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
  10093. )
  10094. }
  10095. function typedArraySupport () {
  10096. // Can typed array instances can be augmented?
  10097. try {
  10098. var arr = new Uint8Array(1)
  10099. arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } }
  10100. return arr.foo() === 42
  10101. } catch (e) {
  10102. return false
  10103. }
  10104. }
  10105. Object.defineProperty(Buffer.prototype, 'parent', {
  10106. enumerable: true,
  10107. get: function () {
  10108. if (!Buffer.isBuffer(this)) return undefined
  10109. return this.buffer
  10110. }
  10111. })
  10112. Object.defineProperty(Buffer.prototype, 'offset', {
  10113. enumerable: true,
  10114. get: function () {
  10115. if (!Buffer.isBuffer(this)) return undefined
  10116. return this.byteOffset
  10117. }
  10118. })
  10119. function createBuffer (length) {
  10120. if (length > K_MAX_LENGTH) {
  10121. throw new RangeError('The value "' + length + '" is invalid for option "size"')
  10122. }
  10123. // Return an augmented `Uint8Array` instance
  10124. var buf = new Uint8Array(length)
  10125. buf.__proto__ = Buffer.prototype
  10126. return buf
  10127. }
  10128. /**
  10129. * The Buffer constructor returns instances of `Uint8Array` that have their
  10130. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  10131. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  10132. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  10133. * returns a single octet.
  10134. *
  10135. * The `Uint8Array` prototype remains unmodified.
  10136. */
  10137. function Buffer (arg, encodingOrOffset, length) {
  10138. // Common case.
  10139. if (typeof arg === 'number') {
  10140. if (typeof encodingOrOffset === 'string') {
  10141. throw new TypeError(
  10142. 'The "string" argument must be of type string. Received type number'
  10143. )
  10144. }
  10145. return allocUnsafe(arg)
  10146. }
  10147. return from(arg, encodingOrOffset, length)
  10148. }
  10149. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  10150. if (typeof Symbol !== 'undefined' && Symbol.species != null &&
  10151. Buffer[Symbol.species] === Buffer) {
  10152. Object.defineProperty(Buffer, Symbol.species, {
  10153. value: null,
  10154. configurable: true,
  10155. enumerable: false,
  10156. writable: false
  10157. })
  10158. }
  10159. Buffer.poolSize = 8192 // not used by this implementation
  10160. function from (value, encodingOrOffset, length) {
  10161. if (typeof value === 'string') {
  10162. return fromString(value, encodingOrOffset)
  10163. }
  10164. if (ArrayBuffer.isView(value)) {
  10165. return fromArrayLike(value)
  10166. }
  10167. if (value == null) {
  10168. throw TypeError(
  10169. 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
  10170. 'or Array-like Object. Received type ' + (typeof value)
  10171. )
  10172. }
  10173. if (isInstance(value, ArrayBuffer) ||
  10174. (value && isInstance(value.buffer, ArrayBuffer))) {
  10175. return fromArrayBuffer(value, encodingOrOffset, length)
  10176. }
  10177. if (typeof value === 'number') {
  10178. throw new TypeError(
  10179. 'The "value" argument must not be of type number. Received type number'
  10180. )
  10181. }
  10182. var valueOf = value.valueOf && value.valueOf()
  10183. if (valueOf != null && valueOf !== value) {
  10184. return Buffer.from(valueOf, encodingOrOffset, length)
  10185. }
  10186. var b = fromObject(value)
  10187. if (b) return b
  10188. if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
  10189. typeof value[Symbol.toPrimitive] === 'function') {
  10190. return Buffer.from(
  10191. value[Symbol.toPrimitive]('string'), encodingOrOffset, length
  10192. )
  10193. }
  10194. throw new TypeError(
  10195. 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
  10196. 'or Array-like Object. Received type ' + (typeof value)
  10197. )
  10198. }
  10199. /**
  10200. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  10201. * if value is a number.
  10202. * Buffer.from(str[, encoding])
  10203. * Buffer.from(array)
  10204. * Buffer.from(buffer)
  10205. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  10206. **/
  10207. Buffer.from = function (value, encodingOrOffset, length) {
  10208. return from(value, encodingOrOffset, length)
  10209. }
  10210. // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
  10211. // https://github.com/feross/buffer/pull/148
  10212. Buffer.prototype.__proto__ = Uint8Array.prototype
  10213. Buffer.__proto__ = Uint8Array
  10214. function assertSize (size) {
  10215. if (typeof size !== 'number') {
  10216. throw new TypeError('"size" argument must be of type number')
  10217. } else if (size < 0) {
  10218. throw new RangeError('The value "' + size + '" is invalid for option "size"')
  10219. }
  10220. }
  10221. function alloc (size, fill, encoding) {
  10222. assertSize(size)
  10223. if (size <= 0) {
  10224. return createBuffer(size)
  10225. }
  10226. if (fill !== undefined) {
  10227. // Only pay attention to encoding if it's a string. This
  10228. // prevents accidentally sending in a number that would
  10229. // be interpretted as a start offset.
  10230. return typeof encoding === 'string'
  10231. ? createBuffer(size).fill(fill, encoding)
  10232. : createBuffer(size).fill(fill)
  10233. }
  10234. return createBuffer(size)
  10235. }
  10236. /**
  10237. * Creates a new filled Buffer instance.
  10238. * alloc(size[, fill[, encoding]])
  10239. **/
  10240. Buffer.alloc = function (size, fill, encoding) {
  10241. return alloc(size, fill, encoding)
  10242. }
  10243. function allocUnsafe (size) {
  10244. assertSize(size)
  10245. return createBuffer(size < 0 ? 0 : checked(size) | 0)
  10246. }
  10247. /**
  10248. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  10249. * */
  10250. Buffer.allocUnsafe = function (size) {
  10251. return allocUnsafe(size)
  10252. }
  10253. /**
  10254. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  10255. */
  10256. Buffer.allocUnsafeSlow = function (size) {
  10257. return allocUnsafe(size)
  10258. }
  10259. function fromString (string, encoding) {
  10260. if (typeof encoding !== 'string' || encoding === '') {
  10261. encoding = 'utf8'
  10262. }
  10263. if (!Buffer.isEncoding(encoding)) {
  10264. throw new TypeError('Unknown encoding: ' + encoding)
  10265. }
  10266. var length = byteLength(string, encoding) | 0
  10267. var buf = createBuffer(length)
  10268. var actual = buf.write(string, encoding)
  10269. if (actual !== length) {
  10270. // Writing a hex string, for example, that contains invalid characters will
  10271. // cause everything after the first invalid character to be ignored. (e.g.
  10272. // 'abxxcd' will be treated as 'ab')
  10273. buf = buf.slice(0, actual)
  10274. }
  10275. return buf
  10276. }
  10277. function fromArrayLike (array) {
  10278. var length = array.length < 0 ? 0 : checked(array.length) | 0
  10279. var buf = createBuffer(length)
  10280. for (var i = 0; i < length; i += 1) {
  10281. buf[i] = array[i] & 255
  10282. }
  10283. return buf
  10284. }
  10285. function fromArrayBuffer (array, byteOffset, length) {
  10286. if (byteOffset < 0 || array.byteLength < byteOffset) {
  10287. throw new RangeError('"offset" is outside of buffer bounds')
  10288. }
  10289. if (array.byteLength < byteOffset + (length || 0)) {
  10290. throw new RangeError('"length" is outside of buffer bounds')
  10291. }
  10292. var buf
  10293. if (byteOffset === undefined && length === undefined) {
  10294. buf = new Uint8Array(array)
  10295. } else if (length === undefined) {
  10296. buf = new Uint8Array(array, byteOffset)
  10297. } else {
  10298. buf = new Uint8Array(array, byteOffset, length)
  10299. }
  10300. // Return an augmented `Uint8Array` instance
  10301. buf.__proto__ = Buffer.prototype
  10302. return buf
  10303. }
  10304. function fromObject (obj) {
  10305. if (Buffer.isBuffer(obj)) {
  10306. var len = checked(obj.length) | 0
  10307. var buf = createBuffer(len)
  10308. if (buf.length === 0) {
  10309. return buf
  10310. }
  10311. obj.copy(buf, 0, 0, len)
  10312. return buf
  10313. }
  10314. if (obj.length !== undefined) {
  10315. if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
  10316. return createBuffer(0)
  10317. }
  10318. return fromArrayLike(obj)
  10319. }
  10320. if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
  10321. return fromArrayLike(obj.data)
  10322. }
  10323. }
  10324. function checked (length) {
  10325. // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
  10326. // length is NaN (which is otherwise coerced to zero.)
  10327. if (length >= K_MAX_LENGTH) {
  10328. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  10329. 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
  10330. }
  10331. return length | 0
  10332. }
  10333. function SlowBuffer (length) {
  10334. if (+length != length) { // eslint-disable-line eqeqeq
  10335. length = 0
  10336. }
  10337. return Buffer.alloc(+length)
  10338. }
  10339. Buffer.isBuffer = function isBuffer (b) {
  10340. return b != null && b._isBuffer === true &&
  10341. b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
  10342. }
  10343. Buffer.compare = function compare (a, b) {
  10344. if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)
  10345. if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)
  10346. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  10347. throw new TypeError(
  10348. 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
  10349. )
  10350. }
  10351. if (a === b) return 0
  10352. var x = a.length
  10353. var y = b.length
  10354. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  10355. if (a[i] !== b[i]) {
  10356. x = a[i]
  10357. y = b[i]
  10358. break
  10359. }
  10360. }
  10361. if (x < y) return -1
  10362. if (y < x) return 1
  10363. return 0
  10364. }
  10365. Buffer.isEncoding = function isEncoding (encoding) {
  10366. switch (String(encoding).toLowerCase()) {
  10367. case 'hex':
  10368. case 'utf8':
  10369. case 'utf-8':
  10370. case 'ascii':
  10371. case 'latin1':
  10372. case 'binary':
  10373. case 'base64':
  10374. case 'ucs2':
  10375. case 'ucs-2':
  10376. case 'utf16le':
  10377. case 'utf-16le':
  10378. return true
  10379. default:
  10380. return false
  10381. }
  10382. }
  10383. Buffer.concat = function concat (list, length) {
  10384. if (!Array.isArray(list)) {
  10385. throw new TypeError('"list" argument must be an Array of Buffers')
  10386. }
  10387. if (list.length === 0) {
  10388. return Buffer.alloc(0)
  10389. }
  10390. var i
  10391. if (length === undefined) {
  10392. length = 0
  10393. for (i = 0; i < list.length; ++i) {
  10394. length += list[i].length
  10395. }
  10396. }
  10397. var buffer = Buffer.allocUnsafe(length)
  10398. var pos = 0
  10399. for (i = 0; i < list.length; ++i) {
  10400. var buf = list[i]
  10401. if (isInstance(buf, Uint8Array)) {
  10402. buf = Buffer.from(buf)
  10403. }
  10404. if (!Buffer.isBuffer(buf)) {
  10405. throw new TypeError('"list" argument must be an Array of Buffers')
  10406. }
  10407. buf.copy(buffer, pos)
  10408. pos += buf.length
  10409. }
  10410. return buffer
  10411. }
  10412. function byteLength (string, encoding) {
  10413. if (Buffer.isBuffer(string)) {
  10414. return string.length
  10415. }
  10416. if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
  10417. return string.byteLength
  10418. }
  10419. if (typeof string !== 'string') {
  10420. throw new TypeError(
  10421. 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
  10422. 'Received type ' + typeof string
  10423. )
  10424. }
  10425. var len = string.length
  10426. var mustMatch = (arguments.length > 2 && arguments[2] === true)
  10427. if (!mustMatch && len === 0) return 0
  10428. // Use a for loop to avoid recursion
  10429. var loweredCase = false
  10430. for (;;) {
  10431. switch (encoding) {
  10432. case 'ascii':
  10433. case 'latin1':
  10434. case 'binary':
  10435. return len
  10436. case 'utf8':
  10437. case 'utf-8':
  10438. return utf8ToBytes(string).length
  10439. case 'ucs2':
  10440. case 'ucs-2':
  10441. case 'utf16le':
  10442. case 'utf-16le':
  10443. return len * 2
  10444. case 'hex':
  10445. return len >>> 1
  10446. case 'base64':
  10447. return base64ToBytes(string).length
  10448. default:
  10449. if (loweredCase) {
  10450. return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
  10451. }
  10452. encoding = ('' + encoding).toLowerCase()
  10453. loweredCase = true
  10454. }
  10455. }
  10456. }
  10457. Buffer.byteLength = byteLength
  10458. function slowToString (encoding, start, end) {
  10459. var loweredCase = false
  10460. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  10461. // property of a typed array.
  10462. // This behaves neither like String nor Uint8Array in that we set start/end
  10463. // to their upper/lower bounds if the value passed is out of range.
  10464. // undefined is handled specially as per ECMA-262 6th Edition,
  10465. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  10466. if (start === undefined || start < 0) {
  10467. start = 0
  10468. }
  10469. // Return early if start > this.length. Done here to prevent potential uint32
  10470. // coercion fail below.
  10471. if (start > this.length) {
  10472. return ''
  10473. }
  10474. if (end === undefined || end > this.length) {
  10475. end = this.length
  10476. }
  10477. if (end <= 0) {
  10478. return ''
  10479. }
  10480. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  10481. end >>>= 0
  10482. start >>>= 0
  10483. if (end <= start) {
  10484. return ''
  10485. }
  10486. if (!encoding) encoding = 'utf8'
  10487. while (true) {
  10488. switch (encoding) {
  10489. case 'hex':
  10490. return hexSlice(this, start, end)
  10491. case 'utf8':
  10492. case 'utf-8':
  10493. return utf8Slice(this, start, end)
  10494. case 'ascii':
  10495. return asciiSlice(this, start, end)
  10496. case 'latin1':
  10497. case 'binary':
  10498. return latin1Slice(this, start, end)
  10499. case 'base64':
  10500. return base64Slice(this, start, end)
  10501. case 'ucs2':
  10502. case 'ucs-2':
  10503. case 'utf16le':
  10504. case 'utf-16le':
  10505. return utf16leSlice(this, start, end)
  10506. default:
  10507. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  10508. encoding = (encoding + '').toLowerCase()
  10509. loweredCase = true
  10510. }
  10511. }
  10512. }
  10513. // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
  10514. // to detect a Buffer instance. It's not possible to use `instanceof Buffer`
  10515. // reliably in a browserify context because there could be multiple different
  10516. // copies of the 'buffer' package in use. This method works even for Buffer
  10517. // instances that were created from another copy of the `buffer` package.
  10518. // See: https://github.com/feross/buffer/issues/154
  10519. Buffer.prototype._isBuffer = true
  10520. function swap (b, n, m) {
  10521. var i = b[n]
  10522. b[n] = b[m]
  10523. b[m] = i
  10524. }
  10525. Buffer.prototype.swap16 = function swap16 () {
  10526. var len = this.length
  10527. if (len % 2 !== 0) {
  10528. throw new RangeError('Buffer size must be a multiple of 16-bits')
  10529. }
  10530. for (var i = 0; i < len; i += 2) {
  10531. swap(this, i, i + 1)
  10532. }
  10533. return this
  10534. }
  10535. Buffer.prototype.swap32 = function swap32 () {
  10536. var len = this.length
  10537. if (len % 4 !== 0) {
  10538. throw new RangeError('Buffer size must be a multiple of 32-bits')
  10539. }
  10540. for (var i = 0; i < len; i += 4) {
  10541. swap(this, i, i + 3)
  10542. swap(this, i + 1, i + 2)
  10543. }
  10544. return this
  10545. }
  10546. Buffer.prototype.swap64 = function swap64 () {
  10547. var len = this.length
  10548. if (len % 8 !== 0) {
  10549. throw new RangeError('Buffer size must be a multiple of 64-bits')
  10550. }
  10551. for (var i = 0; i < len; i += 8) {
  10552. swap(this, i, i + 7)
  10553. swap(this, i + 1, i + 6)
  10554. swap(this, i + 2, i + 5)
  10555. swap(this, i + 3, i + 4)
  10556. }
  10557. return this
  10558. }
  10559. Buffer.prototype.toString = function toString () {
  10560. var length = this.length
  10561. if (length === 0) return ''
  10562. if (arguments.length === 0) return utf8Slice(this, 0, length)
  10563. return slowToString.apply(this, arguments)
  10564. }
  10565. Buffer.prototype.toLocaleString = Buffer.prototype.toString
  10566. Buffer.prototype.equals = function equals (b) {
  10567. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  10568. if (this === b) return true
  10569. return Buffer.compare(this, b) === 0
  10570. }
  10571. Buffer.prototype.inspect = function inspect () {
  10572. var str = ''
  10573. var max = exports.INSPECT_MAX_BYTES
  10574. str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()
  10575. if (this.length > max) str += ' ... '
  10576. return '<Buffer ' + str + '>'
  10577. }
  10578. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  10579. if (isInstance(target, Uint8Array)) {
  10580. target = Buffer.from(target, target.offset, target.byteLength)
  10581. }
  10582. if (!Buffer.isBuffer(target)) {
  10583. throw new TypeError(
  10584. 'The "target" argument must be one of type Buffer or Uint8Array. ' +
  10585. 'Received type ' + (typeof target)
  10586. )
  10587. }
  10588. if (start === undefined) {
  10589. start = 0
  10590. }
  10591. if (end === undefined) {
  10592. end = target ? target.length : 0
  10593. }
  10594. if (thisStart === undefined) {
  10595. thisStart = 0
  10596. }
  10597. if (thisEnd === undefined) {
  10598. thisEnd = this.length
  10599. }
  10600. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  10601. throw new RangeError('out of range index')
  10602. }
  10603. if (thisStart >= thisEnd && start >= end) {
  10604. return 0
  10605. }
  10606. if (thisStart >= thisEnd) {
  10607. return -1
  10608. }
  10609. if (start >= end) {
  10610. return 1
  10611. }
  10612. start >>>= 0
  10613. end >>>= 0
  10614. thisStart >>>= 0
  10615. thisEnd >>>= 0
  10616. if (this === target) return 0
  10617. var x = thisEnd - thisStart
  10618. var y = end - start
  10619. var len = Math.min(x, y)
  10620. var thisCopy = this.slice(thisStart, thisEnd)
  10621. var targetCopy = target.slice(start, end)
  10622. for (var i = 0; i < len; ++i) {
  10623. if (thisCopy[i] !== targetCopy[i]) {
  10624. x = thisCopy[i]
  10625. y = targetCopy[i]
  10626. break
  10627. }
  10628. }
  10629. if (x < y) return -1
  10630. if (y < x) return 1
  10631. return 0
  10632. }
  10633. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  10634. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  10635. //
  10636. // Arguments:
  10637. // - buffer - a Buffer to search
  10638. // - val - a string, Buffer, or number
  10639. // - byteOffset - an index into `buffer`; will be clamped to an int32
  10640. // - encoding - an optional encoding, relevant is val is a string
  10641. // - dir - true for indexOf, false for lastIndexOf
  10642. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  10643. // Empty buffer means no match
  10644. if (buffer.length === 0) return -1
  10645. // Normalize byteOffset
  10646. if (typeof byteOffset === 'string') {
  10647. encoding = byteOffset
  10648. byteOffset = 0
  10649. } else if (byteOffset > 0x7fffffff) {
  10650. byteOffset = 0x7fffffff
  10651. } else if (byteOffset < -0x80000000) {
  10652. byteOffset = -0x80000000
  10653. }
  10654. byteOffset = +byteOffset // Coerce to Number.
  10655. if (numberIsNaN(byteOffset)) {
  10656. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  10657. byteOffset = dir ? 0 : (buffer.length - 1)
  10658. }
  10659. // Normalize byteOffset: negative offsets start from the end of the buffer
  10660. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  10661. if (byteOffset >= buffer.length) {
  10662. if (dir) return -1
  10663. else byteOffset = buffer.length - 1
  10664. } else if (byteOffset < 0) {
  10665. if (dir) byteOffset = 0
  10666. else return -1
  10667. }
  10668. // Normalize val
  10669. if (typeof val === 'string') {
  10670. val = Buffer.from(val, encoding)
  10671. }
  10672. // Finally, search either indexOf (if dir is true) or lastIndexOf
  10673. if (Buffer.isBuffer(val)) {
  10674. // Special case: looking for empty string/buffer always fails
  10675. if (val.length === 0) {
  10676. return -1
  10677. }
  10678. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  10679. } else if (typeof val === 'number') {
  10680. val = val & 0xFF // Search for a byte value [0-255]
  10681. if (typeof Uint8Array.prototype.indexOf === 'function') {
  10682. if (dir) {
  10683. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  10684. } else {
  10685. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  10686. }
  10687. }
  10688. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  10689. }
  10690. throw new TypeError('val must be string, number or Buffer')
  10691. }
  10692. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  10693. var indexSize = 1
  10694. var arrLength = arr.length
  10695. var valLength = val.length
  10696. if (encoding !== undefined) {
  10697. encoding = String(encoding).toLowerCase()
  10698. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  10699. encoding === 'utf16le' || encoding === 'utf-16le') {
  10700. if (arr.length < 2 || val.length < 2) {
  10701. return -1
  10702. }
  10703. indexSize = 2
  10704. arrLength /= 2
  10705. valLength /= 2
  10706. byteOffset /= 2
  10707. }
  10708. }
  10709. function read (buf, i) {
  10710. if (indexSize === 1) {
  10711. return buf[i]
  10712. } else {
  10713. return buf.readUInt16BE(i * indexSize)
  10714. }
  10715. }
  10716. var i
  10717. if (dir) {
  10718. var foundIndex = -1
  10719. for (i = byteOffset; i < arrLength; i++) {
  10720. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  10721. if (foundIndex === -1) foundIndex = i
  10722. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  10723. } else {
  10724. if (foundIndex !== -1) i -= i - foundIndex
  10725. foundIndex = -1
  10726. }
  10727. }
  10728. } else {
  10729. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  10730. for (i = byteOffset; i >= 0; i--) {
  10731. var found = true
  10732. for (var j = 0; j < valLength; j++) {
  10733. if (read(arr, i + j) !== read(val, j)) {
  10734. found = false
  10735. break
  10736. }
  10737. }
  10738. if (found) return i
  10739. }
  10740. }
  10741. return -1
  10742. }
  10743. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  10744. return this.indexOf(val, byteOffset, encoding) !== -1
  10745. }
  10746. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  10747. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  10748. }
  10749. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  10750. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  10751. }
  10752. function hexWrite (buf, string, offset, length) {
  10753. offset = Number(offset) || 0
  10754. var remaining = buf.length - offset
  10755. if (!length) {
  10756. length = remaining
  10757. } else {
  10758. length = Number(length)
  10759. if (length > remaining) {
  10760. length = remaining
  10761. }
  10762. }
  10763. var strLen = string.length
  10764. if (length > strLen / 2) {
  10765. length = strLen / 2
  10766. }
  10767. for (var i = 0; i < length; ++i) {
  10768. var parsed = parseInt(string.substr(i * 2, 2), 16)
  10769. if (numberIsNaN(parsed)) return i
  10770. buf[offset + i] = parsed
  10771. }
  10772. return i
  10773. }
  10774. function utf8Write (buf, string, offset, length) {
  10775. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  10776. }
  10777. function asciiWrite (buf, string, offset, length) {
  10778. return blitBuffer(asciiToBytes(string), buf, offset, length)
  10779. }
  10780. function latin1Write (buf, string, offset, length) {
  10781. return asciiWrite(buf, string, offset, length)
  10782. }
  10783. function base64Write (buf, string, offset, length) {
  10784. return blitBuffer(base64ToBytes(string), buf, offset, length)
  10785. }
  10786. function ucs2Write (buf, string, offset, length) {
  10787. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  10788. }
  10789. Buffer.prototype.write = function write (string, offset, length, encoding) {
  10790. // Buffer#write(string)
  10791. if (offset === undefined) {
  10792. encoding = 'utf8'
  10793. length = this.length
  10794. offset = 0
  10795. // Buffer#write(string, encoding)
  10796. } else if (length === undefined && typeof offset === 'string') {
  10797. encoding = offset
  10798. length = this.length
  10799. offset = 0
  10800. // Buffer#write(string, offset[, length][, encoding])
  10801. } else if (isFinite(offset)) {
  10802. offset = offset >>> 0
  10803. if (isFinite(length)) {
  10804. length = length >>> 0
  10805. if (encoding === undefined) encoding = 'utf8'
  10806. } else {
  10807. encoding = length
  10808. length = undefined
  10809. }
  10810. } else {
  10811. throw new Error(
  10812. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  10813. )
  10814. }
  10815. var remaining = this.length - offset
  10816. if (length === undefined || length > remaining) length = remaining
  10817. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  10818. throw new RangeError('Attempt to write outside buffer bounds')
  10819. }
  10820. if (!encoding) encoding = 'utf8'
  10821. var loweredCase = false
  10822. for (;;) {
  10823. switch (encoding) {
  10824. case 'hex':
  10825. return hexWrite(this, string, offset, length)
  10826. case 'utf8':
  10827. case 'utf-8':
  10828. return utf8Write(this, string, offset, length)
  10829. case 'ascii':
  10830. return asciiWrite(this, string, offset, length)
  10831. case 'latin1':
  10832. case 'binary':
  10833. return latin1Write(this, string, offset, length)
  10834. case 'base64':
  10835. // Warning: maxLength not taken into account in base64Write
  10836. return base64Write(this, string, offset, length)
  10837. case 'ucs2':
  10838. case 'ucs-2':
  10839. case 'utf16le':
  10840. case 'utf-16le':
  10841. return ucs2Write(this, string, offset, length)
  10842. default:
  10843. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  10844. encoding = ('' + encoding).toLowerCase()
  10845. loweredCase = true
  10846. }
  10847. }
  10848. }
  10849. Buffer.prototype.toJSON = function toJSON () {
  10850. return {
  10851. type: 'Buffer',
  10852. data: Array.prototype.slice.call(this._arr || this, 0)
  10853. }
  10854. }
  10855. function base64Slice (buf, start, end) {
  10856. if (start === 0 && end === buf.length) {
  10857. return base64.fromByteArray(buf)
  10858. } else {
  10859. return base64.fromByteArray(buf.slice(start, end))
  10860. }
  10861. }
  10862. function utf8Slice (buf, start, end) {
  10863. end = Math.min(buf.length, end)
  10864. var res = []
  10865. var i = start
  10866. while (i < end) {
  10867. var firstByte = buf[i]
  10868. var codePoint = null
  10869. var bytesPerSequence = (firstByte > 0xEF) ? 4
  10870. : (firstByte > 0xDF) ? 3
  10871. : (firstByte > 0xBF) ? 2
  10872. : 1
  10873. if (i + bytesPerSequence <= end) {
  10874. var secondByte, thirdByte, fourthByte, tempCodePoint
  10875. switch (bytesPerSequence) {
  10876. case 1:
  10877. if (firstByte < 0x80) {
  10878. codePoint = firstByte
  10879. }
  10880. break
  10881. case 2:
  10882. secondByte = buf[i + 1]
  10883. if ((secondByte & 0xC0) === 0x80) {
  10884. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  10885. if (tempCodePoint > 0x7F) {
  10886. codePoint = tempCodePoint
  10887. }
  10888. }
  10889. break
  10890. case 3:
  10891. secondByte = buf[i + 1]
  10892. thirdByte = buf[i + 2]
  10893. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  10894. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  10895. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  10896. codePoint = tempCodePoint
  10897. }
  10898. }
  10899. break
  10900. case 4:
  10901. secondByte = buf[i + 1]
  10902. thirdByte = buf[i + 2]
  10903. fourthByte = buf[i + 3]
  10904. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  10905. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  10906. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  10907. codePoint = tempCodePoint
  10908. }
  10909. }
  10910. }
  10911. }
  10912. if (codePoint === null) {
  10913. // we did not generate a valid codePoint so insert a
  10914. // replacement char (U+FFFD) and advance only 1 byte
  10915. codePoint = 0xFFFD
  10916. bytesPerSequence = 1
  10917. } else if (codePoint > 0xFFFF) {
  10918. // encode to utf16 (surrogate pair dance)
  10919. codePoint -= 0x10000
  10920. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  10921. codePoint = 0xDC00 | codePoint & 0x3FF
  10922. }
  10923. res.push(codePoint)
  10924. i += bytesPerSequence
  10925. }
  10926. return decodeCodePointsArray(res)
  10927. }
  10928. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  10929. // the lowest limit is Chrome, with 0x10000 args.
  10930. // We go 1 magnitude less, for safety
  10931. var MAX_ARGUMENTS_LENGTH = 0x1000
  10932. function decodeCodePointsArray (codePoints) {
  10933. var len = codePoints.length
  10934. if (len <= MAX_ARGUMENTS_LENGTH) {
  10935. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  10936. }
  10937. // Decode in chunks to avoid "call stack size exceeded".
  10938. var res = ''
  10939. var i = 0
  10940. while (i < len) {
  10941. res += String.fromCharCode.apply(
  10942. String,
  10943. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  10944. )
  10945. }
  10946. return res
  10947. }
  10948. function asciiSlice (buf, start, end) {
  10949. var ret = ''
  10950. end = Math.min(buf.length, end)
  10951. for (var i = start; i < end; ++i) {
  10952. ret += String.fromCharCode(buf[i] & 0x7F)
  10953. }
  10954. return ret
  10955. }
  10956. function latin1Slice (buf, start, end) {
  10957. var ret = ''
  10958. end = Math.min(buf.length, end)
  10959. for (var i = start; i < end; ++i) {
  10960. ret += String.fromCharCode(buf[i])
  10961. }
  10962. return ret
  10963. }
  10964. function hexSlice (buf, start, end) {
  10965. var len = buf.length
  10966. if (!start || start < 0) start = 0
  10967. if (!end || end < 0 || end > len) end = len
  10968. var out = ''
  10969. for (var i = start; i < end; ++i) {
  10970. out += toHex(buf[i])
  10971. }
  10972. return out
  10973. }
  10974. function utf16leSlice (buf, start, end) {
  10975. var bytes = buf.slice(start, end)
  10976. var res = ''
  10977. for (var i = 0; i < bytes.length; i += 2) {
  10978. res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
  10979. }
  10980. return res
  10981. }
  10982. Buffer.prototype.slice = function slice (start, end) {
  10983. var len = this.length
  10984. start = ~~start
  10985. end = end === undefined ? len : ~~end
  10986. if (start < 0) {
  10987. start += len
  10988. if (start < 0) start = 0
  10989. } else if (start > len) {
  10990. start = len
  10991. }
  10992. if (end < 0) {
  10993. end += len
  10994. if (end < 0) end = 0
  10995. } else if (end > len) {
  10996. end = len
  10997. }
  10998. if (end < start) end = start
  10999. var newBuf = this.subarray(start, end)
  11000. // Return an augmented `Uint8Array` instance
  11001. newBuf.__proto__ = Buffer.prototype
  11002. return newBuf
  11003. }
  11004. /*
  11005. * Need to make sure that buffer isn't trying to write out of bounds.
  11006. */
  11007. function checkOffset (offset, ext, length) {
  11008. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  11009. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  11010. }
  11011. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  11012. offset = offset >>> 0
  11013. byteLength = byteLength >>> 0
  11014. if (!noAssert) checkOffset(offset, byteLength, this.length)
  11015. var val = this[offset]
  11016. var mul = 1
  11017. var i = 0
  11018. while (++i < byteLength && (mul *= 0x100)) {
  11019. val += this[offset + i] * mul
  11020. }
  11021. return val
  11022. }
  11023. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  11024. offset = offset >>> 0
  11025. byteLength = byteLength >>> 0
  11026. if (!noAssert) {
  11027. checkOffset(offset, byteLength, this.length)
  11028. }
  11029. var val = this[offset + --byteLength]
  11030. var mul = 1
  11031. while (byteLength > 0 && (mul *= 0x100)) {
  11032. val += this[offset + --byteLength] * mul
  11033. }
  11034. return val
  11035. }
  11036. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  11037. offset = offset >>> 0
  11038. if (!noAssert) checkOffset(offset, 1, this.length)
  11039. return this[offset]
  11040. }
  11041. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  11042. offset = offset >>> 0
  11043. if (!noAssert) checkOffset(offset, 2, this.length)
  11044. return this[offset] | (this[offset + 1] << 8)
  11045. }
  11046. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  11047. offset = offset >>> 0
  11048. if (!noAssert) checkOffset(offset, 2, this.length)
  11049. return (this[offset] << 8) | this[offset + 1]
  11050. }
  11051. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  11052. offset = offset >>> 0
  11053. if (!noAssert) checkOffset(offset, 4, this.length)
  11054. return ((this[offset]) |
  11055. (this[offset + 1] << 8) |
  11056. (this[offset + 2] << 16)) +
  11057. (this[offset + 3] * 0x1000000)
  11058. }
  11059. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  11060. offset = offset >>> 0
  11061. if (!noAssert) checkOffset(offset, 4, this.length)
  11062. return (this[offset] * 0x1000000) +
  11063. ((this[offset + 1] << 16) |
  11064. (this[offset + 2] << 8) |
  11065. this[offset + 3])
  11066. }
  11067. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  11068. offset = offset >>> 0
  11069. byteLength = byteLength >>> 0
  11070. if (!noAssert) checkOffset(offset, byteLength, this.length)
  11071. var val = this[offset]
  11072. var mul = 1
  11073. var i = 0
  11074. while (++i < byteLength && (mul *= 0x100)) {
  11075. val += this[offset + i] * mul
  11076. }
  11077. mul *= 0x80
  11078. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  11079. return val
  11080. }
  11081. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  11082. offset = offset >>> 0
  11083. byteLength = byteLength >>> 0
  11084. if (!noAssert) checkOffset(offset, byteLength, this.length)
  11085. var i = byteLength
  11086. var mul = 1
  11087. var val = this[offset + --i]
  11088. while (i > 0 && (mul *= 0x100)) {
  11089. val += this[offset + --i] * mul
  11090. }
  11091. mul *= 0x80
  11092. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  11093. return val
  11094. }
  11095. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  11096. offset = offset >>> 0
  11097. if (!noAssert) checkOffset(offset, 1, this.length)
  11098. if (!(this[offset] & 0x80)) return (this[offset])
  11099. return ((0xff - this[offset] + 1) * -1)
  11100. }
  11101. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  11102. offset = offset >>> 0
  11103. if (!noAssert) checkOffset(offset, 2, this.length)
  11104. var val = this[offset] | (this[offset + 1] << 8)
  11105. return (val & 0x8000) ? val | 0xFFFF0000 : val
  11106. }
  11107. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  11108. offset = offset >>> 0
  11109. if (!noAssert) checkOffset(offset, 2, this.length)
  11110. var val = this[offset + 1] | (this[offset] << 8)
  11111. return (val & 0x8000) ? val | 0xFFFF0000 : val
  11112. }
  11113. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  11114. offset = offset >>> 0
  11115. if (!noAssert) checkOffset(offset, 4, this.length)
  11116. return (this[offset]) |
  11117. (this[offset + 1] << 8) |
  11118. (this[offset + 2] << 16) |
  11119. (this[offset + 3] << 24)
  11120. }
  11121. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  11122. offset = offset >>> 0
  11123. if (!noAssert) checkOffset(offset, 4, this.length)
  11124. return (this[offset] << 24) |
  11125. (this[offset + 1] << 16) |
  11126. (this[offset + 2] << 8) |
  11127. (this[offset + 3])
  11128. }
  11129. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  11130. offset = offset >>> 0
  11131. if (!noAssert) checkOffset(offset, 4, this.length)
  11132. return ieee754.read(this, offset, true, 23, 4)
  11133. }
  11134. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  11135. offset = offset >>> 0
  11136. if (!noAssert) checkOffset(offset, 4, this.length)
  11137. return ieee754.read(this, offset, false, 23, 4)
  11138. }
  11139. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  11140. offset = offset >>> 0
  11141. if (!noAssert) checkOffset(offset, 8, this.length)
  11142. return ieee754.read(this, offset, true, 52, 8)
  11143. }
  11144. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  11145. offset = offset >>> 0
  11146. if (!noAssert) checkOffset(offset, 8, this.length)
  11147. return ieee754.read(this, offset, false, 52, 8)
  11148. }
  11149. function checkInt (buf, value, offset, ext, max, min) {
  11150. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  11151. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  11152. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  11153. }
  11154. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  11155. value = +value
  11156. offset = offset >>> 0
  11157. byteLength = byteLength >>> 0
  11158. if (!noAssert) {
  11159. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  11160. checkInt(this, value, offset, byteLength, maxBytes, 0)
  11161. }
  11162. var mul = 1
  11163. var i = 0
  11164. this[offset] = value & 0xFF
  11165. while (++i < byteLength && (mul *= 0x100)) {
  11166. this[offset + i] = (value / mul) & 0xFF
  11167. }
  11168. return offset + byteLength
  11169. }
  11170. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  11171. value = +value
  11172. offset = offset >>> 0
  11173. byteLength = byteLength >>> 0
  11174. if (!noAssert) {
  11175. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  11176. checkInt(this, value, offset, byteLength, maxBytes, 0)
  11177. }
  11178. var i = byteLength - 1
  11179. var mul = 1
  11180. this[offset + i] = value & 0xFF
  11181. while (--i >= 0 && (mul *= 0x100)) {
  11182. this[offset + i] = (value / mul) & 0xFF
  11183. }
  11184. return offset + byteLength
  11185. }
  11186. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  11187. value = +value
  11188. offset = offset >>> 0
  11189. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  11190. this[offset] = (value & 0xff)
  11191. return offset + 1
  11192. }
  11193. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  11194. value = +value
  11195. offset = offset >>> 0
  11196. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  11197. this[offset] = (value & 0xff)
  11198. this[offset + 1] = (value >>> 8)
  11199. return offset + 2
  11200. }
  11201. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  11202. value = +value
  11203. offset = offset >>> 0
  11204. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  11205. this[offset] = (value >>> 8)
  11206. this[offset + 1] = (value & 0xff)
  11207. return offset + 2
  11208. }
  11209. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  11210. value = +value
  11211. offset = offset >>> 0
  11212. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  11213. this[offset + 3] = (value >>> 24)
  11214. this[offset + 2] = (value >>> 16)
  11215. this[offset + 1] = (value >>> 8)
  11216. this[offset] = (value & 0xff)
  11217. return offset + 4
  11218. }
  11219. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  11220. value = +value
  11221. offset = offset >>> 0
  11222. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  11223. this[offset] = (value >>> 24)
  11224. this[offset + 1] = (value >>> 16)
  11225. this[offset + 2] = (value >>> 8)
  11226. this[offset + 3] = (value & 0xff)
  11227. return offset + 4
  11228. }
  11229. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  11230. value = +value
  11231. offset = offset >>> 0
  11232. if (!noAssert) {
  11233. var limit = Math.pow(2, (8 * byteLength) - 1)
  11234. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  11235. }
  11236. var i = 0
  11237. var mul = 1
  11238. var sub = 0
  11239. this[offset] = value & 0xFF
  11240. while (++i < byteLength && (mul *= 0x100)) {
  11241. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  11242. sub = 1
  11243. }
  11244. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  11245. }
  11246. return offset + byteLength
  11247. }
  11248. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  11249. value = +value
  11250. offset = offset >>> 0
  11251. if (!noAssert) {
  11252. var limit = Math.pow(2, (8 * byteLength) - 1)
  11253. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  11254. }
  11255. var i = byteLength - 1
  11256. var mul = 1
  11257. var sub = 0
  11258. this[offset + i] = value & 0xFF
  11259. while (--i >= 0 && (mul *= 0x100)) {
  11260. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  11261. sub = 1
  11262. }
  11263. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  11264. }
  11265. return offset + byteLength
  11266. }
  11267. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  11268. value = +value
  11269. offset = offset >>> 0
  11270. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  11271. if (value < 0) value = 0xff + value + 1
  11272. this[offset] = (value & 0xff)
  11273. return offset + 1
  11274. }
  11275. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  11276. value = +value
  11277. offset = offset >>> 0
  11278. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  11279. this[offset] = (value & 0xff)
  11280. this[offset + 1] = (value >>> 8)
  11281. return offset + 2
  11282. }
  11283. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  11284. value = +value
  11285. offset = offset >>> 0
  11286. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  11287. this[offset] = (value >>> 8)
  11288. this[offset + 1] = (value & 0xff)
  11289. return offset + 2
  11290. }
  11291. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  11292. value = +value
  11293. offset = offset >>> 0
  11294. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  11295. this[offset] = (value & 0xff)
  11296. this[offset + 1] = (value >>> 8)
  11297. this[offset + 2] = (value >>> 16)
  11298. this[offset + 3] = (value >>> 24)
  11299. return offset + 4
  11300. }
  11301. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  11302. value = +value
  11303. offset = offset >>> 0
  11304. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  11305. if (value < 0) value = 0xffffffff + value + 1
  11306. this[offset] = (value >>> 24)
  11307. this[offset + 1] = (value >>> 16)
  11308. this[offset + 2] = (value >>> 8)
  11309. this[offset + 3] = (value & 0xff)
  11310. return offset + 4
  11311. }
  11312. function checkIEEE754 (buf, value, offset, ext, max, min) {
  11313. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  11314. if (offset < 0) throw new RangeError('Index out of range')
  11315. }
  11316. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  11317. value = +value
  11318. offset = offset >>> 0
  11319. if (!noAssert) {
  11320. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  11321. }
  11322. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  11323. return offset + 4
  11324. }
  11325. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  11326. return writeFloat(this, value, offset, true, noAssert)
  11327. }
  11328. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  11329. return writeFloat(this, value, offset, false, noAssert)
  11330. }
  11331. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  11332. value = +value
  11333. offset = offset >>> 0
  11334. if (!noAssert) {
  11335. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  11336. }
  11337. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  11338. return offset + 8
  11339. }
  11340. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  11341. return writeDouble(this, value, offset, true, noAssert)
  11342. }
  11343. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  11344. return writeDouble(this, value, offset, false, noAssert)
  11345. }
  11346. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  11347. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  11348. if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
  11349. if (!start) start = 0
  11350. if (!end && end !== 0) end = this.length
  11351. if (targetStart >= target.length) targetStart = target.length
  11352. if (!targetStart) targetStart = 0
  11353. if (end > 0 && end < start) end = start
  11354. // Copy 0 bytes; we're done
  11355. if (end === start) return 0
  11356. if (target.length === 0 || this.length === 0) return 0
  11357. // Fatal error conditions
  11358. if (targetStart < 0) {
  11359. throw new RangeError('targetStart out of bounds')
  11360. }
  11361. if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
  11362. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  11363. // Are we oob?
  11364. if (end > this.length) end = this.length
  11365. if (target.length - targetStart < end - start) {
  11366. end = target.length - targetStart + start
  11367. }
  11368. var len = end - start
  11369. if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
  11370. // Use built-in when available, missing from IE11
  11371. this.copyWithin(targetStart, start, end)
  11372. } else if (this === target && start < targetStart && targetStart < end) {
  11373. // descending copy from end
  11374. for (var i = len - 1; i >= 0; --i) {
  11375. target[i + targetStart] = this[i + start]
  11376. }
  11377. } else {
  11378. Uint8Array.prototype.set.call(
  11379. target,
  11380. this.subarray(start, end),
  11381. targetStart
  11382. )
  11383. }
  11384. return len
  11385. }
  11386. // Usage:
  11387. // buffer.fill(number[, offset[, end]])
  11388. // buffer.fill(buffer[, offset[, end]])
  11389. // buffer.fill(string[, offset[, end]][, encoding])
  11390. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  11391. // Handle string cases:
  11392. if (typeof val === 'string') {
  11393. if (typeof start === 'string') {
  11394. encoding = start
  11395. start = 0
  11396. end = this.length
  11397. } else if (typeof end === 'string') {
  11398. encoding = end
  11399. end = this.length
  11400. }
  11401. if (encoding !== undefined && typeof encoding !== 'string') {
  11402. throw new TypeError('encoding must be a string')
  11403. }
  11404. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  11405. throw new TypeError('Unknown encoding: ' + encoding)
  11406. }
  11407. if (val.length === 1) {
  11408. var code = val.charCodeAt(0)
  11409. if ((encoding === 'utf8' && code < 128) ||
  11410. encoding === 'latin1') {
  11411. // Fast path: If `val` fits into a single byte, use that numeric value.
  11412. val = code
  11413. }
  11414. }
  11415. } else if (typeof val === 'number') {
  11416. val = val & 255
  11417. }
  11418. // Invalid ranges are not set to a default, so can range check early.
  11419. if (start < 0 || this.length < start || this.length < end) {
  11420. throw new RangeError('Out of range index')
  11421. }
  11422. if (end <= start) {
  11423. return this
  11424. }
  11425. start = start >>> 0
  11426. end = end === undefined ? this.length : end >>> 0
  11427. if (!val) val = 0
  11428. var i
  11429. if (typeof val === 'number') {
  11430. for (i = start; i < end; ++i) {
  11431. this[i] = val
  11432. }
  11433. } else {
  11434. var bytes = Buffer.isBuffer(val)
  11435. ? val
  11436. : Buffer.from(val, encoding)
  11437. var len = bytes.length
  11438. if (len === 0) {
  11439. throw new TypeError('The value "' + val +
  11440. '" is invalid for argument "value"')
  11441. }
  11442. for (i = 0; i < end - start; ++i) {
  11443. this[i + start] = bytes[i % len]
  11444. }
  11445. }
  11446. return this
  11447. }
  11448. // HELPER FUNCTIONS
  11449. // ================
  11450. var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
  11451. function base64clean (str) {
  11452. // Node takes equal signs as end of the Base64 encoding
  11453. str = str.split('=')[0]
  11454. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  11455. str = str.trim().replace(INVALID_BASE64_RE, '')
  11456. // Node converts strings with length < 2 to ''
  11457. if (str.length < 2) return ''
  11458. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  11459. while (str.length % 4 !== 0) {
  11460. str = str + '='
  11461. }
  11462. return str
  11463. }
  11464. function toHex (n) {
  11465. if (n < 16) return '0' + n.toString(16)
  11466. return n.toString(16)
  11467. }
  11468. function utf8ToBytes (string, units) {
  11469. units = units || Infinity
  11470. var codePoint
  11471. var length = string.length
  11472. var leadSurrogate = null
  11473. var bytes = []
  11474. for (var i = 0; i < length; ++i) {
  11475. codePoint = string.charCodeAt(i)
  11476. // is surrogate component
  11477. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  11478. // last char was a lead
  11479. if (!leadSurrogate) {
  11480. // no lead yet
  11481. if (codePoint > 0xDBFF) {
  11482. // unexpected trail
  11483. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  11484. continue
  11485. } else if (i + 1 === length) {
  11486. // unpaired lead
  11487. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  11488. continue
  11489. }
  11490. // valid lead
  11491. leadSurrogate = codePoint
  11492. continue
  11493. }
  11494. // 2 leads in a row
  11495. if (codePoint < 0xDC00) {
  11496. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  11497. leadSurrogate = codePoint
  11498. continue
  11499. }
  11500. // valid surrogate pair
  11501. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  11502. } else if (leadSurrogate) {
  11503. // valid bmp char, but last char was a lead
  11504. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  11505. }
  11506. leadSurrogate = null
  11507. // encode utf8
  11508. if (codePoint < 0x80) {
  11509. if ((units -= 1) < 0) break
  11510. bytes.push(codePoint)
  11511. } else if (codePoint < 0x800) {
  11512. if ((units -= 2) < 0) break
  11513. bytes.push(
  11514. codePoint >> 0x6 | 0xC0,
  11515. codePoint & 0x3F | 0x80
  11516. )
  11517. } else if (codePoint < 0x10000) {
  11518. if ((units -= 3) < 0) break
  11519. bytes.push(
  11520. codePoint >> 0xC | 0xE0,
  11521. codePoint >> 0x6 & 0x3F | 0x80,
  11522. codePoint & 0x3F | 0x80
  11523. )
  11524. } else if (codePoint < 0x110000) {
  11525. if ((units -= 4) < 0) break
  11526. bytes.push(
  11527. codePoint >> 0x12 | 0xF0,
  11528. codePoint >> 0xC & 0x3F | 0x80,
  11529. codePoint >> 0x6 & 0x3F | 0x80,
  11530. codePoint & 0x3F | 0x80
  11531. )
  11532. } else {
  11533. throw new Error('Invalid code point')
  11534. }
  11535. }
  11536. return bytes
  11537. }
  11538. function asciiToBytes (str) {
  11539. var byteArray = []
  11540. for (var i = 0; i < str.length; ++i) {
  11541. // Node's code seems to be doing this and not & 0x7F..
  11542. byteArray.push(str.charCodeAt(i) & 0xFF)
  11543. }
  11544. return byteArray
  11545. }
  11546. function utf16leToBytes (str, units) {
  11547. var c, hi, lo
  11548. var byteArray = []
  11549. for (var i = 0; i < str.length; ++i) {
  11550. if ((units -= 2) < 0) break
  11551. c = str.charCodeAt(i)
  11552. hi = c >> 8
  11553. lo = c % 256
  11554. byteArray.push(lo)
  11555. byteArray.push(hi)
  11556. }
  11557. return byteArray
  11558. }
  11559. function base64ToBytes (str) {
  11560. return base64.toByteArray(base64clean(str))
  11561. }
  11562. function blitBuffer (src, dst, offset, length) {
  11563. for (var i = 0; i < length; ++i) {
  11564. if ((i + offset >= dst.length) || (i >= src.length)) break
  11565. dst[i + offset] = src[i]
  11566. }
  11567. return i
  11568. }
  11569. // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
  11570. // the `instanceof` check but they should be treated as of that type.
  11571. // See: https://github.com/feross/buffer/issues/166
  11572. function isInstance (obj, type) {
  11573. return obj instanceof type ||
  11574. (obj != null && obj.constructor != null && obj.constructor.name != null &&
  11575. obj.constructor.name === type.name)
  11576. }
  11577. function numberIsNaN (obj) {
  11578. // For IE11 support
  11579. return obj !== obj // eslint-disable-line no-self-compare
  11580. }
  11581. }).call(this,require("buffer").Buffer)
  11582. },{"base64-js":76,"buffer":98,"ieee754":300}],99:[function(require,module,exports){
  11583. module.exports = {
  11584. "100": "Continue",
  11585. "101": "Switching Protocols",
  11586. "102": "Processing",
  11587. "200": "OK",
  11588. "201": "Created",
  11589. "202": "Accepted",
  11590. "203": "Non-Authoritative Information",
  11591. "204": "No Content",
  11592. "205": "Reset Content",
  11593. "206": "Partial Content",
  11594. "207": "Multi-Status",
  11595. "208": "Already Reported",
  11596. "226": "IM Used",
  11597. "300": "Multiple Choices",
  11598. "301": "Moved Permanently",
  11599. "302": "Found",
  11600. "303": "See Other",
  11601. "304": "Not Modified",
  11602. "305": "Use Proxy",
  11603. "307": "Temporary Redirect",
  11604. "308": "Permanent Redirect",
  11605. "400": "Bad Request",
  11606. "401": "Unauthorized",
  11607. "402": "Payment Required",
  11608. "403": "Forbidden",
  11609. "404": "Not Found",
  11610. "405": "Method Not Allowed",
  11611. "406": "Not Acceptable",
  11612. "407": "Proxy Authentication Required",
  11613. "408": "Request Timeout",
  11614. "409": "Conflict",
  11615. "410": "Gone",
  11616. "411": "Length Required",
  11617. "412": "Precondition Failed",
  11618. "413": "Payload Too Large",
  11619. "414": "URI Too Long",
  11620. "415": "Unsupported Media Type",
  11621. "416": "Range Not Satisfiable",
  11622. "417": "Expectation Failed",
  11623. "418": "I'm a teapot",
  11624. "421": "Misdirected Request",
  11625. "422": "Unprocessable Entity",
  11626. "423": "Locked",
  11627. "424": "Failed Dependency",
  11628. "425": "Unordered Collection",
  11629. "426": "Upgrade Required",
  11630. "428": "Precondition Required",
  11631. "429": "Too Many Requests",
  11632. "431": "Request Header Fields Too Large",
  11633. "451": "Unavailable For Legal Reasons",
  11634. "500": "Internal Server Error",
  11635. "501": "Not Implemented",
  11636. "502": "Bad Gateway",
  11637. "503": "Service Unavailable",
  11638. "504": "Gateway Timeout",
  11639. "505": "HTTP Version Not Supported",
  11640. "506": "Variant Also Negotiates",
  11641. "507": "Insufficient Storage",
  11642. "508": "Loop Detected",
  11643. "509": "Bandwidth Limit Exceeded",
  11644. "510": "Not Extended",
  11645. "511": "Network Authentication Required"
  11646. }
  11647. },{}],100:[function(require,module,exports){
  11648. module.exports={
  11649. "O_RDONLY": 0,
  11650. "O_WRONLY": 1,
  11651. "O_RDWR": 2,
  11652. "S_IFMT": 61440,
  11653. "S_IFREG": 32768,
  11654. "S_IFDIR": 16384,
  11655. "S_IFCHR": 8192,
  11656. "S_IFBLK": 24576,
  11657. "S_IFIFO": 4096,
  11658. "S_IFLNK": 40960,
  11659. "S_IFSOCK": 49152,
  11660. "O_CREAT": 512,
  11661. "O_EXCL": 2048,
  11662. "O_NOCTTY": 131072,
  11663. "O_TRUNC": 1024,
  11664. "O_APPEND": 8,
  11665. "O_DIRECTORY": 1048576,
  11666. "O_NOFOLLOW": 256,
  11667. "O_SYNC": 128,
  11668. "O_SYMLINK": 2097152,
  11669. "O_NONBLOCK": 4,
  11670. "S_IRWXU": 448,
  11671. "S_IRUSR": 256,
  11672. "S_IWUSR": 128,
  11673. "S_IXUSR": 64,
  11674. "S_IRWXG": 56,
  11675. "S_IRGRP": 32,
  11676. "S_IWGRP": 16,
  11677. "S_IXGRP": 8,
  11678. "S_IRWXO": 7,
  11679. "S_IROTH": 4,
  11680. "S_IWOTH": 2,
  11681. "S_IXOTH": 1,
  11682. "E2BIG": 7,
  11683. "EACCES": 13,
  11684. "EADDRINUSE": 48,
  11685. "EADDRNOTAVAIL": 49,
  11686. "EAFNOSUPPORT": 47,
  11687. "EAGAIN": 35,
  11688. "EALREADY": 37,
  11689. "EBADF": 9,
  11690. "EBADMSG": 94,
  11691. "EBUSY": 16,
  11692. "ECANCELED": 89,
  11693. "ECHILD": 10,
  11694. "ECONNABORTED": 53,
  11695. "ECONNREFUSED": 61,
  11696. "ECONNRESET": 54,
  11697. "EDEADLK": 11,
  11698. "EDESTADDRREQ": 39,
  11699. "EDOM": 33,
  11700. "EDQUOT": 69,
  11701. "EEXIST": 17,
  11702. "EFAULT": 14,
  11703. "EFBIG": 27,
  11704. "EHOSTUNREACH": 65,
  11705. "EIDRM": 90,
  11706. "EILSEQ": 92,
  11707. "EINPROGRESS": 36,
  11708. "EINTR": 4,
  11709. "EINVAL": 22,
  11710. "EIO": 5,
  11711. "EISCONN": 56,
  11712. "EISDIR": 21,
  11713. "ELOOP": 62,
  11714. "EMFILE": 24,
  11715. "EMLINK": 31,
  11716. "EMSGSIZE": 40,
  11717. "EMULTIHOP": 95,
  11718. "ENAMETOOLONG": 63,
  11719. "ENETDOWN": 50,
  11720. "ENETRESET": 52,
  11721. "ENETUNREACH": 51,
  11722. "ENFILE": 23,
  11723. "ENOBUFS": 55,
  11724. "ENODATA": 96,
  11725. "ENODEV": 19,
  11726. "ENOENT": 2,
  11727. "ENOEXEC": 8,
  11728. "ENOLCK": 77,
  11729. "ENOLINK": 97,
  11730. "ENOMEM": 12,
  11731. "ENOMSG": 91,
  11732. "ENOPROTOOPT": 42,
  11733. "ENOSPC": 28,
  11734. "ENOSR": 98,
  11735. "ENOSTR": 99,
  11736. "ENOSYS": 78,
  11737. "ENOTCONN": 57,
  11738. "ENOTDIR": 20,
  11739. "ENOTEMPTY": 66,
  11740. "ENOTSOCK": 38,
  11741. "ENOTSUP": 45,
  11742. "ENOTTY": 25,
  11743. "ENXIO": 6,
  11744. "EOPNOTSUPP": 102,
  11745. "EOVERFLOW": 84,
  11746. "EPERM": 1,
  11747. "EPIPE": 32,
  11748. "EPROTO": 100,
  11749. "EPROTONOSUPPORT": 43,
  11750. "EPROTOTYPE": 41,
  11751. "ERANGE": 34,
  11752. "EROFS": 30,
  11753. "ESPIPE": 29,
  11754. "ESRCH": 3,
  11755. "ESTALE": 70,
  11756. "ETIME": 101,
  11757. "ETIMEDOUT": 60,
  11758. "ETXTBSY": 26,
  11759. "EWOULDBLOCK": 35,
  11760. "EXDEV": 18,
  11761. "SIGHUP": 1,
  11762. "SIGINT": 2,
  11763. "SIGQUIT": 3,
  11764. "SIGILL": 4,
  11765. "SIGTRAP": 5,
  11766. "SIGABRT": 6,
  11767. "SIGIOT": 6,
  11768. "SIGBUS": 10,
  11769. "SIGFPE": 8,
  11770. "SIGKILL": 9,
  11771. "SIGUSR1": 30,
  11772. "SIGSEGV": 11,
  11773. "SIGUSR2": 31,
  11774. "SIGPIPE": 13,
  11775. "SIGALRM": 14,
  11776. "SIGTERM": 15,
  11777. "SIGCHLD": 20,
  11778. "SIGCONT": 19,
  11779. "SIGSTOP": 17,
  11780. "SIGTSTP": 18,
  11781. "SIGTTIN": 21,
  11782. "SIGTTOU": 22,
  11783. "SIGURG": 16,
  11784. "SIGXCPU": 24,
  11785. "SIGXFSZ": 25,
  11786. "SIGVTALRM": 26,
  11787. "SIGPROF": 27,
  11788. "SIGWINCH": 28,
  11789. "SIGIO": 23,
  11790. "SIGSYS": 12,
  11791. "SSL_OP_ALL": 2147486719,
  11792. "SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION": 262144,
  11793. "SSL_OP_CIPHER_SERVER_PREFERENCE": 4194304,
  11794. "SSL_OP_CISCO_ANYCONNECT": 32768,
  11795. "SSL_OP_COOKIE_EXCHANGE": 8192,
  11796. "SSL_OP_CRYPTOPRO_TLSEXT_BUG": 2147483648,
  11797. "SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS": 2048,
  11798. "SSL_OP_EPHEMERAL_RSA": 0,
  11799. "SSL_OP_LEGACY_SERVER_CONNECT": 4,
  11800. "SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER": 32,
  11801. "SSL_OP_MICROSOFT_SESS_ID_BUG": 1,
  11802. "SSL_OP_MSIE_SSLV2_RSA_PADDING": 0,
  11803. "SSL_OP_NETSCAPE_CA_DN_BUG": 536870912,
  11804. "SSL_OP_NETSCAPE_CHALLENGE_BUG": 2,
  11805. "SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG": 1073741824,
  11806. "SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG": 8,
  11807. "SSL_OP_NO_COMPRESSION": 131072,
  11808. "SSL_OP_NO_QUERY_MTU": 4096,
  11809. "SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION": 65536,
  11810. "SSL_OP_NO_SSLv2": 16777216,
  11811. "SSL_OP_NO_SSLv3": 33554432,
  11812. "SSL_OP_NO_TICKET": 16384,
  11813. "SSL_OP_NO_TLSv1": 67108864,
  11814. "SSL_OP_NO_TLSv1_1": 268435456,
  11815. "SSL_OP_NO_TLSv1_2": 134217728,
  11816. "SSL_OP_PKCS1_CHECK_1": 0,
  11817. "SSL_OP_PKCS1_CHECK_2": 0,
  11818. "SSL_OP_SINGLE_DH_USE": 1048576,
  11819. "SSL_OP_SINGLE_ECDH_USE": 524288,
  11820. "SSL_OP_SSLEAY_080_CLIENT_DH_BUG": 128,
  11821. "SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG": 0,
  11822. "SSL_OP_TLS_BLOCK_PADDING_BUG": 512,
  11823. "SSL_OP_TLS_D5_BUG": 256,
  11824. "SSL_OP_TLS_ROLLBACK_BUG": 8388608,
  11825. "ENGINE_METHOD_DSA": 2,
  11826. "ENGINE_METHOD_DH": 4,
  11827. "ENGINE_METHOD_RAND": 8,
  11828. "ENGINE_METHOD_ECDH": 16,
  11829. "ENGINE_METHOD_ECDSA": 32,
  11830. "ENGINE_METHOD_CIPHERS": 64,
  11831. "ENGINE_METHOD_DIGESTS": 128,
  11832. "ENGINE_METHOD_STORE": 256,
  11833. "ENGINE_METHOD_PKEY_METHS": 512,
  11834. "ENGINE_METHOD_PKEY_ASN1_METHS": 1024,
  11835. "ENGINE_METHOD_ALL": 65535,
  11836. "ENGINE_METHOD_NONE": 0,
  11837. "DH_CHECK_P_NOT_SAFE_PRIME": 2,
  11838. "DH_CHECK_P_NOT_PRIME": 1,
  11839. "DH_UNABLE_TO_CHECK_GENERATOR": 4,
  11840. "DH_NOT_SUITABLE_GENERATOR": 8,
  11841. "NPN_ENABLED": 1,
  11842. "RSA_PKCS1_PADDING": 1,
  11843. "RSA_SSLV23_PADDING": 2,
  11844. "RSA_NO_PADDING": 3,
  11845. "RSA_PKCS1_OAEP_PADDING": 4,
  11846. "RSA_X931_PADDING": 5,
  11847. "RSA_PKCS1_PSS_PADDING": 6,
  11848. "POINT_CONVERSION_COMPRESSED": 2,
  11849. "POINT_CONVERSION_UNCOMPRESSED": 4,
  11850. "POINT_CONVERSION_HYBRID": 6,
  11851. "F_OK": 0,
  11852. "R_OK": 4,
  11853. "W_OK": 2,
  11854. "X_OK": 1,
  11855. "UV_UDP_REUSEADDR": 4
  11856. }
  11857. },{}],101:[function(require,module,exports){
  11858. /*!
  11859. * copy-to - index.js
  11860. * Copyright(c) 2014 dead_horse <dead_horse@qq.com>
  11861. * MIT Licensed
  11862. */
  11863. 'use strict';
  11864. /**
  11865. * slice() reference.
  11866. */
  11867. var slice = Array.prototype.slice;
  11868. /**
  11869. * Expose copy
  11870. *
  11871. * ```
  11872. * copy({foo: 'nar', hello: 'copy'}).to({hello: 'world'});
  11873. * copy({foo: 'nar', hello: 'copy'}).toCover({hello: 'world'});
  11874. * ```
  11875. *
  11876. * @param {Object} src
  11877. * @return {Copy}
  11878. */
  11879. module.exports = Copy;
  11880. /**
  11881. * Copy
  11882. * @param {Object} src
  11883. * @param {Boolean} withAccess
  11884. */
  11885. function Copy(src, withAccess) {
  11886. if (!(this instanceof Copy)) return new Copy(src, withAccess);
  11887. this.src = src;
  11888. this._withAccess = withAccess;
  11889. }
  11890. /**
  11891. * copy properties include getter and setter
  11892. * @param {[type]} val [description]
  11893. * @return {[type]} [description]
  11894. */
  11895. Copy.prototype.withAccess = function (w) {
  11896. this._withAccess = w !== false;
  11897. return this;
  11898. };
  11899. /**
  11900. * pick keys in src
  11901. *
  11902. * @api: public
  11903. */
  11904. Copy.prototype.pick = function(keys) {
  11905. if (!Array.isArray(keys)) {
  11906. keys = slice.call(arguments);
  11907. }
  11908. if (keys.length) {
  11909. this.keys = keys;
  11910. }
  11911. return this;
  11912. };
  11913. /**
  11914. * copy src to target,
  11915. * do not cover any property target has
  11916. * @param {Object} to
  11917. *
  11918. * @api: public
  11919. */
  11920. Copy.prototype.to = function(to) {
  11921. to = to || {};
  11922. if (!this.src) return to;
  11923. var keys = this.keys || Object.keys(this.src);
  11924. if (!this._withAccess) {
  11925. for (var i = 0; i < keys.length; i++) {
  11926. key = keys[i];
  11927. if (to[key] !== undefined) continue;
  11928. to[key] = this.src[key];
  11929. }
  11930. return to;
  11931. }
  11932. for (var i = 0; i < keys.length; i++) {
  11933. var key = keys[i];
  11934. if (!notDefined(to, key)) continue;
  11935. var getter = this.src.__lookupGetter__(key);
  11936. var setter = this.src.__lookupSetter__(key);
  11937. if (getter) to.__defineGetter__(key, getter);
  11938. if (setter) to.__defineSetter__(key, setter);
  11939. if (!getter && !setter) {
  11940. to[key] = this.src[key];
  11941. }
  11942. }
  11943. return to;
  11944. };
  11945. /**
  11946. * copy src to target,
  11947. * override any property target has
  11948. * @param {Object} to
  11949. *
  11950. * @api: public
  11951. */
  11952. Copy.prototype.toCover = function(to) {
  11953. var keys = this.keys || Object.keys(this.src);
  11954. for (var i = 0; i < keys.length; i++) {
  11955. var key = keys[i];
  11956. delete to[key];
  11957. var getter = this.src.__lookupGetter__(key);
  11958. var setter = this.src.__lookupSetter__(key);
  11959. if (getter) to.__defineGetter__(key, getter);
  11960. if (setter) to.__defineSetter__(key, setter);
  11961. if (!getter && !setter) {
  11962. to[key] = this.src[key];
  11963. }
  11964. }
  11965. };
  11966. Copy.prototype.override = Copy.prototype.toCover;
  11967. /**
  11968. * append another object to src
  11969. * @param {Obj} obj
  11970. * @return {Copy}
  11971. */
  11972. Copy.prototype.and = function (obj) {
  11973. var src = {};
  11974. this.to(src);
  11975. this.src = obj;
  11976. this.to(src);
  11977. this.src = src;
  11978. return this;
  11979. };
  11980. /**
  11981. * check obj[key] if not defiend
  11982. * @param {Object} obj
  11983. * @param {String} key
  11984. * @return {Boolean}
  11985. */
  11986. function notDefined(obj, key) {
  11987. return obj[key] === undefined
  11988. && obj.__lookupGetter__(key) === undefined
  11989. && obj.__lookupSetter__(key) === undefined;
  11990. }
  11991. },{}],102:[function(require,module,exports){
  11992. module.exports = function (it) {
  11993. if (typeof it != 'function') {
  11994. throw TypeError(String(it) + ' is not a function');
  11995. } return it;
  11996. };
  11997. },{}],103:[function(require,module,exports){
  11998. var isObject = require('../internals/is-object');
  11999. module.exports = function (it) {
  12000. if (!isObject(it) && it !== null) {
  12001. throw TypeError("Can't set " + String(it) + ' as a prototype');
  12002. } return it;
  12003. };
  12004. },{"../internals/is-object":164}],104:[function(require,module,exports){
  12005. var wellKnownSymbol = require('../internals/well-known-symbol');
  12006. var create = require('../internals/object-create');
  12007. var definePropertyModule = require('../internals/object-define-property');
  12008. var UNSCOPABLES = wellKnownSymbol('unscopables');
  12009. var ArrayPrototype = Array.prototype;
  12010. // Array.prototype[@@unscopables]
  12011. // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
  12012. if (ArrayPrototype[UNSCOPABLES] == undefined) {
  12013. definePropertyModule.f(ArrayPrototype, UNSCOPABLES, {
  12014. configurable: true,
  12015. value: create(null)
  12016. });
  12017. }
  12018. // add a key to Array.prototype[@@unscopables]
  12019. module.exports = function (key) {
  12020. ArrayPrototype[UNSCOPABLES][key] = true;
  12021. };
  12022. },{"../internals/object-create":178,"../internals/object-define-property":180,"../internals/well-known-symbol":231}],105:[function(require,module,exports){
  12023. 'use strict';
  12024. var charAt = require('../internals/string-multibyte').charAt;
  12025. // `AdvanceStringIndex` abstract operation
  12026. // https://tc39.github.io/ecma262/#sec-advancestringindex
  12027. module.exports = function (S, index, unicode) {
  12028. return index + (unicode ? charAt(S, index).length : 1);
  12029. };
  12030. },{"../internals/string-multibyte":211}],106:[function(require,module,exports){
  12031. module.exports = function (it, Constructor, name) {
  12032. if (!(it instanceof Constructor)) {
  12033. throw TypeError('Incorrect ' + (name ? name + ' ' : '') + 'invocation');
  12034. } return it;
  12035. };
  12036. },{}],107:[function(require,module,exports){
  12037. var isObject = require('../internals/is-object');
  12038. module.exports = function (it) {
  12039. if (!isObject(it)) {
  12040. throw TypeError(String(it) + ' is not an object');
  12041. } return it;
  12042. };
  12043. },{"../internals/is-object":164}],108:[function(require,module,exports){
  12044. module.exports = typeof ArrayBuffer !== 'undefined' && typeof DataView !== 'undefined';
  12045. },{}],109:[function(require,module,exports){
  12046. 'use strict';
  12047. var NATIVE_ARRAY_BUFFER = require('../internals/array-buffer-native');
  12048. var DESCRIPTORS = require('../internals/descriptors');
  12049. var global = require('../internals/global');
  12050. var isObject = require('../internals/is-object');
  12051. var has = require('../internals/has');
  12052. var classof = require('../internals/classof');
  12053. var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
  12054. var redefine = require('../internals/redefine');
  12055. var defineProperty = require('../internals/object-define-property').f;
  12056. var getPrototypeOf = require('../internals/object-get-prototype-of');
  12057. var setPrototypeOf = require('../internals/object-set-prototype-of');
  12058. var wellKnownSymbol = require('../internals/well-known-symbol');
  12059. var uid = require('../internals/uid');
  12060. var Int8Array = global.Int8Array;
  12061. var Int8ArrayPrototype = Int8Array && Int8Array.prototype;
  12062. var Uint8ClampedArray = global.Uint8ClampedArray;
  12063. var Uint8ClampedArrayPrototype = Uint8ClampedArray && Uint8ClampedArray.prototype;
  12064. var TypedArray = Int8Array && getPrototypeOf(Int8Array);
  12065. var TypedArrayPrototype = Int8ArrayPrototype && getPrototypeOf(Int8ArrayPrototype);
  12066. var ObjectPrototype = Object.prototype;
  12067. var isPrototypeOf = ObjectPrototype.isPrototypeOf;
  12068. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  12069. var TYPED_ARRAY_TAG = uid('TYPED_ARRAY_TAG');
  12070. // Fixing native typed arrays in Opera Presto crashes the browser, see #595
  12071. var NATIVE_ARRAY_BUFFER_VIEWS = NATIVE_ARRAY_BUFFER && !!setPrototypeOf && classof(global.opera) !== 'Opera';
  12072. var TYPED_ARRAY_TAG_REQIRED = false;
  12073. var NAME;
  12074. var TypedArrayConstructorsList = {
  12075. Int8Array: 1,
  12076. Uint8Array: 1,
  12077. Uint8ClampedArray: 1,
  12078. Int16Array: 2,
  12079. Uint16Array: 2,
  12080. Int32Array: 4,
  12081. Uint32Array: 4,
  12082. Float32Array: 4,
  12083. Float64Array: 8
  12084. };
  12085. var isView = function isView(it) {
  12086. var klass = classof(it);
  12087. return klass === 'DataView' || has(TypedArrayConstructorsList, klass);
  12088. };
  12089. var isTypedArray = function (it) {
  12090. return isObject(it) && has(TypedArrayConstructorsList, classof(it));
  12091. };
  12092. var aTypedArray = function (it) {
  12093. if (isTypedArray(it)) return it;
  12094. throw TypeError('Target is not a typed array');
  12095. };
  12096. var aTypedArrayConstructor = function (C) {
  12097. if (setPrototypeOf) {
  12098. if (isPrototypeOf.call(TypedArray, C)) return C;
  12099. } else for (var ARRAY in TypedArrayConstructorsList) if (has(TypedArrayConstructorsList, NAME)) {
  12100. var TypedArrayConstructor = global[ARRAY];
  12101. if (TypedArrayConstructor && (C === TypedArrayConstructor || isPrototypeOf.call(TypedArrayConstructor, C))) {
  12102. return C;
  12103. }
  12104. } throw TypeError('Target is not a typed array constructor');
  12105. };
  12106. var exportTypedArrayMethod = function (KEY, property, forced) {
  12107. if (!DESCRIPTORS) return;
  12108. if (forced) for (var ARRAY in TypedArrayConstructorsList) {
  12109. var TypedArrayConstructor = global[ARRAY];
  12110. if (TypedArrayConstructor && has(TypedArrayConstructor.prototype, KEY)) {
  12111. delete TypedArrayConstructor.prototype[KEY];
  12112. }
  12113. }
  12114. if (!TypedArrayPrototype[KEY] || forced) {
  12115. redefine(TypedArrayPrototype, KEY, forced ? property
  12116. : NATIVE_ARRAY_BUFFER_VIEWS && Int8ArrayPrototype[KEY] || property);
  12117. }
  12118. };
  12119. var exportTypedArrayStaticMethod = function (KEY, property, forced) {
  12120. var ARRAY, TypedArrayConstructor;
  12121. if (!DESCRIPTORS) return;
  12122. if (setPrototypeOf) {
  12123. if (forced) for (ARRAY in TypedArrayConstructorsList) {
  12124. TypedArrayConstructor = global[ARRAY];
  12125. if (TypedArrayConstructor && has(TypedArrayConstructor, KEY)) {
  12126. delete TypedArrayConstructor[KEY];
  12127. }
  12128. }
  12129. if (!TypedArray[KEY] || forced) {
  12130. // V8 ~ Chrome 49-50 `%TypedArray%` methods are non-writable non-configurable
  12131. try {
  12132. return redefine(TypedArray, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && Int8Array[KEY] || property);
  12133. } catch (error) { /* empty */ }
  12134. } else return;
  12135. }
  12136. for (ARRAY in TypedArrayConstructorsList) {
  12137. TypedArrayConstructor = global[ARRAY];
  12138. if (TypedArrayConstructor && (!TypedArrayConstructor[KEY] || forced)) {
  12139. redefine(TypedArrayConstructor, KEY, property);
  12140. }
  12141. }
  12142. };
  12143. for (NAME in TypedArrayConstructorsList) {
  12144. if (!global[NAME]) NATIVE_ARRAY_BUFFER_VIEWS = false;
  12145. }
  12146. // WebKit bug - typed arrays constructors prototype is Object.prototype
  12147. if (!NATIVE_ARRAY_BUFFER_VIEWS || typeof TypedArray != 'function' || TypedArray === Function.prototype) {
  12148. // eslint-disable-next-line no-shadow
  12149. TypedArray = function TypedArray() {
  12150. throw TypeError('Incorrect invocation');
  12151. };
  12152. if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) {
  12153. if (global[NAME]) setPrototypeOf(global[NAME], TypedArray);
  12154. }
  12155. }
  12156. if (!NATIVE_ARRAY_BUFFER_VIEWS || !TypedArrayPrototype || TypedArrayPrototype === ObjectPrototype) {
  12157. TypedArrayPrototype = TypedArray.prototype;
  12158. if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) {
  12159. if (global[NAME]) setPrototypeOf(global[NAME].prototype, TypedArrayPrototype);
  12160. }
  12161. }
  12162. // WebKit bug - one more object in Uint8ClampedArray prototype chain
  12163. if (NATIVE_ARRAY_BUFFER_VIEWS && getPrototypeOf(Uint8ClampedArrayPrototype) !== TypedArrayPrototype) {
  12164. setPrototypeOf(Uint8ClampedArrayPrototype, TypedArrayPrototype);
  12165. }
  12166. if (DESCRIPTORS && !has(TypedArrayPrototype, TO_STRING_TAG)) {
  12167. TYPED_ARRAY_TAG_REQIRED = true;
  12168. defineProperty(TypedArrayPrototype, TO_STRING_TAG, { get: function () {
  12169. return isObject(this) ? this[TYPED_ARRAY_TAG] : undefined;
  12170. } });
  12171. for (NAME in TypedArrayConstructorsList) if (global[NAME]) {
  12172. createNonEnumerableProperty(global[NAME], TYPED_ARRAY_TAG, NAME);
  12173. }
  12174. }
  12175. module.exports = {
  12176. NATIVE_ARRAY_BUFFER_VIEWS: NATIVE_ARRAY_BUFFER_VIEWS,
  12177. TYPED_ARRAY_TAG: TYPED_ARRAY_TAG_REQIRED && TYPED_ARRAY_TAG,
  12178. aTypedArray: aTypedArray,
  12179. aTypedArrayConstructor: aTypedArrayConstructor,
  12180. exportTypedArrayMethod: exportTypedArrayMethod,
  12181. exportTypedArrayStaticMethod: exportTypedArrayStaticMethod,
  12182. isView: isView,
  12183. isTypedArray: isTypedArray,
  12184. TypedArray: TypedArray,
  12185. TypedArrayPrototype: TypedArrayPrototype
  12186. };
  12187. },{"../internals/array-buffer-native":108,"../internals/classof":126,"../internals/create-non-enumerable-property":131,"../internals/descriptors":136,"../internals/global":150,"../internals/has":151,"../internals/is-object":164,"../internals/object-define-property":180,"../internals/object-get-prototype-of":185,"../internals/object-set-prototype-of":189,"../internals/redefine":197,"../internals/uid":228,"../internals/well-known-symbol":231}],110:[function(require,module,exports){
  12188. 'use strict';
  12189. var global = require('../internals/global');
  12190. var DESCRIPTORS = require('../internals/descriptors');
  12191. var NATIVE_ARRAY_BUFFER = require('../internals/array-buffer-native');
  12192. var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
  12193. var redefineAll = require('../internals/redefine-all');
  12194. var fails = require('../internals/fails');
  12195. var anInstance = require('../internals/an-instance');
  12196. var toInteger = require('../internals/to-integer');
  12197. var toLength = require('../internals/to-length');
  12198. var toIndex = require('../internals/to-index');
  12199. var IEEE754 = require('../internals/ieee754');
  12200. var getPrototypeOf = require('../internals/object-get-prototype-of');
  12201. var setPrototypeOf = require('../internals/object-set-prototype-of');
  12202. var getOwnPropertyNames = require('../internals/object-get-own-property-names').f;
  12203. var defineProperty = require('../internals/object-define-property').f;
  12204. var arrayFill = require('../internals/array-fill');
  12205. var setToStringTag = require('../internals/set-to-string-tag');
  12206. var InternalStateModule = require('../internals/internal-state');
  12207. var getInternalState = InternalStateModule.get;
  12208. var setInternalState = InternalStateModule.set;
  12209. var ARRAY_BUFFER = 'ArrayBuffer';
  12210. var DATA_VIEW = 'DataView';
  12211. var PROTOTYPE = 'prototype';
  12212. var WRONG_LENGTH = 'Wrong length';
  12213. var WRONG_INDEX = 'Wrong index';
  12214. var NativeArrayBuffer = global[ARRAY_BUFFER];
  12215. var $ArrayBuffer = NativeArrayBuffer;
  12216. var $DataView = global[DATA_VIEW];
  12217. var $DataViewPrototype = $DataView && $DataView[PROTOTYPE];
  12218. var ObjectPrototype = Object.prototype;
  12219. var RangeError = global.RangeError;
  12220. var packIEEE754 = IEEE754.pack;
  12221. var unpackIEEE754 = IEEE754.unpack;
  12222. var packInt8 = function (number) {
  12223. return [number & 0xFF];
  12224. };
  12225. var packInt16 = function (number) {
  12226. return [number & 0xFF, number >> 8 & 0xFF];
  12227. };
  12228. var packInt32 = function (number) {
  12229. return [number & 0xFF, number >> 8 & 0xFF, number >> 16 & 0xFF, number >> 24 & 0xFF];
  12230. };
  12231. var unpackInt32 = function (buffer) {
  12232. return buffer[3] << 24 | buffer[2] << 16 | buffer[1] << 8 | buffer[0];
  12233. };
  12234. var packFloat32 = function (number) {
  12235. return packIEEE754(number, 23, 4);
  12236. };
  12237. var packFloat64 = function (number) {
  12238. return packIEEE754(number, 52, 8);
  12239. };
  12240. var addGetter = function (Constructor, key) {
  12241. defineProperty(Constructor[PROTOTYPE], key, { get: function () { return getInternalState(this)[key]; } });
  12242. };
  12243. var get = function (view, count, index, isLittleEndian) {
  12244. var intIndex = toIndex(index);
  12245. var store = getInternalState(view);
  12246. if (intIndex + count > store.byteLength) throw RangeError(WRONG_INDEX);
  12247. var bytes = getInternalState(store.buffer).bytes;
  12248. var start = intIndex + store.byteOffset;
  12249. var pack = bytes.slice(start, start + count);
  12250. return isLittleEndian ? pack : pack.reverse();
  12251. };
  12252. var set = function (view, count, index, conversion, value, isLittleEndian) {
  12253. var intIndex = toIndex(index);
  12254. var store = getInternalState(view);
  12255. if (intIndex + count > store.byteLength) throw RangeError(WRONG_INDEX);
  12256. var bytes = getInternalState(store.buffer).bytes;
  12257. var start = intIndex + store.byteOffset;
  12258. var pack = conversion(+value);
  12259. for (var i = 0; i < count; i++) bytes[start + i] = pack[isLittleEndian ? i : count - i - 1];
  12260. };
  12261. if (!NATIVE_ARRAY_BUFFER) {
  12262. $ArrayBuffer = function ArrayBuffer(length) {
  12263. anInstance(this, $ArrayBuffer, ARRAY_BUFFER);
  12264. var byteLength = toIndex(length);
  12265. setInternalState(this, {
  12266. bytes: arrayFill.call(new Array(byteLength), 0),
  12267. byteLength: byteLength
  12268. });
  12269. if (!DESCRIPTORS) this.byteLength = byteLength;
  12270. };
  12271. $DataView = function DataView(buffer, byteOffset, byteLength) {
  12272. anInstance(this, $DataView, DATA_VIEW);
  12273. anInstance(buffer, $ArrayBuffer, DATA_VIEW);
  12274. var bufferLength = getInternalState(buffer).byteLength;
  12275. var offset = toInteger(byteOffset);
  12276. if (offset < 0 || offset > bufferLength) throw RangeError('Wrong offset');
  12277. byteLength = byteLength === undefined ? bufferLength - offset : toLength(byteLength);
  12278. if (offset + byteLength > bufferLength) throw RangeError(WRONG_LENGTH);
  12279. setInternalState(this, {
  12280. buffer: buffer,
  12281. byteLength: byteLength,
  12282. byteOffset: offset
  12283. });
  12284. if (!DESCRIPTORS) {
  12285. this.buffer = buffer;
  12286. this.byteLength = byteLength;
  12287. this.byteOffset = offset;
  12288. }
  12289. };
  12290. if (DESCRIPTORS) {
  12291. addGetter($ArrayBuffer, 'byteLength');
  12292. addGetter($DataView, 'buffer');
  12293. addGetter($DataView, 'byteLength');
  12294. addGetter($DataView, 'byteOffset');
  12295. }
  12296. redefineAll($DataView[PROTOTYPE], {
  12297. getInt8: function getInt8(byteOffset) {
  12298. return get(this, 1, byteOffset)[0] << 24 >> 24;
  12299. },
  12300. getUint8: function getUint8(byteOffset) {
  12301. return get(this, 1, byteOffset)[0];
  12302. },
  12303. getInt16: function getInt16(byteOffset /* , littleEndian */) {
  12304. var bytes = get(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : undefined);
  12305. return (bytes[1] << 8 | bytes[0]) << 16 >> 16;
  12306. },
  12307. getUint16: function getUint16(byteOffset /* , littleEndian */) {
  12308. var bytes = get(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : undefined);
  12309. return bytes[1] << 8 | bytes[0];
  12310. },
  12311. getInt32: function getInt32(byteOffset /* , littleEndian */) {
  12312. return unpackInt32(get(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined));
  12313. },
  12314. getUint32: function getUint32(byteOffset /* , littleEndian */) {
  12315. return unpackInt32(get(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined)) >>> 0;
  12316. },
  12317. getFloat32: function getFloat32(byteOffset /* , littleEndian */) {
  12318. return unpackIEEE754(get(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined), 23);
  12319. },
  12320. getFloat64: function getFloat64(byteOffset /* , littleEndian */) {
  12321. return unpackIEEE754(get(this, 8, byteOffset, arguments.length > 1 ? arguments[1] : undefined), 52);
  12322. },
  12323. setInt8: function setInt8(byteOffset, value) {
  12324. set(this, 1, byteOffset, packInt8, value);
  12325. },
  12326. setUint8: function setUint8(byteOffset, value) {
  12327. set(this, 1, byteOffset, packInt8, value);
  12328. },
  12329. setInt16: function setInt16(byteOffset, value /* , littleEndian */) {
  12330. set(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : undefined);
  12331. },
  12332. setUint16: function setUint16(byteOffset, value /* , littleEndian */) {
  12333. set(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : undefined);
  12334. },
  12335. setInt32: function setInt32(byteOffset, value /* , littleEndian */) {
  12336. set(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : undefined);
  12337. },
  12338. setUint32: function setUint32(byteOffset, value /* , littleEndian */) {
  12339. set(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : undefined);
  12340. },
  12341. setFloat32: function setFloat32(byteOffset, value /* , littleEndian */) {
  12342. set(this, 4, byteOffset, packFloat32, value, arguments.length > 2 ? arguments[2] : undefined);
  12343. },
  12344. setFloat64: function setFloat64(byteOffset, value /* , littleEndian */) {
  12345. set(this, 8, byteOffset, packFloat64, value, arguments.length > 2 ? arguments[2] : undefined);
  12346. }
  12347. });
  12348. } else {
  12349. if (!fails(function () {
  12350. NativeArrayBuffer(1);
  12351. }) || !fails(function () {
  12352. new NativeArrayBuffer(-1); // eslint-disable-line no-new
  12353. }) || fails(function () {
  12354. new NativeArrayBuffer(); // eslint-disable-line no-new
  12355. new NativeArrayBuffer(1.5); // eslint-disable-line no-new
  12356. new NativeArrayBuffer(NaN); // eslint-disable-line no-new
  12357. return NativeArrayBuffer.name != ARRAY_BUFFER;
  12358. })) {
  12359. $ArrayBuffer = function ArrayBuffer(length) {
  12360. anInstance(this, $ArrayBuffer);
  12361. return new NativeArrayBuffer(toIndex(length));
  12362. };
  12363. var ArrayBufferPrototype = $ArrayBuffer[PROTOTYPE] = NativeArrayBuffer[PROTOTYPE];
  12364. for (var keys = getOwnPropertyNames(NativeArrayBuffer), j = 0, key; keys.length > j;) {
  12365. if (!((key = keys[j++]) in $ArrayBuffer)) {
  12366. createNonEnumerableProperty($ArrayBuffer, key, NativeArrayBuffer[key]);
  12367. }
  12368. }
  12369. ArrayBufferPrototype.constructor = $ArrayBuffer;
  12370. }
  12371. // WebKit bug - the same parent prototype for typed arrays and data view
  12372. if (setPrototypeOf && getPrototypeOf($DataViewPrototype) !== ObjectPrototype) {
  12373. setPrototypeOf($DataViewPrototype, ObjectPrototype);
  12374. }
  12375. // iOS Safari 7.x bug
  12376. var testView = new $DataView(new $ArrayBuffer(2));
  12377. var nativeSetInt8 = $DataViewPrototype.setInt8;
  12378. testView.setInt8(0, 2147483648);
  12379. testView.setInt8(1, 2147483649);
  12380. if (testView.getInt8(0) || !testView.getInt8(1)) redefineAll($DataViewPrototype, {
  12381. setInt8: function setInt8(byteOffset, value) {
  12382. nativeSetInt8.call(this, byteOffset, value << 24 >> 24);
  12383. },
  12384. setUint8: function setUint8(byteOffset, value) {
  12385. nativeSetInt8.call(this, byteOffset, value << 24 >> 24);
  12386. }
  12387. }, { unsafe: true });
  12388. }
  12389. setToStringTag($ArrayBuffer, ARRAY_BUFFER);
  12390. setToStringTag($DataView, DATA_VIEW);
  12391. module.exports = {
  12392. ArrayBuffer: $ArrayBuffer,
  12393. DataView: $DataView
  12394. };
  12395. },{"../internals/an-instance":106,"../internals/array-buffer-native":108,"../internals/array-fill":112,"../internals/create-non-enumerable-property":131,"../internals/descriptors":136,"../internals/fails":145,"../internals/global":150,"../internals/ieee754":156,"../internals/internal-state":160,"../internals/object-define-property":180,"../internals/object-get-own-property-names":183,"../internals/object-get-prototype-of":185,"../internals/object-set-prototype-of":189,"../internals/redefine-all":196,"../internals/set-to-string-tag":206,"../internals/to-index":216,"../internals/to-integer":218,"../internals/to-length":219}],111:[function(require,module,exports){
  12396. 'use strict';
  12397. var toObject = require('../internals/to-object');
  12398. var toAbsoluteIndex = require('../internals/to-absolute-index');
  12399. var toLength = require('../internals/to-length');
  12400. var min = Math.min;
  12401. // `Array.prototype.copyWithin` method implementation
  12402. // https://tc39.github.io/ecma262/#sec-array.prototype.copywithin
  12403. module.exports = [].copyWithin || function copyWithin(target /* = 0 */, start /* = 0, end = @length */) {
  12404. var O = toObject(this);
  12405. var len = toLength(O.length);
  12406. var to = toAbsoluteIndex(target, len);
  12407. var from = toAbsoluteIndex(start, len);
  12408. var end = arguments.length > 2 ? arguments[2] : undefined;
  12409. var count = min((end === undefined ? len : toAbsoluteIndex(end, len)) - from, len - to);
  12410. var inc = 1;
  12411. if (from < to && to < from + count) {
  12412. inc = -1;
  12413. from += count - 1;
  12414. to += count - 1;
  12415. }
  12416. while (count-- > 0) {
  12417. if (from in O) O[to] = O[from];
  12418. else delete O[to];
  12419. to += inc;
  12420. from += inc;
  12421. } return O;
  12422. };
  12423. },{"../internals/to-absolute-index":215,"../internals/to-length":219,"../internals/to-object":220}],112:[function(require,module,exports){
  12424. 'use strict';
  12425. var toObject = require('../internals/to-object');
  12426. var toAbsoluteIndex = require('../internals/to-absolute-index');
  12427. var toLength = require('../internals/to-length');
  12428. // `Array.prototype.fill` method implementation
  12429. // https://tc39.github.io/ecma262/#sec-array.prototype.fill
  12430. module.exports = function fill(value /* , start = 0, end = @length */) {
  12431. var O = toObject(this);
  12432. var length = toLength(O.length);
  12433. var argumentsLength = arguments.length;
  12434. var index = toAbsoluteIndex(argumentsLength > 1 ? arguments[1] : undefined, length);
  12435. var end = argumentsLength > 2 ? arguments[2] : undefined;
  12436. var endPos = end === undefined ? length : toAbsoluteIndex(end, length);
  12437. while (endPos > index) O[index++] = value;
  12438. return O;
  12439. };
  12440. },{"../internals/to-absolute-index":215,"../internals/to-length":219,"../internals/to-object":220}],113:[function(require,module,exports){
  12441. 'use strict';
  12442. var $forEach = require('../internals/array-iteration').forEach;
  12443. var arrayMethodIsStrict = require('../internals/array-method-is-strict');
  12444. var arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');
  12445. var STRICT_METHOD = arrayMethodIsStrict('forEach');
  12446. var USES_TO_LENGTH = arrayMethodUsesToLength('forEach');
  12447. // `Array.prototype.forEach` method implementation
  12448. // https://tc39.github.io/ecma262/#sec-array.prototype.foreach
  12449. module.exports = (!STRICT_METHOD || !USES_TO_LENGTH) ? function forEach(callbackfn /* , thisArg */) {
  12450. return $forEach(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  12451. } : [].forEach;
  12452. },{"../internals/array-iteration":116,"../internals/array-method-is-strict":119,"../internals/array-method-uses-to-length":120}],114:[function(require,module,exports){
  12453. 'use strict';
  12454. var bind = require('../internals/function-bind-context');
  12455. var toObject = require('../internals/to-object');
  12456. var callWithSafeIterationClosing = require('../internals/call-with-safe-iteration-closing');
  12457. var isArrayIteratorMethod = require('../internals/is-array-iterator-method');
  12458. var toLength = require('../internals/to-length');
  12459. var createProperty = require('../internals/create-property');
  12460. var getIteratorMethod = require('../internals/get-iterator-method');
  12461. // `Array.from` method implementation
  12462. // https://tc39.github.io/ecma262/#sec-array.from
  12463. module.exports = function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
  12464. var O = toObject(arrayLike);
  12465. var C = typeof this == 'function' ? this : Array;
  12466. var argumentsLength = arguments.length;
  12467. var mapfn = argumentsLength > 1 ? arguments[1] : undefined;
  12468. var mapping = mapfn !== undefined;
  12469. var iteratorMethod = getIteratorMethod(O);
  12470. var index = 0;
  12471. var length, result, step, iterator, next, value;
  12472. if (mapping) mapfn = bind(mapfn, argumentsLength > 2 ? arguments[2] : undefined, 2);
  12473. // if the target is not iterable or it's an array with the default iterator - use a simple case
  12474. if (iteratorMethod != undefined && !(C == Array && isArrayIteratorMethod(iteratorMethod))) {
  12475. iterator = iteratorMethod.call(O);
  12476. next = iterator.next;
  12477. result = new C();
  12478. for (;!(step = next.call(iterator)).done; index++) {
  12479. value = mapping ? callWithSafeIterationClosing(iterator, mapfn, [step.value, index], true) : step.value;
  12480. createProperty(result, index, value);
  12481. }
  12482. } else {
  12483. length = toLength(O.length);
  12484. result = new C(length);
  12485. for (;length > index; index++) {
  12486. value = mapping ? mapfn(O[index], index) : O[index];
  12487. createProperty(result, index, value);
  12488. }
  12489. }
  12490. result.length = index;
  12491. return result;
  12492. };
  12493. },{"../internals/call-with-safe-iteration-closing":123,"../internals/create-property":133,"../internals/function-bind-context":147,"../internals/get-iterator-method":149,"../internals/is-array-iterator-method":161,"../internals/to-length":219,"../internals/to-object":220}],115:[function(require,module,exports){
  12494. var toIndexedObject = require('../internals/to-indexed-object');
  12495. var toLength = require('../internals/to-length');
  12496. var toAbsoluteIndex = require('../internals/to-absolute-index');
  12497. // `Array.prototype.{ indexOf, includes }` methods implementation
  12498. var createMethod = function (IS_INCLUDES) {
  12499. return function ($this, el, fromIndex) {
  12500. var O = toIndexedObject($this);
  12501. var length = toLength(O.length);
  12502. var index = toAbsoluteIndex(fromIndex, length);
  12503. var value;
  12504. // Array#includes uses SameValueZero equality algorithm
  12505. // eslint-disable-next-line no-self-compare
  12506. if (IS_INCLUDES && el != el) while (length > index) {
  12507. value = O[index++];
  12508. // eslint-disable-next-line no-self-compare
  12509. if (value != value) return true;
  12510. // Array#indexOf ignores holes, Array#includes - not
  12511. } else for (;length > index; index++) {
  12512. if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
  12513. } return !IS_INCLUDES && -1;
  12514. };
  12515. };
  12516. module.exports = {
  12517. // `Array.prototype.includes` method
  12518. // https://tc39.github.io/ecma262/#sec-array.prototype.includes
  12519. includes: createMethod(true),
  12520. // `Array.prototype.indexOf` method
  12521. // https://tc39.github.io/ecma262/#sec-array.prototype.indexof
  12522. indexOf: createMethod(false)
  12523. };
  12524. },{"../internals/to-absolute-index":215,"../internals/to-indexed-object":217,"../internals/to-length":219}],116:[function(require,module,exports){
  12525. var bind = require('../internals/function-bind-context');
  12526. var IndexedObject = require('../internals/indexed-object');
  12527. var toObject = require('../internals/to-object');
  12528. var toLength = require('../internals/to-length');
  12529. var arraySpeciesCreate = require('../internals/array-species-create');
  12530. var push = [].push;
  12531. // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex }` methods implementation
  12532. var createMethod = function (TYPE) {
  12533. var IS_MAP = TYPE == 1;
  12534. var IS_FILTER = TYPE == 2;
  12535. var IS_SOME = TYPE == 3;
  12536. var IS_EVERY = TYPE == 4;
  12537. var IS_FIND_INDEX = TYPE == 6;
  12538. var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
  12539. return function ($this, callbackfn, that, specificCreate) {
  12540. var O = toObject($this);
  12541. var self = IndexedObject(O);
  12542. var boundFunction = bind(callbackfn, that, 3);
  12543. var length = toLength(self.length);
  12544. var index = 0;
  12545. var create = specificCreate || arraySpeciesCreate;
  12546. var target = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
  12547. var value, result;
  12548. for (;length > index; index++) if (NO_HOLES || index in self) {
  12549. value = self[index];
  12550. result = boundFunction(value, index, O);
  12551. if (TYPE) {
  12552. if (IS_MAP) target[index] = result; // map
  12553. else if (result) switch (TYPE) {
  12554. case 3: return true; // some
  12555. case 5: return value; // find
  12556. case 6: return index; // findIndex
  12557. case 2: push.call(target, value); // filter
  12558. } else if (IS_EVERY) return false; // every
  12559. }
  12560. }
  12561. return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;
  12562. };
  12563. };
  12564. module.exports = {
  12565. // `Array.prototype.forEach` method
  12566. // https://tc39.github.io/ecma262/#sec-array.prototype.foreach
  12567. forEach: createMethod(0),
  12568. // `Array.prototype.map` method
  12569. // https://tc39.github.io/ecma262/#sec-array.prototype.map
  12570. map: createMethod(1),
  12571. // `Array.prototype.filter` method
  12572. // https://tc39.github.io/ecma262/#sec-array.prototype.filter
  12573. filter: createMethod(2),
  12574. // `Array.prototype.some` method
  12575. // https://tc39.github.io/ecma262/#sec-array.prototype.some
  12576. some: createMethod(3),
  12577. // `Array.prototype.every` method
  12578. // https://tc39.github.io/ecma262/#sec-array.prototype.every
  12579. every: createMethod(4),
  12580. // `Array.prototype.find` method
  12581. // https://tc39.github.io/ecma262/#sec-array.prototype.find
  12582. find: createMethod(5),
  12583. // `Array.prototype.findIndex` method
  12584. // https://tc39.github.io/ecma262/#sec-array.prototype.findIndex
  12585. findIndex: createMethod(6)
  12586. };
  12587. },{"../internals/array-species-create":122,"../internals/function-bind-context":147,"../internals/indexed-object":157,"../internals/to-length":219,"../internals/to-object":220}],117:[function(require,module,exports){
  12588. 'use strict';
  12589. var toIndexedObject = require('../internals/to-indexed-object');
  12590. var toInteger = require('../internals/to-integer');
  12591. var toLength = require('../internals/to-length');
  12592. var arrayMethodIsStrict = require('../internals/array-method-is-strict');
  12593. var arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');
  12594. var min = Math.min;
  12595. var nativeLastIndexOf = [].lastIndexOf;
  12596. var NEGATIVE_ZERO = !!nativeLastIndexOf && 1 / [1].lastIndexOf(1, -0) < 0;
  12597. var STRICT_METHOD = arrayMethodIsStrict('lastIndexOf');
  12598. // For preventing possible almost infinite loop in non-standard implementations, test the forward version of the method
  12599. var USES_TO_LENGTH = arrayMethodUsesToLength('indexOf', { ACCESSORS: true, 1: 0 });
  12600. var FORCED = NEGATIVE_ZERO || !STRICT_METHOD || !USES_TO_LENGTH;
  12601. // `Array.prototype.lastIndexOf` method implementation
  12602. // https://tc39.github.io/ecma262/#sec-array.prototype.lastindexof
  12603. module.exports = FORCED ? function lastIndexOf(searchElement /* , fromIndex = @[*-1] */) {
  12604. // convert -0 to +0
  12605. if (NEGATIVE_ZERO) return nativeLastIndexOf.apply(this, arguments) || 0;
  12606. var O = toIndexedObject(this);
  12607. var length = toLength(O.length);
  12608. var index = length - 1;
  12609. if (arguments.length > 1) index = min(index, toInteger(arguments[1]));
  12610. if (index < 0) index = length + index;
  12611. for (;index >= 0; index--) if (index in O && O[index] === searchElement) return index || 0;
  12612. return -1;
  12613. } : nativeLastIndexOf;
  12614. },{"../internals/array-method-is-strict":119,"../internals/array-method-uses-to-length":120,"../internals/to-indexed-object":217,"../internals/to-integer":218,"../internals/to-length":219}],118:[function(require,module,exports){
  12615. var fails = require('../internals/fails');
  12616. var wellKnownSymbol = require('../internals/well-known-symbol');
  12617. var V8_VERSION = require('../internals/engine-v8-version');
  12618. var SPECIES = wellKnownSymbol('species');
  12619. module.exports = function (METHOD_NAME) {
  12620. // We can't use this feature detection in V8 since it causes
  12621. // deoptimization and serious performance degradation
  12622. // https://github.com/zloirock/core-js/issues/677
  12623. return V8_VERSION >= 51 || !fails(function () {
  12624. var array = [];
  12625. var constructor = array.constructor = {};
  12626. constructor[SPECIES] = function () {
  12627. return { foo: 1 };
  12628. };
  12629. return array[METHOD_NAME](Boolean).foo !== 1;
  12630. });
  12631. };
  12632. },{"../internals/engine-v8-version":142,"../internals/fails":145,"../internals/well-known-symbol":231}],119:[function(require,module,exports){
  12633. 'use strict';
  12634. var fails = require('../internals/fails');
  12635. module.exports = function (METHOD_NAME, argument) {
  12636. var method = [][METHOD_NAME];
  12637. return !!method && fails(function () {
  12638. // eslint-disable-next-line no-useless-call,no-throw-literal
  12639. method.call(null, argument || function () { throw 1; }, 1);
  12640. });
  12641. };
  12642. },{"../internals/fails":145}],120:[function(require,module,exports){
  12643. var DESCRIPTORS = require('../internals/descriptors');
  12644. var fails = require('../internals/fails');
  12645. var has = require('../internals/has');
  12646. var defineProperty = Object.defineProperty;
  12647. var cache = {};
  12648. var thrower = function (it) { throw it; };
  12649. module.exports = function (METHOD_NAME, options) {
  12650. if (has(cache, METHOD_NAME)) return cache[METHOD_NAME];
  12651. if (!options) options = {};
  12652. var method = [][METHOD_NAME];
  12653. var ACCESSORS = has(options, 'ACCESSORS') ? options.ACCESSORS : false;
  12654. var argument0 = has(options, 0) ? options[0] : thrower;
  12655. var argument1 = has(options, 1) ? options[1] : undefined;
  12656. return cache[METHOD_NAME] = !!method && !fails(function () {
  12657. if (ACCESSORS && !DESCRIPTORS) return true;
  12658. var O = { length: -1 };
  12659. if (ACCESSORS) defineProperty(O, 1, { enumerable: true, get: thrower });
  12660. else O[1] = 1;
  12661. method.call(O, argument0, argument1);
  12662. });
  12663. };
  12664. },{"../internals/descriptors":136,"../internals/fails":145,"../internals/has":151}],121:[function(require,module,exports){
  12665. var aFunction = require('../internals/a-function');
  12666. var toObject = require('../internals/to-object');
  12667. var IndexedObject = require('../internals/indexed-object');
  12668. var toLength = require('../internals/to-length');
  12669. // `Array.prototype.{ reduce, reduceRight }` methods implementation
  12670. var createMethod = function (IS_RIGHT) {
  12671. return function (that, callbackfn, argumentsLength, memo) {
  12672. aFunction(callbackfn);
  12673. var O = toObject(that);
  12674. var self = IndexedObject(O);
  12675. var length = toLength(O.length);
  12676. var index = IS_RIGHT ? length - 1 : 0;
  12677. var i = IS_RIGHT ? -1 : 1;
  12678. if (argumentsLength < 2) while (true) {
  12679. if (index in self) {
  12680. memo = self[index];
  12681. index += i;
  12682. break;
  12683. }
  12684. index += i;
  12685. if (IS_RIGHT ? index < 0 : length <= index) {
  12686. throw TypeError('Reduce of empty array with no initial value');
  12687. }
  12688. }
  12689. for (;IS_RIGHT ? index >= 0 : length > index; index += i) if (index in self) {
  12690. memo = callbackfn(memo, self[index], index, O);
  12691. }
  12692. return memo;
  12693. };
  12694. };
  12695. module.exports = {
  12696. // `Array.prototype.reduce` method
  12697. // https://tc39.github.io/ecma262/#sec-array.prototype.reduce
  12698. left: createMethod(false),
  12699. // `Array.prototype.reduceRight` method
  12700. // https://tc39.github.io/ecma262/#sec-array.prototype.reduceright
  12701. right: createMethod(true)
  12702. };
  12703. },{"../internals/a-function":102,"../internals/indexed-object":157,"../internals/to-length":219,"../internals/to-object":220}],122:[function(require,module,exports){
  12704. var isObject = require('../internals/is-object');
  12705. var isArray = require('../internals/is-array');
  12706. var wellKnownSymbol = require('../internals/well-known-symbol');
  12707. var SPECIES = wellKnownSymbol('species');
  12708. // `ArraySpeciesCreate` abstract operation
  12709. // https://tc39.github.io/ecma262/#sec-arrayspeciescreate
  12710. module.exports = function (originalArray, length) {
  12711. var C;
  12712. if (isArray(originalArray)) {
  12713. C = originalArray.constructor;
  12714. // cross-realm fallback
  12715. if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
  12716. else if (isObject(C)) {
  12717. C = C[SPECIES];
  12718. if (C === null) C = undefined;
  12719. }
  12720. } return new (C === undefined ? Array : C)(length === 0 ? 0 : length);
  12721. };
  12722. },{"../internals/is-array":162,"../internals/is-object":164,"../internals/well-known-symbol":231}],123:[function(require,module,exports){
  12723. var anObject = require('../internals/an-object');
  12724. var iteratorClose = require('../internals/iterator-close');
  12725. // call something on iterator step with safe closing on error
  12726. module.exports = function (iterator, fn, value, ENTRIES) {
  12727. try {
  12728. return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value);
  12729. // 7.4.6 IteratorClose(iterator, completion)
  12730. } catch (error) {
  12731. iteratorClose(iterator);
  12732. throw error;
  12733. }
  12734. };
  12735. },{"../internals/an-object":107,"../internals/iterator-close":168}],124:[function(require,module,exports){
  12736. var wellKnownSymbol = require('../internals/well-known-symbol');
  12737. var ITERATOR = wellKnownSymbol('iterator');
  12738. var SAFE_CLOSING = false;
  12739. try {
  12740. var called = 0;
  12741. var iteratorWithReturn = {
  12742. next: function () {
  12743. return { done: !!called++ };
  12744. },
  12745. 'return': function () {
  12746. SAFE_CLOSING = true;
  12747. }
  12748. };
  12749. iteratorWithReturn[ITERATOR] = function () {
  12750. return this;
  12751. };
  12752. // eslint-disable-next-line no-throw-literal
  12753. Array.from(iteratorWithReturn, function () { throw 2; });
  12754. } catch (error) { /* empty */ }
  12755. module.exports = function (exec, SKIP_CLOSING) {
  12756. if (!SKIP_CLOSING && !SAFE_CLOSING) return false;
  12757. var ITERATION_SUPPORT = false;
  12758. try {
  12759. var object = {};
  12760. object[ITERATOR] = function () {
  12761. return {
  12762. next: function () {
  12763. return { done: ITERATION_SUPPORT = true };
  12764. }
  12765. };
  12766. };
  12767. exec(object);
  12768. } catch (error) { /* empty */ }
  12769. return ITERATION_SUPPORT;
  12770. };
  12771. },{"../internals/well-known-symbol":231}],125:[function(require,module,exports){
  12772. var toString = {}.toString;
  12773. module.exports = function (it) {
  12774. return toString.call(it).slice(8, -1);
  12775. };
  12776. },{}],126:[function(require,module,exports){
  12777. var TO_STRING_TAG_SUPPORT = require('../internals/to-string-tag-support');
  12778. var classofRaw = require('../internals/classof-raw');
  12779. var wellKnownSymbol = require('../internals/well-known-symbol');
  12780. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  12781. // ES3 wrong here
  12782. var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
  12783. // fallback for IE11 Script Access Denied error
  12784. var tryGet = function (it, key) {
  12785. try {
  12786. return it[key];
  12787. } catch (error) { /* empty */ }
  12788. };
  12789. // getting tag from ES6+ `Object.prototype.toString`
  12790. module.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
  12791. var O, tag, result;
  12792. return it === undefined ? 'Undefined' : it === null ? 'Null'
  12793. // @@toStringTag case
  12794. : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG)) == 'string' ? tag
  12795. // builtinTag case
  12796. : CORRECT_ARGUMENTS ? classofRaw(O)
  12797. // ES3 arguments fallback
  12798. : (result = classofRaw(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : result;
  12799. };
  12800. },{"../internals/classof-raw":125,"../internals/to-string-tag-support":224,"../internals/well-known-symbol":231}],127:[function(require,module,exports){
  12801. var has = require('../internals/has');
  12802. var ownKeys = require('../internals/own-keys');
  12803. var getOwnPropertyDescriptorModule = require('../internals/object-get-own-property-descriptor');
  12804. var definePropertyModule = require('../internals/object-define-property');
  12805. module.exports = function (target, source) {
  12806. var keys = ownKeys(source);
  12807. var defineProperty = definePropertyModule.f;
  12808. var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  12809. for (var i = 0; i < keys.length; i++) {
  12810. var key = keys[i];
  12811. if (!has(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));
  12812. }
  12813. };
  12814. },{"../internals/has":151,"../internals/object-define-property":180,"../internals/object-get-own-property-descriptor":181,"../internals/own-keys":192}],128:[function(require,module,exports){
  12815. var wellKnownSymbol = require('../internals/well-known-symbol');
  12816. var MATCH = wellKnownSymbol('match');
  12817. module.exports = function (METHOD_NAME) {
  12818. var regexp = /./;
  12819. try {
  12820. '/./'[METHOD_NAME](regexp);
  12821. } catch (error1) {
  12822. try {
  12823. regexp[MATCH] = false;
  12824. return '/./'[METHOD_NAME](regexp);
  12825. } catch (error2) { /* empty */ }
  12826. } return false;
  12827. };
  12828. },{"../internals/well-known-symbol":231}],129:[function(require,module,exports){
  12829. var fails = require('../internals/fails');
  12830. module.exports = !fails(function () {
  12831. function F() { /* empty */ }
  12832. F.prototype.constructor = null;
  12833. return Object.getPrototypeOf(new F()) !== F.prototype;
  12834. });
  12835. },{"../internals/fails":145}],130:[function(require,module,exports){
  12836. 'use strict';
  12837. var IteratorPrototype = require('../internals/iterators-core').IteratorPrototype;
  12838. var create = require('../internals/object-create');
  12839. var createPropertyDescriptor = require('../internals/create-property-descriptor');
  12840. var setToStringTag = require('../internals/set-to-string-tag');
  12841. var Iterators = require('../internals/iterators');
  12842. var returnThis = function () { return this; };
  12843. module.exports = function (IteratorConstructor, NAME, next) {
  12844. var TO_STRING_TAG = NAME + ' Iterator';
  12845. IteratorConstructor.prototype = create(IteratorPrototype, { next: createPropertyDescriptor(1, next) });
  12846. setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true);
  12847. Iterators[TO_STRING_TAG] = returnThis;
  12848. return IteratorConstructor;
  12849. };
  12850. },{"../internals/create-property-descriptor":132,"../internals/iterators":170,"../internals/iterators-core":169,"../internals/object-create":178,"../internals/set-to-string-tag":206}],131:[function(require,module,exports){
  12851. var DESCRIPTORS = require('../internals/descriptors');
  12852. var definePropertyModule = require('../internals/object-define-property');
  12853. var createPropertyDescriptor = require('../internals/create-property-descriptor');
  12854. module.exports = DESCRIPTORS ? function (object, key, value) {
  12855. return definePropertyModule.f(object, key, createPropertyDescriptor(1, value));
  12856. } : function (object, key, value) {
  12857. object[key] = value;
  12858. return object;
  12859. };
  12860. },{"../internals/create-property-descriptor":132,"../internals/descriptors":136,"../internals/object-define-property":180}],132:[function(require,module,exports){
  12861. module.exports = function (bitmap, value) {
  12862. return {
  12863. enumerable: !(bitmap & 1),
  12864. configurable: !(bitmap & 2),
  12865. writable: !(bitmap & 4),
  12866. value: value
  12867. };
  12868. };
  12869. },{}],133:[function(require,module,exports){
  12870. 'use strict';
  12871. var toPrimitive = require('../internals/to-primitive');
  12872. var definePropertyModule = require('../internals/object-define-property');
  12873. var createPropertyDescriptor = require('../internals/create-property-descriptor');
  12874. module.exports = function (object, key, value) {
  12875. var propertyKey = toPrimitive(key);
  12876. if (propertyKey in object) definePropertyModule.f(object, propertyKey, createPropertyDescriptor(0, value));
  12877. else object[propertyKey] = value;
  12878. };
  12879. },{"../internals/create-property-descriptor":132,"../internals/object-define-property":180,"../internals/to-primitive":223}],134:[function(require,module,exports){
  12880. 'use strict';
  12881. var $ = require('../internals/export');
  12882. var createIteratorConstructor = require('../internals/create-iterator-constructor');
  12883. var getPrototypeOf = require('../internals/object-get-prototype-of');
  12884. var setPrototypeOf = require('../internals/object-set-prototype-of');
  12885. var setToStringTag = require('../internals/set-to-string-tag');
  12886. var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
  12887. var redefine = require('../internals/redefine');
  12888. var wellKnownSymbol = require('../internals/well-known-symbol');
  12889. var IS_PURE = require('../internals/is-pure');
  12890. var Iterators = require('../internals/iterators');
  12891. var IteratorsCore = require('../internals/iterators-core');
  12892. var IteratorPrototype = IteratorsCore.IteratorPrototype;
  12893. var BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS;
  12894. var ITERATOR = wellKnownSymbol('iterator');
  12895. var KEYS = 'keys';
  12896. var VALUES = 'values';
  12897. var ENTRIES = 'entries';
  12898. var returnThis = function () { return this; };
  12899. module.exports = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {
  12900. createIteratorConstructor(IteratorConstructor, NAME, next);
  12901. var getIterationMethod = function (KIND) {
  12902. if (KIND === DEFAULT && defaultIterator) return defaultIterator;
  12903. if (!BUGGY_SAFARI_ITERATORS && KIND in IterablePrototype) return IterablePrototype[KIND];
  12904. switch (KIND) {
  12905. case KEYS: return function keys() { return new IteratorConstructor(this, KIND); };
  12906. case VALUES: return function values() { return new IteratorConstructor(this, KIND); };
  12907. case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); };
  12908. } return function () { return new IteratorConstructor(this); };
  12909. };
  12910. var TO_STRING_TAG = NAME + ' Iterator';
  12911. var INCORRECT_VALUES_NAME = false;
  12912. var IterablePrototype = Iterable.prototype;
  12913. var nativeIterator = IterablePrototype[ITERATOR]
  12914. || IterablePrototype['@@iterator']
  12915. || DEFAULT && IterablePrototype[DEFAULT];
  12916. var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT);
  12917. var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator;
  12918. var CurrentIteratorPrototype, methods, KEY;
  12919. // fix native
  12920. if (anyNativeIterator) {
  12921. CurrentIteratorPrototype = getPrototypeOf(anyNativeIterator.call(new Iterable()));
  12922. if (IteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) {
  12923. if (!IS_PURE && getPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) {
  12924. if (setPrototypeOf) {
  12925. setPrototypeOf(CurrentIteratorPrototype, IteratorPrototype);
  12926. } else if (typeof CurrentIteratorPrototype[ITERATOR] != 'function') {
  12927. createNonEnumerableProperty(CurrentIteratorPrototype, ITERATOR, returnThis);
  12928. }
  12929. }
  12930. // Set @@toStringTag to native iterators
  12931. setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true);
  12932. if (IS_PURE) Iterators[TO_STRING_TAG] = returnThis;
  12933. }
  12934. }
  12935. // fix Array#{values, @@iterator}.name in V8 / FF
  12936. if (DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) {
  12937. INCORRECT_VALUES_NAME = true;
  12938. defaultIterator = function values() { return nativeIterator.call(this); };
  12939. }
  12940. // define iterator
  12941. if ((!IS_PURE || FORCED) && IterablePrototype[ITERATOR] !== defaultIterator) {
  12942. createNonEnumerableProperty(IterablePrototype, ITERATOR, defaultIterator);
  12943. }
  12944. Iterators[NAME] = defaultIterator;
  12945. // export additional methods
  12946. if (DEFAULT) {
  12947. methods = {
  12948. values: getIterationMethod(VALUES),
  12949. keys: IS_SET ? defaultIterator : getIterationMethod(KEYS),
  12950. entries: getIterationMethod(ENTRIES)
  12951. };
  12952. if (FORCED) for (KEY in methods) {
  12953. if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
  12954. redefine(IterablePrototype, KEY, methods[KEY]);
  12955. }
  12956. } else $({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods);
  12957. }
  12958. return methods;
  12959. };
  12960. },{"../internals/create-iterator-constructor":130,"../internals/create-non-enumerable-property":131,"../internals/export":144,"../internals/is-pure":165,"../internals/iterators":170,"../internals/iterators-core":169,"../internals/object-get-prototype-of":185,"../internals/object-set-prototype-of":189,"../internals/redefine":197,"../internals/set-to-string-tag":206,"../internals/well-known-symbol":231}],135:[function(require,module,exports){
  12961. var path = require('../internals/path');
  12962. var has = require('../internals/has');
  12963. var wrappedWellKnownSymbolModule = require('../internals/well-known-symbol-wrapped');
  12964. var defineProperty = require('../internals/object-define-property').f;
  12965. module.exports = function (NAME) {
  12966. var Symbol = path.Symbol || (path.Symbol = {});
  12967. if (!has(Symbol, NAME)) defineProperty(Symbol, NAME, {
  12968. value: wrappedWellKnownSymbolModule.f(NAME)
  12969. });
  12970. };
  12971. },{"../internals/has":151,"../internals/object-define-property":180,"../internals/path":193,"../internals/well-known-symbol-wrapped":230}],136:[function(require,module,exports){
  12972. var fails = require('../internals/fails');
  12973. // Thank's IE8 for his funny defineProperty
  12974. module.exports = !fails(function () {
  12975. return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
  12976. });
  12977. },{"../internals/fails":145}],137:[function(require,module,exports){
  12978. var global = require('../internals/global');
  12979. var isObject = require('../internals/is-object');
  12980. var document = global.document;
  12981. // typeof document.createElement is 'object' in old IE
  12982. var EXISTS = isObject(document) && isObject(document.createElement);
  12983. module.exports = function (it) {
  12984. return EXISTS ? document.createElement(it) : {};
  12985. };
  12986. },{"../internals/global":150,"../internals/is-object":164}],138:[function(require,module,exports){
  12987. // iterable DOM collections
  12988. // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods
  12989. module.exports = {
  12990. CSSRuleList: 0,
  12991. CSSStyleDeclaration: 0,
  12992. CSSValueList: 0,
  12993. ClientRectList: 0,
  12994. DOMRectList: 0,
  12995. DOMStringList: 0,
  12996. DOMTokenList: 1,
  12997. DataTransferItemList: 0,
  12998. FileList: 0,
  12999. HTMLAllCollection: 0,
  13000. HTMLCollection: 0,
  13001. HTMLFormElement: 0,
  13002. HTMLSelectElement: 0,
  13003. MediaList: 0,
  13004. MimeTypeArray: 0,
  13005. NamedNodeMap: 0,
  13006. NodeList: 1,
  13007. PaintRequestList: 0,
  13008. Plugin: 0,
  13009. PluginArray: 0,
  13010. SVGLengthList: 0,
  13011. SVGNumberList: 0,
  13012. SVGPathSegList: 0,
  13013. SVGPointList: 0,
  13014. SVGStringList: 0,
  13015. SVGTransformList: 0,
  13016. SourceBufferList: 0,
  13017. StyleSheetList: 0,
  13018. TextTrackCueList: 0,
  13019. TextTrackList: 0,
  13020. TouchList: 0
  13021. };
  13022. },{}],139:[function(require,module,exports){
  13023. var userAgent = require('../internals/engine-user-agent');
  13024. module.exports = /(iphone|ipod|ipad).*applewebkit/i.test(userAgent);
  13025. },{"../internals/engine-user-agent":141}],140:[function(require,module,exports){
  13026. var classof = require('../internals/classof-raw');
  13027. var global = require('../internals/global');
  13028. module.exports = classof(global.process) == 'process';
  13029. },{"../internals/classof-raw":125,"../internals/global":150}],141:[function(require,module,exports){
  13030. var getBuiltIn = require('../internals/get-built-in');
  13031. module.exports = getBuiltIn('navigator', 'userAgent') || '';
  13032. },{"../internals/get-built-in":148}],142:[function(require,module,exports){
  13033. var global = require('../internals/global');
  13034. var userAgent = require('../internals/engine-user-agent');
  13035. var process = global.process;
  13036. var versions = process && process.versions;
  13037. var v8 = versions && versions.v8;
  13038. var match, version;
  13039. if (v8) {
  13040. match = v8.split('.');
  13041. version = match[0] + match[1];
  13042. } else if (userAgent) {
  13043. match = userAgent.match(/Edge\/(\d+)/);
  13044. if (!match || match[1] >= 74) {
  13045. match = userAgent.match(/Chrome\/(\d+)/);
  13046. if (match) version = match[1];
  13047. }
  13048. }
  13049. module.exports = version && +version;
  13050. },{"../internals/engine-user-agent":141,"../internals/global":150}],143:[function(require,module,exports){
  13051. // IE8- don't enum bug keys
  13052. module.exports = [
  13053. 'constructor',
  13054. 'hasOwnProperty',
  13055. 'isPrototypeOf',
  13056. 'propertyIsEnumerable',
  13057. 'toLocaleString',
  13058. 'toString',
  13059. 'valueOf'
  13060. ];
  13061. },{}],144:[function(require,module,exports){
  13062. var global = require('../internals/global');
  13063. var getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;
  13064. var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
  13065. var redefine = require('../internals/redefine');
  13066. var setGlobal = require('../internals/set-global');
  13067. var copyConstructorProperties = require('../internals/copy-constructor-properties');
  13068. var isForced = require('../internals/is-forced');
  13069. /*
  13070. options.target - name of the target object
  13071. options.global - target is the global object
  13072. options.stat - export as static methods of target
  13073. options.proto - export as prototype methods of target
  13074. options.real - real prototype method for the `pure` version
  13075. options.forced - export even if the native feature is available
  13076. options.bind - bind methods to the target, required for the `pure` version
  13077. options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
  13078. options.unsafe - use the simple assignment of property instead of delete + defineProperty
  13079. options.sham - add a flag to not completely full polyfills
  13080. options.enumerable - export as enumerable property
  13081. options.noTargetGet - prevent calling a getter on target
  13082. */
  13083. module.exports = function (options, source) {
  13084. var TARGET = options.target;
  13085. var GLOBAL = options.global;
  13086. var STATIC = options.stat;
  13087. var FORCED, target, key, targetProperty, sourceProperty, descriptor;
  13088. if (GLOBAL) {
  13089. target = global;
  13090. } else if (STATIC) {
  13091. target = global[TARGET] || setGlobal(TARGET, {});
  13092. } else {
  13093. target = (global[TARGET] || {}).prototype;
  13094. }
  13095. if (target) for (key in source) {
  13096. sourceProperty = source[key];
  13097. if (options.noTargetGet) {
  13098. descriptor = getOwnPropertyDescriptor(target, key);
  13099. targetProperty = descriptor && descriptor.value;
  13100. } else targetProperty = target[key];
  13101. FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
  13102. // contained in target
  13103. if (!FORCED && targetProperty !== undefined) {
  13104. if (typeof sourceProperty === typeof targetProperty) continue;
  13105. copyConstructorProperties(sourceProperty, targetProperty);
  13106. }
  13107. // add a flag to not completely full polyfills
  13108. if (options.sham || (targetProperty && targetProperty.sham)) {
  13109. createNonEnumerableProperty(sourceProperty, 'sham', true);
  13110. }
  13111. // extend global
  13112. redefine(target, key, sourceProperty, options);
  13113. }
  13114. };
  13115. },{"../internals/copy-constructor-properties":127,"../internals/create-non-enumerable-property":131,"../internals/global":150,"../internals/is-forced":163,"../internals/object-get-own-property-descriptor":181,"../internals/redefine":197,"../internals/set-global":204}],145:[function(require,module,exports){
  13116. module.exports = function (exec) {
  13117. try {
  13118. return !!exec();
  13119. } catch (error) {
  13120. return true;
  13121. }
  13122. };
  13123. },{}],146:[function(require,module,exports){
  13124. 'use strict';
  13125. // TODO: Remove from `core-js@4` since it's moved to entry points
  13126. require('../modules/es.regexp.exec');
  13127. var redefine = require('../internals/redefine');
  13128. var fails = require('../internals/fails');
  13129. var wellKnownSymbol = require('../internals/well-known-symbol');
  13130. var regexpExec = require('../internals/regexp-exec');
  13131. var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
  13132. var SPECIES = wellKnownSymbol('species');
  13133. var REPLACE_SUPPORTS_NAMED_GROUPS = !fails(function () {
  13134. // #replace needs built-in support for named groups.
  13135. // #match works fine because it just return the exec results, even if it has
  13136. // a "grops" property.
  13137. var re = /./;
  13138. re.exec = function () {
  13139. var result = [];
  13140. result.groups = { a: '7' };
  13141. return result;
  13142. };
  13143. return ''.replace(re, '$<a>') !== '7';
  13144. });
  13145. // IE <= 11 replaces $0 with the whole match, as if it was $&
  13146. // https://stackoverflow.com/questions/6024666/getting-ie-to-replace-a-regex-with-the-literal-string-0
  13147. var REPLACE_KEEPS_$0 = (function () {
  13148. return 'a'.replace(/./, '$0') === '$0';
  13149. })();
  13150. var REPLACE = wellKnownSymbol('replace');
  13151. // Safari <= 13.0.3(?) substitutes nth capture where n>m with an empty string
  13152. var REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE = (function () {
  13153. if (/./[REPLACE]) {
  13154. return /./[REPLACE]('a', '$0') === '';
  13155. }
  13156. return false;
  13157. })();
  13158. // Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec
  13159. // Weex JS has frozen built-in prototypes, so use try / catch wrapper
  13160. var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = !fails(function () {
  13161. var re = /(?:)/;
  13162. var originalExec = re.exec;
  13163. re.exec = function () { return originalExec.apply(this, arguments); };
  13164. var result = 'ab'.split(re);
  13165. return result.length !== 2 || result[0] !== 'a' || result[1] !== 'b';
  13166. });
  13167. module.exports = function (KEY, length, exec, sham) {
  13168. var SYMBOL = wellKnownSymbol(KEY);
  13169. var DELEGATES_TO_SYMBOL = !fails(function () {
  13170. // String methods call symbol-named RegEp methods
  13171. var O = {};
  13172. O[SYMBOL] = function () { return 7; };
  13173. return ''[KEY](O) != 7;
  13174. });
  13175. var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails(function () {
  13176. // Symbol-named RegExp methods call .exec
  13177. var execCalled = false;
  13178. var re = /a/;
  13179. if (KEY === 'split') {
  13180. // We can't use real regex here since it causes deoptimization
  13181. // and serious performance degradation in V8
  13182. // https://github.com/zloirock/core-js/issues/306
  13183. re = {};
  13184. // RegExp[@@split] doesn't call the regex's exec method, but first creates
  13185. // a new one. We need to return the patched regex when creating the new one.
  13186. re.constructor = {};
  13187. re.constructor[SPECIES] = function () { return re; };
  13188. re.flags = '';
  13189. re[SYMBOL] = /./[SYMBOL];
  13190. }
  13191. re.exec = function () { execCalled = true; return null; };
  13192. re[SYMBOL]('');
  13193. return !execCalled;
  13194. });
  13195. if (
  13196. !DELEGATES_TO_SYMBOL ||
  13197. !DELEGATES_TO_EXEC ||
  13198. (KEY === 'replace' && !(
  13199. REPLACE_SUPPORTS_NAMED_GROUPS &&
  13200. REPLACE_KEEPS_$0 &&
  13201. !REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE
  13202. )) ||
  13203. (KEY === 'split' && !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC)
  13204. ) {
  13205. var nativeRegExpMethod = /./[SYMBOL];
  13206. var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) {
  13207. if (regexp.exec === regexpExec) {
  13208. if (DELEGATES_TO_SYMBOL && !forceStringMethod) {
  13209. // The native String method already delegates to @@method (this
  13210. // polyfilled function), leasing to infinite recursion.
  13211. // We avoid it by directly calling the native @@method method.
  13212. return { done: true, value: nativeRegExpMethod.call(regexp, str, arg2) };
  13213. }
  13214. return { done: true, value: nativeMethod.call(str, regexp, arg2) };
  13215. }
  13216. return { done: false };
  13217. }, {
  13218. REPLACE_KEEPS_$0: REPLACE_KEEPS_$0,
  13219. REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE: REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE
  13220. });
  13221. var stringMethod = methods[0];
  13222. var regexMethod = methods[1];
  13223. redefine(String.prototype, KEY, stringMethod);
  13224. redefine(RegExp.prototype, SYMBOL, length == 2
  13225. // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)
  13226. // 21.2.5.11 RegExp.prototype[@@split](string, limit)
  13227. ? function (string, arg) { return regexMethod.call(string, this, arg); }
  13228. // 21.2.5.6 RegExp.prototype[@@match](string)
  13229. // 21.2.5.9 RegExp.prototype[@@search](string)
  13230. : function (string) { return regexMethod.call(string, this); }
  13231. );
  13232. }
  13233. if (sham) createNonEnumerableProperty(RegExp.prototype[SYMBOL], 'sham', true);
  13234. };
  13235. },{"../internals/create-non-enumerable-property":131,"../internals/fails":145,"../internals/redefine":197,"../internals/regexp-exec":199,"../internals/well-known-symbol":231,"../modules/es.regexp.exec":256}],147:[function(require,module,exports){
  13236. var aFunction = require('../internals/a-function');
  13237. // optional / simple context binding
  13238. module.exports = function (fn, that, length) {
  13239. aFunction(fn);
  13240. if (that === undefined) return fn;
  13241. switch (length) {
  13242. case 0: return function () {
  13243. return fn.call(that);
  13244. };
  13245. case 1: return function (a) {
  13246. return fn.call(that, a);
  13247. };
  13248. case 2: return function (a, b) {
  13249. return fn.call(that, a, b);
  13250. };
  13251. case 3: return function (a, b, c) {
  13252. return fn.call(that, a, b, c);
  13253. };
  13254. }
  13255. return function (/* ...args */) {
  13256. return fn.apply(that, arguments);
  13257. };
  13258. };
  13259. },{"../internals/a-function":102}],148:[function(require,module,exports){
  13260. var path = require('../internals/path');
  13261. var global = require('../internals/global');
  13262. var aFunction = function (variable) {
  13263. return typeof variable == 'function' ? variable : undefined;
  13264. };
  13265. module.exports = function (namespace, method) {
  13266. return arguments.length < 2 ? aFunction(path[namespace]) || aFunction(global[namespace])
  13267. : path[namespace] && path[namespace][method] || global[namespace] && global[namespace][method];
  13268. };
  13269. },{"../internals/global":150,"../internals/path":193}],149:[function(require,module,exports){
  13270. var classof = require('../internals/classof');
  13271. var Iterators = require('../internals/iterators');
  13272. var wellKnownSymbol = require('../internals/well-known-symbol');
  13273. var ITERATOR = wellKnownSymbol('iterator');
  13274. module.exports = function (it) {
  13275. if (it != undefined) return it[ITERATOR]
  13276. || it['@@iterator']
  13277. || Iterators[classof(it)];
  13278. };
  13279. },{"../internals/classof":126,"../internals/iterators":170,"../internals/well-known-symbol":231}],150:[function(require,module,exports){
  13280. (function (global){
  13281. var check = function (it) {
  13282. return it && it.Math == Math && it;
  13283. };
  13284. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  13285. module.exports =
  13286. // eslint-disable-next-line no-undef
  13287. check(typeof globalThis == 'object' && globalThis) ||
  13288. check(typeof window == 'object' && window) ||
  13289. check(typeof self == 'object' && self) ||
  13290. check(typeof global == 'object' && global) ||
  13291. // eslint-disable-next-line no-new-func
  13292. (function () { return this; })() || Function('return this')();
  13293. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  13294. },{}],151:[function(require,module,exports){
  13295. var hasOwnProperty = {}.hasOwnProperty;
  13296. module.exports = function (it, key) {
  13297. return hasOwnProperty.call(it, key);
  13298. };
  13299. },{}],152:[function(require,module,exports){
  13300. module.exports = {};
  13301. },{}],153:[function(require,module,exports){
  13302. var global = require('../internals/global');
  13303. module.exports = function (a, b) {
  13304. var console = global.console;
  13305. if (console && console.error) {
  13306. arguments.length === 1 ? console.error(a) : console.error(a, b);
  13307. }
  13308. };
  13309. },{"../internals/global":150}],154:[function(require,module,exports){
  13310. var getBuiltIn = require('../internals/get-built-in');
  13311. module.exports = getBuiltIn('document', 'documentElement');
  13312. },{"../internals/get-built-in":148}],155:[function(require,module,exports){
  13313. var DESCRIPTORS = require('../internals/descriptors');
  13314. var fails = require('../internals/fails');
  13315. var createElement = require('../internals/document-create-element');
  13316. // Thank's IE8 for his funny defineProperty
  13317. module.exports = !DESCRIPTORS && !fails(function () {
  13318. return Object.defineProperty(createElement('div'), 'a', {
  13319. get: function () { return 7; }
  13320. }).a != 7;
  13321. });
  13322. },{"../internals/descriptors":136,"../internals/document-create-element":137,"../internals/fails":145}],156:[function(require,module,exports){
  13323. // IEEE754 conversions based on https://github.com/feross/ieee754
  13324. // eslint-disable-next-line no-shadow-restricted-names
  13325. var Infinity = 1 / 0;
  13326. var abs = Math.abs;
  13327. var pow = Math.pow;
  13328. var floor = Math.floor;
  13329. var log = Math.log;
  13330. var LN2 = Math.LN2;
  13331. var pack = function (number, mantissaLength, bytes) {
  13332. var buffer = new Array(bytes);
  13333. var exponentLength = bytes * 8 - mantissaLength - 1;
  13334. var eMax = (1 << exponentLength) - 1;
  13335. var eBias = eMax >> 1;
  13336. var rt = mantissaLength === 23 ? pow(2, -24) - pow(2, -77) : 0;
  13337. var sign = number < 0 || number === 0 && 1 / number < 0 ? 1 : 0;
  13338. var index = 0;
  13339. var exponent, mantissa, c;
  13340. number = abs(number);
  13341. // eslint-disable-next-line no-self-compare
  13342. if (number != number || number === Infinity) {
  13343. // eslint-disable-next-line no-self-compare
  13344. mantissa = number != number ? 1 : 0;
  13345. exponent = eMax;
  13346. } else {
  13347. exponent = floor(log(number) / LN2);
  13348. if (number * (c = pow(2, -exponent)) < 1) {
  13349. exponent--;
  13350. c *= 2;
  13351. }
  13352. if (exponent + eBias >= 1) {
  13353. number += rt / c;
  13354. } else {
  13355. number += rt * pow(2, 1 - eBias);
  13356. }
  13357. if (number * c >= 2) {
  13358. exponent++;
  13359. c /= 2;
  13360. }
  13361. if (exponent + eBias >= eMax) {
  13362. mantissa = 0;
  13363. exponent = eMax;
  13364. } else if (exponent + eBias >= 1) {
  13365. mantissa = (number * c - 1) * pow(2, mantissaLength);
  13366. exponent = exponent + eBias;
  13367. } else {
  13368. mantissa = number * pow(2, eBias - 1) * pow(2, mantissaLength);
  13369. exponent = 0;
  13370. }
  13371. }
  13372. for (; mantissaLength >= 8; buffer[index++] = mantissa & 255, mantissa /= 256, mantissaLength -= 8);
  13373. exponent = exponent << mantissaLength | mantissa;
  13374. exponentLength += mantissaLength;
  13375. for (; exponentLength > 0; buffer[index++] = exponent & 255, exponent /= 256, exponentLength -= 8);
  13376. buffer[--index] |= sign * 128;
  13377. return buffer;
  13378. };
  13379. var unpack = function (buffer, mantissaLength) {
  13380. var bytes = buffer.length;
  13381. var exponentLength = bytes * 8 - mantissaLength - 1;
  13382. var eMax = (1 << exponentLength) - 1;
  13383. var eBias = eMax >> 1;
  13384. var nBits = exponentLength - 7;
  13385. var index = bytes - 1;
  13386. var sign = buffer[index--];
  13387. var exponent = sign & 127;
  13388. var mantissa;
  13389. sign >>= 7;
  13390. for (; nBits > 0; exponent = exponent * 256 + buffer[index], index--, nBits -= 8);
  13391. mantissa = exponent & (1 << -nBits) - 1;
  13392. exponent >>= -nBits;
  13393. nBits += mantissaLength;
  13394. for (; nBits > 0; mantissa = mantissa * 256 + buffer[index], index--, nBits -= 8);
  13395. if (exponent === 0) {
  13396. exponent = 1 - eBias;
  13397. } else if (exponent === eMax) {
  13398. return mantissa ? NaN : sign ? -Infinity : Infinity;
  13399. } else {
  13400. mantissa = mantissa + pow(2, mantissaLength);
  13401. exponent = exponent - eBias;
  13402. } return (sign ? -1 : 1) * mantissa * pow(2, exponent - mantissaLength);
  13403. };
  13404. module.exports = {
  13405. pack: pack,
  13406. unpack: unpack
  13407. };
  13408. },{}],157:[function(require,module,exports){
  13409. var fails = require('../internals/fails');
  13410. var classof = require('../internals/classof-raw');
  13411. var split = ''.split;
  13412. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  13413. module.exports = fails(function () {
  13414. // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
  13415. // eslint-disable-next-line no-prototype-builtins
  13416. return !Object('z').propertyIsEnumerable(0);
  13417. }) ? function (it) {
  13418. return classof(it) == 'String' ? split.call(it, '') : Object(it);
  13419. } : Object;
  13420. },{"../internals/classof-raw":125,"../internals/fails":145}],158:[function(require,module,exports){
  13421. var isObject = require('../internals/is-object');
  13422. var setPrototypeOf = require('../internals/object-set-prototype-of');
  13423. // makes subclassing work correct for wrapped built-ins
  13424. module.exports = function ($this, dummy, Wrapper) {
  13425. var NewTarget, NewTargetPrototype;
  13426. if (
  13427. // it can work only with native `setPrototypeOf`
  13428. setPrototypeOf &&
  13429. // we haven't completely correct pre-ES6 way for getting `new.target`, so use this
  13430. typeof (NewTarget = dummy.constructor) == 'function' &&
  13431. NewTarget !== Wrapper &&
  13432. isObject(NewTargetPrototype = NewTarget.prototype) &&
  13433. NewTargetPrototype !== Wrapper.prototype
  13434. ) setPrototypeOf($this, NewTargetPrototype);
  13435. return $this;
  13436. };
  13437. },{"../internals/is-object":164,"../internals/object-set-prototype-of":189}],159:[function(require,module,exports){
  13438. var store = require('../internals/shared-store');
  13439. var functionToString = Function.toString;
  13440. // this helper broken in `3.4.1-3.4.4`, so we can't use `shared` helper
  13441. if (typeof store.inspectSource != 'function') {
  13442. store.inspectSource = function (it) {
  13443. return functionToString.call(it);
  13444. };
  13445. }
  13446. module.exports = store.inspectSource;
  13447. },{"../internals/shared-store":208}],160:[function(require,module,exports){
  13448. var NATIVE_WEAK_MAP = require('../internals/native-weak-map');
  13449. var global = require('../internals/global');
  13450. var isObject = require('../internals/is-object');
  13451. var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
  13452. var objectHas = require('../internals/has');
  13453. var shared = require('../internals/shared-store');
  13454. var sharedKey = require('../internals/shared-key');
  13455. var hiddenKeys = require('../internals/hidden-keys');
  13456. var WeakMap = global.WeakMap;
  13457. var set, get, has;
  13458. var enforce = function (it) {
  13459. return has(it) ? get(it) : set(it, {});
  13460. };
  13461. var getterFor = function (TYPE) {
  13462. return function (it) {
  13463. var state;
  13464. if (!isObject(it) || (state = get(it)).type !== TYPE) {
  13465. throw TypeError('Incompatible receiver, ' + TYPE + ' required');
  13466. } return state;
  13467. };
  13468. };
  13469. if (NATIVE_WEAK_MAP) {
  13470. var store = shared.state || (shared.state = new WeakMap());
  13471. var wmget = store.get;
  13472. var wmhas = store.has;
  13473. var wmset = store.set;
  13474. set = function (it, metadata) {
  13475. metadata.facade = it;
  13476. wmset.call(store, it, metadata);
  13477. return metadata;
  13478. };
  13479. get = function (it) {
  13480. return wmget.call(store, it) || {};
  13481. };
  13482. has = function (it) {
  13483. return wmhas.call(store, it);
  13484. };
  13485. } else {
  13486. var STATE = sharedKey('state');
  13487. hiddenKeys[STATE] = true;
  13488. set = function (it, metadata) {
  13489. metadata.facade = it;
  13490. createNonEnumerableProperty(it, STATE, metadata);
  13491. return metadata;
  13492. };
  13493. get = function (it) {
  13494. return objectHas(it, STATE) ? it[STATE] : {};
  13495. };
  13496. has = function (it) {
  13497. return objectHas(it, STATE);
  13498. };
  13499. }
  13500. module.exports = {
  13501. set: set,
  13502. get: get,
  13503. has: has,
  13504. enforce: enforce,
  13505. getterFor: getterFor
  13506. };
  13507. },{"../internals/create-non-enumerable-property":131,"../internals/global":150,"../internals/has":151,"../internals/hidden-keys":152,"../internals/is-object":164,"../internals/native-weak-map":174,"../internals/shared-key":207,"../internals/shared-store":208}],161:[function(require,module,exports){
  13508. var wellKnownSymbol = require('../internals/well-known-symbol');
  13509. var Iterators = require('../internals/iterators');
  13510. var ITERATOR = wellKnownSymbol('iterator');
  13511. var ArrayPrototype = Array.prototype;
  13512. // check on default Array iterator
  13513. module.exports = function (it) {
  13514. return it !== undefined && (Iterators.Array === it || ArrayPrototype[ITERATOR] === it);
  13515. };
  13516. },{"../internals/iterators":170,"../internals/well-known-symbol":231}],162:[function(require,module,exports){
  13517. var classof = require('../internals/classof-raw');
  13518. // `IsArray` abstract operation
  13519. // https://tc39.github.io/ecma262/#sec-isarray
  13520. module.exports = Array.isArray || function isArray(arg) {
  13521. return classof(arg) == 'Array';
  13522. };
  13523. },{"../internals/classof-raw":125}],163:[function(require,module,exports){
  13524. var fails = require('../internals/fails');
  13525. var replacement = /#|\.prototype\./;
  13526. var isForced = function (feature, detection) {
  13527. var value = data[normalize(feature)];
  13528. return value == POLYFILL ? true
  13529. : value == NATIVE ? false
  13530. : typeof detection == 'function' ? fails(detection)
  13531. : !!detection;
  13532. };
  13533. var normalize = isForced.normalize = function (string) {
  13534. return String(string).replace(replacement, '.').toLowerCase();
  13535. };
  13536. var data = isForced.data = {};
  13537. var NATIVE = isForced.NATIVE = 'N';
  13538. var POLYFILL = isForced.POLYFILL = 'P';
  13539. module.exports = isForced;
  13540. },{"../internals/fails":145}],164:[function(require,module,exports){
  13541. module.exports = function (it) {
  13542. return typeof it === 'object' ? it !== null : typeof it === 'function';
  13543. };
  13544. },{}],165:[function(require,module,exports){
  13545. module.exports = false;
  13546. },{}],166:[function(require,module,exports){
  13547. var isObject = require('../internals/is-object');
  13548. var classof = require('../internals/classof-raw');
  13549. var wellKnownSymbol = require('../internals/well-known-symbol');
  13550. var MATCH = wellKnownSymbol('match');
  13551. // `IsRegExp` abstract operation
  13552. // https://tc39.github.io/ecma262/#sec-isregexp
  13553. module.exports = function (it) {
  13554. var isRegExp;
  13555. return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classof(it) == 'RegExp');
  13556. };
  13557. },{"../internals/classof-raw":125,"../internals/is-object":164,"../internals/well-known-symbol":231}],167:[function(require,module,exports){
  13558. var anObject = require('../internals/an-object');
  13559. var isArrayIteratorMethod = require('../internals/is-array-iterator-method');
  13560. var toLength = require('../internals/to-length');
  13561. var bind = require('../internals/function-bind-context');
  13562. var getIteratorMethod = require('../internals/get-iterator-method');
  13563. var iteratorClose = require('../internals/iterator-close');
  13564. var Result = function (stopped, result) {
  13565. this.stopped = stopped;
  13566. this.result = result;
  13567. };
  13568. module.exports = function (iterable, unboundFunction, options) {
  13569. var that = options && options.that;
  13570. var AS_ENTRIES = !!(options && options.AS_ENTRIES);
  13571. var IS_ITERATOR = !!(options && options.IS_ITERATOR);
  13572. var INTERRUPTED = !!(options && options.INTERRUPTED);
  13573. var fn = bind(unboundFunction, that, 1 + AS_ENTRIES + INTERRUPTED);
  13574. var iterator, iterFn, index, length, result, next, step;
  13575. var stop = function (condition) {
  13576. if (iterator) iteratorClose(iterator);
  13577. return new Result(true, condition);
  13578. };
  13579. var callFn = function (value) {
  13580. if (AS_ENTRIES) {
  13581. anObject(value);
  13582. return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
  13583. } return INTERRUPTED ? fn(value, stop) : fn(value);
  13584. };
  13585. if (IS_ITERATOR) {
  13586. iterator = iterable;
  13587. } else {
  13588. iterFn = getIteratorMethod(iterable);
  13589. if (typeof iterFn != 'function') throw TypeError('Target is not iterable');
  13590. // optimisation for array iterators
  13591. if (isArrayIteratorMethod(iterFn)) {
  13592. for (index = 0, length = toLength(iterable.length); length > index; index++) {
  13593. result = callFn(iterable[index]);
  13594. if (result && result instanceof Result) return result;
  13595. } return new Result(false);
  13596. }
  13597. iterator = iterFn.call(iterable);
  13598. }
  13599. next = iterator.next;
  13600. while (!(step = next.call(iterator)).done) {
  13601. try {
  13602. result = callFn(step.value);
  13603. } catch (error) {
  13604. iteratorClose(iterator);
  13605. throw error;
  13606. }
  13607. if (typeof result == 'object' && result && result instanceof Result) return result;
  13608. } return new Result(false);
  13609. };
  13610. },{"../internals/an-object":107,"../internals/function-bind-context":147,"../internals/get-iterator-method":149,"../internals/is-array-iterator-method":161,"../internals/iterator-close":168,"../internals/to-length":219}],168:[function(require,module,exports){
  13611. var anObject = require('../internals/an-object');
  13612. module.exports = function (iterator) {
  13613. var returnMethod = iterator['return'];
  13614. if (returnMethod !== undefined) {
  13615. return anObject(returnMethod.call(iterator)).value;
  13616. }
  13617. };
  13618. },{"../internals/an-object":107}],169:[function(require,module,exports){
  13619. 'use strict';
  13620. var getPrototypeOf = require('../internals/object-get-prototype-of');
  13621. var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
  13622. var has = require('../internals/has');
  13623. var wellKnownSymbol = require('../internals/well-known-symbol');
  13624. var IS_PURE = require('../internals/is-pure');
  13625. var ITERATOR = wellKnownSymbol('iterator');
  13626. var BUGGY_SAFARI_ITERATORS = false;
  13627. var returnThis = function () { return this; };
  13628. // `%IteratorPrototype%` object
  13629. // https://tc39.github.io/ecma262/#sec-%iteratorprototype%-object
  13630. var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator;
  13631. if ([].keys) {
  13632. arrayIterator = [].keys();
  13633. // Safari 8 has buggy iterators w/o `next`
  13634. if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;
  13635. else {
  13636. PrototypeOfArrayIteratorPrototype = getPrototypeOf(getPrototypeOf(arrayIterator));
  13637. if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype;
  13638. }
  13639. }
  13640. if (IteratorPrototype == undefined) IteratorPrototype = {};
  13641. // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
  13642. if (!IS_PURE && !has(IteratorPrototype, ITERATOR)) {
  13643. createNonEnumerableProperty(IteratorPrototype, ITERATOR, returnThis);
  13644. }
  13645. module.exports = {
  13646. IteratorPrototype: IteratorPrototype,
  13647. BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS
  13648. };
  13649. },{"../internals/create-non-enumerable-property":131,"../internals/has":151,"../internals/is-pure":165,"../internals/object-get-prototype-of":185,"../internals/well-known-symbol":231}],170:[function(require,module,exports){
  13650. arguments[4][152][0].apply(exports,arguments)
  13651. },{"dup":152}],171:[function(require,module,exports){
  13652. var global = require('../internals/global');
  13653. var getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;
  13654. var macrotask = require('../internals/task').set;
  13655. var IS_IOS = require('../internals/engine-is-ios');
  13656. var IS_NODE = require('../internals/engine-is-node');
  13657. var MutationObserver = global.MutationObserver || global.WebKitMutationObserver;
  13658. var document = global.document;
  13659. var process = global.process;
  13660. var Promise = global.Promise;
  13661. // Node.js 11 shows ExperimentalWarning on getting `queueMicrotask`
  13662. var queueMicrotaskDescriptor = getOwnPropertyDescriptor(global, 'queueMicrotask');
  13663. var queueMicrotask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value;
  13664. var flush, head, last, notify, toggle, node, promise, then;
  13665. // modern engines have queueMicrotask method
  13666. if (!queueMicrotask) {
  13667. flush = function () {
  13668. var parent, fn;
  13669. if (IS_NODE && (parent = process.domain)) parent.exit();
  13670. while (head) {
  13671. fn = head.fn;
  13672. head = head.next;
  13673. try {
  13674. fn();
  13675. } catch (error) {
  13676. if (head) notify();
  13677. else last = undefined;
  13678. throw error;
  13679. }
  13680. } last = undefined;
  13681. if (parent) parent.enter();
  13682. };
  13683. // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339
  13684. if (!IS_IOS && !IS_NODE && MutationObserver && document) {
  13685. toggle = true;
  13686. node = document.createTextNode('');
  13687. new MutationObserver(flush).observe(node, { characterData: true });
  13688. notify = function () {
  13689. node.data = toggle = !toggle;
  13690. };
  13691. // environments with maybe non-completely correct, but existent Promise
  13692. } else if (Promise && Promise.resolve) {
  13693. // Promise.resolve without an argument throws an error in LG WebOS 2
  13694. promise = Promise.resolve(undefined);
  13695. then = promise.then;
  13696. notify = function () {
  13697. then.call(promise, flush);
  13698. };
  13699. // Node.js without promises
  13700. } else if (IS_NODE) {
  13701. notify = function () {
  13702. process.nextTick(flush);
  13703. };
  13704. // for other environments - macrotask based on:
  13705. // - setImmediate
  13706. // - MessageChannel
  13707. // - window.postMessag
  13708. // - onreadystatechange
  13709. // - setTimeout
  13710. } else {
  13711. notify = function () {
  13712. // strange IE + webpack dev server bug - use .call(global)
  13713. macrotask.call(global, flush);
  13714. };
  13715. }
  13716. }
  13717. module.exports = queueMicrotask || function (fn) {
  13718. var task = { fn: fn, next: undefined };
  13719. if (last) last.next = task;
  13720. if (!head) {
  13721. head = task;
  13722. notify();
  13723. } last = task;
  13724. };
  13725. },{"../internals/engine-is-ios":139,"../internals/engine-is-node":140,"../internals/global":150,"../internals/object-get-own-property-descriptor":181,"../internals/task":214}],172:[function(require,module,exports){
  13726. var global = require('../internals/global');
  13727. module.exports = global.Promise;
  13728. },{"../internals/global":150}],173:[function(require,module,exports){
  13729. var fails = require('../internals/fails');
  13730. module.exports = !!Object.getOwnPropertySymbols && !fails(function () {
  13731. // Chrome 38 Symbol has incorrect toString conversion
  13732. // eslint-disable-next-line no-undef
  13733. return !String(Symbol());
  13734. });
  13735. },{"../internals/fails":145}],174:[function(require,module,exports){
  13736. var global = require('../internals/global');
  13737. var inspectSource = require('../internals/inspect-source');
  13738. var WeakMap = global.WeakMap;
  13739. module.exports = typeof WeakMap === 'function' && /native code/.test(inspectSource(WeakMap));
  13740. },{"../internals/global":150,"../internals/inspect-source":159}],175:[function(require,module,exports){
  13741. 'use strict';
  13742. var aFunction = require('../internals/a-function');
  13743. var PromiseCapability = function (C) {
  13744. var resolve, reject;
  13745. this.promise = new C(function ($$resolve, $$reject) {
  13746. if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');
  13747. resolve = $$resolve;
  13748. reject = $$reject;
  13749. });
  13750. this.resolve = aFunction(resolve);
  13751. this.reject = aFunction(reject);
  13752. };
  13753. // 25.4.1.5 NewPromiseCapability(C)
  13754. module.exports.f = function (C) {
  13755. return new PromiseCapability(C);
  13756. };
  13757. },{"../internals/a-function":102}],176:[function(require,module,exports){
  13758. var isRegExp = require('../internals/is-regexp');
  13759. module.exports = function (it) {
  13760. if (isRegExp(it)) {
  13761. throw TypeError("The method doesn't accept regular expressions");
  13762. } return it;
  13763. };
  13764. },{"../internals/is-regexp":166}],177:[function(require,module,exports){
  13765. 'use strict';
  13766. var DESCRIPTORS = require('../internals/descriptors');
  13767. var fails = require('../internals/fails');
  13768. var objectKeys = require('../internals/object-keys');
  13769. var getOwnPropertySymbolsModule = require('../internals/object-get-own-property-symbols');
  13770. var propertyIsEnumerableModule = require('../internals/object-property-is-enumerable');
  13771. var toObject = require('../internals/to-object');
  13772. var IndexedObject = require('../internals/indexed-object');
  13773. var nativeAssign = Object.assign;
  13774. var defineProperty = Object.defineProperty;
  13775. // `Object.assign` method
  13776. // https://tc39.github.io/ecma262/#sec-object.assign
  13777. module.exports = !nativeAssign || fails(function () {
  13778. // should have correct order of operations (Edge bug)
  13779. if (DESCRIPTORS && nativeAssign({ b: 1 }, nativeAssign(defineProperty({}, 'a', {
  13780. enumerable: true,
  13781. get: function () {
  13782. defineProperty(this, 'b', {
  13783. value: 3,
  13784. enumerable: false
  13785. });
  13786. }
  13787. }), { b: 2 })).b !== 1) return true;
  13788. // should work with symbols and should have deterministic property order (V8 bug)
  13789. var A = {};
  13790. var B = {};
  13791. // eslint-disable-next-line no-undef
  13792. var symbol = Symbol();
  13793. var alphabet = 'abcdefghijklmnopqrst';
  13794. A[symbol] = 7;
  13795. alphabet.split('').forEach(function (chr) { B[chr] = chr; });
  13796. return nativeAssign({}, A)[symbol] != 7 || objectKeys(nativeAssign({}, B)).join('') != alphabet;
  13797. }) ? function assign(target, source) { // eslint-disable-line no-unused-vars
  13798. var T = toObject(target);
  13799. var argumentsLength = arguments.length;
  13800. var index = 1;
  13801. var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  13802. var propertyIsEnumerable = propertyIsEnumerableModule.f;
  13803. while (argumentsLength > index) {
  13804. var S = IndexedObject(arguments[index++]);
  13805. var keys = getOwnPropertySymbols ? objectKeys(S).concat(getOwnPropertySymbols(S)) : objectKeys(S);
  13806. var length = keys.length;
  13807. var j = 0;
  13808. var key;
  13809. while (length > j) {
  13810. key = keys[j++];
  13811. if (!DESCRIPTORS || propertyIsEnumerable.call(S, key)) T[key] = S[key];
  13812. }
  13813. } return T;
  13814. } : nativeAssign;
  13815. },{"../internals/descriptors":136,"../internals/fails":145,"../internals/indexed-object":157,"../internals/object-get-own-property-symbols":184,"../internals/object-keys":187,"../internals/object-property-is-enumerable":188,"../internals/to-object":220}],178:[function(require,module,exports){
  13816. var anObject = require('../internals/an-object');
  13817. var defineProperties = require('../internals/object-define-properties');
  13818. var enumBugKeys = require('../internals/enum-bug-keys');
  13819. var hiddenKeys = require('../internals/hidden-keys');
  13820. var html = require('../internals/html');
  13821. var documentCreateElement = require('../internals/document-create-element');
  13822. var sharedKey = require('../internals/shared-key');
  13823. var GT = '>';
  13824. var LT = '<';
  13825. var PROTOTYPE = 'prototype';
  13826. var SCRIPT = 'script';
  13827. var IE_PROTO = sharedKey('IE_PROTO');
  13828. var EmptyConstructor = function () { /* empty */ };
  13829. var scriptTag = function (content) {
  13830. return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
  13831. };
  13832. // Create object with fake `null` prototype: use ActiveX Object with cleared prototype
  13833. var NullProtoObjectViaActiveX = function (activeXDocument) {
  13834. activeXDocument.write(scriptTag(''));
  13835. activeXDocument.close();
  13836. var temp = activeXDocument.parentWindow.Object;
  13837. activeXDocument = null; // avoid memory leak
  13838. return temp;
  13839. };
  13840. // Create object with fake `null` prototype: use iframe Object with cleared prototype
  13841. var NullProtoObjectViaIFrame = function () {
  13842. // Thrash, waste and sodomy: IE GC bug
  13843. var iframe = documentCreateElement('iframe');
  13844. var JS = 'java' + SCRIPT + ':';
  13845. var iframeDocument;
  13846. iframe.style.display = 'none';
  13847. html.appendChild(iframe);
  13848. // https://github.com/zloirock/core-js/issues/475
  13849. iframe.src = String(JS);
  13850. iframeDocument = iframe.contentWindow.document;
  13851. iframeDocument.open();
  13852. iframeDocument.write(scriptTag('document.F=Object'));
  13853. iframeDocument.close();
  13854. return iframeDocument.F;
  13855. };
  13856. // Check for document.domain and active x support
  13857. // No need to use active x approach when document.domain is not set
  13858. // see https://github.com/es-shims/es5-shim/issues/150
  13859. // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
  13860. // avoid IE GC bug
  13861. var activeXDocument;
  13862. var NullProtoObject = function () {
  13863. try {
  13864. /* global ActiveXObject */
  13865. activeXDocument = document.domain && new ActiveXObject('htmlfile');
  13866. } catch (error) { /* ignore */ }
  13867. NullProtoObject = activeXDocument ? NullProtoObjectViaActiveX(activeXDocument) : NullProtoObjectViaIFrame();
  13868. var length = enumBugKeys.length;
  13869. while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
  13870. return NullProtoObject();
  13871. };
  13872. hiddenKeys[IE_PROTO] = true;
  13873. // `Object.create` method
  13874. // https://tc39.github.io/ecma262/#sec-object.create
  13875. module.exports = Object.create || function create(O, Properties) {
  13876. var result;
  13877. if (O !== null) {
  13878. EmptyConstructor[PROTOTYPE] = anObject(O);
  13879. result = new EmptyConstructor();
  13880. EmptyConstructor[PROTOTYPE] = null;
  13881. // add "__proto__" for Object.getPrototypeOf polyfill
  13882. result[IE_PROTO] = O;
  13883. } else result = NullProtoObject();
  13884. return Properties === undefined ? result : defineProperties(result, Properties);
  13885. };
  13886. },{"../internals/an-object":107,"../internals/document-create-element":137,"../internals/enum-bug-keys":143,"../internals/hidden-keys":152,"../internals/html":154,"../internals/object-define-properties":179,"../internals/shared-key":207}],179:[function(require,module,exports){
  13887. var DESCRIPTORS = require('../internals/descriptors');
  13888. var definePropertyModule = require('../internals/object-define-property');
  13889. var anObject = require('../internals/an-object');
  13890. var objectKeys = require('../internals/object-keys');
  13891. // `Object.defineProperties` method
  13892. // https://tc39.github.io/ecma262/#sec-object.defineproperties
  13893. module.exports = DESCRIPTORS ? Object.defineProperties : function defineProperties(O, Properties) {
  13894. anObject(O);
  13895. var keys = objectKeys(Properties);
  13896. var length = keys.length;
  13897. var index = 0;
  13898. var key;
  13899. while (length > index) definePropertyModule.f(O, key = keys[index++], Properties[key]);
  13900. return O;
  13901. };
  13902. },{"../internals/an-object":107,"../internals/descriptors":136,"../internals/object-define-property":180,"../internals/object-keys":187}],180:[function(require,module,exports){
  13903. var DESCRIPTORS = require('../internals/descriptors');
  13904. var IE8_DOM_DEFINE = require('../internals/ie8-dom-define');
  13905. var anObject = require('../internals/an-object');
  13906. var toPrimitive = require('../internals/to-primitive');
  13907. var nativeDefineProperty = Object.defineProperty;
  13908. // `Object.defineProperty` method
  13909. // https://tc39.github.io/ecma262/#sec-object.defineproperty
  13910. exports.f = DESCRIPTORS ? nativeDefineProperty : function defineProperty(O, P, Attributes) {
  13911. anObject(O);
  13912. P = toPrimitive(P, true);
  13913. anObject(Attributes);
  13914. if (IE8_DOM_DEFINE) try {
  13915. return nativeDefineProperty(O, P, Attributes);
  13916. } catch (error) { /* empty */ }
  13917. if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');
  13918. if ('value' in Attributes) O[P] = Attributes.value;
  13919. return O;
  13920. };
  13921. },{"../internals/an-object":107,"../internals/descriptors":136,"../internals/ie8-dom-define":155,"../internals/to-primitive":223}],181:[function(require,module,exports){
  13922. var DESCRIPTORS = require('../internals/descriptors');
  13923. var propertyIsEnumerableModule = require('../internals/object-property-is-enumerable');
  13924. var createPropertyDescriptor = require('../internals/create-property-descriptor');
  13925. var toIndexedObject = require('../internals/to-indexed-object');
  13926. var toPrimitive = require('../internals/to-primitive');
  13927. var has = require('../internals/has');
  13928. var IE8_DOM_DEFINE = require('../internals/ie8-dom-define');
  13929. var nativeGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  13930. // `Object.getOwnPropertyDescriptor` method
  13931. // https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptor
  13932. exports.f = DESCRIPTORS ? nativeGetOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
  13933. O = toIndexedObject(O);
  13934. P = toPrimitive(P, true);
  13935. if (IE8_DOM_DEFINE) try {
  13936. return nativeGetOwnPropertyDescriptor(O, P);
  13937. } catch (error) { /* empty */ }
  13938. if (has(O, P)) return createPropertyDescriptor(!propertyIsEnumerableModule.f.call(O, P), O[P]);
  13939. };
  13940. },{"../internals/create-property-descriptor":132,"../internals/descriptors":136,"../internals/has":151,"../internals/ie8-dom-define":155,"../internals/object-property-is-enumerable":188,"../internals/to-indexed-object":217,"../internals/to-primitive":223}],182:[function(require,module,exports){
  13941. var toIndexedObject = require('../internals/to-indexed-object');
  13942. var nativeGetOwnPropertyNames = require('../internals/object-get-own-property-names').f;
  13943. var toString = {}.toString;
  13944. var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
  13945. ? Object.getOwnPropertyNames(window) : [];
  13946. var getWindowNames = function (it) {
  13947. try {
  13948. return nativeGetOwnPropertyNames(it);
  13949. } catch (error) {
  13950. return windowNames.slice();
  13951. }
  13952. };
  13953. // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
  13954. module.exports.f = function getOwnPropertyNames(it) {
  13955. return windowNames && toString.call(it) == '[object Window]'
  13956. ? getWindowNames(it)
  13957. : nativeGetOwnPropertyNames(toIndexedObject(it));
  13958. };
  13959. },{"../internals/object-get-own-property-names":183,"../internals/to-indexed-object":217}],183:[function(require,module,exports){
  13960. var internalObjectKeys = require('../internals/object-keys-internal');
  13961. var enumBugKeys = require('../internals/enum-bug-keys');
  13962. var hiddenKeys = enumBugKeys.concat('length', 'prototype');
  13963. // `Object.getOwnPropertyNames` method
  13964. // https://tc39.github.io/ecma262/#sec-object.getownpropertynames
  13965. exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  13966. return internalObjectKeys(O, hiddenKeys);
  13967. };
  13968. },{"../internals/enum-bug-keys":143,"../internals/object-keys-internal":186}],184:[function(require,module,exports){
  13969. exports.f = Object.getOwnPropertySymbols;
  13970. },{}],185:[function(require,module,exports){
  13971. var has = require('../internals/has');
  13972. var toObject = require('../internals/to-object');
  13973. var sharedKey = require('../internals/shared-key');
  13974. var CORRECT_PROTOTYPE_GETTER = require('../internals/correct-prototype-getter');
  13975. var IE_PROTO = sharedKey('IE_PROTO');
  13976. var ObjectPrototype = Object.prototype;
  13977. // `Object.getPrototypeOf` method
  13978. // https://tc39.github.io/ecma262/#sec-object.getprototypeof
  13979. module.exports = CORRECT_PROTOTYPE_GETTER ? Object.getPrototypeOf : function (O) {
  13980. O = toObject(O);
  13981. if (has(O, IE_PROTO)) return O[IE_PROTO];
  13982. if (typeof O.constructor == 'function' && O instanceof O.constructor) {
  13983. return O.constructor.prototype;
  13984. } return O instanceof Object ? ObjectPrototype : null;
  13985. };
  13986. },{"../internals/correct-prototype-getter":129,"../internals/has":151,"../internals/shared-key":207,"../internals/to-object":220}],186:[function(require,module,exports){
  13987. var has = require('../internals/has');
  13988. var toIndexedObject = require('../internals/to-indexed-object');
  13989. var indexOf = require('../internals/array-includes').indexOf;
  13990. var hiddenKeys = require('../internals/hidden-keys');
  13991. module.exports = function (object, names) {
  13992. var O = toIndexedObject(object);
  13993. var i = 0;
  13994. var result = [];
  13995. var key;
  13996. for (key in O) !has(hiddenKeys, key) && has(O, key) && result.push(key);
  13997. // Don't enum bug & hidden keys
  13998. while (names.length > i) if (has(O, key = names[i++])) {
  13999. ~indexOf(result, key) || result.push(key);
  14000. }
  14001. return result;
  14002. };
  14003. },{"../internals/array-includes":115,"../internals/has":151,"../internals/hidden-keys":152,"../internals/to-indexed-object":217}],187:[function(require,module,exports){
  14004. var internalObjectKeys = require('../internals/object-keys-internal');
  14005. var enumBugKeys = require('../internals/enum-bug-keys');
  14006. // `Object.keys` method
  14007. // https://tc39.github.io/ecma262/#sec-object.keys
  14008. module.exports = Object.keys || function keys(O) {
  14009. return internalObjectKeys(O, enumBugKeys);
  14010. };
  14011. },{"../internals/enum-bug-keys":143,"../internals/object-keys-internal":186}],188:[function(require,module,exports){
  14012. 'use strict';
  14013. var nativePropertyIsEnumerable = {}.propertyIsEnumerable;
  14014. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  14015. // Nashorn ~ JDK8 bug
  14016. var NASHORN_BUG = getOwnPropertyDescriptor && !nativePropertyIsEnumerable.call({ 1: 2 }, 1);
  14017. // `Object.prototype.propertyIsEnumerable` method implementation
  14018. // https://tc39.github.io/ecma262/#sec-object.prototype.propertyisenumerable
  14019. exports.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
  14020. var descriptor = getOwnPropertyDescriptor(this, V);
  14021. return !!descriptor && descriptor.enumerable;
  14022. } : nativePropertyIsEnumerable;
  14023. },{}],189:[function(require,module,exports){
  14024. var anObject = require('../internals/an-object');
  14025. var aPossiblePrototype = require('../internals/a-possible-prototype');
  14026. // `Object.setPrototypeOf` method
  14027. // https://tc39.github.io/ecma262/#sec-object.setprototypeof
  14028. // Works with __proto__ only. Old v8 can't work with null proto objects.
  14029. /* eslint-disable no-proto */
  14030. module.exports = Object.setPrototypeOf || ('__proto__' in {} ? function () {
  14031. var CORRECT_SETTER = false;
  14032. var test = {};
  14033. var setter;
  14034. try {
  14035. setter = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set;
  14036. setter.call(test, []);
  14037. CORRECT_SETTER = test instanceof Array;
  14038. } catch (error) { /* empty */ }
  14039. return function setPrototypeOf(O, proto) {
  14040. anObject(O);
  14041. aPossiblePrototype(proto);
  14042. if (CORRECT_SETTER) setter.call(O, proto);
  14043. else O.__proto__ = proto;
  14044. return O;
  14045. };
  14046. }() : undefined);
  14047. },{"../internals/a-possible-prototype":103,"../internals/an-object":107}],190:[function(require,module,exports){
  14048. var DESCRIPTORS = require('../internals/descriptors');
  14049. var objectKeys = require('../internals/object-keys');
  14050. var toIndexedObject = require('../internals/to-indexed-object');
  14051. var propertyIsEnumerable = require('../internals/object-property-is-enumerable').f;
  14052. // `Object.{ entries, values }` methods implementation
  14053. var createMethod = function (TO_ENTRIES) {
  14054. return function (it) {
  14055. var O = toIndexedObject(it);
  14056. var keys = objectKeys(O);
  14057. var length = keys.length;
  14058. var i = 0;
  14059. var result = [];
  14060. var key;
  14061. while (length > i) {
  14062. key = keys[i++];
  14063. if (!DESCRIPTORS || propertyIsEnumerable.call(O, key)) {
  14064. result.push(TO_ENTRIES ? [key, O[key]] : O[key]);
  14065. }
  14066. }
  14067. return result;
  14068. };
  14069. };
  14070. module.exports = {
  14071. // `Object.entries` method
  14072. // https://tc39.github.io/ecma262/#sec-object.entries
  14073. entries: createMethod(true),
  14074. // `Object.values` method
  14075. // https://tc39.github.io/ecma262/#sec-object.values
  14076. values: createMethod(false)
  14077. };
  14078. },{"../internals/descriptors":136,"../internals/object-keys":187,"../internals/object-property-is-enumerable":188,"../internals/to-indexed-object":217}],191:[function(require,module,exports){
  14079. 'use strict';
  14080. var TO_STRING_TAG_SUPPORT = require('../internals/to-string-tag-support');
  14081. var classof = require('../internals/classof');
  14082. // `Object.prototype.toString` method implementation
  14083. // https://tc39.github.io/ecma262/#sec-object.prototype.tostring
  14084. module.exports = TO_STRING_TAG_SUPPORT ? {}.toString : function toString() {
  14085. return '[object ' + classof(this) + ']';
  14086. };
  14087. },{"../internals/classof":126,"../internals/to-string-tag-support":224}],192:[function(require,module,exports){
  14088. var getBuiltIn = require('../internals/get-built-in');
  14089. var getOwnPropertyNamesModule = require('../internals/object-get-own-property-names');
  14090. var getOwnPropertySymbolsModule = require('../internals/object-get-own-property-symbols');
  14091. var anObject = require('../internals/an-object');
  14092. // all object keys, includes non-enumerable and symbols
  14093. module.exports = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
  14094. var keys = getOwnPropertyNamesModule.f(anObject(it));
  14095. var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  14096. return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys;
  14097. };
  14098. },{"../internals/an-object":107,"../internals/get-built-in":148,"../internals/object-get-own-property-names":183,"../internals/object-get-own-property-symbols":184}],193:[function(require,module,exports){
  14099. var global = require('../internals/global');
  14100. module.exports = global;
  14101. },{"../internals/global":150}],194:[function(require,module,exports){
  14102. module.exports = function (exec) {
  14103. try {
  14104. return { error: false, value: exec() };
  14105. } catch (error) {
  14106. return { error: true, value: error };
  14107. }
  14108. };
  14109. },{}],195:[function(require,module,exports){
  14110. var anObject = require('../internals/an-object');
  14111. var isObject = require('../internals/is-object');
  14112. var newPromiseCapability = require('../internals/new-promise-capability');
  14113. module.exports = function (C, x) {
  14114. anObject(C);
  14115. if (isObject(x) && x.constructor === C) return x;
  14116. var promiseCapability = newPromiseCapability.f(C);
  14117. var resolve = promiseCapability.resolve;
  14118. resolve(x);
  14119. return promiseCapability.promise;
  14120. };
  14121. },{"../internals/an-object":107,"../internals/is-object":164,"../internals/new-promise-capability":175}],196:[function(require,module,exports){
  14122. var redefine = require('../internals/redefine');
  14123. module.exports = function (target, src, options) {
  14124. for (var key in src) redefine(target, key, src[key], options);
  14125. return target;
  14126. };
  14127. },{"../internals/redefine":197}],197:[function(require,module,exports){
  14128. var global = require('../internals/global');
  14129. var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
  14130. var has = require('../internals/has');
  14131. var setGlobal = require('../internals/set-global');
  14132. var inspectSource = require('../internals/inspect-source');
  14133. var InternalStateModule = require('../internals/internal-state');
  14134. var getInternalState = InternalStateModule.get;
  14135. var enforceInternalState = InternalStateModule.enforce;
  14136. var TEMPLATE = String(String).split('String');
  14137. (module.exports = function (O, key, value, options) {
  14138. var unsafe = options ? !!options.unsafe : false;
  14139. var simple = options ? !!options.enumerable : false;
  14140. var noTargetGet = options ? !!options.noTargetGet : false;
  14141. var state;
  14142. if (typeof value == 'function') {
  14143. if (typeof key == 'string' && !has(value, 'name')) {
  14144. createNonEnumerableProperty(value, 'name', key);
  14145. }
  14146. state = enforceInternalState(value);
  14147. if (!state.source) {
  14148. state.source = TEMPLATE.join(typeof key == 'string' ? key : '');
  14149. }
  14150. }
  14151. if (O === global) {
  14152. if (simple) O[key] = value;
  14153. else setGlobal(key, value);
  14154. return;
  14155. } else if (!unsafe) {
  14156. delete O[key];
  14157. } else if (!noTargetGet && O[key]) {
  14158. simple = true;
  14159. }
  14160. if (simple) O[key] = value;
  14161. else createNonEnumerableProperty(O, key, value);
  14162. // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
  14163. })(Function.prototype, 'toString', function toString() {
  14164. return typeof this == 'function' && getInternalState(this).source || inspectSource(this);
  14165. });
  14166. },{"../internals/create-non-enumerable-property":131,"../internals/global":150,"../internals/has":151,"../internals/inspect-source":159,"../internals/internal-state":160,"../internals/set-global":204}],198:[function(require,module,exports){
  14167. var classof = require('./classof-raw');
  14168. var regexpExec = require('./regexp-exec');
  14169. // `RegExpExec` abstract operation
  14170. // https://tc39.github.io/ecma262/#sec-regexpexec
  14171. module.exports = function (R, S) {
  14172. var exec = R.exec;
  14173. if (typeof exec === 'function') {
  14174. var result = exec.call(R, S);
  14175. if (typeof result !== 'object') {
  14176. throw TypeError('RegExp exec method returned something other than an Object or null');
  14177. }
  14178. return result;
  14179. }
  14180. if (classof(R) !== 'RegExp') {
  14181. throw TypeError('RegExp#exec called on incompatible receiver');
  14182. }
  14183. return regexpExec.call(R, S);
  14184. };
  14185. },{"./classof-raw":125,"./regexp-exec":199}],199:[function(require,module,exports){
  14186. 'use strict';
  14187. var regexpFlags = require('./regexp-flags');
  14188. var stickyHelpers = require('./regexp-sticky-helpers');
  14189. var nativeExec = RegExp.prototype.exec;
  14190. // This always refers to the native implementation, because the
  14191. // String#replace polyfill uses ./fix-regexp-well-known-symbol-logic.js,
  14192. // which loads this file before patching the method.
  14193. var nativeReplace = String.prototype.replace;
  14194. var patchedExec = nativeExec;
  14195. var UPDATES_LAST_INDEX_WRONG = (function () {
  14196. var re1 = /a/;
  14197. var re2 = /b*/g;
  14198. nativeExec.call(re1, 'a');
  14199. nativeExec.call(re2, 'a');
  14200. return re1.lastIndex !== 0 || re2.lastIndex !== 0;
  14201. })();
  14202. var UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y || stickyHelpers.BROKEN_CARET;
  14203. // nonparticipating capturing group, copied from es5-shim's String#split patch.
  14204. var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;
  14205. var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y;
  14206. if (PATCH) {
  14207. patchedExec = function exec(str) {
  14208. var re = this;
  14209. var lastIndex, reCopy, match, i;
  14210. var sticky = UNSUPPORTED_Y && re.sticky;
  14211. var flags = regexpFlags.call(re);
  14212. var source = re.source;
  14213. var charsAdded = 0;
  14214. var strCopy = str;
  14215. if (sticky) {
  14216. flags = flags.replace('y', '');
  14217. if (flags.indexOf('g') === -1) {
  14218. flags += 'g';
  14219. }
  14220. strCopy = String(str).slice(re.lastIndex);
  14221. // Support anchored sticky behavior.
  14222. if (re.lastIndex > 0 && (!re.multiline || re.multiline && str[re.lastIndex - 1] !== '\n')) {
  14223. source = '(?: ' + source + ')';
  14224. strCopy = ' ' + strCopy;
  14225. charsAdded++;
  14226. }
  14227. // ^(? + rx + ) is needed, in combination with some str slicing, to
  14228. // simulate the 'y' flag.
  14229. reCopy = new RegExp('^(?:' + source + ')', flags);
  14230. }
  14231. if (NPCG_INCLUDED) {
  14232. reCopy = new RegExp('^' + source + '$(?!\\s)', flags);
  14233. }
  14234. if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex;
  14235. match = nativeExec.call(sticky ? reCopy : re, strCopy);
  14236. if (sticky) {
  14237. if (match) {
  14238. match.input = match.input.slice(charsAdded);
  14239. match[0] = match[0].slice(charsAdded);
  14240. match.index = re.lastIndex;
  14241. re.lastIndex += match[0].length;
  14242. } else re.lastIndex = 0;
  14243. } else if (UPDATES_LAST_INDEX_WRONG && match) {
  14244. re.lastIndex = re.global ? match.index + match[0].length : lastIndex;
  14245. }
  14246. if (NPCG_INCLUDED && match && match.length > 1) {
  14247. // Fix browsers whose `exec` methods don't consistently return `undefined`
  14248. // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/
  14249. nativeReplace.call(match[0], reCopy, function () {
  14250. for (i = 1; i < arguments.length - 2; i++) {
  14251. if (arguments[i] === undefined) match[i] = undefined;
  14252. }
  14253. });
  14254. }
  14255. return match;
  14256. };
  14257. }
  14258. module.exports = patchedExec;
  14259. },{"./regexp-flags":200,"./regexp-sticky-helpers":201}],200:[function(require,module,exports){
  14260. 'use strict';
  14261. var anObject = require('../internals/an-object');
  14262. // `RegExp.prototype.flags` getter implementation
  14263. // https://tc39.github.io/ecma262/#sec-get-regexp.prototype.flags
  14264. module.exports = function () {
  14265. var that = anObject(this);
  14266. var result = '';
  14267. if (that.global) result += 'g';
  14268. if (that.ignoreCase) result += 'i';
  14269. if (that.multiline) result += 'm';
  14270. if (that.dotAll) result += 's';
  14271. if (that.unicode) result += 'u';
  14272. if (that.sticky) result += 'y';
  14273. return result;
  14274. };
  14275. },{"../internals/an-object":107}],201:[function(require,module,exports){
  14276. 'use strict';
  14277. var fails = require('./fails');
  14278. // babel-minify transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError,
  14279. // so we use an intermediate function.
  14280. function RE(s, f) {
  14281. return RegExp(s, f);
  14282. }
  14283. exports.UNSUPPORTED_Y = fails(function () {
  14284. // babel-minify transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError
  14285. var re = RE('a', 'y');
  14286. re.lastIndex = 2;
  14287. return re.exec('abcd') != null;
  14288. });
  14289. exports.BROKEN_CARET = fails(function () {
  14290. // https://bugzilla.mozilla.org/show_bug.cgi?id=773687
  14291. var re = RE('^r', 'gy');
  14292. re.lastIndex = 2;
  14293. return re.exec('str') != null;
  14294. });
  14295. },{"./fails":145}],202:[function(require,module,exports){
  14296. // `RequireObjectCoercible` abstract operation
  14297. // https://tc39.github.io/ecma262/#sec-requireobjectcoercible
  14298. module.exports = function (it) {
  14299. if (it == undefined) throw TypeError("Can't call method on " + it);
  14300. return it;
  14301. };
  14302. },{}],203:[function(require,module,exports){
  14303. // `SameValue` abstract operation
  14304. // https://tc39.github.io/ecma262/#sec-samevalue
  14305. module.exports = Object.is || function is(x, y) {
  14306. // eslint-disable-next-line no-self-compare
  14307. return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y;
  14308. };
  14309. },{}],204:[function(require,module,exports){
  14310. var global = require('../internals/global');
  14311. var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
  14312. module.exports = function (key, value) {
  14313. try {
  14314. createNonEnumerableProperty(global, key, value);
  14315. } catch (error) {
  14316. global[key] = value;
  14317. } return value;
  14318. };
  14319. },{"../internals/create-non-enumerable-property":131,"../internals/global":150}],205:[function(require,module,exports){
  14320. 'use strict';
  14321. var getBuiltIn = require('../internals/get-built-in');
  14322. var definePropertyModule = require('../internals/object-define-property');
  14323. var wellKnownSymbol = require('../internals/well-known-symbol');
  14324. var DESCRIPTORS = require('../internals/descriptors');
  14325. var SPECIES = wellKnownSymbol('species');
  14326. module.exports = function (CONSTRUCTOR_NAME) {
  14327. var Constructor = getBuiltIn(CONSTRUCTOR_NAME);
  14328. var defineProperty = definePropertyModule.f;
  14329. if (DESCRIPTORS && Constructor && !Constructor[SPECIES]) {
  14330. defineProperty(Constructor, SPECIES, {
  14331. configurable: true,
  14332. get: function () { return this; }
  14333. });
  14334. }
  14335. };
  14336. },{"../internals/descriptors":136,"../internals/get-built-in":148,"../internals/object-define-property":180,"../internals/well-known-symbol":231}],206:[function(require,module,exports){
  14337. var defineProperty = require('../internals/object-define-property').f;
  14338. var has = require('../internals/has');
  14339. var wellKnownSymbol = require('../internals/well-known-symbol');
  14340. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  14341. module.exports = function (it, TAG, STATIC) {
  14342. if (it && !has(it = STATIC ? it : it.prototype, TO_STRING_TAG)) {
  14343. defineProperty(it, TO_STRING_TAG, { configurable: true, value: TAG });
  14344. }
  14345. };
  14346. },{"../internals/has":151,"../internals/object-define-property":180,"../internals/well-known-symbol":231}],207:[function(require,module,exports){
  14347. var shared = require('../internals/shared');
  14348. var uid = require('../internals/uid');
  14349. var keys = shared('keys');
  14350. module.exports = function (key) {
  14351. return keys[key] || (keys[key] = uid(key));
  14352. };
  14353. },{"../internals/shared":209,"../internals/uid":228}],208:[function(require,module,exports){
  14354. var global = require('../internals/global');
  14355. var setGlobal = require('../internals/set-global');
  14356. var SHARED = '__core-js_shared__';
  14357. var store = global[SHARED] || setGlobal(SHARED, {});
  14358. module.exports = store;
  14359. },{"../internals/global":150,"../internals/set-global":204}],209:[function(require,module,exports){
  14360. var IS_PURE = require('../internals/is-pure');
  14361. var store = require('../internals/shared-store');
  14362. (module.exports = function (key, value) {
  14363. return store[key] || (store[key] = value !== undefined ? value : {});
  14364. })('versions', []).push({
  14365. version: '3.7.0',
  14366. mode: IS_PURE ? 'pure' : 'global',
  14367. copyright: '© 2020 Denis Pushkarev (zloirock.ru)'
  14368. });
  14369. },{"../internals/is-pure":165,"../internals/shared-store":208}],210:[function(require,module,exports){
  14370. var anObject = require('../internals/an-object');
  14371. var aFunction = require('../internals/a-function');
  14372. var wellKnownSymbol = require('../internals/well-known-symbol');
  14373. var SPECIES = wellKnownSymbol('species');
  14374. // `SpeciesConstructor` abstract operation
  14375. // https://tc39.github.io/ecma262/#sec-speciesconstructor
  14376. module.exports = function (O, defaultConstructor) {
  14377. var C = anObject(O).constructor;
  14378. var S;
  14379. return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? defaultConstructor : aFunction(S);
  14380. };
  14381. },{"../internals/a-function":102,"../internals/an-object":107,"../internals/well-known-symbol":231}],211:[function(require,module,exports){
  14382. var toInteger = require('../internals/to-integer');
  14383. var requireObjectCoercible = require('../internals/require-object-coercible');
  14384. // `String.prototype.{ codePointAt, at }` methods implementation
  14385. var createMethod = function (CONVERT_TO_STRING) {
  14386. return function ($this, pos) {
  14387. var S = String(requireObjectCoercible($this));
  14388. var position = toInteger(pos);
  14389. var size = S.length;
  14390. var first, second;
  14391. if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
  14392. first = S.charCodeAt(position);
  14393. return first < 0xD800 || first > 0xDBFF || position + 1 === size
  14394. || (second = S.charCodeAt(position + 1)) < 0xDC00 || second > 0xDFFF
  14395. ? CONVERT_TO_STRING ? S.charAt(position) : first
  14396. : CONVERT_TO_STRING ? S.slice(position, position + 2) : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
  14397. };
  14398. };
  14399. module.exports = {
  14400. // `String.prototype.codePointAt` method
  14401. // https://tc39.github.io/ecma262/#sec-string.prototype.codepointat
  14402. codeAt: createMethod(false),
  14403. // `String.prototype.at` method
  14404. // https://github.com/mathiasbynens/String.prototype.at
  14405. charAt: createMethod(true)
  14406. };
  14407. },{"../internals/require-object-coercible":202,"../internals/to-integer":218}],212:[function(require,module,exports){
  14408. var fails = require('../internals/fails');
  14409. var whitespaces = require('../internals/whitespaces');
  14410. var non = '\u200B\u0085\u180E';
  14411. // check that a method works with the correct list
  14412. // of whitespaces and has a correct name
  14413. module.exports = function (METHOD_NAME) {
  14414. return fails(function () {
  14415. return !!whitespaces[METHOD_NAME]() || non[METHOD_NAME]() != non || whitespaces[METHOD_NAME].name !== METHOD_NAME;
  14416. });
  14417. };
  14418. },{"../internals/fails":145,"../internals/whitespaces":232}],213:[function(require,module,exports){
  14419. var requireObjectCoercible = require('../internals/require-object-coercible');
  14420. var whitespaces = require('../internals/whitespaces');
  14421. var whitespace = '[' + whitespaces + ']';
  14422. var ltrim = RegExp('^' + whitespace + whitespace + '*');
  14423. var rtrim = RegExp(whitespace + whitespace + '*$');
  14424. // `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation
  14425. var createMethod = function (TYPE) {
  14426. return function ($this) {
  14427. var string = String(requireObjectCoercible($this));
  14428. if (TYPE & 1) string = string.replace(ltrim, '');
  14429. if (TYPE & 2) string = string.replace(rtrim, '');
  14430. return string;
  14431. };
  14432. };
  14433. module.exports = {
  14434. // `String.prototype.{ trimLeft, trimStart }` methods
  14435. // https://tc39.github.io/ecma262/#sec-string.prototype.trimstart
  14436. start: createMethod(1),
  14437. // `String.prototype.{ trimRight, trimEnd }` methods
  14438. // https://tc39.github.io/ecma262/#sec-string.prototype.trimend
  14439. end: createMethod(2),
  14440. // `String.prototype.trim` method
  14441. // https://tc39.github.io/ecma262/#sec-string.prototype.trim
  14442. trim: createMethod(3)
  14443. };
  14444. },{"../internals/require-object-coercible":202,"../internals/whitespaces":232}],214:[function(require,module,exports){
  14445. var global = require('../internals/global');
  14446. var fails = require('../internals/fails');
  14447. var bind = require('../internals/function-bind-context');
  14448. var html = require('../internals/html');
  14449. var createElement = require('../internals/document-create-element');
  14450. var IS_IOS = require('../internals/engine-is-ios');
  14451. var IS_NODE = require('../internals/engine-is-node');
  14452. var location = global.location;
  14453. var set = global.setImmediate;
  14454. var clear = global.clearImmediate;
  14455. var process = global.process;
  14456. var MessageChannel = global.MessageChannel;
  14457. var Dispatch = global.Dispatch;
  14458. var counter = 0;
  14459. var queue = {};
  14460. var ONREADYSTATECHANGE = 'onreadystatechange';
  14461. var defer, channel, port;
  14462. var run = function (id) {
  14463. // eslint-disable-next-line no-prototype-builtins
  14464. if (queue.hasOwnProperty(id)) {
  14465. var fn = queue[id];
  14466. delete queue[id];
  14467. fn();
  14468. }
  14469. };
  14470. var runner = function (id) {
  14471. return function () {
  14472. run(id);
  14473. };
  14474. };
  14475. var listener = function (event) {
  14476. run(event.data);
  14477. };
  14478. var post = function (id) {
  14479. // old engines have not location.origin
  14480. global.postMessage(id + '', location.protocol + '//' + location.host);
  14481. };
  14482. // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
  14483. if (!set || !clear) {
  14484. set = function setImmediate(fn) {
  14485. var args = [];
  14486. var i = 1;
  14487. while (arguments.length > i) args.push(arguments[i++]);
  14488. queue[++counter] = function () {
  14489. // eslint-disable-next-line no-new-func
  14490. (typeof fn == 'function' ? fn : Function(fn)).apply(undefined, args);
  14491. };
  14492. defer(counter);
  14493. return counter;
  14494. };
  14495. clear = function clearImmediate(id) {
  14496. delete queue[id];
  14497. };
  14498. // Node.js 0.8-
  14499. if (IS_NODE) {
  14500. defer = function (id) {
  14501. process.nextTick(runner(id));
  14502. };
  14503. // Sphere (JS game engine) Dispatch API
  14504. } else if (Dispatch && Dispatch.now) {
  14505. defer = function (id) {
  14506. Dispatch.now(runner(id));
  14507. };
  14508. // Browsers with MessageChannel, includes WebWorkers
  14509. // except iOS - https://github.com/zloirock/core-js/issues/624
  14510. } else if (MessageChannel && !IS_IOS) {
  14511. channel = new MessageChannel();
  14512. port = channel.port2;
  14513. channel.port1.onmessage = listener;
  14514. defer = bind(port.postMessage, port, 1);
  14515. // Browsers with postMessage, skip WebWorkers
  14516. // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
  14517. } else if (
  14518. global.addEventListener &&
  14519. typeof postMessage == 'function' &&
  14520. !global.importScripts &&
  14521. location && location.protocol !== 'file:' &&
  14522. !fails(post)
  14523. ) {
  14524. defer = post;
  14525. global.addEventListener('message', listener, false);
  14526. // IE8-
  14527. } else if (ONREADYSTATECHANGE in createElement('script')) {
  14528. defer = function (id) {
  14529. html.appendChild(createElement('script'))[ONREADYSTATECHANGE] = function () {
  14530. html.removeChild(this);
  14531. run(id);
  14532. };
  14533. };
  14534. // Rest old browsers
  14535. } else {
  14536. defer = function (id) {
  14537. setTimeout(runner(id), 0);
  14538. };
  14539. }
  14540. }
  14541. module.exports = {
  14542. set: set,
  14543. clear: clear
  14544. };
  14545. },{"../internals/document-create-element":137,"../internals/engine-is-ios":139,"../internals/engine-is-node":140,"../internals/fails":145,"../internals/function-bind-context":147,"../internals/global":150,"../internals/html":154}],215:[function(require,module,exports){
  14546. var toInteger = require('../internals/to-integer');
  14547. var max = Math.max;
  14548. var min = Math.min;
  14549. // Helper for a popular repeating case of the spec:
  14550. // Let integer be ? ToInteger(index).
  14551. // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
  14552. module.exports = function (index, length) {
  14553. var integer = toInteger(index);
  14554. return integer < 0 ? max(integer + length, 0) : min(integer, length);
  14555. };
  14556. },{"../internals/to-integer":218}],216:[function(require,module,exports){
  14557. var toInteger = require('../internals/to-integer');
  14558. var toLength = require('../internals/to-length');
  14559. // `ToIndex` abstract operation
  14560. // https://tc39.github.io/ecma262/#sec-toindex
  14561. module.exports = function (it) {
  14562. if (it === undefined) return 0;
  14563. var number = toInteger(it);
  14564. var length = toLength(number);
  14565. if (number !== length) throw RangeError('Wrong length or index');
  14566. return length;
  14567. };
  14568. },{"../internals/to-integer":218,"../internals/to-length":219}],217:[function(require,module,exports){
  14569. // toObject with fallback for non-array-like ES3 strings
  14570. var IndexedObject = require('../internals/indexed-object');
  14571. var requireObjectCoercible = require('../internals/require-object-coercible');
  14572. module.exports = function (it) {
  14573. return IndexedObject(requireObjectCoercible(it));
  14574. };
  14575. },{"../internals/indexed-object":157,"../internals/require-object-coercible":202}],218:[function(require,module,exports){
  14576. var ceil = Math.ceil;
  14577. var floor = Math.floor;
  14578. // `ToInteger` abstract operation
  14579. // https://tc39.github.io/ecma262/#sec-tointeger
  14580. module.exports = function (argument) {
  14581. return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor : ceil)(argument);
  14582. };
  14583. },{}],219:[function(require,module,exports){
  14584. var toInteger = require('../internals/to-integer');
  14585. var min = Math.min;
  14586. // `ToLength` abstract operation
  14587. // https://tc39.github.io/ecma262/#sec-tolength
  14588. module.exports = function (argument) {
  14589. return argument > 0 ? min(toInteger(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
  14590. };
  14591. },{"../internals/to-integer":218}],220:[function(require,module,exports){
  14592. var requireObjectCoercible = require('../internals/require-object-coercible');
  14593. // `ToObject` abstract operation
  14594. // https://tc39.github.io/ecma262/#sec-toobject
  14595. module.exports = function (argument) {
  14596. return Object(requireObjectCoercible(argument));
  14597. };
  14598. },{"../internals/require-object-coercible":202}],221:[function(require,module,exports){
  14599. var toPositiveInteger = require('../internals/to-positive-integer');
  14600. module.exports = function (it, BYTES) {
  14601. var offset = toPositiveInteger(it);
  14602. if (offset % BYTES) throw RangeError('Wrong offset');
  14603. return offset;
  14604. };
  14605. },{"../internals/to-positive-integer":222}],222:[function(require,module,exports){
  14606. var toInteger = require('../internals/to-integer');
  14607. module.exports = function (it) {
  14608. var result = toInteger(it);
  14609. if (result < 0) throw RangeError("The argument can't be less than 0");
  14610. return result;
  14611. };
  14612. },{"../internals/to-integer":218}],223:[function(require,module,exports){
  14613. var isObject = require('../internals/is-object');
  14614. // `ToPrimitive` abstract operation
  14615. // https://tc39.github.io/ecma262/#sec-toprimitive
  14616. // instead of the ES6 spec version, we didn't implement @@toPrimitive case
  14617. // and the second argument - flag - preferred type is a string
  14618. module.exports = function (input, PREFERRED_STRING) {
  14619. if (!isObject(input)) return input;
  14620. var fn, val;
  14621. if (PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;
  14622. if (typeof (fn = input.valueOf) == 'function' && !isObject(val = fn.call(input))) return val;
  14623. if (!PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;
  14624. throw TypeError("Can't convert object to primitive value");
  14625. };
  14626. },{"../internals/is-object":164}],224:[function(require,module,exports){
  14627. var wellKnownSymbol = require('../internals/well-known-symbol');
  14628. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  14629. var test = {};
  14630. test[TO_STRING_TAG] = 'z';
  14631. module.exports = String(test) === '[object z]';
  14632. },{"../internals/well-known-symbol":231}],225:[function(require,module,exports){
  14633. 'use strict';
  14634. var $ = require('../internals/export');
  14635. var global = require('../internals/global');
  14636. var DESCRIPTORS = require('../internals/descriptors');
  14637. var TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS = require('../internals/typed-array-constructors-require-wrappers');
  14638. var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
  14639. var ArrayBufferModule = require('../internals/array-buffer');
  14640. var anInstance = require('../internals/an-instance');
  14641. var createPropertyDescriptor = require('../internals/create-property-descriptor');
  14642. var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
  14643. var toLength = require('../internals/to-length');
  14644. var toIndex = require('../internals/to-index');
  14645. var toOffset = require('../internals/to-offset');
  14646. var toPrimitive = require('../internals/to-primitive');
  14647. var has = require('../internals/has');
  14648. var classof = require('../internals/classof');
  14649. var isObject = require('../internals/is-object');
  14650. var create = require('../internals/object-create');
  14651. var setPrototypeOf = require('../internals/object-set-prototype-of');
  14652. var getOwnPropertyNames = require('../internals/object-get-own-property-names').f;
  14653. var typedArrayFrom = require('../internals/typed-array-from');
  14654. var forEach = require('../internals/array-iteration').forEach;
  14655. var setSpecies = require('../internals/set-species');
  14656. var definePropertyModule = require('../internals/object-define-property');
  14657. var getOwnPropertyDescriptorModule = require('../internals/object-get-own-property-descriptor');
  14658. var InternalStateModule = require('../internals/internal-state');
  14659. var inheritIfRequired = require('../internals/inherit-if-required');
  14660. var getInternalState = InternalStateModule.get;
  14661. var setInternalState = InternalStateModule.set;
  14662. var nativeDefineProperty = definePropertyModule.f;
  14663. var nativeGetOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  14664. var round = Math.round;
  14665. var RangeError = global.RangeError;
  14666. var ArrayBuffer = ArrayBufferModule.ArrayBuffer;
  14667. var DataView = ArrayBufferModule.DataView;
  14668. var NATIVE_ARRAY_BUFFER_VIEWS = ArrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS;
  14669. var TYPED_ARRAY_TAG = ArrayBufferViewCore.TYPED_ARRAY_TAG;
  14670. var TypedArray = ArrayBufferViewCore.TypedArray;
  14671. var TypedArrayPrototype = ArrayBufferViewCore.TypedArrayPrototype;
  14672. var aTypedArrayConstructor = ArrayBufferViewCore.aTypedArrayConstructor;
  14673. var isTypedArray = ArrayBufferViewCore.isTypedArray;
  14674. var BYTES_PER_ELEMENT = 'BYTES_PER_ELEMENT';
  14675. var WRONG_LENGTH = 'Wrong length';
  14676. var fromList = function (C, list) {
  14677. var index = 0;
  14678. var length = list.length;
  14679. var result = new (aTypedArrayConstructor(C))(length);
  14680. while (length > index) result[index] = list[index++];
  14681. return result;
  14682. };
  14683. var addGetter = function (it, key) {
  14684. nativeDefineProperty(it, key, { get: function () {
  14685. return getInternalState(this)[key];
  14686. } });
  14687. };
  14688. var isArrayBuffer = function (it) {
  14689. var klass;
  14690. return it instanceof ArrayBuffer || (klass = classof(it)) == 'ArrayBuffer' || klass == 'SharedArrayBuffer';
  14691. };
  14692. var isTypedArrayIndex = function (target, key) {
  14693. return isTypedArray(target)
  14694. && typeof key != 'symbol'
  14695. && key in target
  14696. && String(+key) == String(key);
  14697. };
  14698. var wrappedGetOwnPropertyDescriptor = function getOwnPropertyDescriptor(target, key) {
  14699. return isTypedArrayIndex(target, key = toPrimitive(key, true))
  14700. ? createPropertyDescriptor(2, target[key])
  14701. : nativeGetOwnPropertyDescriptor(target, key);
  14702. };
  14703. var wrappedDefineProperty = function defineProperty(target, key, descriptor) {
  14704. if (isTypedArrayIndex(target, key = toPrimitive(key, true))
  14705. && isObject(descriptor)
  14706. && has(descriptor, 'value')
  14707. && !has(descriptor, 'get')
  14708. && !has(descriptor, 'set')
  14709. // TODO: add validation descriptor w/o calling accessors
  14710. && !descriptor.configurable
  14711. && (!has(descriptor, 'writable') || descriptor.writable)
  14712. && (!has(descriptor, 'enumerable') || descriptor.enumerable)
  14713. ) {
  14714. target[key] = descriptor.value;
  14715. return target;
  14716. } return nativeDefineProperty(target, key, descriptor);
  14717. };
  14718. if (DESCRIPTORS) {
  14719. if (!NATIVE_ARRAY_BUFFER_VIEWS) {
  14720. getOwnPropertyDescriptorModule.f = wrappedGetOwnPropertyDescriptor;
  14721. definePropertyModule.f = wrappedDefineProperty;
  14722. addGetter(TypedArrayPrototype, 'buffer');
  14723. addGetter(TypedArrayPrototype, 'byteOffset');
  14724. addGetter(TypedArrayPrototype, 'byteLength');
  14725. addGetter(TypedArrayPrototype, 'length');
  14726. }
  14727. $({ target: 'Object', stat: true, forced: !NATIVE_ARRAY_BUFFER_VIEWS }, {
  14728. getOwnPropertyDescriptor: wrappedGetOwnPropertyDescriptor,
  14729. defineProperty: wrappedDefineProperty
  14730. });
  14731. module.exports = function (TYPE, wrapper, CLAMPED) {
  14732. var BYTES = TYPE.match(/\d+$/)[0] / 8;
  14733. var CONSTRUCTOR_NAME = TYPE + (CLAMPED ? 'Clamped' : '') + 'Array';
  14734. var GETTER = 'get' + TYPE;
  14735. var SETTER = 'set' + TYPE;
  14736. var NativeTypedArrayConstructor = global[CONSTRUCTOR_NAME];
  14737. var TypedArrayConstructor = NativeTypedArrayConstructor;
  14738. var TypedArrayConstructorPrototype = TypedArrayConstructor && TypedArrayConstructor.prototype;
  14739. var exported = {};
  14740. var getter = function (that, index) {
  14741. var data = getInternalState(that);
  14742. return data.view[GETTER](index * BYTES + data.byteOffset, true);
  14743. };
  14744. var setter = function (that, index, value) {
  14745. var data = getInternalState(that);
  14746. if (CLAMPED) value = (value = round(value)) < 0 ? 0 : value > 0xFF ? 0xFF : value & 0xFF;
  14747. data.view[SETTER](index * BYTES + data.byteOffset, value, true);
  14748. };
  14749. var addElement = function (that, index) {
  14750. nativeDefineProperty(that, index, {
  14751. get: function () {
  14752. return getter(this, index);
  14753. },
  14754. set: function (value) {
  14755. return setter(this, index, value);
  14756. },
  14757. enumerable: true
  14758. });
  14759. };
  14760. if (!NATIVE_ARRAY_BUFFER_VIEWS) {
  14761. TypedArrayConstructor = wrapper(function (that, data, offset, $length) {
  14762. anInstance(that, TypedArrayConstructor, CONSTRUCTOR_NAME);
  14763. var index = 0;
  14764. var byteOffset = 0;
  14765. var buffer, byteLength, length;
  14766. if (!isObject(data)) {
  14767. length = toIndex(data);
  14768. byteLength = length * BYTES;
  14769. buffer = new ArrayBuffer(byteLength);
  14770. } else if (isArrayBuffer(data)) {
  14771. buffer = data;
  14772. byteOffset = toOffset(offset, BYTES);
  14773. var $len = data.byteLength;
  14774. if ($length === undefined) {
  14775. if ($len % BYTES) throw RangeError(WRONG_LENGTH);
  14776. byteLength = $len - byteOffset;
  14777. if (byteLength < 0) throw RangeError(WRONG_LENGTH);
  14778. } else {
  14779. byteLength = toLength($length) * BYTES;
  14780. if (byteLength + byteOffset > $len) throw RangeError(WRONG_LENGTH);
  14781. }
  14782. length = byteLength / BYTES;
  14783. } else if (isTypedArray(data)) {
  14784. return fromList(TypedArrayConstructor, data);
  14785. } else {
  14786. return typedArrayFrom.call(TypedArrayConstructor, data);
  14787. }
  14788. setInternalState(that, {
  14789. buffer: buffer,
  14790. byteOffset: byteOffset,
  14791. byteLength: byteLength,
  14792. length: length,
  14793. view: new DataView(buffer)
  14794. });
  14795. while (index < length) addElement(that, index++);
  14796. });
  14797. if (setPrototypeOf) setPrototypeOf(TypedArrayConstructor, TypedArray);
  14798. TypedArrayConstructorPrototype = TypedArrayConstructor.prototype = create(TypedArrayPrototype);
  14799. } else if (TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS) {
  14800. TypedArrayConstructor = wrapper(function (dummy, data, typedArrayOffset, $length) {
  14801. anInstance(dummy, TypedArrayConstructor, CONSTRUCTOR_NAME);
  14802. return inheritIfRequired(function () {
  14803. if (!isObject(data)) return new NativeTypedArrayConstructor(toIndex(data));
  14804. if (isArrayBuffer(data)) return $length !== undefined
  14805. ? new NativeTypedArrayConstructor(data, toOffset(typedArrayOffset, BYTES), $length)
  14806. : typedArrayOffset !== undefined
  14807. ? new NativeTypedArrayConstructor(data, toOffset(typedArrayOffset, BYTES))
  14808. : new NativeTypedArrayConstructor(data);
  14809. if (isTypedArray(data)) return fromList(TypedArrayConstructor, data);
  14810. return typedArrayFrom.call(TypedArrayConstructor, data);
  14811. }(), dummy, TypedArrayConstructor);
  14812. });
  14813. if (setPrototypeOf) setPrototypeOf(TypedArrayConstructor, TypedArray);
  14814. forEach(getOwnPropertyNames(NativeTypedArrayConstructor), function (key) {
  14815. if (!(key in TypedArrayConstructor)) {
  14816. createNonEnumerableProperty(TypedArrayConstructor, key, NativeTypedArrayConstructor[key]);
  14817. }
  14818. });
  14819. TypedArrayConstructor.prototype = TypedArrayConstructorPrototype;
  14820. }
  14821. if (TypedArrayConstructorPrototype.constructor !== TypedArrayConstructor) {
  14822. createNonEnumerableProperty(TypedArrayConstructorPrototype, 'constructor', TypedArrayConstructor);
  14823. }
  14824. if (TYPED_ARRAY_TAG) {
  14825. createNonEnumerableProperty(TypedArrayConstructorPrototype, TYPED_ARRAY_TAG, CONSTRUCTOR_NAME);
  14826. }
  14827. exported[CONSTRUCTOR_NAME] = TypedArrayConstructor;
  14828. $({
  14829. global: true, forced: TypedArrayConstructor != NativeTypedArrayConstructor, sham: !NATIVE_ARRAY_BUFFER_VIEWS
  14830. }, exported);
  14831. if (!(BYTES_PER_ELEMENT in TypedArrayConstructor)) {
  14832. createNonEnumerableProperty(TypedArrayConstructor, BYTES_PER_ELEMENT, BYTES);
  14833. }
  14834. if (!(BYTES_PER_ELEMENT in TypedArrayConstructorPrototype)) {
  14835. createNonEnumerableProperty(TypedArrayConstructorPrototype, BYTES_PER_ELEMENT, BYTES);
  14836. }
  14837. setSpecies(CONSTRUCTOR_NAME);
  14838. };
  14839. } else module.exports = function () { /* empty */ };
  14840. },{"../internals/an-instance":106,"../internals/array-buffer":110,"../internals/array-buffer-view-core":109,"../internals/array-iteration":116,"../internals/classof":126,"../internals/create-non-enumerable-property":131,"../internals/create-property-descriptor":132,"../internals/descriptors":136,"../internals/export":144,"../internals/global":150,"../internals/has":151,"../internals/inherit-if-required":158,"../internals/internal-state":160,"../internals/is-object":164,"../internals/object-create":178,"../internals/object-define-property":180,"../internals/object-get-own-property-descriptor":181,"../internals/object-get-own-property-names":183,"../internals/object-set-prototype-of":189,"../internals/set-species":205,"../internals/to-index":216,"../internals/to-length":219,"../internals/to-offset":221,"../internals/to-primitive":223,"../internals/typed-array-constructors-require-wrappers":226,"../internals/typed-array-from":227}],226:[function(require,module,exports){
  14841. /* eslint-disable no-new */
  14842. var global = require('../internals/global');
  14843. var fails = require('../internals/fails');
  14844. var checkCorrectnessOfIteration = require('../internals/check-correctness-of-iteration');
  14845. var NATIVE_ARRAY_BUFFER_VIEWS = require('../internals/array-buffer-view-core').NATIVE_ARRAY_BUFFER_VIEWS;
  14846. var ArrayBuffer = global.ArrayBuffer;
  14847. var Int8Array = global.Int8Array;
  14848. module.exports = !NATIVE_ARRAY_BUFFER_VIEWS || !fails(function () {
  14849. Int8Array(1);
  14850. }) || !fails(function () {
  14851. new Int8Array(-1);
  14852. }) || !checkCorrectnessOfIteration(function (iterable) {
  14853. new Int8Array();
  14854. new Int8Array(null);
  14855. new Int8Array(1.5);
  14856. new Int8Array(iterable);
  14857. }, true) || fails(function () {
  14858. // Safari (11+) bug - a reason why even Safari 13 should load a typed array polyfill
  14859. return new Int8Array(new ArrayBuffer(2), 1, undefined).length !== 1;
  14860. });
  14861. },{"../internals/array-buffer-view-core":109,"../internals/check-correctness-of-iteration":124,"../internals/fails":145,"../internals/global":150}],227:[function(require,module,exports){
  14862. var toObject = require('../internals/to-object');
  14863. var toLength = require('../internals/to-length');
  14864. var getIteratorMethod = require('../internals/get-iterator-method');
  14865. var isArrayIteratorMethod = require('../internals/is-array-iterator-method');
  14866. var bind = require('../internals/function-bind-context');
  14867. var aTypedArrayConstructor = require('../internals/array-buffer-view-core').aTypedArrayConstructor;
  14868. module.exports = function from(source /* , mapfn, thisArg */) {
  14869. var O = toObject(source);
  14870. var argumentsLength = arguments.length;
  14871. var mapfn = argumentsLength > 1 ? arguments[1] : undefined;
  14872. var mapping = mapfn !== undefined;
  14873. var iteratorMethod = getIteratorMethod(O);
  14874. var i, length, result, step, iterator, next;
  14875. if (iteratorMethod != undefined && !isArrayIteratorMethod(iteratorMethod)) {
  14876. iterator = iteratorMethod.call(O);
  14877. next = iterator.next;
  14878. O = [];
  14879. while (!(step = next.call(iterator)).done) {
  14880. O.push(step.value);
  14881. }
  14882. }
  14883. if (mapping && argumentsLength > 2) {
  14884. mapfn = bind(mapfn, arguments[2], 2);
  14885. }
  14886. length = toLength(O.length);
  14887. result = new (aTypedArrayConstructor(this))(length);
  14888. for (i = 0; length > i; i++) {
  14889. result[i] = mapping ? mapfn(O[i], i) : O[i];
  14890. }
  14891. return result;
  14892. };
  14893. },{"../internals/array-buffer-view-core":109,"../internals/function-bind-context":147,"../internals/get-iterator-method":149,"../internals/is-array-iterator-method":161,"../internals/to-length":219,"../internals/to-object":220}],228:[function(require,module,exports){
  14894. var id = 0;
  14895. var postfix = Math.random();
  14896. module.exports = function (key) {
  14897. return 'Symbol(' + String(key === undefined ? '' : key) + ')_' + (++id + postfix).toString(36);
  14898. };
  14899. },{}],229:[function(require,module,exports){
  14900. var NATIVE_SYMBOL = require('../internals/native-symbol');
  14901. module.exports = NATIVE_SYMBOL
  14902. // eslint-disable-next-line no-undef
  14903. && !Symbol.sham
  14904. // eslint-disable-next-line no-undef
  14905. && typeof Symbol.iterator == 'symbol';
  14906. },{"../internals/native-symbol":173}],230:[function(require,module,exports){
  14907. var wellKnownSymbol = require('../internals/well-known-symbol');
  14908. exports.f = wellKnownSymbol;
  14909. },{"../internals/well-known-symbol":231}],231:[function(require,module,exports){
  14910. var global = require('../internals/global');
  14911. var shared = require('../internals/shared');
  14912. var has = require('../internals/has');
  14913. var uid = require('../internals/uid');
  14914. var NATIVE_SYMBOL = require('../internals/native-symbol');
  14915. var USE_SYMBOL_AS_UID = require('../internals/use-symbol-as-uid');
  14916. var WellKnownSymbolsStore = shared('wks');
  14917. var Symbol = global.Symbol;
  14918. var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol : Symbol && Symbol.withoutSetter || uid;
  14919. module.exports = function (name) {
  14920. if (!has(WellKnownSymbolsStore, name)) {
  14921. if (NATIVE_SYMBOL && has(Symbol, name)) WellKnownSymbolsStore[name] = Symbol[name];
  14922. else WellKnownSymbolsStore[name] = createWellKnownSymbol('Symbol.' + name);
  14923. } return WellKnownSymbolsStore[name];
  14924. };
  14925. },{"../internals/global":150,"../internals/has":151,"../internals/native-symbol":173,"../internals/shared":209,"../internals/uid":228,"../internals/use-symbol-as-uid":229}],232:[function(require,module,exports){
  14926. // a string of all valid unicode whitespaces
  14927. // eslint-disable-next-line max-len
  14928. module.exports = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
  14929. },{}],233:[function(require,module,exports){
  14930. 'use strict';
  14931. var $ = require('../internals/export');
  14932. var fails = require('../internals/fails');
  14933. var ArrayBufferModule = require('../internals/array-buffer');
  14934. var anObject = require('../internals/an-object');
  14935. var toAbsoluteIndex = require('../internals/to-absolute-index');
  14936. var toLength = require('../internals/to-length');
  14937. var speciesConstructor = require('../internals/species-constructor');
  14938. var ArrayBuffer = ArrayBufferModule.ArrayBuffer;
  14939. var DataView = ArrayBufferModule.DataView;
  14940. var nativeArrayBufferSlice = ArrayBuffer.prototype.slice;
  14941. var INCORRECT_SLICE = fails(function () {
  14942. return !new ArrayBuffer(2).slice(1, undefined).byteLength;
  14943. });
  14944. // `ArrayBuffer.prototype.slice` method
  14945. // https://tc39.github.io/ecma262/#sec-arraybuffer.prototype.slice
  14946. $({ target: 'ArrayBuffer', proto: true, unsafe: true, forced: INCORRECT_SLICE }, {
  14947. slice: function slice(start, end) {
  14948. if (nativeArrayBufferSlice !== undefined && end === undefined) {
  14949. return nativeArrayBufferSlice.call(anObject(this), start); // FF fix
  14950. }
  14951. var length = anObject(this).byteLength;
  14952. var first = toAbsoluteIndex(start, length);
  14953. var fin = toAbsoluteIndex(end === undefined ? length : end, length);
  14954. var result = new (speciesConstructor(this, ArrayBuffer))(toLength(fin - first));
  14955. var viewSource = new DataView(this);
  14956. var viewTarget = new DataView(result);
  14957. var index = 0;
  14958. while (first < fin) {
  14959. viewTarget.setUint8(index++, viewSource.getUint8(first++));
  14960. } return result;
  14961. }
  14962. });
  14963. },{"../internals/an-object":107,"../internals/array-buffer":110,"../internals/export":144,"../internals/fails":145,"../internals/species-constructor":210,"../internals/to-absolute-index":215,"../internals/to-length":219}],234:[function(require,module,exports){
  14964. 'use strict';
  14965. var $ = require('../internals/export');
  14966. var fails = require('../internals/fails');
  14967. var isArray = require('../internals/is-array');
  14968. var isObject = require('../internals/is-object');
  14969. var toObject = require('../internals/to-object');
  14970. var toLength = require('../internals/to-length');
  14971. var createProperty = require('../internals/create-property');
  14972. var arraySpeciesCreate = require('../internals/array-species-create');
  14973. var arrayMethodHasSpeciesSupport = require('../internals/array-method-has-species-support');
  14974. var wellKnownSymbol = require('../internals/well-known-symbol');
  14975. var V8_VERSION = require('../internals/engine-v8-version');
  14976. var IS_CONCAT_SPREADABLE = wellKnownSymbol('isConcatSpreadable');
  14977. var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF;
  14978. var MAXIMUM_ALLOWED_INDEX_EXCEEDED = 'Maximum allowed index exceeded';
  14979. // We can't use this feature detection in V8 since it causes
  14980. // deoptimization and serious performance degradation
  14981. // https://github.com/zloirock/core-js/issues/679
  14982. var IS_CONCAT_SPREADABLE_SUPPORT = V8_VERSION >= 51 || !fails(function () {
  14983. var array = [];
  14984. array[IS_CONCAT_SPREADABLE] = false;
  14985. return array.concat()[0] !== array;
  14986. });
  14987. var SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('concat');
  14988. var isConcatSpreadable = function (O) {
  14989. if (!isObject(O)) return false;
  14990. var spreadable = O[IS_CONCAT_SPREADABLE];
  14991. return spreadable !== undefined ? !!spreadable : isArray(O);
  14992. };
  14993. var FORCED = !IS_CONCAT_SPREADABLE_SUPPORT || !SPECIES_SUPPORT;
  14994. // `Array.prototype.concat` method
  14995. // https://tc39.github.io/ecma262/#sec-array.prototype.concat
  14996. // with adding support of @@isConcatSpreadable and @@species
  14997. $({ target: 'Array', proto: true, forced: FORCED }, {
  14998. concat: function concat(arg) { // eslint-disable-line no-unused-vars
  14999. var O = toObject(this);
  15000. var A = arraySpeciesCreate(O, 0);
  15001. var n = 0;
  15002. var i, k, length, len, E;
  15003. for (i = -1, length = arguments.length; i < length; i++) {
  15004. E = i === -1 ? O : arguments[i];
  15005. if (isConcatSpreadable(E)) {
  15006. len = toLength(E.length);
  15007. if (n + len > MAX_SAFE_INTEGER) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);
  15008. for (k = 0; k < len; k++, n++) if (k in E) createProperty(A, n, E[k]);
  15009. } else {
  15010. if (n >= MAX_SAFE_INTEGER) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);
  15011. createProperty(A, n++, E);
  15012. }
  15013. }
  15014. A.length = n;
  15015. return A;
  15016. }
  15017. });
  15018. },{"../internals/array-method-has-species-support":118,"../internals/array-species-create":122,"../internals/create-property":133,"../internals/engine-v8-version":142,"../internals/export":144,"../internals/fails":145,"../internals/is-array":162,"../internals/is-object":164,"../internals/to-length":219,"../internals/to-object":220,"../internals/well-known-symbol":231}],235:[function(require,module,exports){
  15019. var $ = require('../internals/export');
  15020. var fill = require('../internals/array-fill');
  15021. var addToUnscopables = require('../internals/add-to-unscopables');
  15022. // `Array.prototype.fill` method
  15023. // https://tc39.github.io/ecma262/#sec-array.prototype.fill
  15024. $({ target: 'Array', proto: true }, {
  15025. fill: fill
  15026. });
  15027. // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
  15028. addToUnscopables('fill');
  15029. },{"../internals/add-to-unscopables":104,"../internals/array-fill":112,"../internals/export":144}],236:[function(require,module,exports){
  15030. 'use strict';
  15031. var $ = require('../internals/export');
  15032. var $filter = require('../internals/array-iteration').filter;
  15033. var arrayMethodHasSpeciesSupport = require('../internals/array-method-has-species-support');
  15034. var arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');
  15035. var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('filter');
  15036. // Edge 14- issue
  15037. var USES_TO_LENGTH = arrayMethodUsesToLength('filter');
  15038. // `Array.prototype.filter` method
  15039. // https://tc39.github.io/ecma262/#sec-array.prototype.filter
  15040. // with adding support of @@species
  15041. $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT || !USES_TO_LENGTH }, {
  15042. filter: function filter(callbackfn /* , thisArg */) {
  15043. return $filter(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  15044. }
  15045. });
  15046. },{"../internals/array-iteration":116,"../internals/array-method-has-species-support":118,"../internals/array-method-uses-to-length":120,"../internals/export":144}],237:[function(require,module,exports){
  15047. 'use strict';
  15048. var $ = require('../internals/export');
  15049. var $find = require('../internals/array-iteration').find;
  15050. var addToUnscopables = require('../internals/add-to-unscopables');
  15051. var arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');
  15052. var FIND = 'find';
  15053. var SKIPS_HOLES = true;
  15054. var USES_TO_LENGTH = arrayMethodUsesToLength(FIND);
  15055. // Shouldn't skip holes
  15056. if (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; });
  15057. // `Array.prototype.find` method
  15058. // https://tc39.github.io/ecma262/#sec-array.prototype.find
  15059. $({ target: 'Array', proto: true, forced: SKIPS_HOLES || !USES_TO_LENGTH }, {
  15060. find: function find(callbackfn /* , that = undefined */) {
  15061. return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  15062. }
  15063. });
  15064. // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
  15065. addToUnscopables(FIND);
  15066. },{"../internals/add-to-unscopables":104,"../internals/array-iteration":116,"../internals/array-method-uses-to-length":120,"../internals/export":144}],238:[function(require,module,exports){
  15067. 'use strict';
  15068. var $ = require('../internals/export');
  15069. var forEach = require('../internals/array-for-each');
  15070. // `Array.prototype.forEach` method
  15071. // https://tc39.github.io/ecma262/#sec-array.prototype.foreach
  15072. $({ target: 'Array', proto: true, forced: [].forEach != forEach }, {
  15073. forEach: forEach
  15074. });
  15075. },{"../internals/array-for-each":113,"../internals/export":144}],239:[function(require,module,exports){
  15076. var $ = require('../internals/export');
  15077. var from = require('../internals/array-from');
  15078. var checkCorrectnessOfIteration = require('../internals/check-correctness-of-iteration');
  15079. var INCORRECT_ITERATION = !checkCorrectnessOfIteration(function (iterable) {
  15080. Array.from(iterable);
  15081. });
  15082. // `Array.from` method
  15083. // https://tc39.github.io/ecma262/#sec-array.from
  15084. $({ target: 'Array', stat: true, forced: INCORRECT_ITERATION }, {
  15085. from: from
  15086. });
  15087. },{"../internals/array-from":114,"../internals/check-correctness-of-iteration":124,"../internals/export":144}],240:[function(require,module,exports){
  15088. 'use strict';
  15089. var $ = require('../internals/export');
  15090. var $includes = require('../internals/array-includes').includes;
  15091. var addToUnscopables = require('../internals/add-to-unscopables');
  15092. var arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');
  15093. var USES_TO_LENGTH = arrayMethodUsesToLength('indexOf', { ACCESSORS: true, 1: 0 });
  15094. // `Array.prototype.includes` method
  15095. // https://tc39.github.io/ecma262/#sec-array.prototype.includes
  15096. $({ target: 'Array', proto: true, forced: !USES_TO_LENGTH }, {
  15097. includes: function includes(el /* , fromIndex = 0 */) {
  15098. return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
  15099. }
  15100. });
  15101. // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
  15102. addToUnscopables('includes');
  15103. },{"../internals/add-to-unscopables":104,"../internals/array-includes":115,"../internals/array-method-uses-to-length":120,"../internals/export":144}],241:[function(require,module,exports){
  15104. 'use strict';
  15105. var $ = require('../internals/export');
  15106. var $indexOf = require('../internals/array-includes').indexOf;
  15107. var arrayMethodIsStrict = require('../internals/array-method-is-strict');
  15108. var arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');
  15109. var nativeIndexOf = [].indexOf;
  15110. var NEGATIVE_ZERO = !!nativeIndexOf && 1 / [1].indexOf(1, -0) < 0;
  15111. var STRICT_METHOD = arrayMethodIsStrict('indexOf');
  15112. var USES_TO_LENGTH = arrayMethodUsesToLength('indexOf', { ACCESSORS: true, 1: 0 });
  15113. // `Array.prototype.indexOf` method
  15114. // https://tc39.github.io/ecma262/#sec-array.prototype.indexof
  15115. $({ target: 'Array', proto: true, forced: NEGATIVE_ZERO || !STRICT_METHOD || !USES_TO_LENGTH }, {
  15116. indexOf: function indexOf(searchElement /* , fromIndex = 0 */) {
  15117. return NEGATIVE_ZERO
  15118. // convert -0 to +0
  15119. ? nativeIndexOf.apply(this, arguments) || 0
  15120. : $indexOf(this, searchElement, arguments.length > 1 ? arguments[1] : undefined);
  15121. }
  15122. });
  15123. },{"../internals/array-includes":115,"../internals/array-method-is-strict":119,"../internals/array-method-uses-to-length":120,"../internals/export":144}],242:[function(require,module,exports){
  15124. 'use strict';
  15125. var toIndexedObject = require('../internals/to-indexed-object');
  15126. var addToUnscopables = require('../internals/add-to-unscopables');
  15127. var Iterators = require('../internals/iterators');
  15128. var InternalStateModule = require('../internals/internal-state');
  15129. var defineIterator = require('../internals/define-iterator');
  15130. var ARRAY_ITERATOR = 'Array Iterator';
  15131. var setInternalState = InternalStateModule.set;
  15132. var getInternalState = InternalStateModule.getterFor(ARRAY_ITERATOR);
  15133. // `Array.prototype.entries` method
  15134. // https://tc39.github.io/ecma262/#sec-array.prototype.entries
  15135. // `Array.prototype.keys` method
  15136. // https://tc39.github.io/ecma262/#sec-array.prototype.keys
  15137. // `Array.prototype.values` method
  15138. // https://tc39.github.io/ecma262/#sec-array.prototype.values
  15139. // `Array.prototype[@@iterator]` method
  15140. // https://tc39.github.io/ecma262/#sec-array.prototype-@@iterator
  15141. // `CreateArrayIterator` internal method
  15142. // https://tc39.github.io/ecma262/#sec-createarrayiterator
  15143. module.exports = defineIterator(Array, 'Array', function (iterated, kind) {
  15144. setInternalState(this, {
  15145. type: ARRAY_ITERATOR,
  15146. target: toIndexedObject(iterated), // target
  15147. index: 0, // next index
  15148. kind: kind // kind
  15149. });
  15150. // `%ArrayIteratorPrototype%.next` method
  15151. // https://tc39.github.io/ecma262/#sec-%arrayiteratorprototype%.next
  15152. }, function () {
  15153. var state = getInternalState(this);
  15154. var target = state.target;
  15155. var kind = state.kind;
  15156. var index = state.index++;
  15157. if (!target || index >= target.length) {
  15158. state.target = undefined;
  15159. return { value: undefined, done: true };
  15160. }
  15161. if (kind == 'keys') return { value: index, done: false };
  15162. if (kind == 'values') return { value: target[index], done: false };
  15163. return { value: [index, target[index]], done: false };
  15164. }, 'values');
  15165. // argumentsList[@@iterator] is %ArrayProto_values%
  15166. // https://tc39.github.io/ecma262/#sec-createunmappedargumentsobject
  15167. // https://tc39.github.io/ecma262/#sec-createmappedargumentsobject
  15168. Iterators.Arguments = Iterators.Array;
  15169. // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
  15170. addToUnscopables('keys');
  15171. addToUnscopables('values');
  15172. addToUnscopables('entries');
  15173. },{"../internals/add-to-unscopables":104,"../internals/define-iterator":134,"../internals/internal-state":160,"../internals/iterators":170,"../internals/to-indexed-object":217}],243:[function(require,module,exports){
  15174. 'use strict';
  15175. var $ = require('../internals/export');
  15176. var IndexedObject = require('../internals/indexed-object');
  15177. var toIndexedObject = require('../internals/to-indexed-object');
  15178. var arrayMethodIsStrict = require('../internals/array-method-is-strict');
  15179. var nativeJoin = [].join;
  15180. var ES3_STRINGS = IndexedObject != Object;
  15181. var STRICT_METHOD = arrayMethodIsStrict('join', ',');
  15182. // `Array.prototype.join` method
  15183. // https://tc39.github.io/ecma262/#sec-array.prototype.join
  15184. $({ target: 'Array', proto: true, forced: ES3_STRINGS || !STRICT_METHOD }, {
  15185. join: function join(separator) {
  15186. return nativeJoin.call(toIndexedObject(this), separator === undefined ? ',' : separator);
  15187. }
  15188. });
  15189. },{"../internals/array-method-is-strict":119,"../internals/export":144,"../internals/indexed-object":157,"../internals/to-indexed-object":217}],244:[function(require,module,exports){
  15190. var $ = require('../internals/export');
  15191. var lastIndexOf = require('../internals/array-last-index-of');
  15192. // `Array.prototype.lastIndexOf` method
  15193. // https://tc39.github.io/ecma262/#sec-array.prototype.lastindexof
  15194. $({ target: 'Array', proto: true, forced: lastIndexOf !== [].lastIndexOf }, {
  15195. lastIndexOf: lastIndexOf
  15196. });
  15197. },{"../internals/array-last-index-of":117,"../internals/export":144}],245:[function(require,module,exports){
  15198. 'use strict';
  15199. var $ = require('../internals/export');
  15200. var $map = require('../internals/array-iteration').map;
  15201. var arrayMethodHasSpeciesSupport = require('../internals/array-method-has-species-support');
  15202. var arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');
  15203. var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('map');
  15204. // FF49- issue
  15205. var USES_TO_LENGTH = arrayMethodUsesToLength('map');
  15206. // `Array.prototype.map` method
  15207. // https://tc39.github.io/ecma262/#sec-array.prototype.map
  15208. // with adding support of @@species
  15209. $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT || !USES_TO_LENGTH }, {
  15210. map: function map(callbackfn /* , thisArg */) {
  15211. return $map(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  15212. }
  15213. });
  15214. },{"../internals/array-iteration":116,"../internals/array-method-has-species-support":118,"../internals/array-method-uses-to-length":120,"../internals/export":144}],246:[function(require,module,exports){
  15215. 'use strict';
  15216. var $ = require('../internals/export');
  15217. var isObject = require('../internals/is-object');
  15218. var isArray = require('../internals/is-array');
  15219. var toAbsoluteIndex = require('../internals/to-absolute-index');
  15220. var toLength = require('../internals/to-length');
  15221. var toIndexedObject = require('../internals/to-indexed-object');
  15222. var createProperty = require('../internals/create-property');
  15223. var wellKnownSymbol = require('../internals/well-known-symbol');
  15224. var arrayMethodHasSpeciesSupport = require('../internals/array-method-has-species-support');
  15225. var arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');
  15226. var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('slice');
  15227. var USES_TO_LENGTH = arrayMethodUsesToLength('slice', { ACCESSORS: true, 0: 0, 1: 2 });
  15228. var SPECIES = wellKnownSymbol('species');
  15229. var nativeSlice = [].slice;
  15230. var max = Math.max;
  15231. // `Array.prototype.slice` method
  15232. // https://tc39.github.io/ecma262/#sec-array.prototype.slice
  15233. // fallback for not array-like ES3 strings and DOM objects
  15234. $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT || !USES_TO_LENGTH }, {
  15235. slice: function slice(start, end) {
  15236. var O = toIndexedObject(this);
  15237. var length = toLength(O.length);
  15238. var k = toAbsoluteIndex(start, length);
  15239. var fin = toAbsoluteIndex(end === undefined ? length : end, length);
  15240. // inline `ArraySpeciesCreate` for usage native `Array#slice` where it's possible
  15241. var Constructor, result, n;
  15242. if (isArray(O)) {
  15243. Constructor = O.constructor;
  15244. // cross-realm fallback
  15245. if (typeof Constructor == 'function' && (Constructor === Array || isArray(Constructor.prototype))) {
  15246. Constructor = undefined;
  15247. } else if (isObject(Constructor)) {
  15248. Constructor = Constructor[SPECIES];
  15249. if (Constructor === null) Constructor = undefined;
  15250. }
  15251. if (Constructor === Array || Constructor === undefined) {
  15252. return nativeSlice.call(O, k, fin);
  15253. }
  15254. }
  15255. result = new (Constructor === undefined ? Array : Constructor)(max(fin - k, 0));
  15256. for (n = 0; k < fin; k++, n++) if (k in O) createProperty(result, n, O[k]);
  15257. result.length = n;
  15258. return result;
  15259. }
  15260. });
  15261. },{"../internals/array-method-has-species-support":118,"../internals/array-method-uses-to-length":120,"../internals/create-property":133,"../internals/export":144,"../internals/is-array":162,"../internals/is-object":164,"../internals/to-absolute-index":215,"../internals/to-indexed-object":217,"../internals/to-length":219,"../internals/well-known-symbol":231}],247:[function(require,module,exports){
  15262. 'use strict';
  15263. var $ = require('../internals/export');
  15264. var aFunction = require('../internals/a-function');
  15265. var toObject = require('../internals/to-object');
  15266. var fails = require('../internals/fails');
  15267. var arrayMethodIsStrict = require('../internals/array-method-is-strict');
  15268. var test = [];
  15269. var nativeSort = test.sort;
  15270. // IE8-
  15271. var FAILS_ON_UNDEFINED = fails(function () {
  15272. test.sort(undefined);
  15273. });
  15274. // V8 bug
  15275. var FAILS_ON_NULL = fails(function () {
  15276. test.sort(null);
  15277. });
  15278. // Old WebKit
  15279. var STRICT_METHOD = arrayMethodIsStrict('sort');
  15280. var FORCED = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || !STRICT_METHOD;
  15281. // `Array.prototype.sort` method
  15282. // https://tc39.github.io/ecma262/#sec-array.prototype.sort
  15283. $({ target: 'Array', proto: true, forced: FORCED }, {
  15284. sort: function sort(comparefn) {
  15285. return comparefn === undefined
  15286. ? nativeSort.call(toObject(this))
  15287. : nativeSort.call(toObject(this), aFunction(comparefn));
  15288. }
  15289. });
  15290. },{"../internals/a-function":102,"../internals/array-method-is-strict":119,"../internals/export":144,"../internals/fails":145,"../internals/to-object":220}],248:[function(require,module,exports){
  15291. 'use strict';
  15292. var $ = require('../internals/export');
  15293. var toAbsoluteIndex = require('../internals/to-absolute-index');
  15294. var toInteger = require('../internals/to-integer');
  15295. var toLength = require('../internals/to-length');
  15296. var toObject = require('../internals/to-object');
  15297. var arraySpeciesCreate = require('../internals/array-species-create');
  15298. var createProperty = require('../internals/create-property');
  15299. var arrayMethodHasSpeciesSupport = require('../internals/array-method-has-species-support');
  15300. var arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');
  15301. var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('splice');
  15302. var USES_TO_LENGTH = arrayMethodUsesToLength('splice', { ACCESSORS: true, 0: 0, 1: 2 });
  15303. var max = Math.max;
  15304. var min = Math.min;
  15305. var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF;
  15306. var MAXIMUM_ALLOWED_LENGTH_EXCEEDED = 'Maximum allowed length exceeded';
  15307. // `Array.prototype.splice` method
  15308. // https://tc39.github.io/ecma262/#sec-array.prototype.splice
  15309. // with adding support of @@species
  15310. $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT || !USES_TO_LENGTH }, {
  15311. splice: function splice(start, deleteCount /* , ...items */) {
  15312. var O = toObject(this);
  15313. var len = toLength(O.length);
  15314. var actualStart = toAbsoluteIndex(start, len);
  15315. var argumentsLength = arguments.length;
  15316. var insertCount, actualDeleteCount, A, k, from, to;
  15317. if (argumentsLength === 0) {
  15318. insertCount = actualDeleteCount = 0;
  15319. } else if (argumentsLength === 1) {
  15320. insertCount = 0;
  15321. actualDeleteCount = len - actualStart;
  15322. } else {
  15323. insertCount = argumentsLength - 2;
  15324. actualDeleteCount = min(max(toInteger(deleteCount), 0), len - actualStart);
  15325. }
  15326. if (len + insertCount - actualDeleteCount > MAX_SAFE_INTEGER) {
  15327. throw TypeError(MAXIMUM_ALLOWED_LENGTH_EXCEEDED);
  15328. }
  15329. A = arraySpeciesCreate(O, actualDeleteCount);
  15330. for (k = 0; k < actualDeleteCount; k++) {
  15331. from = actualStart + k;
  15332. if (from in O) createProperty(A, k, O[from]);
  15333. }
  15334. A.length = actualDeleteCount;
  15335. if (insertCount < actualDeleteCount) {
  15336. for (k = actualStart; k < len - actualDeleteCount; k++) {
  15337. from = k + actualDeleteCount;
  15338. to = k + insertCount;
  15339. if (from in O) O[to] = O[from];
  15340. else delete O[to];
  15341. }
  15342. for (k = len; k > len - actualDeleteCount + insertCount; k--) delete O[k - 1];
  15343. } else if (insertCount > actualDeleteCount) {
  15344. for (k = len - actualDeleteCount; k > actualStart; k--) {
  15345. from = k + actualDeleteCount - 1;
  15346. to = k + insertCount - 1;
  15347. if (from in O) O[to] = O[from];
  15348. else delete O[to];
  15349. }
  15350. }
  15351. for (k = 0; k < insertCount; k++) {
  15352. O[k + actualStart] = arguments[k + 2];
  15353. }
  15354. O.length = len - actualDeleteCount + insertCount;
  15355. return A;
  15356. }
  15357. });
  15358. },{"../internals/array-method-has-species-support":118,"../internals/array-method-uses-to-length":120,"../internals/array-species-create":122,"../internals/create-property":133,"../internals/export":144,"../internals/to-absolute-index":215,"../internals/to-integer":218,"../internals/to-length":219,"../internals/to-object":220}],249:[function(require,module,exports){
  15359. var DESCRIPTORS = require('../internals/descriptors');
  15360. var defineProperty = require('../internals/object-define-property').f;
  15361. var FunctionPrototype = Function.prototype;
  15362. var FunctionPrototypeToString = FunctionPrototype.toString;
  15363. var nameRE = /^\s*function ([^ (]*)/;
  15364. var NAME = 'name';
  15365. // Function instances `.name` property
  15366. // https://tc39.github.io/ecma262/#sec-function-instances-name
  15367. if (DESCRIPTORS && !(NAME in FunctionPrototype)) {
  15368. defineProperty(FunctionPrototype, NAME, {
  15369. configurable: true,
  15370. get: function () {
  15371. try {
  15372. return FunctionPrototypeToString.call(this).match(nameRE)[1];
  15373. } catch (error) {
  15374. return '';
  15375. }
  15376. }
  15377. });
  15378. }
  15379. },{"../internals/descriptors":136,"../internals/object-define-property":180}],250:[function(require,module,exports){
  15380. 'use strict';
  15381. var DESCRIPTORS = require('../internals/descriptors');
  15382. var global = require('../internals/global');
  15383. var isForced = require('../internals/is-forced');
  15384. var redefine = require('../internals/redefine');
  15385. var has = require('../internals/has');
  15386. var classof = require('../internals/classof-raw');
  15387. var inheritIfRequired = require('../internals/inherit-if-required');
  15388. var toPrimitive = require('../internals/to-primitive');
  15389. var fails = require('../internals/fails');
  15390. var create = require('../internals/object-create');
  15391. var getOwnPropertyNames = require('../internals/object-get-own-property-names').f;
  15392. var getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;
  15393. var defineProperty = require('../internals/object-define-property').f;
  15394. var trim = require('../internals/string-trim').trim;
  15395. var NUMBER = 'Number';
  15396. var NativeNumber = global[NUMBER];
  15397. var NumberPrototype = NativeNumber.prototype;
  15398. // Opera ~12 has broken Object#toString
  15399. var BROKEN_CLASSOF = classof(create(NumberPrototype)) == NUMBER;
  15400. // `ToNumber` abstract operation
  15401. // https://tc39.github.io/ecma262/#sec-tonumber
  15402. var toNumber = function (argument) {
  15403. var it = toPrimitive(argument, false);
  15404. var first, third, radix, maxCode, digits, length, index, code;
  15405. if (typeof it == 'string' && it.length > 2) {
  15406. it = trim(it);
  15407. first = it.charCodeAt(0);
  15408. if (first === 43 || first === 45) {
  15409. third = it.charCodeAt(2);
  15410. if (third === 88 || third === 120) return NaN; // Number('+0x1') should be NaN, old V8 fix
  15411. } else if (first === 48) {
  15412. switch (it.charCodeAt(1)) {
  15413. case 66: case 98: radix = 2; maxCode = 49; break; // fast equal of /^0b[01]+$/i
  15414. case 79: case 111: radix = 8; maxCode = 55; break; // fast equal of /^0o[0-7]+$/i
  15415. default: return +it;
  15416. }
  15417. digits = it.slice(2);
  15418. length = digits.length;
  15419. for (index = 0; index < length; index++) {
  15420. code = digits.charCodeAt(index);
  15421. // parseInt parses a string to a first unavailable symbol
  15422. // but ToNumber should return NaN if a string contains unavailable symbols
  15423. if (code < 48 || code > maxCode) return NaN;
  15424. } return parseInt(digits, radix);
  15425. }
  15426. } return +it;
  15427. };
  15428. // `Number` constructor
  15429. // https://tc39.github.io/ecma262/#sec-number-constructor
  15430. if (isForced(NUMBER, !NativeNumber(' 0o1') || !NativeNumber('0b1') || NativeNumber('+0x1'))) {
  15431. var NumberWrapper = function Number(value) {
  15432. var it = arguments.length < 1 ? 0 : value;
  15433. var dummy = this;
  15434. return dummy instanceof NumberWrapper
  15435. // check on 1..constructor(foo) case
  15436. && (BROKEN_CLASSOF ? fails(function () { NumberPrototype.valueOf.call(dummy); }) : classof(dummy) != NUMBER)
  15437. ? inheritIfRequired(new NativeNumber(toNumber(it)), dummy, NumberWrapper) : toNumber(it);
  15438. };
  15439. for (var keys = DESCRIPTORS ? getOwnPropertyNames(NativeNumber) : (
  15440. // ES3:
  15441. 'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' +
  15442. // ES2015 (in case, if modules with ES2015 Number statics required before):
  15443. 'EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,' +
  15444. 'MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger'
  15445. ).split(','), j = 0, key; keys.length > j; j++) {
  15446. if (has(NativeNumber, key = keys[j]) && !has(NumberWrapper, key)) {
  15447. defineProperty(NumberWrapper, key, getOwnPropertyDescriptor(NativeNumber, key));
  15448. }
  15449. }
  15450. NumberWrapper.prototype = NumberPrototype;
  15451. NumberPrototype.constructor = NumberWrapper;
  15452. redefine(global, NUMBER, NumberWrapper);
  15453. }
  15454. },{"../internals/classof-raw":125,"../internals/descriptors":136,"../internals/fails":145,"../internals/global":150,"../internals/has":151,"../internals/inherit-if-required":158,"../internals/is-forced":163,"../internals/object-create":178,"../internals/object-define-property":180,"../internals/object-get-own-property-descriptor":181,"../internals/object-get-own-property-names":183,"../internals/redefine":197,"../internals/string-trim":213,"../internals/to-primitive":223}],251:[function(require,module,exports){
  15455. var $ = require('../internals/export');
  15456. var assign = require('../internals/object-assign');
  15457. // `Object.assign` method
  15458. // https://tc39.github.io/ecma262/#sec-object.assign
  15459. $({ target: 'Object', stat: true, forced: Object.assign !== assign }, {
  15460. assign: assign
  15461. });
  15462. },{"../internals/export":144,"../internals/object-assign":177}],252:[function(require,module,exports){
  15463. var $ = require('../internals/export');
  15464. var $entries = require('../internals/object-to-array').entries;
  15465. // `Object.entries` method
  15466. // https://tc39.github.io/ecma262/#sec-object.entries
  15467. $({ target: 'Object', stat: true }, {
  15468. entries: function entries(O) {
  15469. return $entries(O);
  15470. }
  15471. });
  15472. },{"../internals/export":144,"../internals/object-to-array":190}],253:[function(require,module,exports){
  15473. var $ = require('../internals/export');
  15474. var toObject = require('../internals/to-object');
  15475. var nativeKeys = require('../internals/object-keys');
  15476. var fails = require('../internals/fails');
  15477. var FAILS_ON_PRIMITIVES = fails(function () { nativeKeys(1); });
  15478. // `Object.keys` method
  15479. // https://tc39.github.io/ecma262/#sec-object.keys
  15480. $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, {
  15481. keys: function keys(it) {
  15482. return nativeKeys(toObject(it));
  15483. }
  15484. });
  15485. },{"../internals/export":144,"../internals/fails":145,"../internals/object-keys":187,"../internals/to-object":220}],254:[function(require,module,exports){
  15486. var TO_STRING_TAG_SUPPORT = require('../internals/to-string-tag-support');
  15487. var redefine = require('../internals/redefine');
  15488. var toString = require('../internals/object-to-string');
  15489. // `Object.prototype.toString` method
  15490. // https://tc39.github.io/ecma262/#sec-object.prototype.tostring
  15491. if (!TO_STRING_TAG_SUPPORT) {
  15492. redefine(Object.prototype, 'toString', toString, { unsafe: true });
  15493. }
  15494. },{"../internals/object-to-string":191,"../internals/redefine":197,"../internals/to-string-tag-support":224}],255:[function(require,module,exports){
  15495. 'use strict';
  15496. var $ = require('../internals/export');
  15497. var IS_PURE = require('../internals/is-pure');
  15498. var global = require('../internals/global');
  15499. var getBuiltIn = require('../internals/get-built-in');
  15500. var NativePromise = require('../internals/native-promise-constructor');
  15501. var redefine = require('../internals/redefine');
  15502. var redefineAll = require('../internals/redefine-all');
  15503. var setToStringTag = require('../internals/set-to-string-tag');
  15504. var setSpecies = require('../internals/set-species');
  15505. var isObject = require('../internals/is-object');
  15506. var aFunction = require('../internals/a-function');
  15507. var anInstance = require('../internals/an-instance');
  15508. var inspectSource = require('../internals/inspect-source');
  15509. var iterate = require('../internals/iterate');
  15510. var checkCorrectnessOfIteration = require('../internals/check-correctness-of-iteration');
  15511. var speciesConstructor = require('../internals/species-constructor');
  15512. var task = require('../internals/task').set;
  15513. var microtask = require('../internals/microtask');
  15514. var promiseResolve = require('../internals/promise-resolve');
  15515. var hostReportErrors = require('../internals/host-report-errors');
  15516. var newPromiseCapabilityModule = require('../internals/new-promise-capability');
  15517. var perform = require('../internals/perform');
  15518. var InternalStateModule = require('../internals/internal-state');
  15519. var isForced = require('../internals/is-forced');
  15520. var wellKnownSymbol = require('../internals/well-known-symbol');
  15521. var IS_NODE = require('../internals/engine-is-node');
  15522. var V8_VERSION = require('../internals/engine-v8-version');
  15523. var SPECIES = wellKnownSymbol('species');
  15524. var PROMISE = 'Promise';
  15525. var getInternalState = InternalStateModule.get;
  15526. var setInternalState = InternalStateModule.set;
  15527. var getInternalPromiseState = InternalStateModule.getterFor(PROMISE);
  15528. var PromiseConstructor = NativePromise;
  15529. var TypeError = global.TypeError;
  15530. var document = global.document;
  15531. var process = global.process;
  15532. var $fetch = getBuiltIn('fetch');
  15533. var newPromiseCapability = newPromiseCapabilityModule.f;
  15534. var newGenericPromiseCapability = newPromiseCapability;
  15535. var DISPATCH_EVENT = !!(document && document.createEvent && global.dispatchEvent);
  15536. var NATIVE_REJECTION_EVENT = typeof PromiseRejectionEvent == 'function';
  15537. var UNHANDLED_REJECTION = 'unhandledrejection';
  15538. var REJECTION_HANDLED = 'rejectionhandled';
  15539. var PENDING = 0;
  15540. var FULFILLED = 1;
  15541. var REJECTED = 2;
  15542. var HANDLED = 1;
  15543. var UNHANDLED = 2;
  15544. var Internal, OwnPromiseCapability, PromiseWrapper, nativeThen;
  15545. var FORCED = isForced(PROMISE, function () {
  15546. var GLOBAL_CORE_JS_PROMISE = inspectSource(PromiseConstructor) !== String(PromiseConstructor);
  15547. if (!GLOBAL_CORE_JS_PROMISE) {
  15548. // V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
  15549. // https://bugs.chromium.org/p/chromium/issues/detail?id=830565
  15550. // We can't detect it synchronously, so just check versions
  15551. if (V8_VERSION === 66) return true;
  15552. // Unhandled rejections tracking support, NodeJS Promise without it fails @@species test
  15553. if (!IS_NODE && !NATIVE_REJECTION_EVENT) return true;
  15554. }
  15555. // We need Promise#finally in the pure version for preventing prototype pollution
  15556. if (IS_PURE && !PromiseConstructor.prototype['finally']) return true;
  15557. // We can't use @@species feature detection in V8 since it causes
  15558. // deoptimization and performance degradation
  15559. // https://github.com/zloirock/core-js/issues/679
  15560. if (V8_VERSION >= 51 && /native code/.test(PromiseConstructor)) return false;
  15561. // Detect correctness of subclassing with @@species support
  15562. var promise = PromiseConstructor.resolve(1);
  15563. var FakePromise = function (exec) {
  15564. exec(function () { /* empty */ }, function () { /* empty */ });
  15565. };
  15566. var constructor = promise.constructor = {};
  15567. constructor[SPECIES] = FakePromise;
  15568. return !(promise.then(function () { /* empty */ }) instanceof FakePromise);
  15569. });
  15570. var INCORRECT_ITERATION = FORCED || !checkCorrectnessOfIteration(function (iterable) {
  15571. PromiseConstructor.all(iterable)['catch'](function () { /* empty */ });
  15572. });
  15573. // helpers
  15574. var isThenable = function (it) {
  15575. var then;
  15576. return isObject(it) && typeof (then = it.then) == 'function' ? then : false;
  15577. };
  15578. var notify = function (state, isReject) {
  15579. if (state.notified) return;
  15580. state.notified = true;
  15581. var chain = state.reactions;
  15582. microtask(function () {
  15583. var value = state.value;
  15584. var ok = state.state == FULFILLED;
  15585. var index = 0;
  15586. // variable length - can't use forEach
  15587. while (chain.length > index) {
  15588. var reaction = chain[index++];
  15589. var handler = ok ? reaction.ok : reaction.fail;
  15590. var resolve = reaction.resolve;
  15591. var reject = reaction.reject;
  15592. var domain = reaction.domain;
  15593. var result, then, exited;
  15594. try {
  15595. if (handler) {
  15596. if (!ok) {
  15597. if (state.rejection === UNHANDLED) onHandleUnhandled(state);
  15598. state.rejection = HANDLED;
  15599. }
  15600. if (handler === true) result = value;
  15601. else {
  15602. if (domain) domain.enter();
  15603. result = handler(value); // can throw
  15604. if (domain) {
  15605. domain.exit();
  15606. exited = true;
  15607. }
  15608. }
  15609. if (result === reaction.promise) {
  15610. reject(TypeError('Promise-chain cycle'));
  15611. } else if (then = isThenable(result)) {
  15612. then.call(result, resolve, reject);
  15613. } else resolve(result);
  15614. } else reject(value);
  15615. } catch (error) {
  15616. if (domain && !exited) domain.exit();
  15617. reject(error);
  15618. }
  15619. }
  15620. state.reactions = [];
  15621. state.notified = false;
  15622. if (isReject && !state.rejection) onUnhandled(state);
  15623. });
  15624. };
  15625. var dispatchEvent = function (name, promise, reason) {
  15626. var event, handler;
  15627. if (DISPATCH_EVENT) {
  15628. event = document.createEvent('Event');
  15629. event.promise = promise;
  15630. event.reason = reason;
  15631. event.initEvent(name, false, true);
  15632. global.dispatchEvent(event);
  15633. } else event = { promise: promise, reason: reason };
  15634. if (!NATIVE_REJECTION_EVENT && (handler = global['on' + name])) handler(event);
  15635. else if (name === UNHANDLED_REJECTION) hostReportErrors('Unhandled promise rejection', reason);
  15636. };
  15637. var onUnhandled = function (state) {
  15638. task.call(global, function () {
  15639. var promise = state.facade;
  15640. var value = state.value;
  15641. var IS_UNHANDLED = isUnhandled(state);
  15642. var result;
  15643. if (IS_UNHANDLED) {
  15644. result = perform(function () {
  15645. if (IS_NODE) {
  15646. process.emit('unhandledRejection', value, promise);
  15647. } else dispatchEvent(UNHANDLED_REJECTION, promise, value);
  15648. });
  15649. // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
  15650. state.rejection = IS_NODE || isUnhandled(state) ? UNHANDLED : HANDLED;
  15651. if (result.error) throw result.value;
  15652. }
  15653. });
  15654. };
  15655. var isUnhandled = function (state) {
  15656. return state.rejection !== HANDLED && !state.parent;
  15657. };
  15658. var onHandleUnhandled = function (state) {
  15659. task.call(global, function () {
  15660. var promise = state.facade;
  15661. if (IS_NODE) {
  15662. process.emit('rejectionHandled', promise);
  15663. } else dispatchEvent(REJECTION_HANDLED, promise, state.value);
  15664. });
  15665. };
  15666. var bind = function (fn, state, unwrap) {
  15667. return function (value) {
  15668. fn(state, value, unwrap);
  15669. };
  15670. };
  15671. var internalReject = function (state, value, unwrap) {
  15672. if (state.done) return;
  15673. state.done = true;
  15674. if (unwrap) state = unwrap;
  15675. state.value = value;
  15676. state.state = REJECTED;
  15677. notify(state, true);
  15678. };
  15679. var internalResolve = function (state, value, unwrap) {
  15680. if (state.done) return;
  15681. state.done = true;
  15682. if (unwrap) state = unwrap;
  15683. try {
  15684. if (state.facade === value) throw TypeError("Promise can't be resolved itself");
  15685. var then = isThenable(value);
  15686. if (then) {
  15687. microtask(function () {
  15688. var wrapper = { done: false };
  15689. try {
  15690. then.call(value,
  15691. bind(internalResolve, wrapper, state),
  15692. bind(internalReject, wrapper, state)
  15693. );
  15694. } catch (error) {
  15695. internalReject(wrapper, error, state);
  15696. }
  15697. });
  15698. } else {
  15699. state.value = value;
  15700. state.state = FULFILLED;
  15701. notify(state, false);
  15702. }
  15703. } catch (error) {
  15704. internalReject({ done: false }, error, state);
  15705. }
  15706. };
  15707. // constructor polyfill
  15708. if (FORCED) {
  15709. // 25.4.3.1 Promise(executor)
  15710. PromiseConstructor = function Promise(executor) {
  15711. anInstance(this, PromiseConstructor, PROMISE);
  15712. aFunction(executor);
  15713. Internal.call(this);
  15714. var state = getInternalState(this);
  15715. try {
  15716. executor(bind(internalResolve, state), bind(internalReject, state));
  15717. } catch (error) {
  15718. internalReject(state, error);
  15719. }
  15720. };
  15721. // eslint-disable-next-line no-unused-vars
  15722. Internal = function Promise(executor) {
  15723. setInternalState(this, {
  15724. type: PROMISE,
  15725. done: false,
  15726. notified: false,
  15727. parent: false,
  15728. reactions: [],
  15729. rejection: false,
  15730. state: PENDING,
  15731. value: undefined
  15732. });
  15733. };
  15734. Internal.prototype = redefineAll(PromiseConstructor.prototype, {
  15735. // `Promise.prototype.then` method
  15736. // https://tc39.github.io/ecma262/#sec-promise.prototype.then
  15737. then: function then(onFulfilled, onRejected) {
  15738. var state = getInternalPromiseState(this);
  15739. var reaction = newPromiseCapability(speciesConstructor(this, PromiseConstructor));
  15740. reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
  15741. reaction.fail = typeof onRejected == 'function' && onRejected;
  15742. reaction.domain = IS_NODE ? process.domain : undefined;
  15743. state.parent = true;
  15744. state.reactions.push(reaction);
  15745. if (state.state != PENDING) notify(state, false);
  15746. return reaction.promise;
  15747. },
  15748. // `Promise.prototype.catch` method
  15749. // https://tc39.github.io/ecma262/#sec-promise.prototype.catch
  15750. 'catch': function (onRejected) {
  15751. return this.then(undefined, onRejected);
  15752. }
  15753. });
  15754. OwnPromiseCapability = function () {
  15755. var promise = new Internal();
  15756. var state = getInternalState(promise);
  15757. this.promise = promise;
  15758. this.resolve = bind(internalResolve, state);
  15759. this.reject = bind(internalReject, state);
  15760. };
  15761. newPromiseCapabilityModule.f = newPromiseCapability = function (C) {
  15762. return C === PromiseConstructor || C === PromiseWrapper
  15763. ? new OwnPromiseCapability(C)
  15764. : newGenericPromiseCapability(C);
  15765. };
  15766. if (!IS_PURE && typeof NativePromise == 'function') {
  15767. nativeThen = NativePromise.prototype.then;
  15768. // wrap native Promise#then for native async functions
  15769. redefine(NativePromise.prototype, 'then', function then(onFulfilled, onRejected) {
  15770. var that = this;
  15771. return new PromiseConstructor(function (resolve, reject) {
  15772. nativeThen.call(that, resolve, reject);
  15773. }).then(onFulfilled, onRejected);
  15774. // https://github.com/zloirock/core-js/issues/640
  15775. }, { unsafe: true });
  15776. // wrap fetch result
  15777. if (typeof $fetch == 'function') $({ global: true, enumerable: true, forced: true }, {
  15778. // eslint-disable-next-line no-unused-vars
  15779. fetch: function fetch(input /* , init */) {
  15780. return promiseResolve(PromiseConstructor, $fetch.apply(global, arguments));
  15781. }
  15782. });
  15783. }
  15784. }
  15785. $({ global: true, wrap: true, forced: FORCED }, {
  15786. Promise: PromiseConstructor
  15787. });
  15788. setToStringTag(PromiseConstructor, PROMISE, false, true);
  15789. setSpecies(PROMISE);
  15790. PromiseWrapper = getBuiltIn(PROMISE);
  15791. // statics
  15792. $({ target: PROMISE, stat: true, forced: FORCED }, {
  15793. // `Promise.reject` method
  15794. // https://tc39.github.io/ecma262/#sec-promise.reject
  15795. reject: function reject(r) {
  15796. var capability = newPromiseCapability(this);
  15797. capability.reject.call(undefined, r);
  15798. return capability.promise;
  15799. }
  15800. });
  15801. $({ target: PROMISE, stat: true, forced: IS_PURE || FORCED }, {
  15802. // `Promise.resolve` method
  15803. // https://tc39.github.io/ecma262/#sec-promise.resolve
  15804. resolve: function resolve(x) {
  15805. return promiseResolve(IS_PURE && this === PromiseWrapper ? PromiseConstructor : this, x);
  15806. }
  15807. });
  15808. $({ target: PROMISE, stat: true, forced: INCORRECT_ITERATION }, {
  15809. // `Promise.all` method
  15810. // https://tc39.github.io/ecma262/#sec-promise.all
  15811. all: function all(iterable) {
  15812. var C = this;
  15813. var capability = newPromiseCapability(C);
  15814. var resolve = capability.resolve;
  15815. var reject = capability.reject;
  15816. var result = perform(function () {
  15817. var $promiseResolve = aFunction(C.resolve);
  15818. var values = [];
  15819. var counter = 0;
  15820. var remaining = 1;
  15821. iterate(iterable, function (promise) {
  15822. var index = counter++;
  15823. var alreadyCalled = false;
  15824. values.push(undefined);
  15825. remaining++;
  15826. $promiseResolve.call(C, promise).then(function (value) {
  15827. if (alreadyCalled) return;
  15828. alreadyCalled = true;
  15829. values[index] = value;
  15830. --remaining || resolve(values);
  15831. }, reject);
  15832. });
  15833. --remaining || resolve(values);
  15834. });
  15835. if (result.error) reject(result.value);
  15836. return capability.promise;
  15837. },
  15838. // `Promise.race` method
  15839. // https://tc39.github.io/ecma262/#sec-promise.race
  15840. race: function race(iterable) {
  15841. var C = this;
  15842. var capability = newPromiseCapability(C);
  15843. var reject = capability.reject;
  15844. var result = perform(function () {
  15845. var $promiseResolve = aFunction(C.resolve);
  15846. iterate(iterable, function (promise) {
  15847. $promiseResolve.call(C, promise).then(capability.resolve, reject);
  15848. });
  15849. });
  15850. if (result.error) reject(result.value);
  15851. return capability.promise;
  15852. }
  15853. });
  15854. },{"../internals/a-function":102,"../internals/an-instance":106,"../internals/check-correctness-of-iteration":124,"../internals/engine-is-node":140,"../internals/engine-v8-version":142,"../internals/export":144,"../internals/get-built-in":148,"../internals/global":150,"../internals/host-report-errors":153,"../internals/inspect-source":159,"../internals/internal-state":160,"../internals/is-forced":163,"../internals/is-object":164,"../internals/is-pure":165,"../internals/iterate":167,"../internals/microtask":171,"../internals/native-promise-constructor":172,"../internals/new-promise-capability":175,"../internals/perform":194,"../internals/promise-resolve":195,"../internals/redefine":197,"../internals/redefine-all":196,"../internals/set-species":205,"../internals/set-to-string-tag":206,"../internals/species-constructor":210,"../internals/task":214,"../internals/well-known-symbol":231}],256:[function(require,module,exports){
  15855. 'use strict';
  15856. var $ = require('../internals/export');
  15857. var exec = require('../internals/regexp-exec');
  15858. $({ target: 'RegExp', proto: true, forced: /./.exec !== exec }, {
  15859. exec: exec
  15860. });
  15861. },{"../internals/export":144,"../internals/regexp-exec":199}],257:[function(require,module,exports){
  15862. 'use strict';
  15863. var redefine = require('../internals/redefine');
  15864. var anObject = require('../internals/an-object');
  15865. var fails = require('../internals/fails');
  15866. var flags = require('../internals/regexp-flags');
  15867. var TO_STRING = 'toString';
  15868. var RegExpPrototype = RegExp.prototype;
  15869. var nativeToString = RegExpPrototype[TO_STRING];
  15870. var NOT_GENERIC = fails(function () { return nativeToString.call({ source: 'a', flags: 'b' }) != '/a/b'; });
  15871. // FF44- RegExp#toString has a wrong name
  15872. var INCORRECT_NAME = nativeToString.name != TO_STRING;
  15873. // `RegExp.prototype.toString` method
  15874. // https://tc39.github.io/ecma262/#sec-regexp.prototype.tostring
  15875. if (NOT_GENERIC || INCORRECT_NAME) {
  15876. redefine(RegExp.prototype, TO_STRING, function toString() {
  15877. var R = anObject(this);
  15878. var p = String(R.source);
  15879. var rf = R.flags;
  15880. var f = String(rf === undefined && R instanceof RegExp && !('flags' in RegExpPrototype) ? flags.call(R) : rf);
  15881. return '/' + p + '/' + f;
  15882. }, { unsafe: true });
  15883. }
  15884. },{"../internals/an-object":107,"../internals/fails":145,"../internals/redefine":197,"../internals/regexp-flags":200}],258:[function(require,module,exports){
  15885. 'use strict';
  15886. var $ = require('../internals/export');
  15887. var notARegExp = require('../internals/not-a-regexp');
  15888. var requireObjectCoercible = require('../internals/require-object-coercible');
  15889. var correctIsRegExpLogic = require('../internals/correct-is-regexp-logic');
  15890. // `String.prototype.includes` method
  15891. // https://tc39.github.io/ecma262/#sec-string.prototype.includes
  15892. $({ target: 'String', proto: true, forced: !correctIsRegExpLogic('includes') }, {
  15893. includes: function includes(searchString /* , position = 0 */) {
  15894. return !!~String(requireObjectCoercible(this))
  15895. .indexOf(notARegExp(searchString), arguments.length > 1 ? arguments[1] : undefined);
  15896. }
  15897. });
  15898. },{"../internals/correct-is-regexp-logic":128,"../internals/export":144,"../internals/not-a-regexp":176,"../internals/require-object-coercible":202}],259:[function(require,module,exports){
  15899. 'use strict';
  15900. var charAt = require('../internals/string-multibyte').charAt;
  15901. var InternalStateModule = require('../internals/internal-state');
  15902. var defineIterator = require('../internals/define-iterator');
  15903. var STRING_ITERATOR = 'String Iterator';
  15904. var setInternalState = InternalStateModule.set;
  15905. var getInternalState = InternalStateModule.getterFor(STRING_ITERATOR);
  15906. // `String.prototype[@@iterator]` method
  15907. // https://tc39.github.io/ecma262/#sec-string.prototype-@@iterator
  15908. defineIterator(String, 'String', function (iterated) {
  15909. setInternalState(this, {
  15910. type: STRING_ITERATOR,
  15911. string: String(iterated),
  15912. index: 0
  15913. });
  15914. // `%StringIteratorPrototype%.next` method
  15915. // https://tc39.github.io/ecma262/#sec-%stringiteratorprototype%.next
  15916. }, function next() {
  15917. var state = getInternalState(this);
  15918. var string = state.string;
  15919. var index = state.index;
  15920. var point;
  15921. if (index >= string.length) return { value: undefined, done: true };
  15922. point = charAt(string, index);
  15923. state.index += point.length;
  15924. return { value: point, done: false };
  15925. });
  15926. },{"../internals/define-iterator":134,"../internals/internal-state":160,"../internals/string-multibyte":211}],260:[function(require,module,exports){
  15927. 'use strict';
  15928. var fixRegExpWellKnownSymbolLogic = require('../internals/fix-regexp-well-known-symbol-logic');
  15929. var anObject = require('../internals/an-object');
  15930. var toLength = require('../internals/to-length');
  15931. var requireObjectCoercible = require('../internals/require-object-coercible');
  15932. var advanceStringIndex = require('../internals/advance-string-index');
  15933. var regExpExec = require('../internals/regexp-exec-abstract');
  15934. // @@match logic
  15935. fixRegExpWellKnownSymbolLogic('match', 1, function (MATCH, nativeMatch, maybeCallNative) {
  15936. return [
  15937. // `String.prototype.match` method
  15938. // https://tc39.github.io/ecma262/#sec-string.prototype.match
  15939. function match(regexp) {
  15940. var O = requireObjectCoercible(this);
  15941. var matcher = regexp == undefined ? undefined : regexp[MATCH];
  15942. return matcher !== undefined ? matcher.call(regexp, O) : new RegExp(regexp)[MATCH](String(O));
  15943. },
  15944. // `RegExp.prototype[@@match]` method
  15945. // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@match
  15946. function (regexp) {
  15947. var res = maybeCallNative(nativeMatch, regexp, this);
  15948. if (res.done) return res.value;
  15949. var rx = anObject(regexp);
  15950. var S = String(this);
  15951. if (!rx.global) return regExpExec(rx, S);
  15952. var fullUnicode = rx.unicode;
  15953. rx.lastIndex = 0;
  15954. var A = [];
  15955. var n = 0;
  15956. var result;
  15957. while ((result = regExpExec(rx, S)) !== null) {
  15958. var matchStr = String(result[0]);
  15959. A[n] = matchStr;
  15960. if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
  15961. n++;
  15962. }
  15963. return n === 0 ? null : A;
  15964. }
  15965. ];
  15966. });
  15967. },{"../internals/advance-string-index":105,"../internals/an-object":107,"../internals/fix-regexp-well-known-symbol-logic":146,"../internals/regexp-exec-abstract":198,"../internals/require-object-coercible":202,"../internals/to-length":219}],261:[function(require,module,exports){
  15968. 'use strict';
  15969. var fixRegExpWellKnownSymbolLogic = require('../internals/fix-regexp-well-known-symbol-logic');
  15970. var anObject = require('../internals/an-object');
  15971. var toObject = require('../internals/to-object');
  15972. var toLength = require('../internals/to-length');
  15973. var toInteger = require('../internals/to-integer');
  15974. var requireObjectCoercible = require('../internals/require-object-coercible');
  15975. var advanceStringIndex = require('../internals/advance-string-index');
  15976. var regExpExec = require('../internals/regexp-exec-abstract');
  15977. var max = Math.max;
  15978. var min = Math.min;
  15979. var floor = Math.floor;
  15980. var SUBSTITUTION_SYMBOLS = /\$([$&'`]|\d\d?|<[^>]*>)/g;
  15981. var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&'`]|\d\d?)/g;
  15982. var maybeToString = function (it) {
  15983. return it === undefined ? it : String(it);
  15984. };
  15985. // @@replace logic
  15986. fixRegExpWellKnownSymbolLogic('replace', 2, function (REPLACE, nativeReplace, maybeCallNative, reason) {
  15987. var REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE = reason.REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE;
  15988. var REPLACE_KEEPS_$0 = reason.REPLACE_KEEPS_$0;
  15989. var UNSAFE_SUBSTITUTE = REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE ? '$' : '$0';
  15990. return [
  15991. // `String.prototype.replace` method
  15992. // https://tc39.github.io/ecma262/#sec-string.prototype.replace
  15993. function replace(searchValue, replaceValue) {
  15994. var O = requireObjectCoercible(this);
  15995. var replacer = searchValue == undefined ? undefined : searchValue[REPLACE];
  15996. return replacer !== undefined
  15997. ? replacer.call(searchValue, O, replaceValue)
  15998. : nativeReplace.call(String(O), searchValue, replaceValue);
  15999. },
  16000. // `RegExp.prototype[@@replace]` method
  16001. // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@replace
  16002. function (regexp, replaceValue) {
  16003. if (
  16004. (!REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE && REPLACE_KEEPS_$0) ||
  16005. (typeof replaceValue === 'string' && replaceValue.indexOf(UNSAFE_SUBSTITUTE) === -1)
  16006. ) {
  16007. var res = maybeCallNative(nativeReplace, regexp, this, replaceValue);
  16008. if (res.done) return res.value;
  16009. }
  16010. var rx = anObject(regexp);
  16011. var S = String(this);
  16012. var functionalReplace = typeof replaceValue === 'function';
  16013. if (!functionalReplace) replaceValue = String(replaceValue);
  16014. var global = rx.global;
  16015. if (global) {
  16016. var fullUnicode = rx.unicode;
  16017. rx.lastIndex = 0;
  16018. }
  16019. var results = [];
  16020. while (true) {
  16021. var result = regExpExec(rx, S);
  16022. if (result === null) break;
  16023. results.push(result);
  16024. if (!global) break;
  16025. var matchStr = String(result[0]);
  16026. if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
  16027. }
  16028. var accumulatedResult = '';
  16029. var nextSourcePosition = 0;
  16030. for (var i = 0; i < results.length; i++) {
  16031. result = results[i];
  16032. var matched = String(result[0]);
  16033. var position = max(min(toInteger(result.index), S.length), 0);
  16034. var captures = [];
  16035. // NOTE: This is equivalent to
  16036. // captures = result.slice(1).map(maybeToString)
  16037. // but for some reason `nativeSlice.call(result, 1, result.length)` (called in
  16038. // the slice polyfill when slicing native arrays) "doesn't work" in safari 9 and
  16039. // causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it.
  16040. for (var j = 1; j < result.length; j++) captures.push(maybeToString(result[j]));
  16041. var namedCaptures = result.groups;
  16042. if (functionalReplace) {
  16043. var replacerArgs = [matched].concat(captures, position, S);
  16044. if (namedCaptures !== undefined) replacerArgs.push(namedCaptures);
  16045. var replacement = String(replaceValue.apply(undefined, replacerArgs));
  16046. } else {
  16047. replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue);
  16048. }
  16049. if (position >= nextSourcePosition) {
  16050. accumulatedResult += S.slice(nextSourcePosition, position) + replacement;
  16051. nextSourcePosition = position + matched.length;
  16052. }
  16053. }
  16054. return accumulatedResult + S.slice(nextSourcePosition);
  16055. }
  16056. ];
  16057. // https://tc39.github.io/ecma262/#sec-getsubstitution
  16058. function getSubstitution(matched, str, position, captures, namedCaptures, replacement) {
  16059. var tailPos = position + matched.length;
  16060. var m = captures.length;
  16061. var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED;
  16062. if (namedCaptures !== undefined) {
  16063. namedCaptures = toObject(namedCaptures);
  16064. symbols = SUBSTITUTION_SYMBOLS;
  16065. }
  16066. return nativeReplace.call(replacement, symbols, function (match, ch) {
  16067. var capture;
  16068. switch (ch.charAt(0)) {
  16069. case '$': return '$';
  16070. case '&': return matched;
  16071. case '`': return str.slice(0, position);
  16072. case "'": return str.slice(tailPos);
  16073. case '<':
  16074. capture = namedCaptures[ch.slice(1, -1)];
  16075. break;
  16076. default: // \d\d?
  16077. var n = +ch;
  16078. if (n === 0) return match;
  16079. if (n > m) {
  16080. var f = floor(n / 10);
  16081. if (f === 0) return match;
  16082. if (f <= m) return captures[f - 1] === undefined ? ch.charAt(1) : captures[f - 1] + ch.charAt(1);
  16083. return match;
  16084. }
  16085. capture = captures[n - 1];
  16086. }
  16087. return capture === undefined ? '' : capture;
  16088. });
  16089. }
  16090. });
  16091. },{"../internals/advance-string-index":105,"../internals/an-object":107,"../internals/fix-regexp-well-known-symbol-logic":146,"../internals/regexp-exec-abstract":198,"../internals/require-object-coercible":202,"../internals/to-integer":218,"../internals/to-length":219,"../internals/to-object":220}],262:[function(require,module,exports){
  16092. 'use strict';
  16093. var fixRegExpWellKnownSymbolLogic = require('../internals/fix-regexp-well-known-symbol-logic');
  16094. var anObject = require('../internals/an-object');
  16095. var requireObjectCoercible = require('../internals/require-object-coercible');
  16096. var sameValue = require('../internals/same-value');
  16097. var regExpExec = require('../internals/regexp-exec-abstract');
  16098. // @@search logic
  16099. fixRegExpWellKnownSymbolLogic('search', 1, function (SEARCH, nativeSearch, maybeCallNative) {
  16100. return [
  16101. // `String.prototype.search` method
  16102. // https://tc39.github.io/ecma262/#sec-string.prototype.search
  16103. function search(regexp) {
  16104. var O = requireObjectCoercible(this);
  16105. var searcher = regexp == undefined ? undefined : regexp[SEARCH];
  16106. return searcher !== undefined ? searcher.call(regexp, O) : new RegExp(regexp)[SEARCH](String(O));
  16107. },
  16108. // `RegExp.prototype[@@search]` method
  16109. // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@search
  16110. function (regexp) {
  16111. var res = maybeCallNative(nativeSearch, regexp, this);
  16112. if (res.done) return res.value;
  16113. var rx = anObject(regexp);
  16114. var S = String(this);
  16115. var previousLastIndex = rx.lastIndex;
  16116. if (!sameValue(previousLastIndex, 0)) rx.lastIndex = 0;
  16117. var result = regExpExec(rx, S);
  16118. if (!sameValue(rx.lastIndex, previousLastIndex)) rx.lastIndex = previousLastIndex;
  16119. return result === null ? -1 : result.index;
  16120. }
  16121. ];
  16122. });
  16123. },{"../internals/an-object":107,"../internals/fix-regexp-well-known-symbol-logic":146,"../internals/regexp-exec-abstract":198,"../internals/require-object-coercible":202,"../internals/same-value":203}],263:[function(require,module,exports){
  16124. 'use strict';
  16125. var fixRegExpWellKnownSymbolLogic = require('../internals/fix-regexp-well-known-symbol-logic');
  16126. var isRegExp = require('../internals/is-regexp');
  16127. var anObject = require('../internals/an-object');
  16128. var requireObjectCoercible = require('../internals/require-object-coercible');
  16129. var speciesConstructor = require('../internals/species-constructor');
  16130. var advanceStringIndex = require('../internals/advance-string-index');
  16131. var toLength = require('../internals/to-length');
  16132. var callRegExpExec = require('../internals/regexp-exec-abstract');
  16133. var regexpExec = require('../internals/regexp-exec');
  16134. var fails = require('../internals/fails');
  16135. var arrayPush = [].push;
  16136. var min = Math.min;
  16137. var MAX_UINT32 = 0xFFFFFFFF;
  16138. // babel-minify transpiles RegExp('x', 'y') -> /x/y and it causes SyntaxError
  16139. var SUPPORTS_Y = !fails(function () { return !RegExp(MAX_UINT32, 'y'); });
  16140. // @@split logic
  16141. fixRegExpWellKnownSymbolLogic('split', 2, function (SPLIT, nativeSplit, maybeCallNative) {
  16142. var internalSplit;
  16143. if (
  16144. 'abbc'.split(/(b)*/)[1] == 'c' ||
  16145. 'test'.split(/(?:)/, -1).length != 4 ||
  16146. 'ab'.split(/(?:ab)*/).length != 2 ||
  16147. '.'.split(/(.?)(.?)/).length != 4 ||
  16148. '.'.split(/()()/).length > 1 ||
  16149. ''.split(/.?/).length
  16150. ) {
  16151. // based on es5-shim implementation, need to rework it
  16152. internalSplit = function (separator, limit) {
  16153. var string = String(requireObjectCoercible(this));
  16154. var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
  16155. if (lim === 0) return [];
  16156. if (separator === undefined) return [string];
  16157. // If `separator` is not a regex, use native split
  16158. if (!isRegExp(separator)) {
  16159. return nativeSplit.call(string, separator, lim);
  16160. }
  16161. var output = [];
  16162. var flags = (separator.ignoreCase ? 'i' : '') +
  16163. (separator.multiline ? 'm' : '') +
  16164. (separator.unicode ? 'u' : '') +
  16165. (separator.sticky ? 'y' : '');
  16166. var lastLastIndex = 0;
  16167. // Make `global` and avoid `lastIndex` issues by working with a copy
  16168. var separatorCopy = new RegExp(separator.source, flags + 'g');
  16169. var match, lastIndex, lastLength;
  16170. while (match = regexpExec.call(separatorCopy, string)) {
  16171. lastIndex = separatorCopy.lastIndex;
  16172. if (lastIndex > lastLastIndex) {
  16173. output.push(string.slice(lastLastIndex, match.index));
  16174. if (match.length > 1 && match.index < string.length) arrayPush.apply(output, match.slice(1));
  16175. lastLength = match[0].length;
  16176. lastLastIndex = lastIndex;
  16177. if (output.length >= lim) break;
  16178. }
  16179. if (separatorCopy.lastIndex === match.index) separatorCopy.lastIndex++; // Avoid an infinite loop
  16180. }
  16181. if (lastLastIndex === string.length) {
  16182. if (lastLength || !separatorCopy.test('')) output.push('');
  16183. } else output.push(string.slice(lastLastIndex));
  16184. return output.length > lim ? output.slice(0, lim) : output;
  16185. };
  16186. // Chakra, V8
  16187. } else if ('0'.split(undefined, 0).length) {
  16188. internalSplit = function (separator, limit) {
  16189. return separator === undefined && limit === 0 ? [] : nativeSplit.call(this, separator, limit);
  16190. };
  16191. } else internalSplit = nativeSplit;
  16192. return [
  16193. // `String.prototype.split` method
  16194. // https://tc39.github.io/ecma262/#sec-string.prototype.split
  16195. function split(separator, limit) {
  16196. var O = requireObjectCoercible(this);
  16197. var splitter = separator == undefined ? undefined : separator[SPLIT];
  16198. return splitter !== undefined
  16199. ? splitter.call(separator, O, limit)
  16200. : internalSplit.call(String(O), separator, limit);
  16201. },
  16202. // `RegExp.prototype[@@split]` method
  16203. // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@split
  16204. //
  16205. // NOTE: This cannot be properly polyfilled in engines that don't support
  16206. // the 'y' flag.
  16207. function (regexp, limit) {
  16208. var res = maybeCallNative(internalSplit, regexp, this, limit, internalSplit !== nativeSplit);
  16209. if (res.done) return res.value;
  16210. var rx = anObject(regexp);
  16211. var S = String(this);
  16212. var C = speciesConstructor(rx, RegExp);
  16213. var unicodeMatching = rx.unicode;
  16214. var flags = (rx.ignoreCase ? 'i' : '') +
  16215. (rx.multiline ? 'm' : '') +
  16216. (rx.unicode ? 'u' : '') +
  16217. (SUPPORTS_Y ? 'y' : 'g');
  16218. // ^(? + rx + ) is needed, in combination with some S slicing, to
  16219. // simulate the 'y' flag.
  16220. var splitter = new C(SUPPORTS_Y ? rx : '^(?:' + rx.source + ')', flags);
  16221. var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
  16222. if (lim === 0) return [];
  16223. if (S.length === 0) return callRegExpExec(splitter, S) === null ? [S] : [];
  16224. var p = 0;
  16225. var q = 0;
  16226. var A = [];
  16227. while (q < S.length) {
  16228. splitter.lastIndex = SUPPORTS_Y ? q : 0;
  16229. var z = callRegExpExec(splitter, SUPPORTS_Y ? S : S.slice(q));
  16230. var e;
  16231. if (
  16232. z === null ||
  16233. (e = min(toLength(splitter.lastIndex + (SUPPORTS_Y ? 0 : q)), S.length)) === p
  16234. ) {
  16235. q = advanceStringIndex(S, q, unicodeMatching);
  16236. } else {
  16237. A.push(S.slice(p, q));
  16238. if (A.length === lim) return A;
  16239. for (var i = 1; i <= z.length - 1; i++) {
  16240. A.push(z[i]);
  16241. if (A.length === lim) return A;
  16242. }
  16243. q = p = e;
  16244. }
  16245. }
  16246. A.push(S.slice(p));
  16247. return A;
  16248. }
  16249. ];
  16250. }, !SUPPORTS_Y);
  16251. },{"../internals/advance-string-index":105,"../internals/an-object":107,"../internals/fails":145,"../internals/fix-regexp-well-known-symbol-logic":146,"../internals/is-regexp":166,"../internals/regexp-exec":199,"../internals/regexp-exec-abstract":198,"../internals/require-object-coercible":202,"../internals/species-constructor":210,"../internals/to-length":219}],264:[function(require,module,exports){
  16252. 'use strict';
  16253. var $ = require('../internals/export');
  16254. var getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;
  16255. var toLength = require('../internals/to-length');
  16256. var notARegExp = require('../internals/not-a-regexp');
  16257. var requireObjectCoercible = require('../internals/require-object-coercible');
  16258. var correctIsRegExpLogic = require('../internals/correct-is-regexp-logic');
  16259. var IS_PURE = require('../internals/is-pure');
  16260. var nativeStartsWith = ''.startsWith;
  16261. var min = Math.min;
  16262. var CORRECT_IS_REGEXP_LOGIC = correctIsRegExpLogic('startsWith');
  16263. // https://github.com/zloirock/core-js/pull/702
  16264. var MDN_POLYFILL_BUG = !IS_PURE && !CORRECT_IS_REGEXP_LOGIC && !!function () {
  16265. var descriptor = getOwnPropertyDescriptor(String.prototype, 'startsWith');
  16266. return descriptor && !descriptor.writable;
  16267. }();
  16268. // `String.prototype.startsWith` method
  16269. // https://tc39.github.io/ecma262/#sec-string.prototype.startswith
  16270. $({ target: 'String', proto: true, forced: !MDN_POLYFILL_BUG && !CORRECT_IS_REGEXP_LOGIC }, {
  16271. startsWith: function startsWith(searchString /* , position = 0 */) {
  16272. var that = String(requireObjectCoercible(this));
  16273. notARegExp(searchString);
  16274. var index = toLength(min(arguments.length > 1 ? arguments[1] : undefined, that.length));
  16275. var search = String(searchString);
  16276. return nativeStartsWith
  16277. ? nativeStartsWith.call(that, search, index)
  16278. : that.slice(index, index + search.length) === search;
  16279. }
  16280. });
  16281. },{"../internals/correct-is-regexp-logic":128,"../internals/export":144,"../internals/is-pure":165,"../internals/not-a-regexp":176,"../internals/object-get-own-property-descriptor":181,"../internals/require-object-coercible":202,"../internals/to-length":219}],265:[function(require,module,exports){
  16282. 'use strict';
  16283. var $ = require('../internals/export');
  16284. var $trim = require('../internals/string-trim').trim;
  16285. var forcedStringTrimMethod = require('../internals/string-trim-forced');
  16286. // `String.prototype.trim` method
  16287. // https://tc39.github.io/ecma262/#sec-string.prototype.trim
  16288. $({ target: 'String', proto: true, forced: forcedStringTrimMethod('trim') }, {
  16289. trim: function trim() {
  16290. return $trim(this);
  16291. }
  16292. });
  16293. },{"../internals/export":144,"../internals/string-trim":213,"../internals/string-trim-forced":212}],266:[function(require,module,exports){
  16294. // `Symbol.prototype.description` getter
  16295. // https://tc39.github.io/ecma262/#sec-symbol.prototype.description
  16296. 'use strict';
  16297. var $ = require('../internals/export');
  16298. var DESCRIPTORS = require('../internals/descriptors');
  16299. var global = require('../internals/global');
  16300. var has = require('../internals/has');
  16301. var isObject = require('../internals/is-object');
  16302. var defineProperty = require('../internals/object-define-property').f;
  16303. var copyConstructorProperties = require('../internals/copy-constructor-properties');
  16304. var NativeSymbol = global.Symbol;
  16305. if (DESCRIPTORS && typeof NativeSymbol == 'function' && (!('description' in NativeSymbol.prototype) ||
  16306. // Safari 12 bug
  16307. NativeSymbol().description !== undefined
  16308. )) {
  16309. var EmptyStringDescriptionStore = {};
  16310. // wrap Symbol constructor for correct work with undefined description
  16311. var SymbolWrapper = function Symbol() {
  16312. var description = arguments.length < 1 || arguments[0] === undefined ? undefined : String(arguments[0]);
  16313. var result = this instanceof SymbolWrapper
  16314. ? new NativeSymbol(description)
  16315. // in Edge 13, String(Symbol(undefined)) === 'Symbol(undefined)'
  16316. : description === undefined ? NativeSymbol() : NativeSymbol(description);
  16317. if (description === '') EmptyStringDescriptionStore[result] = true;
  16318. return result;
  16319. };
  16320. copyConstructorProperties(SymbolWrapper, NativeSymbol);
  16321. var symbolPrototype = SymbolWrapper.prototype = NativeSymbol.prototype;
  16322. symbolPrototype.constructor = SymbolWrapper;
  16323. var symbolToString = symbolPrototype.toString;
  16324. var native = String(NativeSymbol('test')) == 'Symbol(test)';
  16325. var regexp = /^Symbol\((.*)\)[^)]+$/;
  16326. defineProperty(symbolPrototype, 'description', {
  16327. configurable: true,
  16328. get: function description() {
  16329. var symbol = isObject(this) ? this.valueOf() : this;
  16330. var string = symbolToString.call(symbol);
  16331. if (has(EmptyStringDescriptionStore, symbol)) return '';
  16332. var desc = native ? string.slice(7, -1) : string.replace(regexp, '$1');
  16333. return desc === '' ? undefined : desc;
  16334. }
  16335. });
  16336. $({ global: true, forced: true }, {
  16337. Symbol: SymbolWrapper
  16338. });
  16339. }
  16340. },{"../internals/copy-constructor-properties":127,"../internals/descriptors":136,"../internals/export":144,"../internals/global":150,"../internals/has":151,"../internals/is-object":164,"../internals/object-define-property":180}],267:[function(require,module,exports){
  16341. 'use strict';
  16342. var $ = require('../internals/export');
  16343. var global = require('../internals/global');
  16344. var getBuiltIn = require('../internals/get-built-in');
  16345. var IS_PURE = require('../internals/is-pure');
  16346. var DESCRIPTORS = require('../internals/descriptors');
  16347. var NATIVE_SYMBOL = require('../internals/native-symbol');
  16348. var USE_SYMBOL_AS_UID = require('../internals/use-symbol-as-uid');
  16349. var fails = require('../internals/fails');
  16350. var has = require('../internals/has');
  16351. var isArray = require('../internals/is-array');
  16352. var isObject = require('../internals/is-object');
  16353. var anObject = require('../internals/an-object');
  16354. var toObject = require('../internals/to-object');
  16355. var toIndexedObject = require('../internals/to-indexed-object');
  16356. var toPrimitive = require('../internals/to-primitive');
  16357. var createPropertyDescriptor = require('../internals/create-property-descriptor');
  16358. var nativeObjectCreate = require('../internals/object-create');
  16359. var objectKeys = require('../internals/object-keys');
  16360. var getOwnPropertyNamesModule = require('../internals/object-get-own-property-names');
  16361. var getOwnPropertyNamesExternal = require('../internals/object-get-own-property-names-external');
  16362. var getOwnPropertySymbolsModule = require('../internals/object-get-own-property-symbols');
  16363. var getOwnPropertyDescriptorModule = require('../internals/object-get-own-property-descriptor');
  16364. var definePropertyModule = require('../internals/object-define-property');
  16365. var propertyIsEnumerableModule = require('../internals/object-property-is-enumerable');
  16366. var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
  16367. var redefine = require('../internals/redefine');
  16368. var shared = require('../internals/shared');
  16369. var sharedKey = require('../internals/shared-key');
  16370. var hiddenKeys = require('../internals/hidden-keys');
  16371. var uid = require('../internals/uid');
  16372. var wellKnownSymbol = require('../internals/well-known-symbol');
  16373. var wrappedWellKnownSymbolModule = require('../internals/well-known-symbol-wrapped');
  16374. var defineWellKnownSymbol = require('../internals/define-well-known-symbol');
  16375. var setToStringTag = require('../internals/set-to-string-tag');
  16376. var InternalStateModule = require('../internals/internal-state');
  16377. var $forEach = require('../internals/array-iteration').forEach;
  16378. var HIDDEN = sharedKey('hidden');
  16379. var SYMBOL = 'Symbol';
  16380. var PROTOTYPE = 'prototype';
  16381. var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
  16382. var setInternalState = InternalStateModule.set;
  16383. var getInternalState = InternalStateModule.getterFor(SYMBOL);
  16384. var ObjectPrototype = Object[PROTOTYPE];
  16385. var $Symbol = global.Symbol;
  16386. var $stringify = getBuiltIn('JSON', 'stringify');
  16387. var nativeGetOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  16388. var nativeDefineProperty = definePropertyModule.f;
  16389. var nativeGetOwnPropertyNames = getOwnPropertyNamesExternal.f;
  16390. var nativePropertyIsEnumerable = propertyIsEnumerableModule.f;
  16391. var AllSymbols = shared('symbols');
  16392. var ObjectPrototypeSymbols = shared('op-symbols');
  16393. var StringToSymbolRegistry = shared('string-to-symbol-registry');
  16394. var SymbolToStringRegistry = shared('symbol-to-string-registry');
  16395. var WellKnownSymbolsStore = shared('wks');
  16396. var QObject = global.QObject;
  16397. // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
  16398. var USE_SETTER = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
  16399. // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
  16400. var setSymbolDescriptor = DESCRIPTORS && fails(function () {
  16401. return nativeObjectCreate(nativeDefineProperty({}, 'a', {
  16402. get: function () { return nativeDefineProperty(this, 'a', { value: 7 }).a; }
  16403. })).a != 7;
  16404. }) ? function (O, P, Attributes) {
  16405. var ObjectPrototypeDescriptor = nativeGetOwnPropertyDescriptor(ObjectPrototype, P);
  16406. if (ObjectPrototypeDescriptor) delete ObjectPrototype[P];
  16407. nativeDefineProperty(O, P, Attributes);
  16408. if (ObjectPrototypeDescriptor && O !== ObjectPrototype) {
  16409. nativeDefineProperty(ObjectPrototype, P, ObjectPrototypeDescriptor);
  16410. }
  16411. } : nativeDefineProperty;
  16412. var wrap = function (tag, description) {
  16413. var symbol = AllSymbols[tag] = nativeObjectCreate($Symbol[PROTOTYPE]);
  16414. setInternalState(symbol, {
  16415. type: SYMBOL,
  16416. tag: tag,
  16417. description: description
  16418. });
  16419. if (!DESCRIPTORS) symbol.description = description;
  16420. return symbol;
  16421. };
  16422. var isSymbol = USE_SYMBOL_AS_UID ? function (it) {
  16423. return typeof it == 'symbol';
  16424. } : function (it) {
  16425. return Object(it) instanceof $Symbol;
  16426. };
  16427. var $defineProperty = function defineProperty(O, P, Attributes) {
  16428. if (O === ObjectPrototype) $defineProperty(ObjectPrototypeSymbols, P, Attributes);
  16429. anObject(O);
  16430. var key = toPrimitive(P, true);
  16431. anObject(Attributes);
  16432. if (has(AllSymbols, key)) {
  16433. if (!Attributes.enumerable) {
  16434. if (!has(O, HIDDEN)) nativeDefineProperty(O, HIDDEN, createPropertyDescriptor(1, {}));
  16435. O[HIDDEN][key] = true;
  16436. } else {
  16437. if (has(O, HIDDEN) && O[HIDDEN][key]) O[HIDDEN][key] = false;
  16438. Attributes = nativeObjectCreate(Attributes, { enumerable: createPropertyDescriptor(0, false) });
  16439. } return setSymbolDescriptor(O, key, Attributes);
  16440. } return nativeDefineProperty(O, key, Attributes);
  16441. };
  16442. var $defineProperties = function defineProperties(O, Properties) {
  16443. anObject(O);
  16444. var properties = toIndexedObject(Properties);
  16445. var keys = objectKeys(properties).concat($getOwnPropertySymbols(properties));
  16446. $forEach(keys, function (key) {
  16447. if (!DESCRIPTORS || $propertyIsEnumerable.call(properties, key)) $defineProperty(O, key, properties[key]);
  16448. });
  16449. return O;
  16450. };
  16451. var $create = function create(O, Properties) {
  16452. return Properties === undefined ? nativeObjectCreate(O) : $defineProperties(nativeObjectCreate(O), Properties);
  16453. };
  16454. var $propertyIsEnumerable = function propertyIsEnumerable(V) {
  16455. var P = toPrimitive(V, true);
  16456. var enumerable = nativePropertyIsEnumerable.call(this, P);
  16457. if (this === ObjectPrototype && has(AllSymbols, P) && !has(ObjectPrototypeSymbols, P)) return false;
  16458. return enumerable || !has(this, P) || !has(AllSymbols, P) || has(this, HIDDEN) && this[HIDDEN][P] ? enumerable : true;
  16459. };
  16460. var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(O, P) {
  16461. var it = toIndexedObject(O);
  16462. var key = toPrimitive(P, true);
  16463. if (it === ObjectPrototype && has(AllSymbols, key) && !has(ObjectPrototypeSymbols, key)) return;
  16464. var descriptor = nativeGetOwnPropertyDescriptor(it, key);
  16465. if (descriptor && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) {
  16466. descriptor.enumerable = true;
  16467. }
  16468. return descriptor;
  16469. };
  16470. var $getOwnPropertyNames = function getOwnPropertyNames(O) {
  16471. var names = nativeGetOwnPropertyNames(toIndexedObject(O));
  16472. var result = [];
  16473. $forEach(names, function (key) {
  16474. if (!has(AllSymbols, key) && !has(hiddenKeys, key)) result.push(key);
  16475. });
  16476. return result;
  16477. };
  16478. var $getOwnPropertySymbols = function getOwnPropertySymbols(O) {
  16479. var IS_OBJECT_PROTOTYPE = O === ObjectPrototype;
  16480. var names = nativeGetOwnPropertyNames(IS_OBJECT_PROTOTYPE ? ObjectPrototypeSymbols : toIndexedObject(O));
  16481. var result = [];
  16482. $forEach(names, function (key) {
  16483. if (has(AllSymbols, key) && (!IS_OBJECT_PROTOTYPE || has(ObjectPrototype, key))) {
  16484. result.push(AllSymbols[key]);
  16485. }
  16486. });
  16487. return result;
  16488. };
  16489. // `Symbol` constructor
  16490. // https://tc39.github.io/ecma262/#sec-symbol-constructor
  16491. if (!NATIVE_SYMBOL) {
  16492. $Symbol = function Symbol() {
  16493. if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor');
  16494. var description = !arguments.length || arguments[0] === undefined ? undefined : String(arguments[0]);
  16495. var tag = uid(description);
  16496. var setter = function (value) {
  16497. if (this === ObjectPrototype) setter.call(ObjectPrototypeSymbols, value);
  16498. if (has(this, HIDDEN) && has(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
  16499. setSymbolDescriptor(this, tag, createPropertyDescriptor(1, value));
  16500. };
  16501. if (DESCRIPTORS && USE_SETTER) setSymbolDescriptor(ObjectPrototype, tag, { configurable: true, set: setter });
  16502. return wrap(tag, description);
  16503. };
  16504. redefine($Symbol[PROTOTYPE], 'toString', function toString() {
  16505. return getInternalState(this).tag;
  16506. });
  16507. redefine($Symbol, 'withoutSetter', function (description) {
  16508. return wrap(uid(description), description);
  16509. });
  16510. propertyIsEnumerableModule.f = $propertyIsEnumerable;
  16511. definePropertyModule.f = $defineProperty;
  16512. getOwnPropertyDescriptorModule.f = $getOwnPropertyDescriptor;
  16513. getOwnPropertyNamesModule.f = getOwnPropertyNamesExternal.f = $getOwnPropertyNames;
  16514. getOwnPropertySymbolsModule.f = $getOwnPropertySymbols;
  16515. wrappedWellKnownSymbolModule.f = function (name) {
  16516. return wrap(wellKnownSymbol(name), name);
  16517. };
  16518. if (DESCRIPTORS) {
  16519. // https://github.com/tc39/proposal-Symbol-description
  16520. nativeDefineProperty($Symbol[PROTOTYPE], 'description', {
  16521. configurable: true,
  16522. get: function description() {
  16523. return getInternalState(this).description;
  16524. }
  16525. });
  16526. if (!IS_PURE) {
  16527. redefine(ObjectPrototype, 'propertyIsEnumerable', $propertyIsEnumerable, { unsafe: true });
  16528. }
  16529. }
  16530. }
  16531. $({ global: true, wrap: true, forced: !NATIVE_SYMBOL, sham: !NATIVE_SYMBOL }, {
  16532. Symbol: $Symbol
  16533. });
  16534. $forEach(objectKeys(WellKnownSymbolsStore), function (name) {
  16535. defineWellKnownSymbol(name);
  16536. });
  16537. $({ target: SYMBOL, stat: true, forced: !NATIVE_SYMBOL }, {
  16538. // `Symbol.for` method
  16539. // https://tc39.github.io/ecma262/#sec-symbol.for
  16540. 'for': function (key) {
  16541. var string = String(key);
  16542. if (has(StringToSymbolRegistry, string)) return StringToSymbolRegistry[string];
  16543. var symbol = $Symbol(string);
  16544. StringToSymbolRegistry[string] = symbol;
  16545. SymbolToStringRegistry[symbol] = string;
  16546. return symbol;
  16547. },
  16548. // `Symbol.keyFor` method
  16549. // https://tc39.github.io/ecma262/#sec-symbol.keyfor
  16550. keyFor: function keyFor(sym) {
  16551. if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol');
  16552. if (has(SymbolToStringRegistry, sym)) return SymbolToStringRegistry[sym];
  16553. },
  16554. useSetter: function () { USE_SETTER = true; },
  16555. useSimple: function () { USE_SETTER = false; }
  16556. });
  16557. $({ target: 'Object', stat: true, forced: !NATIVE_SYMBOL, sham: !DESCRIPTORS }, {
  16558. // `Object.create` method
  16559. // https://tc39.github.io/ecma262/#sec-object.create
  16560. create: $create,
  16561. // `Object.defineProperty` method
  16562. // https://tc39.github.io/ecma262/#sec-object.defineproperty
  16563. defineProperty: $defineProperty,
  16564. // `Object.defineProperties` method
  16565. // https://tc39.github.io/ecma262/#sec-object.defineproperties
  16566. defineProperties: $defineProperties,
  16567. // `Object.getOwnPropertyDescriptor` method
  16568. // https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptors
  16569. getOwnPropertyDescriptor: $getOwnPropertyDescriptor
  16570. });
  16571. $({ target: 'Object', stat: true, forced: !NATIVE_SYMBOL }, {
  16572. // `Object.getOwnPropertyNames` method
  16573. // https://tc39.github.io/ecma262/#sec-object.getownpropertynames
  16574. getOwnPropertyNames: $getOwnPropertyNames,
  16575. // `Object.getOwnPropertySymbols` method
  16576. // https://tc39.github.io/ecma262/#sec-object.getownpropertysymbols
  16577. getOwnPropertySymbols: $getOwnPropertySymbols
  16578. });
  16579. // Chrome 38 and 39 `Object.getOwnPropertySymbols` fails on primitives
  16580. // https://bugs.chromium.org/p/v8/issues/detail?id=3443
  16581. $({ target: 'Object', stat: true, forced: fails(function () { getOwnPropertySymbolsModule.f(1); }) }, {
  16582. getOwnPropertySymbols: function getOwnPropertySymbols(it) {
  16583. return getOwnPropertySymbolsModule.f(toObject(it));
  16584. }
  16585. });
  16586. // `JSON.stringify` method behavior with symbols
  16587. // https://tc39.github.io/ecma262/#sec-json.stringify
  16588. if ($stringify) {
  16589. var FORCED_JSON_STRINGIFY = !NATIVE_SYMBOL || fails(function () {
  16590. var symbol = $Symbol();
  16591. // MS Edge converts symbol values to JSON as {}
  16592. return $stringify([symbol]) != '[null]'
  16593. // WebKit converts symbol values to JSON as null
  16594. || $stringify({ a: symbol }) != '{}'
  16595. // V8 throws on boxed symbols
  16596. || $stringify(Object(symbol)) != '{}';
  16597. });
  16598. $({ target: 'JSON', stat: true, forced: FORCED_JSON_STRINGIFY }, {
  16599. // eslint-disable-next-line no-unused-vars
  16600. stringify: function stringify(it, replacer, space) {
  16601. var args = [it];
  16602. var index = 1;
  16603. var $replacer;
  16604. while (arguments.length > index) args.push(arguments[index++]);
  16605. $replacer = replacer;
  16606. if (!isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined
  16607. if (!isArray(replacer)) replacer = function (key, value) {
  16608. if (typeof $replacer == 'function') value = $replacer.call(this, key, value);
  16609. if (!isSymbol(value)) return value;
  16610. };
  16611. args[1] = replacer;
  16612. return $stringify.apply(null, args);
  16613. }
  16614. });
  16615. }
  16616. // `Symbol.prototype[@@toPrimitive]` method
  16617. // https://tc39.github.io/ecma262/#sec-symbol.prototype-@@toprimitive
  16618. if (!$Symbol[PROTOTYPE][TO_PRIMITIVE]) {
  16619. createNonEnumerableProperty($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);
  16620. }
  16621. // `Symbol.prototype[@@toStringTag]` property
  16622. // https://tc39.github.io/ecma262/#sec-symbol.prototype-@@tostringtag
  16623. setToStringTag($Symbol, SYMBOL);
  16624. hiddenKeys[HIDDEN] = true;
  16625. },{"../internals/an-object":107,"../internals/array-iteration":116,"../internals/create-non-enumerable-property":131,"../internals/create-property-descriptor":132,"../internals/define-well-known-symbol":135,"../internals/descriptors":136,"../internals/export":144,"../internals/fails":145,"../internals/get-built-in":148,"../internals/global":150,"../internals/has":151,"../internals/hidden-keys":152,"../internals/internal-state":160,"../internals/is-array":162,"../internals/is-object":164,"../internals/is-pure":165,"../internals/native-symbol":173,"../internals/object-create":178,"../internals/object-define-property":180,"../internals/object-get-own-property-descriptor":181,"../internals/object-get-own-property-names":183,"../internals/object-get-own-property-names-external":182,"../internals/object-get-own-property-symbols":184,"../internals/object-keys":187,"../internals/object-property-is-enumerable":188,"../internals/redefine":197,"../internals/set-to-string-tag":206,"../internals/shared":209,"../internals/shared-key":207,"../internals/to-indexed-object":217,"../internals/to-object":220,"../internals/to-primitive":223,"../internals/uid":228,"../internals/use-symbol-as-uid":229,"../internals/well-known-symbol":231,"../internals/well-known-symbol-wrapped":230}],268:[function(require,module,exports){
  16626. 'use strict';
  16627. var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
  16628. var $copyWithin = require('../internals/array-copy-within');
  16629. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  16630. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  16631. // `%TypedArray%.prototype.copyWithin` method
  16632. // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.copywithin
  16633. exportTypedArrayMethod('copyWithin', function copyWithin(target, start /* , end */) {
  16634. return $copyWithin.call(aTypedArray(this), target, start, arguments.length > 2 ? arguments[2] : undefined);
  16635. });
  16636. },{"../internals/array-buffer-view-core":109,"../internals/array-copy-within":111}],269:[function(require,module,exports){
  16637. 'use strict';
  16638. var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
  16639. var $every = require('../internals/array-iteration').every;
  16640. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  16641. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  16642. // `%TypedArray%.prototype.every` method
  16643. // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.every
  16644. exportTypedArrayMethod('every', function every(callbackfn /* , thisArg */) {
  16645. return $every(aTypedArray(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  16646. });
  16647. },{"../internals/array-buffer-view-core":109,"../internals/array-iteration":116}],270:[function(require,module,exports){
  16648. 'use strict';
  16649. var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
  16650. var $fill = require('../internals/array-fill');
  16651. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  16652. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  16653. // `%TypedArray%.prototype.fill` method
  16654. // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.fill
  16655. // eslint-disable-next-line no-unused-vars
  16656. exportTypedArrayMethod('fill', function fill(value /* , start, end */) {
  16657. return $fill.apply(aTypedArray(this), arguments);
  16658. });
  16659. },{"../internals/array-buffer-view-core":109,"../internals/array-fill":112}],271:[function(require,module,exports){
  16660. 'use strict';
  16661. var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
  16662. var $filter = require('../internals/array-iteration').filter;
  16663. var speciesConstructor = require('../internals/species-constructor');
  16664. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  16665. var aTypedArrayConstructor = ArrayBufferViewCore.aTypedArrayConstructor;
  16666. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  16667. // `%TypedArray%.prototype.filter` method
  16668. // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.filter
  16669. exportTypedArrayMethod('filter', function filter(callbackfn /* , thisArg */) {
  16670. var list = $filter(aTypedArray(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  16671. var C = speciesConstructor(this, this.constructor);
  16672. var index = 0;
  16673. var length = list.length;
  16674. var result = new (aTypedArrayConstructor(C))(length);
  16675. while (length > index) result[index] = list[index++];
  16676. return result;
  16677. });
  16678. },{"../internals/array-buffer-view-core":109,"../internals/array-iteration":116,"../internals/species-constructor":210}],272:[function(require,module,exports){
  16679. 'use strict';
  16680. var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
  16681. var $findIndex = require('../internals/array-iteration').findIndex;
  16682. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  16683. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  16684. // `%TypedArray%.prototype.findIndex` method
  16685. // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.findindex
  16686. exportTypedArrayMethod('findIndex', function findIndex(predicate /* , thisArg */) {
  16687. return $findIndex(aTypedArray(this), predicate, arguments.length > 1 ? arguments[1] : undefined);
  16688. });
  16689. },{"../internals/array-buffer-view-core":109,"../internals/array-iteration":116}],273:[function(require,module,exports){
  16690. 'use strict';
  16691. var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
  16692. var $find = require('../internals/array-iteration').find;
  16693. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  16694. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  16695. // `%TypedArray%.prototype.find` method
  16696. // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.find
  16697. exportTypedArrayMethod('find', function find(predicate /* , thisArg */) {
  16698. return $find(aTypedArray(this), predicate, arguments.length > 1 ? arguments[1] : undefined);
  16699. });
  16700. },{"../internals/array-buffer-view-core":109,"../internals/array-iteration":116}],274:[function(require,module,exports){
  16701. 'use strict';
  16702. var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
  16703. var $forEach = require('../internals/array-iteration').forEach;
  16704. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  16705. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  16706. // `%TypedArray%.prototype.forEach` method
  16707. // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.foreach
  16708. exportTypedArrayMethod('forEach', function forEach(callbackfn /* , thisArg */) {
  16709. $forEach(aTypedArray(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  16710. });
  16711. },{"../internals/array-buffer-view-core":109,"../internals/array-iteration":116}],275:[function(require,module,exports){
  16712. 'use strict';
  16713. var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
  16714. var $includes = require('../internals/array-includes').includes;
  16715. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  16716. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  16717. // `%TypedArray%.prototype.includes` method
  16718. // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.includes
  16719. exportTypedArrayMethod('includes', function includes(searchElement /* , fromIndex */) {
  16720. return $includes(aTypedArray(this), searchElement, arguments.length > 1 ? arguments[1] : undefined);
  16721. });
  16722. },{"../internals/array-buffer-view-core":109,"../internals/array-includes":115}],276:[function(require,module,exports){
  16723. 'use strict';
  16724. var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
  16725. var $indexOf = require('../internals/array-includes').indexOf;
  16726. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  16727. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  16728. // `%TypedArray%.prototype.indexOf` method
  16729. // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.indexof
  16730. exportTypedArrayMethod('indexOf', function indexOf(searchElement /* , fromIndex */) {
  16731. return $indexOf(aTypedArray(this), searchElement, arguments.length > 1 ? arguments[1] : undefined);
  16732. });
  16733. },{"../internals/array-buffer-view-core":109,"../internals/array-includes":115}],277:[function(require,module,exports){
  16734. 'use strict';
  16735. var global = require('../internals/global');
  16736. var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
  16737. var ArrayIterators = require('../modules/es.array.iterator');
  16738. var wellKnownSymbol = require('../internals/well-known-symbol');
  16739. var ITERATOR = wellKnownSymbol('iterator');
  16740. var Uint8Array = global.Uint8Array;
  16741. var arrayValues = ArrayIterators.values;
  16742. var arrayKeys = ArrayIterators.keys;
  16743. var arrayEntries = ArrayIterators.entries;
  16744. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  16745. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  16746. var nativeTypedArrayIterator = Uint8Array && Uint8Array.prototype[ITERATOR];
  16747. var CORRECT_ITER_NAME = !!nativeTypedArrayIterator
  16748. && (nativeTypedArrayIterator.name == 'values' || nativeTypedArrayIterator.name == undefined);
  16749. var typedArrayValues = function values() {
  16750. return arrayValues.call(aTypedArray(this));
  16751. };
  16752. // `%TypedArray%.prototype.entries` method
  16753. // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.entries
  16754. exportTypedArrayMethod('entries', function entries() {
  16755. return arrayEntries.call(aTypedArray(this));
  16756. });
  16757. // `%TypedArray%.prototype.keys` method
  16758. // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.keys
  16759. exportTypedArrayMethod('keys', function keys() {
  16760. return arrayKeys.call(aTypedArray(this));
  16761. });
  16762. // `%TypedArray%.prototype.values` method
  16763. // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.values
  16764. exportTypedArrayMethod('values', typedArrayValues, !CORRECT_ITER_NAME);
  16765. // `%TypedArray%.prototype[@@iterator]` method
  16766. // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype-@@iterator
  16767. exportTypedArrayMethod(ITERATOR, typedArrayValues, !CORRECT_ITER_NAME);
  16768. },{"../internals/array-buffer-view-core":109,"../internals/global":150,"../internals/well-known-symbol":231,"../modules/es.array.iterator":242}],278:[function(require,module,exports){
  16769. 'use strict';
  16770. var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
  16771. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  16772. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  16773. var $join = [].join;
  16774. // `%TypedArray%.prototype.join` method
  16775. // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.join
  16776. // eslint-disable-next-line no-unused-vars
  16777. exportTypedArrayMethod('join', function join(separator) {
  16778. return $join.apply(aTypedArray(this), arguments);
  16779. });
  16780. },{"../internals/array-buffer-view-core":109}],279:[function(require,module,exports){
  16781. 'use strict';
  16782. var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
  16783. var $lastIndexOf = require('../internals/array-last-index-of');
  16784. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  16785. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  16786. // `%TypedArray%.prototype.lastIndexOf` method
  16787. // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.lastindexof
  16788. // eslint-disable-next-line no-unused-vars
  16789. exportTypedArrayMethod('lastIndexOf', function lastIndexOf(searchElement /* , fromIndex */) {
  16790. return $lastIndexOf.apply(aTypedArray(this), arguments);
  16791. });
  16792. },{"../internals/array-buffer-view-core":109,"../internals/array-last-index-of":117}],280:[function(require,module,exports){
  16793. 'use strict';
  16794. var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
  16795. var $map = require('../internals/array-iteration').map;
  16796. var speciesConstructor = require('../internals/species-constructor');
  16797. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  16798. var aTypedArrayConstructor = ArrayBufferViewCore.aTypedArrayConstructor;
  16799. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  16800. // `%TypedArray%.prototype.map` method
  16801. // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.map
  16802. exportTypedArrayMethod('map', function map(mapfn /* , thisArg */) {
  16803. return $map(aTypedArray(this), mapfn, arguments.length > 1 ? arguments[1] : undefined, function (O, length) {
  16804. return new (aTypedArrayConstructor(speciesConstructor(O, O.constructor)))(length);
  16805. });
  16806. });
  16807. },{"../internals/array-buffer-view-core":109,"../internals/array-iteration":116,"../internals/species-constructor":210}],281:[function(require,module,exports){
  16808. 'use strict';
  16809. var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
  16810. var $reduceRight = require('../internals/array-reduce').right;
  16811. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  16812. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  16813. // `%TypedArray%.prototype.reduceRicht` method
  16814. // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.reduceright
  16815. exportTypedArrayMethod('reduceRight', function reduceRight(callbackfn /* , initialValue */) {
  16816. return $reduceRight(aTypedArray(this), callbackfn, arguments.length, arguments.length > 1 ? arguments[1] : undefined);
  16817. });
  16818. },{"../internals/array-buffer-view-core":109,"../internals/array-reduce":121}],282:[function(require,module,exports){
  16819. 'use strict';
  16820. var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
  16821. var $reduce = require('../internals/array-reduce').left;
  16822. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  16823. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  16824. // `%TypedArray%.prototype.reduce` method
  16825. // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.reduce
  16826. exportTypedArrayMethod('reduce', function reduce(callbackfn /* , initialValue */) {
  16827. return $reduce(aTypedArray(this), callbackfn, arguments.length, arguments.length > 1 ? arguments[1] : undefined);
  16828. });
  16829. },{"../internals/array-buffer-view-core":109,"../internals/array-reduce":121}],283:[function(require,module,exports){
  16830. 'use strict';
  16831. var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
  16832. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  16833. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  16834. var floor = Math.floor;
  16835. // `%TypedArray%.prototype.reverse` method
  16836. // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.reverse
  16837. exportTypedArrayMethod('reverse', function reverse() {
  16838. var that = this;
  16839. var length = aTypedArray(that).length;
  16840. var middle = floor(length / 2);
  16841. var index = 0;
  16842. var value;
  16843. while (index < middle) {
  16844. value = that[index];
  16845. that[index++] = that[--length];
  16846. that[length] = value;
  16847. } return that;
  16848. });
  16849. },{"../internals/array-buffer-view-core":109}],284:[function(require,module,exports){
  16850. 'use strict';
  16851. var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
  16852. var toLength = require('../internals/to-length');
  16853. var toOffset = require('../internals/to-offset');
  16854. var toObject = require('../internals/to-object');
  16855. var fails = require('../internals/fails');
  16856. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  16857. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  16858. var FORCED = fails(function () {
  16859. // eslint-disable-next-line no-undef
  16860. new Int8Array(1).set({});
  16861. });
  16862. // `%TypedArray%.prototype.set` method
  16863. // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.set
  16864. exportTypedArrayMethod('set', function set(arrayLike /* , offset */) {
  16865. aTypedArray(this);
  16866. var offset = toOffset(arguments.length > 1 ? arguments[1] : undefined, 1);
  16867. var length = this.length;
  16868. var src = toObject(arrayLike);
  16869. var len = toLength(src.length);
  16870. var index = 0;
  16871. if (len + offset > length) throw RangeError('Wrong length');
  16872. while (index < len) this[offset + index] = src[index++];
  16873. }, FORCED);
  16874. },{"../internals/array-buffer-view-core":109,"../internals/fails":145,"../internals/to-length":219,"../internals/to-object":220,"../internals/to-offset":221}],285:[function(require,module,exports){
  16875. 'use strict';
  16876. var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
  16877. var speciesConstructor = require('../internals/species-constructor');
  16878. var fails = require('../internals/fails');
  16879. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  16880. var aTypedArrayConstructor = ArrayBufferViewCore.aTypedArrayConstructor;
  16881. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  16882. var $slice = [].slice;
  16883. var FORCED = fails(function () {
  16884. // eslint-disable-next-line no-undef
  16885. new Int8Array(1).slice();
  16886. });
  16887. // `%TypedArray%.prototype.slice` method
  16888. // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.slice
  16889. exportTypedArrayMethod('slice', function slice(start, end) {
  16890. var list = $slice.call(aTypedArray(this), start, end);
  16891. var C = speciesConstructor(this, this.constructor);
  16892. var index = 0;
  16893. var length = list.length;
  16894. var result = new (aTypedArrayConstructor(C))(length);
  16895. while (length > index) result[index] = list[index++];
  16896. return result;
  16897. }, FORCED);
  16898. },{"../internals/array-buffer-view-core":109,"../internals/fails":145,"../internals/species-constructor":210}],286:[function(require,module,exports){
  16899. 'use strict';
  16900. var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
  16901. var $some = require('../internals/array-iteration').some;
  16902. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  16903. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  16904. // `%TypedArray%.prototype.some` method
  16905. // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.some
  16906. exportTypedArrayMethod('some', function some(callbackfn /* , thisArg */) {
  16907. return $some(aTypedArray(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  16908. });
  16909. },{"../internals/array-buffer-view-core":109,"../internals/array-iteration":116}],287:[function(require,module,exports){
  16910. 'use strict';
  16911. var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
  16912. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  16913. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  16914. var $sort = [].sort;
  16915. // `%TypedArray%.prototype.sort` method
  16916. // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.sort
  16917. exportTypedArrayMethod('sort', function sort(comparefn) {
  16918. return $sort.call(aTypedArray(this), comparefn);
  16919. });
  16920. },{"../internals/array-buffer-view-core":109}],288:[function(require,module,exports){
  16921. 'use strict';
  16922. var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
  16923. var toLength = require('../internals/to-length');
  16924. var toAbsoluteIndex = require('../internals/to-absolute-index');
  16925. var speciesConstructor = require('../internals/species-constructor');
  16926. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  16927. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  16928. // `%TypedArray%.prototype.subarray` method
  16929. // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.subarray
  16930. exportTypedArrayMethod('subarray', function subarray(begin, end) {
  16931. var O = aTypedArray(this);
  16932. var length = O.length;
  16933. var beginIndex = toAbsoluteIndex(begin, length);
  16934. return new (speciesConstructor(O, O.constructor))(
  16935. O.buffer,
  16936. O.byteOffset + beginIndex * O.BYTES_PER_ELEMENT,
  16937. toLength((end === undefined ? length : toAbsoluteIndex(end, length)) - beginIndex)
  16938. );
  16939. });
  16940. },{"../internals/array-buffer-view-core":109,"../internals/species-constructor":210,"../internals/to-absolute-index":215,"../internals/to-length":219}],289:[function(require,module,exports){
  16941. 'use strict';
  16942. var global = require('../internals/global');
  16943. var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
  16944. var fails = require('../internals/fails');
  16945. var Int8Array = global.Int8Array;
  16946. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  16947. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  16948. var $toLocaleString = [].toLocaleString;
  16949. var $slice = [].slice;
  16950. // iOS Safari 6.x fails here
  16951. var TO_LOCALE_STRING_BUG = !!Int8Array && fails(function () {
  16952. $toLocaleString.call(new Int8Array(1));
  16953. });
  16954. var FORCED = fails(function () {
  16955. return [1, 2].toLocaleString() != new Int8Array([1, 2]).toLocaleString();
  16956. }) || !fails(function () {
  16957. Int8Array.prototype.toLocaleString.call([1, 2]);
  16958. });
  16959. // `%TypedArray%.prototype.toLocaleString` method
  16960. // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.tolocalestring
  16961. exportTypedArrayMethod('toLocaleString', function toLocaleString() {
  16962. return $toLocaleString.apply(TO_LOCALE_STRING_BUG ? $slice.call(aTypedArray(this)) : aTypedArray(this), arguments);
  16963. }, FORCED);
  16964. },{"../internals/array-buffer-view-core":109,"../internals/fails":145,"../internals/global":150}],290:[function(require,module,exports){
  16965. 'use strict';
  16966. var exportTypedArrayMethod = require('../internals/array-buffer-view-core').exportTypedArrayMethod;
  16967. var fails = require('../internals/fails');
  16968. var global = require('../internals/global');
  16969. var Uint8Array = global.Uint8Array;
  16970. var Uint8ArrayPrototype = Uint8Array && Uint8Array.prototype || {};
  16971. var arrayToString = [].toString;
  16972. var arrayJoin = [].join;
  16973. if (fails(function () { arrayToString.call({}); })) {
  16974. arrayToString = function toString() {
  16975. return arrayJoin.call(this);
  16976. };
  16977. }
  16978. var IS_NOT_ARRAY_METHOD = Uint8ArrayPrototype.toString != arrayToString;
  16979. // `%TypedArray%.prototype.toString` method
  16980. // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.tostring
  16981. exportTypedArrayMethod('toString', arrayToString, IS_NOT_ARRAY_METHOD);
  16982. },{"../internals/array-buffer-view-core":109,"../internals/fails":145,"../internals/global":150}],291:[function(require,module,exports){
  16983. var createTypedArrayConstructor = require('../internals/typed-array-constructor');
  16984. // `Uint8Array` constructor
  16985. // https://tc39.github.io/ecma262/#sec-typedarray-objects
  16986. createTypedArrayConstructor('Uint8', function (init) {
  16987. return function Uint8Array(data, byteOffset, length) {
  16988. return init(this, data, byteOffset, length);
  16989. };
  16990. });
  16991. },{"../internals/typed-array-constructor":225}],292:[function(require,module,exports){
  16992. var global = require('../internals/global');
  16993. var DOMIterables = require('../internals/dom-iterables');
  16994. var forEach = require('../internals/array-for-each');
  16995. var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
  16996. for (var COLLECTION_NAME in DOMIterables) {
  16997. var Collection = global[COLLECTION_NAME];
  16998. var CollectionPrototype = Collection && Collection.prototype;
  16999. // some Chrome versions have non-configurable methods on DOMTokenList
  17000. if (CollectionPrototype && CollectionPrototype.forEach !== forEach) try {
  17001. createNonEnumerableProperty(CollectionPrototype, 'forEach', forEach);
  17002. } catch (error) {
  17003. CollectionPrototype.forEach = forEach;
  17004. }
  17005. }
  17006. },{"../internals/array-for-each":113,"../internals/create-non-enumerable-property":131,"../internals/dom-iterables":138,"../internals/global":150}],293:[function(require,module,exports){
  17007. var global = require('../internals/global');
  17008. var DOMIterables = require('../internals/dom-iterables');
  17009. var ArrayIteratorMethods = require('../modules/es.array.iterator');
  17010. var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
  17011. var wellKnownSymbol = require('../internals/well-known-symbol');
  17012. var ITERATOR = wellKnownSymbol('iterator');
  17013. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  17014. var ArrayValues = ArrayIteratorMethods.values;
  17015. for (var COLLECTION_NAME in DOMIterables) {
  17016. var Collection = global[COLLECTION_NAME];
  17017. var CollectionPrototype = Collection && Collection.prototype;
  17018. if (CollectionPrototype) {
  17019. // some Chrome versions have non-configurable methods on DOMTokenList
  17020. if (CollectionPrototype[ITERATOR] !== ArrayValues) try {
  17021. createNonEnumerableProperty(CollectionPrototype, ITERATOR, ArrayValues);
  17022. } catch (error) {
  17023. CollectionPrototype[ITERATOR] = ArrayValues;
  17024. }
  17025. if (!CollectionPrototype[TO_STRING_TAG]) {
  17026. createNonEnumerableProperty(CollectionPrototype, TO_STRING_TAG, COLLECTION_NAME);
  17027. }
  17028. if (DOMIterables[COLLECTION_NAME]) for (var METHOD_NAME in ArrayIteratorMethods) {
  17029. // some Chrome versions have non-configurable methods on DOMTokenList
  17030. if (CollectionPrototype[METHOD_NAME] !== ArrayIteratorMethods[METHOD_NAME]) try {
  17031. createNonEnumerableProperty(CollectionPrototype, METHOD_NAME, ArrayIteratorMethods[METHOD_NAME]);
  17032. } catch (error) {
  17033. CollectionPrototype[METHOD_NAME] = ArrayIteratorMethods[METHOD_NAME];
  17034. }
  17035. }
  17036. }
  17037. }
  17038. },{"../internals/create-non-enumerable-property":131,"../internals/dom-iterables":138,"../internals/global":150,"../internals/well-known-symbol":231,"../modules/es.array.iterator":242}],294:[function(require,module,exports){
  17039. (function (Buffer){
  17040. // Copyright Joyent, Inc. and other Node contributors.
  17041. //
  17042. // Permission is hereby granted, free of charge, to any person obtaining a
  17043. // copy of this software and associated documentation files (the
  17044. // "Software"), to deal in the Software without restriction, including
  17045. // without limitation the rights to use, copy, modify, merge, publish,
  17046. // distribute, sublicense, and/or sell copies of the Software, and to permit
  17047. // persons to whom the Software is furnished to do so, subject to the
  17048. // following conditions:
  17049. //
  17050. // The above copyright notice and this permission notice shall be included
  17051. // in all copies or substantial portions of the Software.
  17052. //
  17053. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  17054. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17055. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  17056. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  17057. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  17058. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  17059. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  17060. // NOTE: These type checking functions intentionally don't use `instanceof`
  17061. // because it is fragile and can be easily faked with `Object.create()`.
  17062. function isArray(arg) {
  17063. if (Array.isArray) {
  17064. return Array.isArray(arg);
  17065. }
  17066. return objectToString(arg) === '[object Array]';
  17067. }
  17068. exports.isArray = isArray;
  17069. function isBoolean(arg) {
  17070. return typeof arg === 'boolean';
  17071. }
  17072. exports.isBoolean = isBoolean;
  17073. function isNull(arg) {
  17074. return arg === null;
  17075. }
  17076. exports.isNull = isNull;
  17077. function isNullOrUndefined(arg) {
  17078. return arg == null;
  17079. }
  17080. exports.isNullOrUndefined = isNullOrUndefined;
  17081. function isNumber(arg) {
  17082. return typeof arg === 'number';
  17083. }
  17084. exports.isNumber = isNumber;
  17085. function isString(arg) {
  17086. return typeof arg === 'string';
  17087. }
  17088. exports.isString = isString;
  17089. function isSymbol(arg) {
  17090. return typeof arg === 'symbol';
  17091. }
  17092. exports.isSymbol = isSymbol;
  17093. function isUndefined(arg) {
  17094. return arg === void 0;
  17095. }
  17096. exports.isUndefined = isUndefined;
  17097. function isRegExp(re) {
  17098. return objectToString(re) === '[object RegExp]';
  17099. }
  17100. exports.isRegExp = isRegExp;
  17101. function isObject(arg) {
  17102. return typeof arg === 'object' && arg !== null;
  17103. }
  17104. exports.isObject = isObject;
  17105. function isDate(d) {
  17106. return objectToString(d) === '[object Date]';
  17107. }
  17108. exports.isDate = isDate;
  17109. function isError(e) {
  17110. return (objectToString(e) === '[object Error]' || e instanceof Error);
  17111. }
  17112. exports.isError = isError;
  17113. function isFunction(arg) {
  17114. return typeof arg === 'function';
  17115. }
  17116. exports.isFunction = isFunction;
  17117. function isPrimitive(arg) {
  17118. return arg === null ||
  17119. typeof arg === 'boolean' ||
  17120. typeof arg === 'number' ||
  17121. typeof arg === 'string' ||
  17122. typeof arg === 'symbol' || // ES6 symbol
  17123. typeof arg === 'undefined';
  17124. }
  17125. exports.isPrimitive = isPrimitive;
  17126. exports.isBuffer = Buffer.isBuffer;
  17127. function objectToString(o) {
  17128. return Object.prototype.toString.call(o);
  17129. }
  17130. }).call(this,{"isBuffer":require("../../is-buffer/index.js")})
  17131. },{"../../is-buffer/index.js":308}],295:[function(require,module,exports){
  17132. /*
  17133. * Date Format 1.2.3
  17134. * (c) 2007-2009 Steven Levithan <stevenlevithan.com>
  17135. * MIT license
  17136. *
  17137. * Includes enhancements by Scott Trenda <scott.trenda.net>
  17138. * and Kris Kowal <cixar.com/~kris.kowal/>
  17139. *
  17140. * Accepts a date, a mask, or a date and a mask.
  17141. * Returns a formatted version of the given date.
  17142. * The date defaults to the current date/time.
  17143. * The mask defaults to dateFormat.masks.default.
  17144. */
  17145. (function(global) {
  17146. 'use strict';
  17147. var dateFormat = (function() {
  17148. var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZWN]|'[^']*'|'[^']*'/g;
  17149. var timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g;
  17150. var timezoneClip = /[^-+\dA-Z]/g;
  17151. // Regexes and supporting functions are cached through closure
  17152. return function (date, mask, utc, gmt) {
  17153. // You can't provide utc if you skip other args (use the 'UTC:' mask prefix)
  17154. if (arguments.length === 1 && kindOf(date) === 'string' && !/\d/.test(date)) {
  17155. mask = date;
  17156. date = undefined;
  17157. }
  17158. date = date || new Date;
  17159. if(!(date instanceof Date)) {
  17160. date = new Date(date);
  17161. }
  17162. if (isNaN(date)) {
  17163. throw TypeError('Invalid date');
  17164. }
  17165. mask = String(dateFormat.masks[mask] || mask || dateFormat.masks['default']);
  17166. // Allow setting the utc/gmt argument via the mask
  17167. var maskSlice = mask.slice(0, 4);
  17168. if (maskSlice === 'UTC:' || maskSlice === 'GMT:') {
  17169. mask = mask.slice(4);
  17170. utc = true;
  17171. if (maskSlice === 'GMT:') {
  17172. gmt = true;
  17173. }
  17174. }
  17175. var _ = utc ? 'getUTC' : 'get';
  17176. var d = date[_ + 'Date']();
  17177. var D = date[_ + 'Day']();
  17178. var m = date[_ + 'Month']();
  17179. var y = date[_ + 'FullYear']();
  17180. var H = date[_ + 'Hours']();
  17181. var M = date[_ + 'Minutes']();
  17182. var s = date[_ + 'Seconds']();
  17183. var L = date[_ + 'Milliseconds']();
  17184. var o = utc ? 0 : date.getTimezoneOffset();
  17185. var W = getWeek(date);
  17186. var N = getDayOfWeek(date);
  17187. var flags = {
  17188. d: d,
  17189. dd: pad(d),
  17190. ddd: dateFormat.i18n.dayNames[D],
  17191. dddd: dateFormat.i18n.dayNames[D + 7],
  17192. m: m + 1,
  17193. mm: pad(m + 1),
  17194. mmm: dateFormat.i18n.monthNames[m],
  17195. mmmm: dateFormat.i18n.monthNames[m + 12],
  17196. yy: String(y).slice(2),
  17197. yyyy: y,
  17198. h: H % 12 || 12,
  17199. hh: pad(H % 12 || 12),
  17200. H: H,
  17201. HH: pad(H),
  17202. M: M,
  17203. MM: pad(M),
  17204. s: s,
  17205. ss: pad(s),
  17206. l: pad(L, 3),
  17207. L: pad(Math.round(L / 10)),
  17208. t: H < 12 ? 'a' : 'p',
  17209. tt: H < 12 ? 'am' : 'pm',
  17210. T: H < 12 ? 'A' : 'P',
  17211. TT: H < 12 ? 'AM' : 'PM',
  17212. Z: gmt ? 'GMT' : utc ? 'UTC' : (String(date).match(timezone) || ['']).pop().replace(timezoneClip, ''),
  17213. o: (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
  17214. S: ['th', 'st', 'nd', 'rd'][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10],
  17215. W: W,
  17216. N: N
  17217. };
  17218. return mask.replace(token, function (match) {
  17219. if (match in flags) {
  17220. return flags[match];
  17221. }
  17222. return match.slice(1, match.length - 1);
  17223. });
  17224. };
  17225. })();
  17226. dateFormat.masks = {
  17227. 'default': 'ddd mmm dd yyyy HH:MM:ss',
  17228. 'shortDate': 'm/d/yy',
  17229. 'mediumDate': 'mmm d, yyyy',
  17230. 'longDate': 'mmmm d, yyyy',
  17231. 'fullDate': 'dddd, mmmm d, yyyy',
  17232. 'shortTime': 'h:MM TT',
  17233. 'mediumTime': 'h:MM:ss TT',
  17234. 'longTime': 'h:MM:ss TT Z',
  17235. 'isoDate': 'yyyy-mm-dd',
  17236. 'isoTime': 'HH:MM:ss',
  17237. 'isoDateTime': 'yyyy-mm-dd\'T\'HH:MM:sso',
  17238. 'isoUtcDateTime': 'UTC:yyyy-mm-dd\'T\'HH:MM:ss\'Z\'',
  17239. 'expiresHeaderFormat': 'ddd, dd mmm yyyy HH:MM:ss Z'
  17240. };
  17241. // Internationalization strings
  17242. dateFormat.i18n = {
  17243. dayNames: [
  17244. 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat',
  17245. 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'
  17246. ],
  17247. monthNames: [
  17248. 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec',
  17249. 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'
  17250. ]
  17251. };
  17252. function pad(val, len) {
  17253. val = String(val);
  17254. len = len || 2;
  17255. while (val.length < len) {
  17256. val = '0' + val;
  17257. }
  17258. return val;
  17259. }
  17260. /**
  17261. * Get the ISO 8601 week number
  17262. * Based on comments from
  17263. * http://techblog.procurios.nl/k/n618/news/view/33796/14863/Calculate-ISO-8601-week-and-year-in-javascript.html
  17264. *
  17265. * @param {Object} `date`
  17266. * @return {Number}
  17267. */
  17268. function getWeek(date) {
  17269. // Remove time components of date
  17270. var targetThursday = new Date(date.getFullYear(), date.getMonth(), date.getDate());
  17271. // Change date to Thursday same week
  17272. targetThursday.setDate(targetThursday.getDate() - ((targetThursday.getDay() + 6) % 7) + 3);
  17273. // Take January 4th as it is always in week 1 (see ISO 8601)
  17274. var firstThursday = new Date(targetThursday.getFullYear(), 0, 4);
  17275. // Change date to Thursday same week
  17276. firstThursday.setDate(firstThursday.getDate() - ((firstThursday.getDay() + 6) % 7) + 3);
  17277. // Check if daylight-saving-time-switch occurred and correct for it
  17278. var ds = targetThursday.getTimezoneOffset() - firstThursday.getTimezoneOffset();
  17279. targetThursday.setHours(targetThursday.getHours() - ds);
  17280. // Number of weeks between target Thursday and first Thursday
  17281. var weekDiff = (targetThursday - firstThursday) / (86400000*7);
  17282. return 1 + Math.floor(weekDiff);
  17283. }
  17284. /**
  17285. * Get ISO-8601 numeric representation of the day of the week
  17286. * 1 (for Monday) through 7 (for Sunday)
  17287. *
  17288. * @param {Object} `date`
  17289. * @return {Number}
  17290. */
  17291. function getDayOfWeek(date) {
  17292. var dow = date.getDay();
  17293. if(dow === 0) {
  17294. dow = 7;
  17295. }
  17296. return dow;
  17297. }
  17298. /**
  17299. * kind-of shortcut
  17300. * @param {*} val
  17301. * @return {String}
  17302. */
  17303. function kindOf(val) {
  17304. if (val === null) {
  17305. return 'null';
  17306. }
  17307. if (val === undefined) {
  17308. return 'undefined';
  17309. }
  17310. if (typeof val !== 'object') {
  17311. return typeof val;
  17312. }
  17313. if (Array.isArray(val)) {
  17314. return 'array';
  17315. }
  17316. return {}.toString.call(val)
  17317. .slice(8, -1).toLowerCase();
  17318. };
  17319. if (typeof define === 'function' && define.amd) {
  17320. define(function () {
  17321. return dateFormat;
  17322. });
  17323. } else if (typeof exports === 'object') {
  17324. module.exports = dateFormat;
  17325. } else {
  17326. global.dateFormat = dateFormat;
  17327. }
  17328. })(this);
  17329. },{}],296:[function(require,module,exports){
  17330. /*!
  17331. * escape-html
  17332. * Copyright(c) 2012-2013 TJ Holowaychuk
  17333. * Copyright(c) 2015 Andreas Lubbe
  17334. * Copyright(c) 2015 Tiancheng "Timothy" Gu
  17335. * MIT Licensed
  17336. */
  17337. 'use strict';
  17338. /**
  17339. * Module variables.
  17340. * @private
  17341. */
  17342. var matchHtmlRegExp = /["'&<>]/;
  17343. /**
  17344. * Module exports.
  17345. * @public
  17346. */
  17347. module.exports = escapeHtml;
  17348. /**
  17349. * Escape special characters in the given string of html.
  17350. *
  17351. * @param {string} string The string to escape for inserting into HTML
  17352. * @return {string}
  17353. * @public
  17354. */
  17355. function escapeHtml(string) {
  17356. var str = '' + string;
  17357. var match = matchHtmlRegExp.exec(str);
  17358. if (!match) {
  17359. return str;
  17360. }
  17361. var escape;
  17362. var html = '';
  17363. var index = 0;
  17364. var lastIndex = 0;
  17365. for (index = match.index; index < str.length; index++) {
  17366. switch (str.charCodeAt(index)) {
  17367. case 34: // "
  17368. escape = '&quot;';
  17369. break;
  17370. case 38: // &
  17371. escape = '&amp;';
  17372. break;
  17373. case 39: // '
  17374. escape = '&#39;';
  17375. break;
  17376. case 60: // <
  17377. escape = '&lt;';
  17378. break;
  17379. case 62: // >
  17380. escape = '&gt;';
  17381. break;
  17382. default:
  17383. continue;
  17384. }
  17385. if (lastIndex !== index) {
  17386. html += str.substring(lastIndex, index);
  17387. }
  17388. lastIndex = index + 1;
  17389. html += escape;
  17390. }
  17391. return lastIndex !== index
  17392. ? html + str.substring(lastIndex, index)
  17393. : html;
  17394. }
  17395. },{}],297:[function(require,module,exports){
  17396. // Copyright Joyent, Inc. and other Node contributors.
  17397. //
  17398. // Permission is hereby granted, free of charge, to any person obtaining a
  17399. // copy of this software and associated documentation files (the
  17400. // "Software"), to deal in the Software without restriction, including
  17401. // without limitation the rights to use, copy, modify, merge, publish,
  17402. // distribute, sublicense, and/or sell copies of the Software, and to permit
  17403. // persons to whom the Software is furnished to do so, subject to the
  17404. // following conditions:
  17405. //
  17406. // The above copyright notice and this permission notice shall be included
  17407. // in all copies or substantial portions of the Software.
  17408. //
  17409. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  17410. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17411. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  17412. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  17413. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  17414. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  17415. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  17416. var objectCreate = Object.create || objectCreatePolyfill
  17417. var objectKeys = Object.keys || objectKeysPolyfill
  17418. var bind = Function.prototype.bind || functionBindPolyfill
  17419. function EventEmitter() {
  17420. if (!this._events || !Object.prototype.hasOwnProperty.call(this, '_events')) {
  17421. this._events = objectCreate(null);
  17422. this._eventsCount = 0;
  17423. }
  17424. this._maxListeners = this._maxListeners || undefined;
  17425. }
  17426. module.exports = EventEmitter;
  17427. // Backwards-compat with node 0.10.x
  17428. EventEmitter.EventEmitter = EventEmitter;
  17429. EventEmitter.prototype._events = undefined;
  17430. EventEmitter.prototype._maxListeners = undefined;
  17431. // By default EventEmitters will print a warning if more than 10 listeners are
  17432. // added to it. This is a useful default which helps finding memory leaks.
  17433. var defaultMaxListeners = 10;
  17434. var hasDefineProperty;
  17435. try {
  17436. var o = {};
  17437. if (Object.defineProperty) Object.defineProperty(o, 'x', { value: 0 });
  17438. hasDefineProperty = o.x === 0;
  17439. } catch (err) { hasDefineProperty = false }
  17440. if (hasDefineProperty) {
  17441. Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
  17442. enumerable: true,
  17443. get: function() {
  17444. return defaultMaxListeners;
  17445. },
  17446. set: function(arg) {
  17447. // check whether the input is a positive number (whose value is zero or
  17448. // greater and not a NaN).
  17449. if (typeof arg !== 'number' || arg < 0 || arg !== arg)
  17450. throw new TypeError('"defaultMaxListeners" must be a positive number');
  17451. defaultMaxListeners = arg;
  17452. }
  17453. });
  17454. } else {
  17455. EventEmitter.defaultMaxListeners = defaultMaxListeners;
  17456. }
  17457. // Obviously not all Emitters should be limited to 10. This function allows
  17458. // that to be increased. Set to zero for unlimited.
  17459. EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
  17460. if (typeof n !== 'number' || n < 0 || isNaN(n))
  17461. throw new TypeError('"n" argument must be a positive number');
  17462. this._maxListeners = n;
  17463. return this;
  17464. };
  17465. function $getMaxListeners(that) {
  17466. if (that._maxListeners === undefined)
  17467. return EventEmitter.defaultMaxListeners;
  17468. return that._maxListeners;
  17469. }
  17470. EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
  17471. return $getMaxListeners(this);
  17472. };
  17473. // These standalone emit* functions are used to optimize calling of event
  17474. // handlers for fast cases because emit() itself often has a variable number of
  17475. // arguments and can be deoptimized because of that. These functions always have
  17476. // the same number of arguments and thus do not get deoptimized, so the code
  17477. // inside them can execute faster.
  17478. function emitNone(handler, isFn, self) {
  17479. if (isFn)
  17480. handler.call(self);
  17481. else {
  17482. var len = handler.length;
  17483. var listeners = arrayClone(handler, len);
  17484. for (var i = 0; i < len; ++i)
  17485. listeners[i].call(self);
  17486. }
  17487. }
  17488. function emitOne(handler, isFn, self, arg1) {
  17489. if (isFn)
  17490. handler.call(self, arg1);
  17491. else {
  17492. var len = handler.length;
  17493. var listeners = arrayClone(handler, len);
  17494. for (var i = 0; i < len; ++i)
  17495. listeners[i].call(self, arg1);
  17496. }
  17497. }
  17498. function emitTwo(handler, isFn, self, arg1, arg2) {
  17499. if (isFn)
  17500. handler.call(self, arg1, arg2);
  17501. else {
  17502. var len = handler.length;
  17503. var listeners = arrayClone(handler, len);
  17504. for (var i = 0; i < len; ++i)
  17505. listeners[i].call(self, arg1, arg2);
  17506. }
  17507. }
  17508. function emitThree(handler, isFn, self, arg1, arg2, arg3) {
  17509. if (isFn)
  17510. handler.call(self, arg1, arg2, arg3);
  17511. else {
  17512. var len = handler.length;
  17513. var listeners = arrayClone(handler, len);
  17514. for (var i = 0; i < len; ++i)
  17515. listeners[i].call(self, arg1, arg2, arg3);
  17516. }
  17517. }
  17518. function emitMany(handler, isFn, self, args) {
  17519. if (isFn)
  17520. handler.apply(self, args);
  17521. else {
  17522. var len = handler.length;
  17523. var listeners = arrayClone(handler, len);
  17524. for (var i = 0; i < len; ++i)
  17525. listeners[i].apply(self, args);
  17526. }
  17527. }
  17528. EventEmitter.prototype.emit = function emit(type) {
  17529. var er, handler, len, args, i, events;
  17530. var doError = (type === 'error');
  17531. events = this._events;
  17532. if (events)
  17533. doError = (doError && events.error == null);
  17534. else if (!doError)
  17535. return false;
  17536. // If there is no 'error' event listener then throw.
  17537. if (doError) {
  17538. if (arguments.length > 1)
  17539. er = arguments[1];
  17540. if (er instanceof Error) {
  17541. throw er; // Unhandled 'error' event
  17542. } else {
  17543. // At least give some kind of context to the user
  17544. var err = new Error('Unhandled "error" event. (' + er + ')');
  17545. err.context = er;
  17546. throw err;
  17547. }
  17548. return false;
  17549. }
  17550. handler = events[type];
  17551. if (!handler)
  17552. return false;
  17553. var isFn = typeof handler === 'function';
  17554. len = arguments.length;
  17555. switch (len) {
  17556. // fast cases
  17557. case 1:
  17558. emitNone(handler, isFn, this);
  17559. break;
  17560. case 2:
  17561. emitOne(handler, isFn, this, arguments[1]);
  17562. break;
  17563. case 3:
  17564. emitTwo(handler, isFn, this, arguments[1], arguments[2]);
  17565. break;
  17566. case 4:
  17567. emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
  17568. break;
  17569. // slower
  17570. default:
  17571. args = new Array(len - 1);
  17572. for (i = 1; i < len; i++)
  17573. args[i - 1] = arguments[i];
  17574. emitMany(handler, isFn, this, args);
  17575. }
  17576. return true;
  17577. };
  17578. function _addListener(target, type, listener, prepend) {
  17579. var m;
  17580. var events;
  17581. var existing;
  17582. if (typeof listener !== 'function')
  17583. throw new TypeError('"listener" argument must be a function');
  17584. events = target._events;
  17585. if (!events) {
  17586. events = target._events = objectCreate(null);
  17587. target._eventsCount = 0;
  17588. } else {
  17589. // To avoid recursion in the case that type === "newListener"! Before
  17590. // adding it to the listeners, first emit "newListener".
  17591. if (events.newListener) {
  17592. target.emit('newListener', type,
  17593. listener.listener ? listener.listener : listener);
  17594. // Re-assign `events` because a newListener handler could have caused the
  17595. // this._events to be assigned to a new object
  17596. events = target._events;
  17597. }
  17598. existing = events[type];
  17599. }
  17600. if (!existing) {
  17601. // Optimize the case of one listener. Don't need the extra array object.
  17602. existing = events[type] = listener;
  17603. ++target._eventsCount;
  17604. } else {
  17605. if (typeof existing === 'function') {
  17606. // Adding the second element, need to change to array.
  17607. existing = events[type] =
  17608. prepend ? [listener, existing] : [existing, listener];
  17609. } else {
  17610. // If we've already got an array, just append.
  17611. if (prepend) {
  17612. existing.unshift(listener);
  17613. } else {
  17614. existing.push(listener);
  17615. }
  17616. }
  17617. // Check for listener leak
  17618. if (!existing.warned) {
  17619. m = $getMaxListeners(target);
  17620. if (m && m > 0 && existing.length > m) {
  17621. existing.warned = true;
  17622. var w = new Error('Possible EventEmitter memory leak detected. ' +
  17623. existing.length + ' "' + String(type) + '" listeners ' +
  17624. 'added. Use emitter.setMaxListeners() to ' +
  17625. 'increase limit.');
  17626. w.name = 'MaxListenersExceededWarning';
  17627. w.emitter = target;
  17628. w.type = type;
  17629. w.count = existing.length;
  17630. if (typeof console === 'object' && console.warn) {
  17631. console.warn('%s: %s', w.name, w.message);
  17632. }
  17633. }
  17634. }
  17635. }
  17636. return target;
  17637. }
  17638. EventEmitter.prototype.addListener = function addListener(type, listener) {
  17639. return _addListener(this, type, listener, false);
  17640. };
  17641. EventEmitter.prototype.on = EventEmitter.prototype.addListener;
  17642. EventEmitter.prototype.prependListener =
  17643. function prependListener(type, listener) {
  17644. return _addListener(this, type, listener, true);
  17645. };
  17646. function onceWrapper() {
  17647. if (!this.fired) {
  17648. this.target.removeListener(this.type, this.wrapFn);
  17649. this.fired = true;
  17650. switch (arguments.length) {
  17651. case 0:
  17652. return this.listener.call(this.target);
  17653. case 1:
  17654. return this.listener.call(this.target, arguments[0]);
  17655. case 2:
  17656. return this.listener.call(this.target, arguments[0], arguments[1]);
  17657. case 3:
  17658. return this.listener.call(this.target, arguments[0], arguments[1],
  17659. arguments[2]);
  17660. default:
  17661. var args = new Array(arguments.length);
  17662. for (var i = 0; i < args.length; ++i)
  17663. args[i] = arguments[i];
  17664. this.listener.apply(this.target, args);
  17665. }
  17666. }
  17667. }
  17668. function _onceWrap(target, type, listener) {
  17669. var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
  17670. var wrapped = bind.call(onceWrapper, state);
  17671. wrapped.listener = listener;
  17672. state.wrapFn = wrapped;
  17673. return wrapped;
  17674. }
  17675. EventEmitter.prototype.once = function once(type, listener) {
  17676. if (typeof listener !== 'function')
  17677. throw new TypeError('"listener" argument must be a function');
  17678. this.on(type, _onceWrap(this, type, listener));
  17679. return this;
  17680. };
  17681. EventEmitter.prototype.prependOnceListener =
  17682. function prependOnceListener(type, listener) {
  17683. if (typeof listener !== 'function')
  17684. throw new TypeError('"listener" argument must be a function');
  17685. this.prependListener(type, _onceWrap(this, type, listener));
  17686. return this;
  17687. };
  17688. // Emits a 'removeListener' event if and only if the listener was removed.
  17689. EventEmitter.prototype.removeListener =
  17690. function removeListener(type, listener) {
  17691. var list, events, position, i, originalListener;
  17692. if (typeof listener !== 'function')
  17693. throw new TypeError('"listener" argument must be a function');
  17694. events = this._events;
  17695. if (!events)
  17696. return this;
  17697. list = events[type];
  17698. if (!list)
  17699. return this;
  17700. if (list === listener || list.listener === listener) {
  17701. if (--this._eventsCount === 0)
  17702. this._events = objectCreate(null);
  17703. else {
  17704. delete events[type];
  17705. if (events.removeListener)
  17706. this.emit('removeListener', type, list.listener || listener);
  17707. }
  17708. } else if (typeof list !== 'function') {
  17709. position = -1;
  17710. for (i = list.length - 1; i >= 0; i--) {
  17711. if (list[i] === listener || list[i].listener === listener) {
  17712. originalListener = list[i].listener;
  17713. position = i;
  17714. break;
  17715. }
  17716. }
  17717. if (position < 0)
  17718. return this;
  17719. if (position === 0)
  17720. list.shift();
  17721. else
  17722. spliceOne(list, position);
  17723. if (list.length === 1)
  17724. events[type] = list[0];
  17725. if (events.removeListener)
  17726. this.emit('removeListener', type, originalListener || listener);
  17727. }
  17728. return this;
  17729. };
  17730. EventEmitter.prototype.removeAllListeners =
  17731. function removeAllListeners(type) {
  17732. var listeners, events, i;
  17733. events = this._events;
  17734. if (!events)
  17735. return this;
  17736. // not listening for removeListener, no need to emit
  17737. if (!events.removeListener) {
  17738. if (arguments.length === 0) {
  17739. this._events = objectCreate(null);
  17740. this._eventsCount = 0;
  17741. } else if (events[type]) {
  17742. if (--this._eventsCount === 0)
  17743. this._events = objectCreate(null);
  17744. else
  17745. delete events[type];
  17746. }
  17747. return this;
  17748. }
  17749. // emit removeListener for all listeners on all events
  17750. if (arguments.length === 0) {
  17751. var keys = objectKeys(events);
  17752. var key;
  17753. for (i = 0; i < keys.length; ++i) {
  17754. key = keys[i];
  17755. if (key === 'removeListener') continue;
  17756. this.removeAllListeners(key);
  17757. }
  17758. this.removeAllListeners('removeListener');
  17759. this._events = objectCreate(null);
  17760. this._eventsCount = 0;
  17761. return this;
  17762. }
  17763. listeners = events[type];
  17764. if (typeof listeners === 'function') {
  17765. this.removeListener(type, listeners);
  17766. } else if (listeners) {
  17767. // LIFO order
  17768. for (i = listeners.length - 1; i >= 0; i--) {
  17769. this.removeListener(type, listeners[i]);
  17770. }
  17771. }
  17772. return this;
  17773. };
  17774. function _listeners(target, type, unwrap) {
  17775. var events = target._events;
  17776. if (!events)
  17777. return [];
  17778. var evlistener = events[type];
  17779. if (!evlistener)
  17780. return [];
  17781. if (typeof evlistener === 'function')
  17782. return unwrap ? [evlistener.listener || evlistener] : [evlistener];
  17783. return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
  17784. }
  17785. EventEmitter.prototype.listeners = function listeners(type) {
  17786. return _listeners(this, type, true);
  17787. };
  17788. EventEmitter.prototype.rawListeners = function rawListeners(type) {
  17789. return _listeners(this, type, false);
  17790. };
  17791. EventEmitter.listenerCount = function(emitter, type) {
  17792. if (typeof emitter.listenerCount === 'function') {
  17793. return emitter.listenerCount(type);
  17794. } else {
  17795. return listenerCount.call(emitter, type);
  17796. }
  17797. };
  17798. EventEmitter.prototype.listenerCount = listenerCount;
  17799. function listenerCount(type) {
  17800. var events = this._events;
  17801. if (events) {
  17802. var evlistener = events[type];
  17803. if (typeof evlistener === 'function') {
  17804. return 1;
  17805. } else if (evlistener) {
  17806. return evlistener.length;
  17807. }
  17808. }
  17809. return 0;
  17810. }
  17811. EventEmitter.prototype.eventNames = function eventNames() {
  17812. return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
  17813. };
  17814. // About 1.5x faster than the two-arg version of Array#splice().
  17815. function spliceOne(list, index) {
  17816. for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1)
  17817. list[i] = list[k];
  17818. list.pop();
  17819. }
  17820. function arrayClone(arr, n) {
  17821. var copy = new Array(n);
  17822. for (var i = 0; i < n; ++i)
  17823. copy[i] = arr[i];
  17824. return copy;
  17825. }
  17826. function unwrapListeners(arr) {
  17827. var ret = new Array(arr.length);
  17828. for (var i = 0; i < ret.length; ++i) {
  17829. ret[i] = arr[i].listener || arr[i];
  17830. }
  17831. return ret;
  17832. }
  17833. function objectCreatePolyfill(proto) {
  17834. var F = function() {};
  17835. F.prototype = proto;
  17836. return new F;
  17837. }
  17838. function objectKeysPolyfill(obj) {
  17839. var keys = [];
  17840. for (var k in obj) if (Object.prototype.hasOwnProperty.call(obj, k)) {
  17841. keys.push(k);
  17842. }
  17843. return k;
  17844. }
  17845. function functionBindPolyfill(context) {
  17846. var fn = this;
  17847. return function () {
  17848. return fn.apply(context, arguments);
  17849. };
  17850. }
  17851. },{}],298:[function(require,module,exports){
  17852. var http = require('http')
  17853. var url = require('url')
  17854. var https = module.exports
  17855. for (var key in http) {
  17856. if (http.hasOwnProperty(key)) https[key] = http[key]
  17857. }
  17858. https.request = function (params, cb) {
  17859. params = validateParams(params)
  17860. return http.request.call(this, params, cb)
  17861. }
  17862. https.get = function (params, cb) {
  17863. params = validateParams(params)
  17864. return http.get.call(this, params, cb)
  17865. }
  17866. function validateParams (params) {
  17867. if (typeof params === 'string') {
  17868. params = url.parse(params)
  17869. }
  17870. if (!params.protocol) {
  17871. params.protocol = 'https:'
  17872. }
  17873. if (params.protocol !== 'https:') {
  17874. throw new Error('Protocol "' + params.protocol + '" not supported. Expected "https:"')
  17875. }
  17876. return params
  17877. }
  17878. },{"http":79,"url":394}],299:[function(require,module,exports){
  17879. /*!
  17880. * humanize-ms - index.js
  17881. * Copyright(c) 2014 dead_horse <dead_horse@qq.com>
  17882. * MIT Licensed
  17883. */
  17884. 'use strict';
  17885. /**
  17886. * Module dependencies.
  17887. */
  17888. var util = require('util');
  17889. var ms = require('ms');
  17890. module.exports = function (t) {
  17891. if (typeof t === 'number') return t;
  17892. var r = ms(t);
  17893. if (r === undefined) {
  17894. var err = new Error(util.format('humanize-ms(%j) result undefined', t));
  17895. console.warn(err.stack);
  17896. }
  17897. return r;
  17898. };
  17899. },{"ms":315,"util":346}],300:[function(require,module,exports){
  17900. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  17901. var e, m
  17902. var eLen = (nBytes * 8) - mLen - 1
  17903. var eMax = (1 << eLen) - 1
  17904. var eBias = eMax >> 1
  17905. var nBits = -7
  17906. var i = isLE ? (nBytes - 1) : 0
  17907. var d = isLE ? -1 : 1
  17908. var s = buffer[offset + i]
  17909. i += d
  17910. e = s & ((1 << (-nBits)) - 1)
  17911. s >>= (-nBits)
  17912. nBits += eLen
  17913. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  17914. m = e & ((1 << (-nBits)) - 1)
  17915. e >>= (-nBits)
  17916. nBits += mLen
  17917. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  17918. if (e === 0) {
  17919. e = 1 - eBias
  17920. } else if (e === eMax) {
  17921. return m ? NaN : ((s ? -1 : 1) * Infinity)
  17922. } else {
  17923. m = m + Math.pow(2, mLen)
  17924. e = e - eBias
  17925. }
  17926. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  17927. }
  17928. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  17929. var e, m, c
  17930. var eLen = (nBytes * 8) - mLen - 1
  17931. var eMax = (1 << eLen) - 1
  17932. var eBias = eMax >> 1
  17933. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  17934. var i = isLE ? 0 : (nBytes - 1)
  17935. var d = isLE ? 1 : -1
  17936. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  17937. value = Math.abs(value)
  17938. if (isNaN(value) || value === Infinity) {
  17939. m = isNaN(value) ? 1 : 0
  17940. e = eMax
  17941. } else {
  17942. e = Math.floor(Math.log(value) / Math.LN2)
  17943. if (value * (c = Math.pow(2, -e)) < 1) {
  17944. e--
  17945. c *= 2
  17946. }
  17947. if (e + eBias >= 1) {
  17948. value += rt / c
  17949. } else {
  17950. value += rt * Math.pow(2, 1 - eBias)
  17951. }
  17952. if (value * c >= 2) {
  17953. e++
  17954. c /= 2
  17955. }
  17956. if (e + eBias >= eMax) {
  17957. m = 0
  17958. e = eMax
  17959. } else if (e + eBias >= 1) {
  17960. m = ((value * c) - 1) * Math.pow(2, mLen)
  17961. e = e + eBias
  17962. } else {
  17963. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  17964. e = 0
  17965. }
  17966. }
  17967. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  17968. e = (e << mLen) | m
  17969. eLen += mLen
  17970. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  17971. buffer[offset + i - d] |= s * 128
  17972. }
  17973. },{}],301:[function(require,module,exports){
  17974. 'use strict';
  17975. var types = [
  17976. require('./nextTick'),
  17977. require('./queueMicrotask'),
  17978. require('./mutation.js'),
  17979. require('./messageChannel'),
  17980. require('./stateChange'),
  17981. require('./timeout')
  17982. ];
  17983. var draining;
  17984. var currentQueue;
  17985. var queueIndex = -1;
  17986. var queue = [];
  17987. var scheduled = false;
  17988. function cleanUpNextTick() {
  17989. if (!draining || !currentQueue) {
  17990. return;
  17991. }
  17992. draining = false;
  17993. if (currentQueue.length) {
  17994. queue = currentQueue.concat(queue);
  17995. } else {
  17996. queueIndex = -1;
  17997. }
  17998. if (queue.length) {
  17999. nextTick();
  18000. }
  18001. }
  18002. //named nextTick for less confusing stack traces
  18003. function nextTick() {
  18004. if (draining) {
  18005. return;
  18006. }
  18007. scheduled = false;
  18008. draining = true;
  18009. var len = queue.length;
  18010. var timeout = setTimeout(cleanUpNextTick);
  18011. while (len) {
  18012. currentQueue = queue;
  18013. queue = [];
  18014. while (currentQueue && ++queueIndex < len) {
  18015. currentQueue[queueIndex].run();
  18016. }
  18017. queueIndex = -1;
  18018. len = queue.length;
  18019. }
  18020. currentQueue = null;
  18021. queueIndex = -1;
  18022. draining = false;
  18023. clearTimeout(timeout);
  18024. }
  18025. var scheduleDrain;
  18026. var i = -1;
  18027. var len = types.length;
  18028. while (++i < len) {
  18029. if (types[i] && types[i].test && types[i].test()) {
  18030. scheduleDrain = types[i].install(nextTick);
  18031. break;
  18032. }
  18033. }
  18034. // v8 likes predictible objects
  18035. function Item(fun, array) {
  18036. this.fun = fun;
  18037. this.array = array;
  18038. }
  18039. Item.prototype.run = function () {
  18040. var fun = this.fun;
  18041. var array = this.array;
  18042. switch (array.length) {
  18043. case 0:
  18044. return fun();
  18045. case 1:
  18046. return fun(array[0]);
  18047. case 2:
  18048. return fun(array[0], array[1]);
  18049. case 3:
  18050. return fun(array[0], array[1], array[2]);
  18051. default:
  18052. return fun.apply(null, array);
  18053. }
  18054. };
  18055. module.exports = immediate;
  18056. function immediate(task) {
  18057. var args = new Array(arguments.length - 1);
  18058. if (arguments.length > 1) {
  18059. for (var i = 1; i < arguments.length; i++) {
  18060. args[i - 1] = arguments[i];
  18061. }
  18062. }
  18063. queue.push(new Item(task, args));
  18064. if (!scheduled && !draining) {
  18065. scheduled = true;
  18066. scheduleDrain();
  18067. }
  18068. }
  18069. },{"./messageChannel":302,"./mutation.js":303,"./nextTick":78,"./queueMicrotask":304,"./stateChange":305,"./timeout":306}],302:[function(require,module,exports){
  18070. (function (global){
  18071. 'use strict';
  18072. exports.test = function () {
  18073. if (global.setImmediate) {
  18074. // we can only get here in IE10
  18075. // which doesn't handel postMessage well
  18076. return false;
  18077. }
  18078. return typeof global.MessageChannel !== 'undefined';
  18079. };
  18080. exports.install = function (func) {
  18081. var channel = new global.MessageChannel();
  18082. channel.port1.onmessage = func;
  18083. return function () {
  18084. channel.port2.postMessage(0);
  18085. };
  18086. };
  18087. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  18088. },{}],303:[function(require,module,exports){
  18089. (function (global){
  18090. 'use strict';
  18091. //based off rsvp https://github.com/tildeio/rsvp.js
  18092. //license https://github.com/tildeio/rsvp.js/blob/master/LICENSE
  18093. //https://github.com/tildeio/rsvp.js/blob/master/lib/rsvp/asap.js
  18094. var Mutation = global.MutationObserver || global.WebKitMutationObserver;
  18095. exports.test = function () {
  18096. return Mutation;
  18097. };
  18098. exports.install = function (handle) {
  18099. var called = 0;
  18100. var observer = new Mutation(handle);
  18101. var element = global.document.createTextNode('');
  18102. observer.observe(element, {
  18103. characterData: true
  18104. });
  18105. return function () {
  18106. element.data = (called = ++called % 2);
  18107. };
  18108. };
  18109. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  18110. },{}],304:[function(require,module,exports){
  18111. (function (global){
  18112. 'use strict';
  18113. exports.test = function () {
  18114. return typeof global.queueMicrotask === 'function';
  18115. };
  18116. exports.install = function (func) {
  18117. return function () {
  18118. global.queueMicrotask(func);
  18119. };
  18120. };
  18121. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  18122. },{}],305:[function(require,module,exports){
  18123. (function (global){
  18124. 'use strict';
  18125. exports.test = function () {
  18126. return 'document' in global && 'onreadystatechange' in global.document.createElement('script');
  18127. };
  18128. exports.install = function (handle) {
  18129. return function () {
  18130. // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
  18131. // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
  18132. var scriptEl = global.document.createElement('script');
  18133. scriptEl.onreadystatechange = function () {
  18134. handle();
  18135. scriptEl.onreadystatechange = null;
  18136. scriptEl.parentNode.removeChild(scriptEl);
  18137. scriptEl = null;
  18138. };
  18139. global.document.documentElement.appendChild(scriptEl);
  18140. return handle;
  18141. };
  18142. };
  18143. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  18144. },{}],306:[function(require,module,exports){
  18145. 'use strict';
  18146. exports.test = function () {
  18147. return true;
  18148. };
  18149. exports.install = function (t) {
  18150. return function () {
  18151. setTimeout(t, 0);
  18152. };
  18153. };
  18154. },{}],307:[function(require,module,exports){
  18155. if (typeof Object.create === 'function') {
  18156. // implementation from standard node.js 'util' module
  18157. module.exports = function inherits(ctor, superCtor) {
  18158. if (superCtor) {
  18159. ctor.super_ = superCtor
  18160. ctor.prototype = Object.create(superCtor.prototype, {
  18161. constructor: {
  18162. value: ctor,
  18163. enumerable: false,
  18164. writable: true,
  18165. configurable: true
  18166. }
  18167. })
  18168. }
  18169. };
  18170. } else {
  18171. // old school shim for old browsers
  18172. module.exports = function inherits(ctor, superCtor) {
  18173. if (superCtor) {
  18174. ctor.super_ = superCtor
  18175. var TempCtor = function () {}
  18176. TempCtor.prototype = superCtor.prototype
  18177. ctor.prototype = new TempCtor()
  18178. ctor.prototype.constructor = ctor
  18179. }
  18180. }
  18181. }
  18182. },{}],308:[function(require,module,exports){
  18183. /*!
  18184. * Determine if an object is a Buffer
  18185. *
  18186. * @author Feross Aboukhadijeh <https://feross.org>
  18187. * @license MIT
  18188. */
  18189. // The _isBuffer check is for Safari 5-7 support, because it's missing
  18190. // Object.prototype.constructor. Remove this eventually
  18191. module.exports = function (obj) {
  18192. return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
  18193. }
  18194. function isBuffer (obj) {
  18195. return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
  18196. }
  18197. // For Node v0.10 support. Remove this eventually.
  18198. function isSlowBuffer (obj) {
  18199. return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
  18200. }
  18201. },{}],309:[function(require,module,exports){
  18202. var toString = {}.toString;
  18203. module.exports = Array.isArray || function (arr) {
  18204. return toString.call(arr) == '[object Array]';
  18205. };
  18206. },{}],310:[function(require,module,exports){
  18207. (function (global){
  18208. /*
  18209. * base64.js
  18210. *
  18211. * Licensed under the BSD 3-Clause License.
  18212. * http://opensource.org/licenses/BSD-3-Clause
  18213. *
  18214. * References:
  18215. * http://en.wikipedia.org/wiki/Base64
  18216. */
  18217. ;(function (global, factory) {
  18218. typeof exports === 'object' && typeof module !== 'undefined'
  18219. ? module.exports = factory(global)
  18220. : typeof define === 'function' && define.amd
  18221. ? define(factory) : factory(global)
  18222. }((
  18223. typeof self !== 'undefined' ? self
  18224. : typeof window !== 'undefined' ? window
  18225. : typeof global !== 'undefined' ? global
  18226. : this
  18227. ), function(global) {
  18228. 'use strict';
  18229. // existing version for noConflict()
  18230. global = global || {};
  18231. var _Base64 = global.Base64;
  18232. var version = "2.5.2";
  18233. // if node.js and NOT React Native, we use Buffer
  18234. var buffer;
  18235. if (typeof module !== 'undefined' && module.exports) {
  18236. try {
  18237. buffer = eval("require('buffer').Buffer");
  18238. } catch (err) {
  18239. buffer = undefined;
  18240. }
  18241. }
  18242. // constants
  18243. var b64chars
  18244. = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  18245. var b64tab = function(bin) {
  18246. var t = {};
  18247. for (var i = 0, l = bin.length; i < l; i++) t[bin.charAt(i)] = i;
  18248. return t;
  18249. }(b64chars);
  18250. var fromCharCode = String.fromCharCode;
  18251. // encoder stuff
  18252. var cb_utob = function(c) {
  18253. if (c.length < 2) {
  18254. var cc = c.charCodeAt(0);
  18255. return cc < 0x80 ? c
  18256. : cc < 0x800 ? (fromCharCode(0xc0 | (cc >>> 6))
  18257. + fromCharCode(0x80 | (cc & 0x3f)))
  18258. : (fromCharCode(0xe0 | ((cc >>> 12) & 0x0f))
  18259. + fromCharCode(0x80 | ((cc >>> 6) & 0x3f))
  18260. + fromCharCode(0x80 | ( cc & 0x3f)));
  18261. } else {
  18262. var cc = 0x10000
  18263. + (c.charCodeAt(0) - 0xD800) * 0x400
  18264. + (c.charCodeAt(1) - 0xDC00);
  18265. return (fromCharCode(0xf0 | ((cc >>> 18) & 0x07))
  18266. + fromCharCode(0x80 | ((cc >>> 12) & 0x3f))
  18267. + fromCharCode(0x80 | ((cc >>> 6) & 0x3f))
  18268. + fromCharCode(0x80 | ( cc & 0x3f)));
  18269. }
  18270. };
  18271. var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
  18272. var utob = function(u) {
  18273. return u.replace(re_utob, cb_utob);
  18274. };
  18275. var cb_encode = function(ccc) {
  18276. var padlen = [0, 2, 1][ccc.length % 3],
  18277. ord = ccc.charCodeAt(0) << 16
  18278. | ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8)
  18279. | ((ccc.length > 2 ? ccc.charCodeAt(2) : 0)),
  18280. chars = [
  18281. b64chars.charAt( ord >>> 18),
  18282. b64chars.charAt((ord >>> 12) & 63),
  18283. padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),
  18284. padlen >= 1 ? '=' : b64chars.charAt(ord & 63)
  18285. ];
  18286. return chars.join('');
  18287. };
  18288. var btoa = global.btoa ? function(b) {
  18289. return global.btoa(b);
  18290. } : function(b) {
  18291. return b.replace(/[\s\S]{1,3}/g, cb_encode);
  18292. };
  18293. var _encode = function(u) {
  18294. var isUint8Array = Object.prototype.toString.call(u) === '[object Uint8Array]';
  18295. return isUint8Array ? u.toString('base64')
  18296. : btoa(utob(String(u)));
  18297. }
  18298. var encode = function(u, urisafe) {
  18299. return !urisafe
  18300. ? _encode(u)
  18301. : _encode(String(u)).replace(/[+\/]/g, function(m0) {
  18302. return m0 == '+' ? '-' : '_';
  18303. }).replace(/=/g, '');
  18304. };
  18305. var encodeURI = function(u) { return encode(u, true) };
  18306. // decoder stuff
  18307. var re_btou = /[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g;
  18308. var cb_btou = function(cccc) {
  18309. switch(cccc.length) {
  18310. case 4:
  18311. var cp = ((0x07 & cccc.charCodeAt(0)) << 18)
  18312. | ((0x3f & cccc.charCodeAt(1)) << 12)
  18313. | ((0x3f & cccc.charCodeAt(2)) << 6)
  18314. | (0x3f & cccc.charCodeAt(3)),
  18315. offset = cp - 0x10000;
  18316. return (fromCharCode((offset >>> 10) + 0xD800)
  18317. + fromCharCode((offset & 0x3FF) + 0xDC00));
  18318. case 3:
  18319. return fromCharCode(
  18320. ((0x0f & cccc.charCodeAt(0)) << 12)
  18321. | ((0x3f & cccc.charCodeAt(1)) << 6)
  18322. | (0x3f & cccc.charCodeAt(2))
  18323. );
  18324. default:
  18325. return fromCharCode(
  18326. ((0x1f & cccc.charCodeAt(0)) << 6)
  18327. | (0x3f & cccc.charCodeAt(1))
  18328. );
  18329. }
  18330. };
  18331. var btou = function(b) {
  18332. return b.replace(re_btou, cb_btou);
  18333. };
  18334. var cb_decode = function(cccc) {
  18335. var len = cccc.length,
  18336. padlen = len % 4,
  18337. n = (len > 0 ? b64tab[cccc.charAt(0)] << 18 : 0)
  18338. | (len > 1 ? b64tab[cccc.charAt(1)] << 12 : 0)
  18339. | (len > 2 ? b64tab[cccc.charAt(2)] << 6 : 0)
  18340. | (len > 3 ? b64tab[cccc.charAt(3)] : 0),
  18341. chars = [
  18342. fromCharCode( n >>> 16),
  18343. fromCharCode((n >>> 8) & 0xff),
  18344. fromCharCode( n & 0xff)
  18345. ];
  18346. chars.length -= [0, 0, 2, 1][padlen];
  18347. return chars.join('');
  18348. };
  18349. var _atob = global.atob ? function(a) {
  18350. return global.atob(a);
  18351. } : function(a){
  18352. return a.replace(/\S{1,4}/g, cb_decode);
  18353. };
  18354. var atob = function(a) {
  18355. return _atob(String(a).replace(/[^A-Za-z0-9\+\/]/g, ''));
  18356. };
  18357. var _decode = buffer ?
  18358. buffer.from && Uint8Array && buffer.from !== Uint8Array.from
  18359. ? function(a) {
  18360. return (a.constructor === buffer.constructor
  18361. ? a : buffer.from(a, 'base64')).toString();
  18362. }
  18363. : function(a) {
  18364. return (a.constructor === buffer.constructor
  18365. ? a : new buffer(a, 'base64')).toString();
  18366. }
  18367. : function(a) { return btou(_atob(a)) };
  18368. var decode = function(a){
  18369. return _decode(
  18370. String(a).replace(/[-_]/g, function(m0) { return m0 == '-' ? '+' : '/' })
  18371. .replace(/[^A-Za-z0-9\+\/]/g, '')
  18372. );
  18373. };
  18374. var noConflict = function() {
  18375. var Base64 = global.Base64;
  18376. global.Base64 = _Base64;
  18377. return Base64;
  18378. };
  18379. // export Base64
  18380. global.Base64 = {
  18381. VERSION: version,
  18382. atob: atob,
  18383. btoa: btoa,
  18384. fromBase64: decode,
  18385. toBase64: encode,
  18386. utob: utob,
  18387. encode: encode,
  18388. encodeURI: encodeURI,
  18389. btou: btou,
  18390. decode: decode,
  18391. noConflict: noConflict,
  18392. __buffer__: buffer
  18393. };
  18394. // if ES5 is available, make Base64.extendString() available
  18395. if (typeof Object.defineProperty === 'function') {
  18396. var noEnum = function(v){
  18397. return {value:v,enumerable:false,writable:true,configurable:true};
  18398. };
  18399. global.Base64.extendString = function () {
  18400. Object.defineProperty(
  18401. String.prototype, 'fromBase64', noEnum(function () {
  18402. return decode(this)
  18403. }));
  18404. Object.defineProperty(
  18405. String.prototype, 'toBase64', noEnum(function (urisafe) {
  18406. return encode(this, urisafe)
  18407. }));
  18408. Object.defineProperty(
  18409. String.prototype, 'toBase64URI', noEnum(function () {
  18410. return encode(this, true)
  18411. }));
  18412. };
  18413. }
  18414. //
  18415. // export Base64 to the namespace
  18416. //
  18417. if (global['Meteor']) { // Meteor.js
  18418. Base64 = global.Base64;
  18419. }
  18420. // module.exports and AMD are mutually exclusive.
  18421. // module.exports has precedence.
  18422. if (typeof module !== 'undefined' && module.exports) {
  18423. module.exports.Base64 = global.Base64;
  18424. }
  18425. else if (typeof define === 'function' && define.amd) {
  18426. // AMD. Register as an anonymous module.
  18427. define([], function(){ return global.Base64 });
  18428. }
  18429. // that's it!
  18430. return {Base64: global.Base64}
  18431. }));
  18432. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  18433. },{}],311:[function(require,module,exports){
  18434. /*!
  18435. * merge-descriptors
  18436. * Copyright(c) 2014 Jonathan Ong
  18437. * Copyright(c) 2015 Douglas Christopher Wilson
  18438. * MIT Licensed
  18439. */
  18440. 'use strict'
  18441. /**
  18442. * Module exports.
  18443. * @public
  18444. */
  18445. module.exports = merge
  18446. /**
  18447. * Module variables.
  18448. * @private
  18449. */
  18450. var hasOwnProperty = Object.prototype.hasOwnProperty
  18451. /**
  18452. * Merge the property descriptors of `src` into `dest`
  18453. *
  18454. * @param {object} dest Object to add descriptors to
  18455. * @param {object} src Object to clone descriptors from
  18456. * @param {boolean} [redefine=true] Redefine `dest` properties with `src` properties
  18457. * @returns {object} Reference to dest
  18458. * @public
  18459. */
  18460. function merge(dest, src, redefine) {
  18461. if (!dest) {
  18462. throw new TypeError('argument dest is required')
  18463. }
  18464. if (!src) {
  18465. throw new TypeError('argument src is required')
  18466. }
  18467. if (redefine === undefined) {
  18468. // Default to true
  18469. redefine = true
  18470. }
  18471. Object.getOwnPropertyNames(src).forEach(function forEachOwnPropertyName(name) {
  18472. if (!redefine && hasOwnProperty.call(dest, name)) {
  18473. // Skip desriptor
  18474. return
  18475. }
  18476. // Copy descriptor
  18477. var descriptor = Object.getOwnPropertyDescriptor(src, name)
  18478. Object.defineProperty(dest, name, descriptor)
  18479. })
  18480. return dest
  18481. }
  18482. },{}],312:[function(require,module,exports){
  18483. 'use strict';
  18484. /**
  18485. * @param typeMap [Object] Map of MIME type -> Array[extensions]
  18486. * @param ...
  18487. */
  18488. function Mime() {
  18489. this._types = Object.create(null);
  18490. this._extensions = Object.create(null);
  18491. for (var i = 0; i < arguments.length; i++) {
  18492. this.define(arguments[i]);
  18493. }
  18494. this.define = this.define.bind(this);
  18495. this.getType = this.getType.bind(this);
  18496. this.getExtension = this.getExtension.bind(this);
  18497. }
  18498. /**
  18499. * Define mimetype -> extension mappings. Each key is a mime-type that maps
  18500. * to an array of extensions associated with the type. The first extension is
  18501. * used as the default extension for the type.
  18502. *
  18503. * e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']});
  18504. *
  18505. * If a type declares an extension that has already been defined, an error will
  18506. * be thrown. To suppress this error and force the extension to be associated
  18507. * with the new type, pass `force`=true. Alternatively, you may prefix the
  18508. * extension with "*" to map the type to extension, without mapping the
  18509. * extension to the type.
  18510. *
  18511. * e.g. mime.define({'audio/wav', ['wav']}, {'audio/x-wav', ['*wav']});
  18512. *
  18513. *
  18514. * @param map (Object) type definitions
  18515. * @param force (Boolean) if true, force overriding of existing definitions
  18516. */
  18517. Mime.prototype.define = function(typeMap, force) {
  18518. for (var type in typeMap) {
  18519. var extensions = typeMap[type].map(function(t) {return t.toLowerCase()});
  18520. type = type.toLowerCase();
  18521. for (var i = 0; i < extensions.length; i++) {
  18522. var ext = extensions[i];
  18523. // '*' prefix = not the preferred type for this extension. So fixup the
  18524. // extension, and skip it.
  18525. if (ext[0] == '*') {
  18526. continue;
  18527. }
  18528. if (!force && (ext in this._types)) {
  18529. throw new Error(
  18530. 'Attempt to change mapping for "' + ext +
  18531. '" extension from "' + this._types[ext] + '" to "' + type +
  18532. '". Pass `force=true` to allow this, otherwise remove "' + ext +
  18533. '" from the list of extensions for "' + type + '".'
  18534. );
  18535. }
  18536. this._types[ext] = type;
  18537. }
  18538. // Use first extension as default
  18539. if (force || !this._extensions[type]) {
  18540. var ext = extensions[0];
  18541. this._extensions[type] = (ext[0] != '*') ? ext : ext.substr(1)
  18542. }
  18543. }
  18544. };
  18545. /**
  18546. * Lookup a mime type based on extension
  18547. */
  18548. Mime.prototype.getType = function(path) {
  18549. path = String(path);
  18550. var last = path.replace(/^.*[/\\]/, '').toLowerCase();
  18551. var ext = last.replace(/^.*\./, '').toLowerCase();
  18552. var hasPath = last.length < path.length;
  18553. var hasDot = ext.length < last.length - 1;
  18554. return (hasDot || !hasPath) && this._types[ext] || null;
  18555. };
  18556. /**
  18557. * Return file extension associated with a mime type
  18558. */
  18559. Mime.prototype.getExtension = function(type) {
  18560. type = /^\s*([^;\s]*)/.test(type) && RegExp.$1;
  18561. return type && this._extensions[type.toLowerCase()] || null;
  18562. };
  18563. module.exports = Mime;
  18564. },{}],313:[function(require,module,exports){
  18565. 'use strict';
  18566. var Mime = require('./Mime');
  18567. module.exports = new Mime(require('./types/standard'));
  18568. },{"./Mime":312,"./types/standard":314}],314:[function(require,module,exports){
  18569. module.exports = {"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/dash+xml":["mpd"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma","es"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js","mjs"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s","m4p"],"application/mrb-consumer+xml":["*xdf"],"application/mrb-publish+xml":["*xdf"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["*xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/ttml+xml":["ttml"],"application/urc-ressheet+xml":["rsheet"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-error+xml":["xer"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/3gpp":["*3gpp"],"audio/adpcm":["adp"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mobile-xmf":["mxmf"],"audio/mp3":["*mp3"],"audio/mp4":["m4a","mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/wav":["wav"],"audio/wave":["*wav"],"audio/webm":["weba"],"audio/xm":["xm"],"font/collection":["ttc"],"font/otf":["otf"],"font/ttf":["ttf"],"font/woff":["woff"],"font/woff2":["woff2"],"image/aces":["exr"],"image/apng":["apng"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"image/emf":["emf"],"image/fits":["fits"],"image/g3fax":["g3"],"image/gif":["gif"],"image/heic":["heic"],"image/heic-sequence":["heics"],"image/heif":["heif"],"image/heif-sequence":["heifs"],"image/hej2k":["hej2"],"image/hsj2":["hsj2"],"image/ief":["ief"],"image/jls":["jls"],"image/jp2":["jp2","jpg2"],"image/jpeg":["jpeg","jpg","jpe"],"image/jph":["jph"],"image/jphc":["jhc"],"image/jpm":["jpm"],"image/jpx":["jpx","jpf"],"image/jxr":["jxr"],"image/jxra":["jxra"],"image/jxrs":["jxrs"],"image/jxs":["jxs"],"image/jxsc":["jxsc"],"image/jxsi":["jxsi"],"image/jxss":["jxss"],"image/ktx":["ktx"],"image/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/stl":["stl"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["markdown","md"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vtt":["vtt"],"text/xml":["*xml"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/jpeg":["jpgv"],"video/jpm":["*jpm","jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/webm":["webm"]};
  18570. },{}],315:[function(require,module,exports){
  18571. /**
  18572. * Helpers.
  18573. */
  18574. var s = 1000;
  18575. var m = s * 60;
  18576. var h = m * 60;
  18577. var d = h * 24;
  18578. var w = d * 7;
  18579. var y = d * 365.25;
  18580. /**
  18581. * Parse or format the given `val`.
  18582. *
  18583. * Options:
  18584. *
  18585. * - `long` verbose formatting [false]
  18586. *
  18587. * @param {String|Number} val
  18588. * @param {Object} [options]
  18589. * @throws {Error} throw an error if val is not a non-empty string or a number
  18590. * @return {String|Number}
  18591. * @api public
  18592. */
  18593. module.exports = function(val, options) {
  18594. options = options || {};
  18595. var type = typeof val;
  18596. if (type === 'string' && val.length > 0) {
  18597. return parse(val);
  18598. } else if (type === 'number' && isFinite(val)) {
  18599. return options.long ? fmtLong(val) : fmtShort(val);
  18600. }
  18601. throw new Error(
  18602. 'val is not a non-empty string or a valid number. val=' +
  18603. JSON.stringify(val)
  18604. );
  18605. };
  18606. /**
  18607. * Parse the given `str` and return milliseconds.
  18608. *
  18609. * @param {String} str
  18610. * @return {Number}
  18611. * @api private
  18612. */
  18613. function parse(str) {
  18614. str = String(str);
  18615. if (str.length > 100) {
  18616. return;
  18617. }
  18618. var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
  18619. str
  18620. );
  18621. if (!match) {
  18622. return;
  18623. }
  18624. var n = parseFloat(match[1]);
  18625. var type = (match[2] || 'ms').toLowerCase();
  18626. switch (type) {
  18627. case 'years':
  18628. case 'year':
  18629. case 'yrs':
  18630. case 'yr':
  18631. case 'y':
  18632. return n * y;
  18633. case 'weeks':
  18634. case 'week':
  18635. case 'w':
  18636. return n * w;
  18637. case 'days':
  18638. case 'day':
  18639. case 'd':
  18640. return n * d;
  18641. case 'hours':
  18642. case 'hour':
  18643. case 'hrs':
  18644. case 'hr':
  18645. case 'h':
  18646. return n * h;
  18647. case 'minutes':
  18648. case 'minute':
  18649. case 'mins':
  18650. case 'min':
  18651. case 'm':
  18652. return n * m;
  18653. case 'seconds':
  18654. case 'second':
  18655. case 'secs':
  18656. case 'sec':
  18657. case 's':
  18658. return n * s;
  18659. case 'milliseconds':
  18660. case 'millisecond':
  18661. case 'msecs':
  18662. case 'msec':
  18663. case 'ms':
  18664. return n;
  18665. default:
  18666. return undefined;
  18667. }
  18668. }
  18669. /**
  18670. * Short format for `ms`.
  18671. *
  18672. * @param {Number} ms
  18673. * @return {String}
  18674. * @api private
  18675. */
  18676. function fmtShort(ms) {
  18677. var msAbs = Math.abs(ms);
  18678. if (msAbs >= d) {
  18679. return Math.round(ms / d) + 'd';
  18680. }
  18681. if (msAbs >= h) {
  18682. return Math.round(ms / h) + 'h';
  18683. }
  18684. if (msAbs >= m) {
  18685. return Math.round(ms / m) + 'm';
  18686. }
  18687. if (msAbs >= s) {
  18688. return Math.round(ms / s) + 's';
  18689. }
  18690. return ms + 'ms';
  18691. }
  18692. /**
  18693. * Long format for `ms`.
  18694. *
  18695. * @param {Number} ms
  18696. * @return {String}
  18697. * @api private
  18698. */
  18699. function fmtLong(ms) {
  18700. var msAbs = Math.abs(ms);
  18701. if (msAbs >= d) {
  18702. return plural(ms, msAbs, d, 'day');
  18703. }
  18704. if (msAbs >= h) {
  18705. return plural(ms, msAbs, h, 'hour');
  18706. }
  18707. if (msAbs >= m) {
  18708. return plural(ms, msAbs, m, 'minute');
  18709. }
  18710. if (msAbs >= s) {
  18711. return plural(ms, msAbs, s, 'second');
  18712. }
  18713. return ms + ' ms';
  18714. }
  18715. /**
  18716. * Pluralization helper.
  18717. */
  18718. function plural(ms, msAbs, n, name) {
  18719. var isPlural = msAbs >= n * 1.5;
  18720. return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
  18721. }
  18722. },{}],316:[function(require,module,exports){
  18723. (function (process){
  18724. // .dirname, .basename, and .extname methods are extracted from Node.js v8.11.1,
  18725. // backported and transplited with Babel, with backwards-compat fixes
  18726. // Copyright Joyent, Inc. and other Node contributors.
  18727. //
  18728. // Permission is hereby granted, free of charge, to any person obtaining a
  18729. // copy of this software and associated documentation files (the
  18730. // "Software"), to deal in the Software without restriction, including
  18731. // without limitation the rights to use, copy, modify, merge, publish,
  18732. // distribute, sublicense, and/or sell copies of the Software, and to permit
  18733. // persons to whom the Software is furnished to do so, subject to the
  18734. // following conditions:
  18735. //
  18736. // The above copyright notice and this permission notice shall be included
  18737. // in all copies or substantial portions of the Software.
  18738. //
  18739. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  18740. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  18741. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  18742. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  18743. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  18744. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  18745. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  18746. // resolves . and .. elements in a path array with directory names there
  18747. // must be no slashes, empty elements, or device names (c:\) in the array
  18748. // (so also no leading and trailing slashes - it does not distinguish
  18749. // relative and absolute paths)
  18750. function normalizeArray(parts, allowAboveRoot) {
  18751. // if the path tries to go above the root, `up` ends up > 0
  18752. var up = 0;
  18753. for (var i = parts.length - 1; i >= 0; i--) {
  18754. var last = parts[i];
  18755. if (last === '.') {
  18756. parts.splice(i, 1);
  18757. } else if (last === '..') {
  18758. parts.splice(i, 1);
  18759. up++;
  18760. } else if (up) {
  18761. parts.splice(i, 1);
  18762. up--;
  18763. }
  18764. }
  18765. // if the path is allowed to go above the root, restore leading ..s
  18766. if (allowAboveRoot) {
  18767. for (; up--; up) {
  18768. parts.unshift('..');
  18769. }
  18770. }
  18771. return parts;
  18772. }
  18773. // path.resolve([from ...], to)
  18774. // posix version
  18775. exports.resolve = function() {
  18776. var resolvedPath = '',
  18777. resolvedAbsolute = false;
  18778. for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
  18779. var path = (i >= 0) ? arguments[i] : process.cwd();
  18780. // Skip empty and invalid entries
  18781. if (typeof path !== 'string') {
  18782. throw new TypeError('Arguments to path.resolve must be strings');
  18783. } else if (!path) {
  18784. continue;
  18785. }
  18786. resolvedPath = path + '/' + resolvedPath;
  18787. resolvedAbsolute = path.charAt(0) === '/';
  18788. }
  18789. // At this point the path should be resolved to a full absolute path, but
  18790. // handle relative paths to be safe (might happen when process.cwd() fails)
  18791. // Normalize the path
  18792. resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
  18793. return !!p;
  18794. }), !resolvedAbsolute).join('/');
  18795. return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
  18796. };
  18797. // path.normalize(path)
  18798. // posix version
  18799. exports.normalize = function(path) {
  18800. var isAbsolute = exports.isAbsolute(path),
  18801. trailingSlash = substr(path, -1) === '/';
  18802. // Normalize the path
  18803. path = normalizeArray(filter(path.split('/'), function(p) {
  18804. return !!p;
  18805. }), !isAbsolute).join('/');
  18806. if (!path && !isAbsolute) {
  18807. path = '.';
  18808. }
  18809. if (path && trailingSlash) {
  18810. path += '/';
  18811. }
  18812. return (isAbsolute ? '/' : '') + path;
  18813. };
  18814. // posix version
  18815. exports.isAbsolute = function(path) {
  18816. return path.charAt(0) === '/';
  18817. };
  18818. // posix version
  18819. exports.join = function() {
  18820. var paths = Array.prototype.slice.call(arguments, 0);
  18821. return exports.normalize(filter(paths, function(p, index) {
  18822. if (typeof p !== 'string') {
  18823. throw new TypeError('Arguments to path.join must be strings');
  18824. }
  18825. return p;
  18826. }).join('/'));
  18827. };
  18828. // path.relative(from, to)
  18829. // posix version
  18830. exports.relative = function(from, to) {
  18831. from = exports.resolve(from).substr(1);
  18832. to = exports.resolve(to).substr(1);
  18833. function trim(arr) {
  18834. var start = 0;
  18835. for (; start < arr.length; start++) {
  18836. if (arr[start] !== '') break;
  18837. }
  18838. var end = arr.length - 1;
  18839. for (; end >= 0; end--) {
  18840. if (arr[end] !== '') break;
  18841. }
  18842. if (start > end) return [];
  18843. return arr.slice(start, end - start + 1);
  18844. }
  18845. var fromParts = trim(from.split('/'));
  18846. var toParts = trim(to.split('/'));
  18847. var length = Math.min(fromParts.length, toParts.length);
  18848. var samePartsLength = length;
  18849. for (var i = 0; i < length; i++) {
  18850. if (fromParts[i] !== toParts[i]) {
  18851. samePartsLength = i;
  18852. break;
  18853. }
  18854. }
  18855. var outputParts = [];
  18856. for (var i = samePartsLength; i < fromParts.length; i++) {
  18857. outputParts.push('..');
  18858. }
  18859. outputParts = outputParts.concat(toParts.slice(samePartsLength));
  18860. return outputParts.join('/');
  18861. };
  18862. exports.sep = '/';
  18863. exports.delimiter = ':';
  18864. exports.dirname = function (path) {
  18865. if (typeof path !== 'string') path = path + '';
  18866. if (path.length === 0) return '.';
  18867. var code = path.charCodeAt(0);
  18868. var hasRoot = code === 47 /*/*/;
  18869. var end = -1;
  18870. var matchedSlash = true;
  18871. for (var i = path.length - 1; i >= 1; --i) {
  18872. code = path.charCodeAt(i);
  18873. if (code === 47 /*/*/) {
  18874. if (!matchedSlash) {
  18875. end = i;
  18876. break;
  18877. }
  18878. } else {
  18879. // We saw the first non-path separator
  18880. matchedSlash = false;
  18881. }
  18882. }
  18883. if (end === -1) return hasRoot ? '/' : '.';
  18884. if (hasRoot && end === 1) {
  18885. // return '//';
  18886. // Backwards-compat fix:
  18887. return '/';
  18888. }
  18889. return path.slice(0, end);
  18890. };
  18891. function basename(path) {
  18892. if (typeof path !== 'string') path = path + '';
  18893. var start = 0;
  18894. var end = -1;
  18895. var matchedSlash = true;
  18896. var i;
  18897. for (i = path.length - 1; i >= 0; --i) {
  18898. if (path.charCodeAt(i) === 47 /*/*/) {
  18899. // If we reached a path separator that was not part of a set of path
  18900. // separators at the end of the string, stop now
  18901. if (!matchedSlash) {
  18902. start = i + 1;
  18903. break;
  18904. }
  18905. } else if (end === -1) {
  18906. // We saw the first non-path separator, mark this as the end of our
  18907. // path component
  18908. matchedSlash = false;
  18909. end = i + 1;
  18910. }
  18911. }
  18912. if (end === -1) return '';
  18913. return path.slice(start, end);
  18914. }
  18915. // Uses a mixed approach for backwards-compatibility, as ext behavior changed
  18916. // in new Node.js versions, so only basename() above is backported here
  18917. exports.basename = function (path, ext) {
  18918. var f = basename(path);
  18919. if (ext && f.substr(-1 * ext.length) === ext) {
  18920. f = f.substr(0, f.length - ext.length);
  18921. }
  18922. return f;
  18923. };
  18924. exports.extname = function (path) {
  18925. if (typeof path !== 'string') path = path + '';
  18926. var startDot = -1;
  18927. var startPart = 0;
  18928. var end = -1;
  18929. var matchedSlash = true;
  18930. // Track the state of characters (if any) we see before our first dot and
  18931. // after any path separator we find
  18932. var preDotState = 0;
  18933. for (var i = path.length - 1; i >= 0; --i) {
  18934. var code = path.charCodeAt(i);
  18935. if (code === 47 /*/*/) {
  18936. // If we reached a path separator that was not part of a set of path
  18937. // separators at the end of the string, stop now
  18938. if (!matchedSlash) {
  18939. startPart = i + 1;
  18940. break;
  18941. }
  18942. continue;
  18943. }
  18944. if (end === -1) {
  18945. // We saw the first non-path separator, mark this as the end of our
  18946. // extension
  18947. matchedSlash = false;
  18948. end = i + 1;
  18949. }
  18950. if (code === 46 /*.*/) {
  18951. // If this is our first dot, mark it as the start of our extension
  18952. if (startDot === -1)
  18953. startDot = i;
  18954. else if (preDotState !== 1)
  18955. preDotState = 1;
  18956. } else if (startDot !== -1) {
  18957. // We saw a non-dot and non-path separator before our dot, so we should
  18958. // have a good chance at having a non-empty extension
  18959. preDotState = -1;
  18960. }
  18961. }
  18962. if (startDot === -1 || end === -1 ||
  18963. // We saw a non-dot character immediately before the dot
  18964. preDotState === 0 ||
  18965. // The (right-most) trimmed path component is exactly '..'
  18966. preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
  18967. return '';
  18968. }
  18969. return path.slice(startDot, end);
  18970. };
  18971. function filter (xs, f) {
  18972. if (xs.filter) return xs.filter(f);
  18973. var res = [];
  18974. for (var i = 0; i < xs.length; i++) {
  18975. if (f(xs[i], i, xs)) res.push(xs[i]);
  18976. }
  18977. return res;
  18978. }
  18979. // String.prototype.substr - negative index don't work in IE8
  18980. var substr = 'ab'.substr(-1) === 'b'
  18981. ? function (str, start, len) { return str.substr(start, len) }
  18982. : function (str, start, len) {
  18983. if (start < 0) start = str.length + start;
  18984. return str.substr(start, len);
  18985. }
  18986. ;
  18987. }).call(this,require('_process'))
  18988. },{"_process":393}],317:[function(require,module,exports){
  18989. (function (global){
  18990. /*!
  18991. * Platform.js <https://mths.be/platform>
  18992. * Copyright 2014-2018 Benjamin Tan <https://bnjmnt4n.now.sh/>
  18993. * Copyright 2011-2013 John-David Dalton <http://allyoucanleet.com/>
  18994. * Available under MIT license <https://mths.be/mit>
  18995. */
  18996. ;(function() {
  18997. 'use strict';
  18998. /** Used to determine if values are of the language type `Object`. */
  18999. var objectTypes = {
  19000. 'function': true,
  19001. 'object': true
  19002. };
  19003. /** Used as a reference to the global object. */
  19004. var root = (objectTypes[typeof window] && window) || this;
  19005. /** Backup possible global object. */
  19006. var oldRoot = root;
  19007. /** Detect free variable `exports`. */
  19008. var freeExports = objectTypes[typeof exports] && exports;
  19009. /** Detect free variable `module`. */
  19010. var freeModule = objectTypes[typeof module] && module && !module.nodeType && module;
  19011. /** Detect free variable `global` from Node.js or Browserified code and use it as `root`. */
  19012. var freeGlobal = freeExports && freeModule && typeof global == 'object' && global;
  19013. if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal)) {
  19014. root = freeGlobal;
  19015. }
  19016. /**
  19017. * Used as the maximum length of an array-like object.
  19018. * See the [ES6 spec](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength)
  19019. * for more details.
  19020. */
  19021. var maxSafeInteger = Math.pow(2, 53) - 1;
  19022. /** Regular expression to detect Opera. */
  19023. var reOpera = /\bOpera/;
  19024. /** Possible global object. */
  19025. var thisBinding = this;
  19026. /** Used for native method references. */
  19027. var objectProto = Object.prototype;
  19028. /** Used to check for own properties of an object. */
  19029. var hasOwnProperty = objectProto.hasOwnProperty;
  19030. /** Used to resolve the internal `[[Class]]` of values. */
  19031. var toString = objectProto.toString;
  19032. /*--------------------------------------------------------------------------*/
  19033. /**
  19034. * Capitalizes a string value.
  19035. *
  19036. * @private
  19037. * @param {string} string The string to capitalize.
  19038. * @returns {string} The capitalized string.
  19039. */
  19040. function capitalize(string) {
  19041. string = String(string);
  19042. return string.charAt(0).toUpperCase() + string.slice(1);
  19043. }
  19044. /**
  19045. * A utility function to clean up the OS name.
  19046. *
  19047. * @private
  19048. * @param {string} os The OS name to clean up.
  19049. * @param {string} [pattern] A `RegExp` pattern matching the OS name.
  19050. * @param {string} [label] A label for the OS.
  19051. */
  19052. function cleanupOS(os, pattern, label) {
  19053. // Platform tokens are defined at:
  19054. // http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx
  19055. // http://web.archive.org/web/20081122053950/http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx
  19056. var data = {
  19057. '10.0': '10',
  19058. '6.4': '10 Technical Preview',
  19059. '6.3': '8.1',
  19060. '6.2': '8',
  19061. '6.1': 'Server 2008 R2 / 7',
  19062. '6.0': 'Server 2008 / Vista',
  19063. '5.2': 'Server 2003 / XP 64-bit',
  19064. '5.1': 'XP',
  19065. '5.01': '2000 SP1',
  19066. '5.0': '2000',
  19067. '4.0': 'NT',
  19068. '4.90': 'ME'
  19069. };
  19070. // Detect Windows version from platform tokens.
  19071. if (pattern && label && /^Win/i.test(os) && !/^Windows Phone /i.test(os) &&
  19072. (data = data[/[\d.]+$/.exec(os)])) {
  19073. os = 'Windows ' + data;
  19074. }
  19075. // Correct character case and cleanup string.
  19076. os = String(os);
  19077. if (pattern && label) {
  19078. os = os.replace(RegExp(pattern, 'i'), label);
  19079. }
  19080. os = format(
  19081. os.replace(/ ce$/i, ' CE')
  19082. .replace(/\bhpw/i, 'web')
  19083. .replace(/\bMacintosh\b/, 'Mac OS')
  19084. .replace(/_PowerPC\b/i, ' OS')
  19085. .replace(/\b(OS X) [^ \d]+/i, '$1')
  19086. .replace(/\bMac (OS X)\b/, '$1')
  19087. .replace(/\/(\d)/, ' $1')
  19088. .replace(/_/g, '.')
  19089. .replace(/(?: BePC|[ .]*fc[ \d.]+)$/i, '')
  19090. .replace(/\bx86\.64\b/gi, 'x86_64')
  19091. .replace(/\b(Windows Phone) OS\b/, '$1')
  19092. .replace(/\b(Chrome OS \w+) [\d.]+\b/, '$1')
  19093. .split(' on ')[0]
  19094. );
  19095. return os;
  19096. }
  19097. /**
  19098. * An iteration utility for arrays and objects.
  19099. *
  19100. * @private
  19101. * @param {Array|Object} object The object to iterate over.
  19102. * @param {Function} callback The function called per iteration.
  19103. */
  19104. function each(object, callback) {
  19105. var index = -1,
  19106. length = object ? object.length : 0;
  19107. if (typeof length == 'number' && length > -1 && length <= maxSafeInteger) {
  19108. while (++index < length) {
  19109. callback(object[index], index, object);
  19110. }
  19111. } else {
  19112. forOwn(object, callback);
  19113. }
  19114. }
  19115. /**
  19116. * Trim and conditionally capitalize string values.
  19117. *
  19118. * @private
  19119. * @param {string} string The string to format.
  19120. * @returns {string} The formatted string.
  19121. */
  19122. function format(string) {
  19123. string = trim(string);
  19124. return /^(?:webOS|i(?:OS|P))/.test(string)
  19125. ? string
  19126. : capitalize(string);
  19127. }
  19128. /**
  19129. * Iterates over an object's own properties, executing the `callback` for each.
  19130. *
  19131. * @private
  19132. * @param {Object} object The object to iterate over.
  19133. * @param {Function} callback The function executed per own property.
  19134. */
  19135. function forOwn(object, callback) {
  19136. for (var key in object) {
  19137. if (hasOwnProperty.call(object, key)) {
  19138. callback(object[key], key, object);
  19139. }
  19140. }
  19141. }
  19142. /**
  19143. * Gets the internal `[[Class]]` of a value.
  19144. *
  19145. * @private
  19146. * @param {*} value The value.
  19147. * @returns {string} The `[[Class]]`.
  19148. */
  19149. function getClassOf(value) {
  19150. return value == null
  19151. ? capitalize(value)
  19152. : toString.call(value).slice(8, -1);
  19153. }
  19154. /**
  19155. * Host objects can return type values that are different from their actual
  19156. * data type. The objects we are concerned with usually return non-primitive
  19157. * types of "object", "function", or "unknown".
  19158. *
  19159. * @private
  19160. * @param {*} object The owner of the property.
  19161. * @param {string} property The property to check.
  19162. * @returns {boolean} Returns `true` if the property value is a non-primitive, else `false`.
  19163. */
  19164. function isHostType(object, property) {
  19165. var type = object != null ? typeof object[property] : 'number';
  19166. return !/^(?:boolean|number|string|undefined)$/.test(type) &&
  19167. (type == 'object' ? !!object[property] : true);
  19168. }
  19169. /**
  19170. * Prepares a string for use in a `RegExp` by making hyphens and spaces optional.
  19171. *
  19172. * @private
  19173. * @param {string} string The string to qualify.
  19174. * @returns {string} The qualified string.
  19175. */
  19176. function qualify(string) {
  19177. return String(string).replace(/([ -])(?!$)/g, '$1?');
  19178. }
  19179. /**
  19180. * A bare-bones `Array#reduce` like utility function.
  19181. *
  19182. * @private
  19183. * @param {Array} array The array to iterate over.
  19184. * @param {Function} callback The function called per iteration.
  19185. * @returns {*} The accumulated result.
  19186. */
  19187. function reduce(array, callback) {
  19188. var accumulator = null;
  19189. each(array, function(value, index) {
  19190. accumulator = callback(accumulator, value, index, array);
  19191. });
  19192. return accumulator;
  19193. }
  19194. /**
  19195. * Removes leading and trailing whitespace from a string.
  19196. *
  19197. * @private
  19198. * @param {string} string The string to trim.
  19199. * @returns {string} The trimmed string.
  19200. */
  19201. function trim(string) {
  19202. return String(string).replace(/^ +| +$/g, '');
  19203. }
  19204. /*--------------------------------------------------------------------------*/
  19205. /**
  19206. * Creates a new platform object.
  19207. *
  19208. * @memberOf platform
  19209. * @param {Object|string} [ua=navigator.userAgent] The user agent string or
  19210. * context object.
  19211. * @returns {Object} A platform object.
  19212. */
  19213. function parse(ua) {
  19214. /** The environment context object. */
  19215. var context = root;
  19216. /** Used to flag when a custom context is provided. */
  19217. var isCustomContext = ua && typeof ua == 'object' && getClassOf(ua) != 'String';
  19218. // Juggle arguments.
  19219. if (isCustomContext) {
  19220. context = ua;
  19221. ua = null;
  19222. }
  19223. /** Browser navigator object. */
  19224. var nav = context.navigator || {};
  19225. /** Browser user agent string. */
  19226. var userAgent = nav.userAgent || '';
  19227. ua || (ua = userAgent);
  19228. /** Used to flag when `thisBinding` is the [ModuleScope]. */
  19229. var isModuleScope = isCustomContext || thisBinding == oldRoot;
  19230. /** Used to detect if browser is like Chrome. */
  19231. var likeChrome = isCustomContext
  19232. ? !!nav.likeChrome
  19233. : /\bChrome\b/.test(ua) && !/internal|\n/i.test(toString.toString());
  19234. /** Internal `[[Class]]` value shortcuts. */
  19235. var objectClass = 'Object',
  19236. airRuntimeClass = isCustomContext ? objectClass : 'ScriptBridgingProxyObject',
  19237. enviroClass = isCustomContext ? objectClass : 'Environment',
  19238. javaClass = (isCustomContext && context.java) ? 'JavaPackage' : getClassOf(context.java),
  19239. phantomClass = isCustomContext ? objectClass : 'RuntimeObject';
  19240. /** Detect Java environments. */
  19241. var java = /\bJava/.test(javaClass) && context.java;
  19242. /** Detect Rhino. */
  19243. var rhino = java && getClassOf(context.environment) == enviroClass;
  19244. /** A character to represent alpha. */
  19245. var alpha = java ? 'a' : '\u03b1';
  19246. /** A character to represent beta. */
  19247. var beta = java ? 'b' : '\u03b2';
  19248. /** Browser document object. */
  19249. var doc = context.document || {};
  19250. /**
  19251. * Detect Opera browser (Presto-based).
  19252. * http://www.howtocreate.co.uk/operaStuff/operaObject.html
  19253. * http://dev.opera.com/articles/view/opera-mini-web-content-authoring-guidelines/#operamini
  19254. */
  19255. var opera = context.operamini || context.opera;
  19256. /** Opera `[[Class]]`. */
  19257. var operaClass = reOpera.test(operaClass = (isCustomContext && opera) ? opera['[[Class]]'] : getClassOf(opera))
  19258. ? operaClass
  19259. : (opera = null);
  19260. /*------------------------------------------------------------------------*/
  19261. /** Temporary variable used over the script's lifetime. */
  19262. var data;
  19263. /** The CPU architecture. */
  19264. var arch = ua;
  19265. /** Platform description array. */
  19266. var description = [];
  19267. /** Platform alpha/beta indicator. */
  19268. var prerelease = null;
  19269. /** A flag to indicate that environment features should be used to resolve the platform. */
  19270. var useFeatures = ua == userAgent;
  19271. /** The browser/environment version. */
  19272. var version = useFeatures && opera && typeof opera.version == 'function' && opera.version();
  19273. /** A flag to indicate if the OS ends with "/ Version" */
  19274. var isSpecialCasedOS;
  19275. /* Detectable layout engines (order is important). */
  19276. var layout = getLayout([
  19277. { 'label': 'EdgeHTML', 'pattern': 'Edge' },
  19278. 'Trident',
  19279. { 'label': 'WebKit', 'pattern': 'AppleWebKit' },
  19280. 'iCab',
  19281. 'Presto',
  19282. 'NetFront',
  19283. 'Tasman',
  19284. 'KHTML',
  19285. 'Gecko'
  19286. ]);
  19287. /* Detectable browser names (order is important). */
  19288. var name = getName([
  19289. 'Adobe AIR',
  19290. 'Arora',
  19291. 'Avant Browser',
  19292. 'Breach',
  19293. 'Camino',
  19294. 'Electron',
  19295. 'Epiphany',
  19296. 'Fennec',
  19297. 'Flock',
  19298. 'Galeon',
  19299. 'GreenBrowser',
  19300. 'iCab',
  19301. 'Iceweasel',
  19302. 'K-Meleon',
  19303. 'Konqueror',
  19304. 'Lunascape',
  19305. 'Maxthon',
  19306. { 'label': 'Microsoft Edge', 'pattern': 'Edge' },
  19307. 'Midori',
  19308. 'Nook Browser',
  19309. 'PaleMoon',
  19310. 'PhantomJS',
  19311. 'Raven',
  19312. 'Rekonq',
  19313. 'RockMelt',
  19314. { 'label': 'Samsung Internet', 'pattern': 'SamsungBrowser' },
  19315. 'SeaMonkey',
  19316. { 'label': 'Silk', 'pattern': '(?:Cloud9|Silk-Accelerated)' },
  19317. 'Sleipnir',
  19318. 'SlimBrowser',
  19319. { 'label': 'SRWare Iron', 'pattern': 'Iron' },
  19320. 'Sunrise',
  19321. 'Swiftfox',
  19322. 'Waterfox',
  19323. 'WebPositive',
  19324. 'Opera Mini',
  19325. { 'label': 'Opera Mini', 'pattern': 'OPiOS' },
  19326. 'Opera',
  19327. { 'label': 'Opera', 'pattern': 'OPR' },
  19328. 'Chrome',
  19329. { 'label': 'Chrome Mobile', 'pattern': '(?:CriOS|CrMo)' },
  19330. { 'label': 'Firefox', 'pattern': '(?:Firefox|Minefield)' },
  19331. { 'label': 'Firefox for iOS', 'pattern': 'FxiOS' },
  19332. { 'label': 'IE', 'pattern': 'IEMobile' },
  19333. { 'label': 'IE', 'pattern': 'MSIE' },
  19334. 'Safari'
  19335. ]);
  19336. /* Detectable products (order is important). */
  19337. var product = getProduct([
  19338. { 'label': 'BlackBerry', 'pattern': 'BB10' },
  19339. 'BlackBerry',
  19340. { 'label': 'Galaxy S', 'pattern': 'GT-I9000' },
  19341. { 'label': 'Galaxy S2', 'pattern': 'GT-I9100' },
  19342. { 'label': 'Galaxy S3', 'pattern': 'GT-I9300' },
  19343. { 'label': 'Galaxy S4', 'pattern': 'GT-I9500' },
  19344. { 'label': 'Galaxy S5', 'pattern': 'SM-G900' },
  19345. { 'label': 'Galaxy S6', 'pattern': 'SM-G920' },
  19346. { 'label': 'Galaxy S6 Edge', 'pattern': 'SM-G925' },
  19347. { 'label': 'Galaxy S7', 'pattern': 'SM-G930' },
  19348. { 'label': 'Galaxy S7 Edge', 'pattern': 'SM-G935' },
  19349. 'Google TV',
  19350. 'Lumia',
  19351. 'iPad',
  19352. 'iPod',
  19353. 'iPhone',
  19354. 'Kindle',
  19355. { 'label': 'Kindle Fire', 'pattern': '(?:Cloud9|Silk-Accelerated)' },
  19356. 'Nexus',
  19357. 'Nook',
  19358. 'PlayBook',
  19359. 'PlayStation Vita',
  19360. 'PlayStation',
  19361. 'TouchPad',
  19362. 'Transformer',
  19363. { 'label': 'Wii U', 'pattern': 'WiiU' },
  19364. 'Wii',
  19365. 'Xbox One',
  19366. { 'label': 'Xbox 360', 'pattern': 'Xbox' },
  19367. 'Xoom'
  19368. ]);
  19369. /* Detectable manufacturers. */
  19370. var manufacturer = getManufacturer({
  19371. 'Apple': { 'iPad': 1, 'iPhone': 1, 'iPod': 1 },
  19372. 'Archos': {},
  19373. 'Amazon': { 'Kindle': 1, 'Kindle Fire': 1 },
  19374. 'Asus': { 'Transformer': 1 },
  19375. 'Barnes & Noble': { 'Nook': 1 },
  19376. 'BlackBerry': { 'PlayBook': 1 },
  19377. 'Google': { 'Google TV': 1, 'Nexus': 1 },
  19378. 'HP': { 'TouchPad': 1 },
  19379. 'HTC': {},
  19380. 'LG': {},
  19381. 'Microsoft': { 'Xbox': 1, 'Xbox One': 1 },
  19382. 'Motorola': { 'Xoom': 1 },
  19383. 'Nintendo': { 'Wii U': 1, 'Wii': 1 },
  19384. 'Nokia': { 'Lumia': 1 },
  19385. 'Samsung': { 'Galaxy S': 1, 'Galaxy S2': 1, 'Galaxy S3': 1, 'Galaxy S4': 1 },
  19386. 'Sony': { 'PlayStation': 1, 'PlayStation Vita': 1 }
  19387. });
  19388. /* Detectable operating systems (order is important). */
  19389. var os = getOS([
  19390. 'Windows Phone',
  19391. 'Android',
  19392. 'CentOS',
  19393. { 'label': 'Chrome OS', 'pattern': 'CrOS' },
  19394. 'Debian',
  19395. 'Fedora',
  19396. 'FreeBSD',
  19397. 'Gentoo',
  19398. 'Haiku',
  19399. 'Kubuntu',
  19400. 'Linux Mint',
  19401. 'OpenBSD',
  19402. 'Red Hat',
  19403. 'SuSE',
  19404. 'Ubuntu',
  19405. 'Xubuntu',
  19406. 'Cygwin',
  19407. 'Symbian OS',
  19408. 'hpwOS',
  19409. 'webOS ',
  19410. 'webOS',
  19411. 'Tablet OS',
  19412. 'Tizen',
  19413. 'Linux',
  19414. 'Mac OS X',
  19415. 'Macintosh',
  19416. 'Mac',
  19417. 'Windows 98;',
  19418. 'Windows '
  19419. ]);
  19420. /*------------------------------------------------------------------------*/
  19421. /**
  19422. * Picks the layout engine from an array of guesses.
  19423. *
  19424. * @private
  19425. * @param {Array} guesses An array of guesses.
  19426. * @returns {null|string} The detected layout engine.
  19427. */
  19428. function getLayout(guesses) {
  19429. return reduce(guesses, function(result, guess) {
  19430. return result || RegExp('\\b' + (
  19431. guess.pattern || qualify(guess)
  19432. ) + '\\b', 'i').exec(ua) && (guess.label || guess);
  19433. });
  19434. }
  19435. /**
  19436. * Picks the manufacturer from an array of guesses.
  19437. *
  19438. * @private
  19439. * @param {Array} guesses An object of guesses.
  19440. * @returns {null|string} The detected manufacturer.
  19441. */
  19442. function getManufacturer(guesses) {
  19443. return reduce(guesses, function(result, value, key) {
  19444. // Lookup the manufacturer by product or scan the UA for the manufacturer.
  19445. return result || (
  19446. value[product] ||
  19447. value[/^[a-z]+(?: +[a-z]+\b)*/i.exec(product)] ||
  19448. RegExp('\\b' + qualify(key) + '(?:\\b|\\w*\\d)', 'i').exec(ua)
  19449. ) && key;
  19450. });
  19451. }
  19452. /**
  19453. * Picks the browser name from an array of guesses.
  19454. *
  19455. * @private
  19456. * @param {Array} guesses An array of guesses.
  19457. * @returns {null|string} The detected browser name.
  19458. */
  19459. function getName(guesses) {
  19460. return reduce(guesses, function(result, guess) {
  19461. return result || RegExp('\\b' + (
  19462. guess.pattern || qualify(guess)
  19463. ) + '\\b', 'i').exec(ua) && (guess.label || guess);
  19464. });
  19465. }
  19466. /**
  19467. * Picks the OS name from an array of guesses.
  19468. *
  19469. * @private
  19470. * @param {Array} guesses An array of guesses.
  19471. * @returns {null|string} The detected OS name.
  19472. */
  19473. function getOS(guesses) {
  19474. return reduce(guesses, function(result, guess) {
  19475. var pattern = guess.pattern || qualify(guess);
  19476. if (!result && (result =
  19477. RegExp('\\b' + pattern + '(?:/[\\d.]+|[ \\w.]*)', 'i').exec(ua)
  19478. )) {
  19479. result = cleanupOS(result, pattern, guess.label || guess);
  19480. }
  19481. return result;
  19482. });
  19483. }
  19484. /**
  19485. * Picks the product name from an array of guesses.
  19486. *
  19487. * @private
  19488. * @param {Array} guesses An array of guesses.
  19489. * @returns {null|string} The detected product name.
  19490. */
  19491. function getProduct(guesses) {
  19492. return reduce(guesses, function(result, guess) {
  19493. var pattern = guess.pattern || qualify(guess);
  19494. if (!result && (result =
  19495. RegExp('\\b' + pattern + ' *\\d+[.\\w_]*', 'i').exec(ua) ||
  19496. RegExp('\\b' + pattern + ' *\\w+-[\\w]*', 'i').exec(ua) ||
  19497. RegExp('\\b' + pattern + '(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)', 'i').exec(ua)
  19498. )) {
  19499. // Split by forward slash and append product version if needed.
  19500. if ((result = String((guess.label && !RegExp(pattern, 'i').test(guess.label)) ? guess.label : result).split('/'))[1] && !/[\d.]+/.test(result[0])) {
  19501. result[0] += ' ' + result[1];
  19502. }
  19503. // Correct character case and cleanup string.
  19504. guess = guess.label || guess;
  19505. result = format(result[0]
  19506. .replace(RegExp(pattern, 'i'), guess)
  19507. .replace(RegExp('; *(?:' + guess + '[_-])?', 'i'), ' ')
  19508. .replace(RegExp('(' + guess + ')[-_.]?(\\w)', 'i'), '$1 $2'));
  19509. }
  19510. return result;
  19511. });
  19512. }
  19513. /**
  19514. * Resolves the version using an array of UA patterns.
  19515. *
  19516. * @private
  19517. * @param {Array} patterns An array of UA patterns.
  19518. * @returns {null|string} The detected version.
  19519. */
  19520. function getVersion(patterns) {
  19521. return reduce(patterns, function(result, pattern) {
  19522. return result || (RegExp(pattern +
  19523. '(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)', 'i').exec(ua) || 0)[1] || null;
  19524. });
  19525. }
  19526. /**
  19527. * Returns `platform.description` when the platform object is coerced to a string.
  19528. *
  19529. * @name toString
  19530. * @memberOf platform
  19531. * @returns {string} Returns `platform.description` if available, else an empty string.
  19532. */
  19533. function toStringPlatform() {
  19534. return this.description || '';
  19535. }
  19536. /*------------------------------------------------------------------------*/
  19537. // Convert layout to an array so we can add extra details.
  19538. layout && (layout = [layout]);
  19539. // Detect product names that contain their manufacturer's name.
  19540. if (manufacturer && !product) {
  19541. product = getProduct([manufacturer]);
  19542. }
  19543. // Clean up Google TV.
  19544. if ((data = /\bGoogle TV\b/.exec(product))) {
  19545. product = data[0];
  19546. }
  19547. // Detect simulators.
  19548. if (/\bSimulator\b/i.test(ua)) {
  19549. product = (product ? product + ' ' : '') + 'Simulator';
  19550. }
  19551. // Detect Opera Mini 8+ running in Turbo/Uncompressed mode on iOS.
  19552. if (name == 'Opera Mini' && /\bOPiOS\b/.test(ua)) {
  19553. description.push('running in Turbo/Uncompressed mode');
  19554. }
  19555. // Detect IE Mobile 11.
  19556. if (name == 'IE' && /\blike iPhone OS\b/.test(ua)) {
  19557. data = parse(ua.replace(/like iPhone OS/, ''));
  19558. manufacturer = data.manufacturer;
  19559. product = data.product;
  19560. }
  19561. // Detect iOS.
  19562. else if (/^iP/.test(product)) {
  19563. name || (name = 'Safari');
  19564. os = 'iOS' + ((data = / OS ([\d_]+)/i.exec(ua))
  19565. ? ' ' + data[1].replace(/_/g, '.')
  19566. : '');
  19567. }
  19568. // Detect Kubuntu.
  19569. else if (name == 'Konqueror' && !/buntu/i.test(os)) {
  19570. os = 'Kubuntu';
  19571. }
  19572. // Detect Android browsers.
  19573. else if ((manufacturer && manufacturer != 'Google' &&
  19574. ((/Chrome/.test(name) && !/\bMobile Safari\b/i.test(ua)) || /\bVita\b/.test(product))) ||
  19575. (/\bAndroid\b/.test(os) && /^Chrome/.test(name) && /\bVersion\//i.test(ua))) {
  19576. name = 'Android Browser';
  19577. os = /\bAndroid\b/.test(os) ? os : 'Android';
  19578. }
  19579. // Detect Silk desktop/accelerated modes.
  19580. else if (name == 'Silk') {
  19581. if (!/\bMobi/i.test(ua)) {
  19582. os = 'Android';
  19583. description.unshift('desktop mode');
  19584. }
  19585. if (/Accelerated *= *true/i.test(ua)) {
  19586. description.unshift('accelerated');
  19587. }
  19588. }
  19589. // Detect PaleMoon identifying as Firefox.
  19590. else if (name == 'PaleMoon' && (data = /\bFirefox\/([\d.]+)\b/.exec(ua))) {
  19591. description.push('identifying as Firefox ' + data[1]);
  19592. }
  19593. // Detect Firefox OS and products running Firefox.
  19594. else if (name == 'Firefox' && (data = /\b(Mobile|Tablet|TV)\b/i.exec(ua))) {
  19595. os || (os = 'Firefox OS');
  19596. product || (product = data[1]);
  19597. }
  19598. // Detect false positives for Firefox/Safari.
  19599. else if (!name || (data = !/\bMinefield\b/i.test(ua) && /\b(?:Firefox|Safari)\b/.exec(name))) {
  19600. // Escape the `/` for Firefox 1.
  19601. if (name && !product && /[\/,]|^[^(]+?\)/.test(ua.slice(ua.indexOf(data + '/') + 8))) {
  19602. // Clear name of false positives.
  19603. name = null;
  19604. }
  19605. // Reassign a generic name.
  19606. if ((data = product || manufacturer || os) &&
  19607. (product || manufacturer || /\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(os))) {
  19608. name = /[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(os) ? os : data) + ' Browser';
  19609. }
  19610. }
  19611. // Add Chrome version to description for Electron.
  19612. else if (name == 'Electron' && (data = (/\bChrome\/([\d.]+)\b/.exec(ua) || 0)[1])) {
  19613. description.push('Chromium ' + data);
  19614. }
  19615. // Detect non-Opera (Presto-based) versions (order is important).
  19616. if (!version) {
  19617. version = getVersion([
  19618. '(?:Cloud9|CriOS|CrMo|Edge|FxiOS|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$))',
  19619. 'Version',
  19620. qualify(name),
  19621. '(?:Firefox|Minefield|NetFront)'
  19622. ]);
  19623. }
  19624. // Detect stubborn layout engines.
  19625. if ((data =
  19626. layout == 'iCab' && parseFloat(version) > 3 && 'WebKit' ||
  19627. /\bOpera\b/.test(name) && (/\bOPR\b/.test(ua) ? 'Blink' : 'Presto') ||
  19628. /\b(?:Midori|Nook|Safari)\b/i.test(ua) && !/^(?:Trident|EdgeHTML)$/.test(layout) && 'WebKit' ||
  19629. !layout && /\bMSIE\b/i.test(ua) && (os == 'Mac OS' ? 'Tasman' : 'Trident') ||
  19630. layout == 'WebKit' && /\bPlayStation\b(?! Vita\b)/i.test(name) && 'NetFront'
  19631. )) {
  19632. layout = [data];
  19633. }
  19634. // Detect Windows Phone 7 desktop mode.
  19635. if (name == 'IE' && (data = (/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(ua) || 0)[1])) {
  19636. name += ' Mobile';
  19637. os = 'Windows Phone ' + (/\+$/.test(data) ? data : data + '.x');
  19638. description.unshift('desktop mode');
  19639. }
  19640. // Detect Windows Phone 8.x desktop mode.
  19641. else if (/\bWPDesktop\b/i.test(ua)) {
  19642. name = 'IE Mobile';
  19643. os = 'Windows Phone 8.x';
  19644. description.unshift('desktop mode');
  19645. version || (version = (/\brv:([\d.]+)/.exec(ua) || 0)[1]);
  19646. }
  19647. // Detect IE 11 identifying as other browsers.
  19648. else if (name != 'IE' && layout == 'Trident' && (data = /\brv:([\d.]+)/.exec(ua))) {
  19649. if (name) {
  19650. description.push('identifying as ' + name + (version ? ' ' + version : ''));
  19651. }
  19652. name = 'IE';
  19653. version = data[1];
  19654. }
  19655. // Leverage environment features.
  19656. if (useFeatures) {
  19657. // Detect server-side environments.
  19658. // Rhino has a global function while others have a global object.
  19659. if (isHostType(context, 'global')) {
  19660. if (java) {
  19661. data = java.lang.System;
  19662. arch = data.getProperty('os.arch');
  19663. os = os || data.getProperty('os.name') + ' ' + data.getProperty('os.version');
  19664. }
  19665. if (rhino) {
  19666. try {
  19667. version = context.require('ringo/engine').version.join('.');
  19668. name = 'RingoJS';
  19669. } catch(e) {
  19670. if ((data = context.system) && data.global.system == context.system) {
  19671. name = 'Narwhal';
  19672. os || (os = data[0].os || null);
  19673. }
  19674. }
  19675. if (!name) {
  19676. name = 'Rhino';
  19677. }
  19678. }
  19679. else if (
  19680. typeof context.process == 'object' && !context.process.browser &&
  19681. (data = context.process)
  19682. ) {
  19683. if (typeof data.versions == 'object') {
  19684. if (typeof data.versions.electron == 'string') {
  19685. description.push('Node ' + data.versions.node);
  19686. name = 'Electron';
  19687. version = data.versions.electron;
  19688. } else if (typeof data.versions.nw == 'string') {
  19689. description.push('Chromium ' + version, 'Node ' + data.versions.node);
  19690. name = 'NW.js';
  19691. version = data.versions.nw;
  19692. }
  19693. }
  19694. if (!name) {
  19695. name = 'Node.js';
  19696. arch = data.arch;
  19697. os = data.platform;
  19698. version = /[\d.]+/.exec(data.version);
  19699. version = version ? version[0] : null;
  19700. }
  19701. }
  19702. }
  19703. // Detect Adobe AIR.
  19704. else if (getClassOf((data = context.runtime)) == airRuntimeClass) {
  19705. name = 'Adobe AIR';
  19706. os = data.flash.system.Capabilities.os;
  19707. }
  19708. // Detect PhantomJS.
  19709. else if (getClassOf((data = context.phantom)) == phantomClass) {
  19710. name = 'PhantomJS';
  19711. version = (data = data.version || null) && (data.major + '.' + data.minor + '.' + data.patch);
  19712. }
  19713. // Detect IE compatibility modes.
  19714. else if (typeof doc.documentMode == 'number' && (data = /\bTrident\/(\d+)/i.exec(ua))) {
  19715. // We're in compatibility mode when the Trident version + 4 doesn't
  19716. // equal the document mode.
  19717. version = [version, doc.documentMode];
  19718. if ((data = +data[1] + 4) != version[1]) {
  19719. description.push('IE ' + version[1] + ' mode');
  19720. layout && (layout[1] = '');
  19721. version[1] = data;
  19722. }
  19723. version = name == 'IE' ? String(version[1].toFixed(1)) : version[0];
  19724. }
  19725. // Detect IE 11 masking as other browsers.
  19726. else if (typeof doc.documentMode == 'number' && /^(?:Chrome|Firefox)\b/.test(name)) {
  19727. description.push('masking as ' + name + ' ' + version);
  19728. name = 'IE';
  19729. version = '11.0';
  19730. layout = ['Trident'];
  19731. os = 'Windows';
  19732. }
  19733. os = os && format(os);
  19734. }
  19735. // Detect prerelease phases.
  19736. if (version && (data =
  19737. /(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(version) ||
  19738. /(?:alpha|beta)(?: ?\d)?/i.exec(ua + ';' + (useFeatures && nav.appMinorVersion)) ||
  19739. /\bMinefield\b/i.test(ua) && 'a'
  19740. )) {
  19741. prerelease = /b/i.test(data) ? 'beta' : 'alpha';
  19742. version = version.replace(RegExp(data + '\\+?$'), '') +
  19743. (prerelease == 'beta' ? beta : alpha) + (/\d+\+?/.exec(data) || '');
  19744. }
  19745. // Detect Firefox Mobile.
  19746. if (name == 'Fennec' || name == 'Firefox' && /\b(?:Android|Firefox OS)\b/.test(os)) {
  19747. name = 'Firefox Mobile';
  19748. }
  19749. // Obscure Maxthon's unreliable version.
  19750. else if (name == 'Maxthon' && version) {
  19751. version = version.replace(/\.[\d.]+/, '.x');
  19752. }
  19753. // Detect Xbox 360 and Xbox One.
  19754. else if (/\bXbox\b/i.test(product)) {
  19755. if (product == 'Xbox 360') {
  19756. os = null;
  19757. }
  19758. if (product == 'Xbox 360' && /\bIEMobile\b/.test(ua)) {
  19759. description.unshift('mobile mode');
  19760. }
  19761. }
  19762. // Add mobile postfix.
  19763. else if ((/^(?:Chrome|IE|Opera)$/.test(name) || name && !product && !/Browser|Mobi/.test(name)) &&
  19764. (os == 'Windows CE' || /Mobi/i.test(ua))) {
  19765. name += ' Mobile';
  19766. }
  19767. // Detect IE platform preview.
  19768. else if (name == 'IE' && useFeatures) {
  19769. try {
  19770. if (context.external === null) {
  19771. description.unshift('platform preview');
  19772. }
  19773. } catch(e) {
  19774. description.unshift('embedded');
  19775. }
  19776. }
  19777. // Detect BlackBerry OS version.
  19778. // http://docs.blackberry.com/en/developers/deliverables/18169/HTTP_headers_sent_by_BB_Browser_1234911_11.jsp
  19779. else if ((/\bBlackBerry\b/.test(product) || /\bBB10\b/.test(ua)) && (data =
  19780. (RegExp(product.replace(/ +/g, ' *') + '/([.\\d]+)', 'i').exec(ua) || 0)[1] ||
  19781. version
  19782. )) {
  19783. data = [data, /BB10/.test(ua)];
  19784. os = (data[1] ? (product = null, manufacturer = 'BlackBerry') : 'Device Software') + ' ' + data[0];
  19785. version = null;
  19786. }
  19787. // Detect Opera identifying/masking itself as another browser.
  19788. // http://www.opera.com/support/kb/view/843/
  19789. else if (this != forOwn && product != 'Wii' && (
  19790. (useFeatures && opera) ||
  19791. (/Opera/.test(name) && /\b(?:MSIE|Firefox)\b/i.test(ua)) ||
  19792. (name == 'Firefox' && /\bOS X (?:\d+\.){2,}/.test(os)) ||
  19793. (name == 'IE' && (
  19794. (os && !/^Win/.test(os) && version > 5.5) ||
  19795. /\bWindows XP\b/.test(os) && version > 8 ||
  19796. version == 8 && !/\bTrident\b/.test(ua)
  19797. ))
  19798. ) && !reOpera.test((data = parse.call(forOwn, ua.replace(reOpera, '') + ';'))) && data.name) {
  19799. // When "identifying", the UA contains both Opera and the other browser's name.
  19800. data = 'ing as ' + data.name + ((data = data.version) ? ' ' + data : '');
  19801. if (reOpera.test(name)) {
  19802. if (/\bIE\b/.test(data) && os == 'Mac OS') {
  19803. os = null;
  19804. }
  19805. data = 'identify' + data;
  19806. }
  19807. // When "masking", the UA contains only the other browser's name.
  19808. else {
  19809. data = 'mask' + data;
  19810. if (operaClass) {
  19811. name = format(operaClass.replace(/([a-z])([A-Z])/g, '$1 $2'));
  19812. } else {
  19813. name = 'Opera';
  19814. }
  19815. if (/\bIE\b/.test(data)) {
  19816. os = null;
  19817. }
  19818. if (!useFeatures) {
  19819. version = null;
  19820. }
  19821. }
  19822. layout = ['Presto'];
  19823. description.push(data);
  19824. }
  19825. // Detect WebKit Nightly and approximate Chrome/Safari versions.
  19826. if ((data = (/\bAppleWebKit\/([\d.]+\+?)/i.exec(ua) || 0)[1])) {
  19827. // Correct build number for numeric comparison.
  19828. // (e.g. "532.5" becomes "532.05")
  19829. data = [parseFloat(data.replace(/\.(\d)$/, '.0$1')), data];
  19830. // Nightly builds are postfixed with a "+".
  19831. if (name == 'Safari' && data[1].slice(-1) == '+') {
  19832. name = 'WebKit Nightly';
  19833. prerelease = 'alpha';
  19834. version = data[1].slice(0, -1);
  19835. }
  19836. // Clear incorrect browser versions.
  19837. else if (version == data[1] ||
  19838. version == (data[2] = (/\bSafari\/([\d.]+\+?)/i.exec(ua) || 0)[1])) {
  19839. version = null;
  19840. }
  19841. // Use the full Chrome version when available.
  19842. data[1] = (/\bChrome\/([\d.]+)/i.exec(ua) || 0)[1];
  19843. // Detect Blink layout engine.
  19844. if (data[0] == 537.36 && data[2] == 537.36 && parseFloat(data[1]) >= 28 && layout == 'WebKit') {
  19845. layout = ['Blink'];
  19846. }
  19847. // Detect JavaScriptCore.
  19848. // http://stackoverflow.com/questions/6768474/how-can-i-detect-which-javascript-engine-v8-or-jsc-is-used-at-runtime-in-androi
  19849. if (!useFeatures || (!likeChrome && !data[1])) {
  19850. layout && (layout[1] = 'like Safari');
  19851. data = (data = data[0], data < 400 ? 1 : data < 500 ? 2 : data < 526 ? 3 : data < 533 ? 4 : data < 534 ? '4+' : data < 535 ? 5 : data < 537 ? 6 : data < 538 ? 7 : data < 601 ? 8 : '8');
  19852. } else {
  19853. layout && (layout[1] = 'like Chrome');
  19854. data = data[1] || (data = data[0], data < 530 ? 1 : data < 532 ? 2 : data < 532.05 ? 3 : data < 533 ? 4 : data < 534.03 ? 5 : data < 534.07 ? 6 : data < 534.10 ? 7 : data < 534.13 ? 8 : data < 534.16 ? 9 : data < 534.24 ? 10 : data < 534.30 ? 11 : data < 535.01 ? 12 : data < 535.02 ? '13+' : data < 535.07 ? 15 : data < 535.11 ? 16 : data < 535.19 ? 17 : data < 536.05 ? 18 : data < 536.10 ? 19 : data < 537.01 ? 20 : data < 537.11 ? '21+' : data < 537.13 ? 23 : data < 537.18 ? 24 : data < 537.24 ? 25 : data < 537.36 ? 26 : layout != 'Blink' ? '27' : '28');
  19855. }
  19856. // Add the postfix of ".x" or "+" for approximate versions.
  19857. layout && (layout[1] += ' ' + (data += typeof data == 'number' ? '.x' : /[.+]/.test(data) ? '' : '+'));
  19858. // Obscure version for some Safari 1-2 releases.
  19859. if (name == 'Safari' && (!version || parseInt(version) > 45)) {
  19860. version = data;
  19861. }
  19862. }
  19863. // Detect Opera desktop modes.
  19864. if (name == 'Opera' && (data = /\bzbov|zvav$/.exec(os))) {
  19865. name += ' ';
  19866. description.unshift('desktop mode');
  19867. if (data == 'zvav') {
  19868. name += 'Mini';
  19869. version = null;
  19870. } else {
  19871. name += 'Mobile';
  19872. }
  19873. os = os.replace(RegExp(' *' + data + '$'), '');
  19874. }
  19875. // Detect Chrome desktop mode.
  19876. else if (name == 'Safari' && /\bChrome\b/.exec(layout && layout[1])) {
  19877. description.unshift('desktop mode');
  19878. name = 'Chrome Mobile';
  19879. version = null;
  19880. if (/\bOS X\b/.test(os)) {
  19881. manufacturer = 'Apple';
  19882. os = 'iOS 4.3+';
  19883. } else {
  19884. os = null;
  19885. }
  19886. }
  19887. // Strip incorrect OS versions.
  19888. if (version && version.indexOf((data = /[\d.]+$/.exec(os))) == 0 &&
  19889. ua.indexOf('/' + data + '-') > -1) {
  19890. os = trim(os.replace(data, ''));
  19891. }
  19892. // Add layout engine.
  19893. if (layout && !/\b(?:Avant|Nook)\b/.test(name) && (
  19894. /Browser|Lunascape|Maxthon/.test(name) ||
  19895. name != 'Safari' && /^iOS/.test(os) && /\bSafari\b/.test(layout[1]) ||
  19896. /^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|Web)/.test(name) && layout[1])) {
  19897. // Don't add layout details to description if they are falsey.
  19898. (data = layout[layout.length - 1]) && description.push(data);
  19899. }
  19900. // Combine contextual information.
  19901. if (description.length) {
  19902. description = ['(' + description.join('; ') + ')'];
  19903. }
  19904. // Append manufacturer to description.
  19905. if (manufacturer && product && product.indexOf(manufacturer) < 0) {
  19906. description.push('on ' + manufacturer);
  19907. }
  19908. // Append product to description.
  19909. if (product) {
  19910. description.push((/^on /.test(description[description.length - 1]) ? '' : 'on ') + product);
  19911. }
  19912. // Parse the OS into an object.
  19913. if (os) {
  19914. data = / ([\d.+]+)$/.exec(os);
  19915. isSpecialCasedOS = data && os.charAt(os.length - data[0].length - 1) == '/';
  19916. os = {
  19917. 'architecture': 32,
  19918. 'family': (data && !isSpecialCasedOS) ? os.replace(data[0], '') : os,
  19919. 'version': data ? data[1] : null,
  19920. 'toString': function() {
  19921. var version = this.version;
  19922. return this.family + ((version && !isSpecialCasedOS) ? ' ' + version : '') + (this.architecture == 64 ? ' 64-bit' : '');
  19923. }
  19924. };
  19925. }
  19926. // Add browser/OS architecture.
  19927. if ((data = /\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(arch)) && !/\bi686\b/i.test(arch)) {
  19928. if (os) {
  19929. os.architecture = 64;
  19930. os.family = os.family.replace(RegExp(' *' + data), '');
  19931. }
  19932. if (
  19933. name && (/\bWOW64\b/i.test(ua) ||
  19934. (useFeatures && /\w(?:86|32)$/.test(nav.cpuClass || nav.platform) && !/\bWin64; x64\b/i.test(ua)))
  19935. ) {
  19936. description.unshift('32-bit');
  19937. }
  19938. }
  19939. // Chrome 39 and above on OS X is always 64-bit.
  19940. else if (
  19941. os && /^OS X/.test(os.family) &&
  19942. name == 'Chrome' && parseFloat(version) >= 39
  19943. ) {
  19944. os.architecture = 64;
  19945. }
  19946. ua || (ua = null);
  19947. /*------------------------------------------------------------------------*/
  19948. /**
  19949. * The platform object.
  19950. *
  19951. * @name platform
  19952. * @type Object
  19953. */
  19954. var platform = {};
  19955. /**
  19956. * The platform description.
  19957. *
  19958. * @memberOf platform
  19959. * @type string|null
  19960. */
  19961. platform.description = ua;
  19962. /**
  19963. * The name of the browser's layout engine.
  19964. *
  19965. * The list of common layout engines include:
  19966. * "Blink", "EdgeHTML", "Gecko", "Trident" and "WebKit"
  19967. *
  19968. * @memberOf platform
  19969. * @type string|null
  19970. */
  19971. platform.layout = layout && layout[0];
  19972. /**
  19973. * The name of the product's manufacturer.
  19974. *
  19975. * The list of manufacturers include:
  19976. * "Apple", "Archos", "Amazon", "Asus", "Barnes & Noble", "BlackBerry",
  19977. * "Google", "HP", "HTC", "LG", "Microsoft", "Motorola", "Nintendo",
  19978. * "Nokia", "Samsung" and "Sony"
  19979. *
  19980. * @memberOf platform
  19981. * @type string|null
  19982. */
  19983. platform.manufacturer = manufacturer;
  19984. /**
  19985. * The name of the browser/environment.
  19986. *
  19987. * The list of common browser names include:
  19988. * "Chrome", "Electron", "Firefox", "Firefox for iOS", "IE",
  19989. * "Microsoft Edge", "PhantomJS", "Safari", "SeaMonkey", "Silk",
  19990. * "Opera Mini" and "Opera"
  19991. *
  19992. * Mobile versions of some browsers have "Mobile" appended to their name:
  19993. * eg. "Chrome Mobile", "Firefox Mobile", "IE Mobile" and "Opera Mobile"
  19994. *
  19995. * @memberOf platform
  19996. * @type string|null
  19997. */
  19998. platform.name = name;
  19999. /**
  20000. * The alpha/beta release indicator.
  20001. *
  20002. * @memberOf platform
  20003. * @type string|null
  20004. */
  20005. platform.prerelease = prerelease;
  20006. /**
  20007. * The name of the product hosting the browser.
  20008. *
  20009. * The list of common products include:
  20010. *
  20011. * "BlackBerry", "Galaxy S4", "Lumia", "iPad", "iPod", "iPhone", "Kindle",
  20012. * "Kindle Fire", "Nexus", "Nook", "PlayBook", "TouchPad" and "Transformer"
  20013. *
  20014. * @memberOf platform
  20015. * @type string|null
  20016. */
  20017. platform.product = product;
  20018. /**
  20019. * The browser's user agent string.
  20020. *
  20021. * @memberOf platform
  20022. * @type string|null
  20023. */
  20024. platform.ua = ua;
  20025. /**
  20026. * The browser/environment version.
  20027. *
  20028. * @memberOf platform
  20029. * @type string|null
  20030. */
  20031. platform.version = name && version;
  20032. /**
  20033. * The name of the operating system.
  20034. *
  20035. * @memberOf platform
  20036. * @type Object
  20037. */
  20038. platform.os = os || {
  20039. /**
  20040. * The CPU architecture the OS is built for.
  20041. *
  20042. * @memberOf platform.os
  20043. * @type number|null
  20044. */
  20045. 'architecture': null,
  20046. /**
  20047. * The family of the OS.
  20048. *
  20049. * Common values include:
  20050. * "Windows", "Windows Server 2008 R2 / 7", "Windows Server 2008 / Vista",
  20051. * "Windows XP", "OS X", "Ubuntu", "Debian", "Fedora", "Red Hat", "SuSE",
  20052. * "Android", "iOS" and "Windows Phone"
  20053. *
  20054. * @memberOf platform.os
  20055. * @type string|null
  20056. */
  20057. 'family': null,
  20058. /**
  20059. * The version of the OS.
  20060. *
  20061. * @memberOf platform.os
  20062. * @type string|null
  20063. */
  20064. 'version': null,
  20065. /**
  20066. * Returns the OS string.
  20067. *
  20068. * @memberOf platform.os
  20069. * @returns {string} The OS string.
  20070. */
  20071. 'toString': function() { return 'null'; }
  20072. };
  20073. platform.parse = parse;
  20074. platform.toString = toStringPlatform;
  20075. if (platform.version) {
  20076. description.unshift(version);
  20077. }
  20078. if (platform.name) {
  20079. description.unshift(name);
  20080. }
  20081. if (os && name && !(os == String(os).split(' ')[0] && (os == name.split(' ')[0] || product))) {
  20082. description.push(product ? '(' + os + ')' : 'on ' + os);
  20083. }
  20084. if (description.length) {
  20085. platform.description = description.join(' ');
  20086. }
  20087. return platform;
  20088. }
  20089. /*--------------------------------------------------------------------------*/
  20090. // Export platform.
  20091. var platform = parse();
  20092. // Some AMD build optimizers, like r.js, check for condition patterns like the following:
  20093. if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
  20094. // Expose platform on the global object to prevent errors when platform is
  20095. // loaded by a script tag in the presence of an AMD loader.
  20096. // See http://requirejs.org/docs/errors.html#mismatch for more details.
  20097. root.platform = platform;
  20098. // Define as an anonymous module so platform can be aliased through path mapping.
  20099. define(function() {
  20100. return platform;
  20101. });
  20102. }
  20103. // Check for `exports` after `define` in case a build optimizer adds an `exports` object.
  20104. else if (freeExports && freeModule) {
  20105. // Export for CommonJS support.
  20106. forOwn(platform, function(value, key) {
  20107. freeExports[key] = value;
  20108. });
  20109. }
  20110. else {
  20111. // Export to the global object.
  20112. root.platform = platform;
  20113. }
  20114. }.call(this));
  20115. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  20116. },{}],318:[function(require,module,exports){
  20117. (function (process){
  20118. 'use strict';
  20119. if (typeof process === 'undefined' ||
  20120. !process.version ||
  20121. process.version.indexOf('v0.') === 0 ||
  20122. process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
  20123. module.exports = { nextTick: nextTick };
  20124. } else {
  20125. module.exports = process
  20126. }
  20127. function nextTick(fn, arg1, arg2, arg3) {
  20128. if (typeof fn !== 'function') {
  20129. throw new TypeError('"callback" argument must be a function');
  20130. }
  20131. var len = arguments.length;
  20132. var args, i;
  20133. switch (len) {
  20134. case 0:
  20135. case 1:
  20136. return process.nextTick(fn);
  20137. case 2:
  20138. return process.nextTick(function afterTickOne() {
  20139. fn.call(null, arg1);
  20140. });
  20141. case 3:
  20142. return process.nextTick(function afterTickTwo() {
  20143. fn.call(null, arg1, arg2);
  20144. });
  20145. case 4:
  20146. return process.nextTick(function afterTickThree() {
  20147. fn.call(null, arg1, arg2, arg3);
  20148. });
  20149. default:
  20150. args = new Array(len - 1);
  20151. i = 0;
  20152. while (i < args.length) {
  20153. args[i++] = arguments[i];
  20154. }
  20155. return process.nextTick(function afterTick() {
  20156. fn.apply(null, args);
  20157. });
  20158. }
  20159. }
  20160. }).call(this,require('_process'))
  20161. },{"_process":393}],319:[function(require,module,exports){
  20162. var immediate = require('immediate');
  20163. var process = module.exports = {};
  20164. process.nextTick = immediate
  20165. process.title = 'browser';
  20166. process.title1 = 'test123';
  20167. process.browser = true;
  20168. process.env = {};
  20169. process.argv = [];
  20170. process.version = ''; // empty string to avoid regexp issues
  20171. process.versions = {};
  20172. function noop() {}
  20173. process.on = noop;
  20174. process.addListener = noop;
  20175. process.once = noop;
  20176. process.off = noop;
  20177. process.removeListener = noop;
  20178. process.removeAllListeners = noop;
  20179. process.emit = noop;
  20180. process.prependListener = noop;
  20181. process.prependOnceListener = noop;
  20182. process.listeners = function (name) { return [] }
  20183. process.binding = function (name) {
  20184. throw new Error('process.binding is not supported');
  20185. };
  20186. process.cwd = function () { return '/' };
  20187. process.chdir = function (dir) {
  20188. throw new Error('process.chdir is not supported');
  20189. };
  20190. process.umask = function() { return 0; };
  20191. },{"immediate":301}],320:[function(require,module,exports){
  20192. (function (global){
  20193. /*! https://mths.be/punycode v1.4.1 by @mathias */
  20194. ;(function(root) {
  20195. /** Detect free variables */
  20196. var freeExports = typeof exports == 'object' && exports &&
  20197. !exports.nodeType && exports;
  20198. var freeModule = typeof module == 'object' && module &&
  20199. !module.nodeType && module;
  20200. var freeGlobal = typeof global == 'object' && global;
  20201. if (
  20202. freeGlobal.global === freeGlobal ||
  20203. freeGlobal.window === freeGlobal ||
  20204. freeGlobal.self === freeGlobal
  20205. ) {
  20206. root = freeGlobal;
  20207. }
  20208. /**
  20209. * The `punycode` object.
  20210. * @name punycode
  20211. * @type Object
  20212. */
  20213. var punycode,
  20214. /** Highest positive signed 32-bit float value */
  20215. maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1
  20216. /** Bootstring parameters */
  20217. base = 36,
  20218. tMin = 1,
  20219. tMax = 26,
  20220. skew = 38,
  20221. damp = 700,
  20222. initialBias = 72,
  20223. initialN = 128, // 0x80
  20224. delimiter = '-', // '\x2D'
  20225. /** Regular expressions */
  20226. regexPunycode = /^xn--/,
  20227. regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars
  20228. regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators
  20229. /** Error messages */
  20230. errors = {
  20231. 'overflow': 'Overflow: input needs wider integers to process',
  20232. 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
  20233. 'invalid-input': 'Invalid input'
  20234. },
  20235. /** Convenience shortcuts */
  20236. baseMinusTMin = base - tMin,
  20237. floor = Math.floor,
  20238. stringFromCharCode = String.fromCharCode,
  20239. /** Temporary variable */
  20240. key;
  20241. /*--------------------------------------------------------------------------*/
  20242. /**
  20243. * A generic error utility function.
  20244. * @private
  20245. * @param {String} type The error type.
  20246. * @returns {Error} Throws a `RangeError` with the applicable error message.
  20247. */
  20248. function error(type) {
  20249. throw new RangeError(errors[type]);
  20250. }
  20251. /**
  20252. * A generic `Array#map` utility function.
  20253. * @private
  20254. * @param {Array} array The array to iterate over.
  20255. * @param {Function} callback The function that gets called for every array
  20256. * item.
  20257. * @returns {Array} A new array of values returned by the callback function.
  20258. */
  20259. function map(array, fn) {
  20260. var length = array.length;
  20261. var result = [];
  20262. while (length--) {
  20263. result[length] = fn(array[length]);
  20264. }
  20265. return result;
  20266. }
  20267. /**
  20268. * A simple `Array#map`-like wrapper to work with domain name strings or email
  20269. * addresses.
  20270. * @private
  20271. * @param {String} domain The domain name or email address.
  20272. * @param {Function} callback The function that gets called for every
  20273. * character.
  20274. * @returns {Array} A new string of characters returned by the callback
  20275. * function.
  20276. */
  20277. function mapDomain(string, fn) {
  20278. var parts = string.split('@');
  20279. var result = '';
  20280. if (parts.length > 1) {
  20281. // In email addresses, only the domain name should be punycoded. Leave
  20282. // the local part (i.e. everything up to `@`) intact.
  20283. result = parts[0] + '@';
  20284. string = parts[1];
  20285. }
  20286. // Avoid `split(regex)` for IE8 compatibility. See #17.
  20287. string = string.replace(regexSeparators, '\x2E');
  20288. var labels = string.split('.');
  20289. var encoded = map(labels, fn).join('.');
  20290. return result + encoded;
  20291. }
  20292. /**
  20293. * Creates an array containing the numeric code points of each Unicode
  20294. * character in the string. While JavaScript uses UCS-2 internally,
  20295. * this function will convert a pair of surrogate halves (each of which
  20296. * UCS-2 exposes as separate characters) into a single code point,
  20297. * matching UTF-16.
  20298. * @see `punycode.ucs2.encode`
  20299. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  20300. * @memberOf punycode.ucs2
  20301. * @name decode
  20302. * @param {String} string The Unicode input string (UCS-2).
  20303. * @returns {Array} The new array of code points.
  20304. */
  20305. function ucs2decode(string) {
  20306. var output = [],
  20307. counter = 0,
  20308. length = string.length,
  20309. value,
  20310. extra;
  20311. while (counter < length) {
  20312. value = string.charCodeAt(counter++);
  20313. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  20314. // high surrogate, and there is a next character
  20315. extra = string.charCodeAt(counter++);
  20316. if ((extra & 0xFC00) == 0xDC00) { // low surrogate
  20317. output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  20318. } else {
  20319. // unmatched surrogate; only append this code unit, in case the next
  20320. // code unit is the high surrogate of a surrogate pair
  20321. output.push(value);
  20322. counter--;
  20323. }
  20324. } else {
  20325. output.push(value);
  20326. }
  20327. }
  20328. return output;
  20329. }
  20330. /**
  20331. * Creates a string based on an array of numeric code points.
  20332. * @see `punycode.ucs2.decode`
  20333. * @memberOf punycode.ucs2
  20334. * @name encode
  20335. * @param {Array} codePoints The array of numeric code points.
  20336. * @returns {String} The new Unicode string (UCS-2).
  20337. */
  20338. function ucs2encode(array) {
  20339. return map(array, function(value) {
  20340. var output = '';
  20341. if (value > 0xFFFF) {
  20342. value -= 0x10000;
  20343. output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
  20344. value = 0xDC00 | value & 0x3FF;
  20345. }
  20346. output += stringFromCharCode(value);
  20347. return output;
  20348. }).join('');
  20349. }
  20350. /**
  20351. * Converts a basic code point into a digit/integer.
  20352. * @see `digitToBasic()`
  20353. * @private
  20354. * @param {Number} codePoint The basic numeric code point value.
  20355. * @returns {Number} The numeric value of a basic code point (for use in
  20356. * representing integers) in the range `0` to `base - 1`, or `base` if
  20357. * the code point does not represent a value.
  20358. */
  20359. function basicToDigit(codePoint) {
  20360. if (codePoint - 48 < 10) {
  20361. return codePoint - 22;
  20362. }
  20363. if (codePoint - 65 < 26) {
  20364. return codePoint - 65;
  20365. }
  20366. if (codePoint - 97 < 26) {
  20367. return codePoint - 97;
  20368. }
  20369. return base;
  20370. }
  20371. /**
  20372. * Converts a digit/integer into a basic code point.
  20373. * @see `basicToDigit()`
  20374. * @private
  20375. * @param {Number} digit The numeric value of a basic code point.
  20376. * @returns {Number} The basic code point whose value (when used for
  20377. * representing integers) is `digit`, which needs to be in the range
  20378. * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
  20379. * used; else, the lowercase form is used. The behavior is undefined
  20380. * if `flag` is non-zero and `digit` has no uppercase form.
  20381. */
  20382. function digitToBasic(digit, flag) {
  20383. // 0..25 map to ASCII a..z or A..Z
  20384. // 26..35 map to ASCII 0..9
  20385. return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
  20386. }
  20387. /**
  20388. * Bias adaptation function as per section 3.4 of RFC 3492.
  20389. * https://tools.ietf.org/html/rfc3492#section-3.4
  20390. * @private
  20391. */
  20392. function adapt(delta, numPoints, firstTime) {
  20393. var k = 0;
  20394. delta = firstTime ? floor(delta / damp) : delta >> 1;
  20395. delta += floor(delta / numPoints);
  20396. for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {
  20397. delta = floor(delta / baseMinusTMin);
  20398. }
  20399. return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
  20400. }
  20401. /**
  20402. * Converts a Punycode string of ASCII-only symbols to a string of Unicode
  20403. * symbols.
  20404. * @memberOf punycode
  20405. * @param {String} input The Punycode string of ASCII-only symbols.
  20406. * @returns {String} The resulting string of Unicode symbols.
  20407. */
  20408. function decode(input) {
  20409. // Don't use UCS-2
  20410. var output = [],
  20411. inputLength = input.length,
  20412. out,
  20413. i = 0,
  20414. n = initialN,
  20415. bias = initialBias,
  20416. basic,
  20417. j,
  20418. index,
  20419. oldi,
  20420. w,
  20421. k,
  20422. digit,
  20423. t,
  20424. /** Cached calculation results */
  20425. baseMinusT;
  20426. // Handle the basic code points: let `basic` be the number of input code
  20427. // points before the last delimiter, or `0` if there is none, then copy
  20428. // the first basic code points to the output.
  20429. basic = input.lastIndexOf(delimiter);
  20430. if (basic < 0) {
  20431. basic = 0;
  20432. }
  20433. for (j = 0; j < basic; ++j) {
  20434. // if it's not a basic code point
  20435. if (input.charCodeAt(j) >= 0x80) {
  20436. error('not-basic');
  20437. }
  20438. output.push(input.charCodeAt(j));
  20439. }
  20440. // Main decoding loop: start just after the last delimiter if any basic code
  20441. // points were copied; start at the beginning otherwise.
  20442. for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {
  20443. // `index` is the index of the next character to be consumed.
  20444. // Decode a generalized variable-length integer into `delta`,
  20445. // which gets added to `i`. The overflow checking is easier
  20446. // if we increase `i` as we go, then subtract off its starting
  20447. // value at the end to obtain `delta`.
  20448. for (oldi = i, w = 1, k = base; /* no condition */; k += base) {
  20449. if (index >= inputLength) {
  20450. error('invalid-input');
  20451. }
  20452. digit = basicToDigit(input.charCodeAt(index++));
  20453. if (digit >= base || digit > floor((maxInt - i) / w)) {
  20454. error('overflow');
  20455. }
  20456. i += digit * w;
  20457. t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  20458. if (digit < t) {
  20459. break;
  20460. }
  20461. baseMinusT = base - t;
  20462. if (w > floor(maxInt / baseMinusT)) {
  20463. error('overflow');
  20464. }
  20465. w *= baseMinusT;
  20466. }
  20467. out = output.length + 1;
  20468. bias = adapt(i - oldi, out, oldi == 0);
  20469. // `i` was supposed to wrap around from `out` to `0`,
  20470. // incrementing `n` each time, so we'll fix that now:
  20471. if (floor(i / out) > maxInt - n) {
  20472. error('overflow');
  20473. }
  20474. n += floor(i / out);
  20475. i %= out;
  20476. // Insert `n` at position `i` of the output
  20477. output.splice(i++, 0, n);
  20478. }
  20479. return ucs2encode(output);
  20480. }
  20481. /**
  20482. * Converts a string of Unicode symbols (e.g. a domain name label) to a
  20483. * Punycode string of ASCII-only symbols.
  20484. * @memberOf punycode
  20485. * @param {String} input The string of Unicode symbols.
  20486. * @returns {String} The resulting Punycode string of ASCII-only symbols.
  20487. */
  20488. function encode(input) {
  20489. var n,
  20490. delta,
  20491. handledCPCount,
  20492. basicLength,
  20493. bias,
  20494. j,
  20495. m,
  20496. q,
  20497. k,
  20498. t,
  20499. currentValue,
  20500. output = [],
  20501. /** `inputLength` will hold the number of code points in `input`. */
  20502. inputLength,
  20503. /** Cached calculation results */
  20504. handledCPCountPlusOne,
  20505. baseMinusT,
  20506. qMinusT;
  20507. // Convert the input in UCS-2 to Unicode
  20508. input = ucs2decode(input);
  20509. // Cache the length
  20510. inputLength = input.length;
  20511. // Initialize the state
  20512. n = initialN;
  20513. delta = 0;
  20514. bias = initialBias;
  20515. // Handle the basic code points
  20516. for (j = 0; j < inputLength; ++j) {
  20517. currentValue = input[j];
  20518. if (currentValue < 0x80) {
  20519. output.push(stringFromCharCode(currentValue));
  20520. }
  20521. }
  20522. handledCPCount = basicLength = output.length;
  20523. // `handledCPCount` is the number of code points that have been handled;
  20524. // `basicLength` is the number of basic code points.
  20525. // Finish the basic string - if it is not empty - with a delimiter
  20526. if (basicLength) {
  20527. output.push(delimiter);
  20528. }
  20529. // Main encoding loop:
  20530. while (handledCPCount < inputLength) {
  20531. // All non-basic code points < n have been handled already. Find the next
  20532. // larger one:
  20533. for (m = maxInt, j = 0; j < inputLength; ++j) {
  20534. currentValue = input[j];
  20535. if (currentValue >= n && currentValue < m) {
  20536. m = currentValue;
  20537. }
  20538. }
  20539. // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
  20540. // but guard against overflow
  20541. handledCPCountPlusOne = handledCPCount + 1;
  20542. if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
  20543. error('overflow');
  20544. }
  20545. delta += (m - n) * handledCPCountPlusOne;
  20546. n = m;
  20547. for (j = 0; j < inputLength; ++j) {
  20548. currentValue = input[j];
  20549. if (currentValue < n && ++delta > maxInt) {
  20550. error('overflow');
  20551. }
  20552. if (currentValue == n) {
  20553. // Represent delta as a generalized variable-length integer
  20554. for (q = delta, k = base; /* no condition */; k += base) {
  20555. t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  20556. if (q < t) {
  20557. break;
  20558. }
  20559. qMinusT = q - t;
  20560. baseMinusT = base - t;
  20561. output.push(
  20562. stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
  20563. );
  20564. q = floor(qMinusT / baseMinusT);
  20565. }
  20566. output.push(stringFromCharCode(digitToBasic(q, 0)));
  20567. bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
  20568. delta = 0;
  20569. ++handledCPCount;
  20570. }
  20571. }
  20572. ++delta;
  20573. ++n;
  20574. }
  20575. return output.join('');
  20576. }
  20577. /**
  20578. * Converts a Punycode string representing a domain name or an email address
  20579. * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
  20580. * it doesn't matter if you call it on a string that has already been
  20581. * converted to Unicode.
  20582. * @memberOf punycode
  20583. * @param {String} input The Punycoded domain name or email address to
  20584. * convert to Unicode.
  20585. * @returns {String} The Unicode representation of the given Punycode
  20586. * string.
  20587. */
  20588. function toUnicode(input) {
  20589. return mapDomain(input, function(string) {
  20590. return regexPunycode.test(string)
  20591. ? decode(string.slice(4).toLowerCase())
  20592. : string;
  20593. });
  20594. }
  20595. /**
  20596. * Converts a Unicode string representing a domain name or an email address to
  20597. * Punycode. Only the non-ASCII parts of the domain name will be converted,
  20598. * i.e. it doesn't matter if you call it with a domain that's already in
  20599. * ASCII.
  20600. * @memberOf punycode
  20601. * @param {String} input The domain name or email address to convert, as a
  20602. * Unicode string.
  20603. * @returns {String} The Punycode representation of the given domain name or
  20604. * email address.
  20605. */
  20606. function toASCII(input) {
  20607. return mapDomain(input, function(string) {
  20608. return regexNonASCII.test(string)
  20609. ? 'xn--' + encode(string)
  20610. : string;
  20611. });
  20612. }
  20613. /*--------------------------------------------------------------------------*/
  20614. /** Define the public API */
  20615. punycode = {
  20616. /**
  20617. * A string representing the current Punycode.js version number.
  20618. * @memberOf punycode
  20619. * @type String
  20620. */
  20621. 'version': '1.4.1',
  20622. /**
  20623. * An object of methods to convert from JavaScript's internal character
  20624. * representation (UCS-2) to Unicode code points, and back.
  20625. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  20626. * @memberOf punycode
  20627. * @type Object
  20628. */
  20629. 'ucs2': {
  20630. 'decode': ucs2decode,
  20631. 'encode': ucs2encode
  20632. },
  20633. 'decode': decode,
  20634. 'encode': encode,
  20635. 'toASCII': toASCII,
  20636. 'toUnicode': toUnicode
  20637. };
  20638. /** Expose `punycode` */
  20639. // Some AMD build optimizers, like r.js, check for specific condition patterns
  20640. // like the following:
  20641. if (
  20642. typeof define == 'function' &&
  20643. typeof define.amd == 'object' &&
  20644. define.amd
  20645. ) {
  20646. define('punycode', function() {
  20647. return punycode;
  20648. });
  20649. } else if (freeExports && freeModule) {
  20650. if (module.exports == freeExports) {
  20651. // in Node.js, io.js, or RingoJS v0.8.0+
  20652. freeModule.exports = punycode;
  20653. } else {
  20654. // in Narwhal or RingoJS v0.7.0-
  20655. for (key in punycode) {
  20656. punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
  20657. }
  20658. }
  20659. } else {
  20660. // in Rhino or a web browser
  20661. root.punycode = punycode;
  20662. }
  20663. }(this));
  20664. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  20665. },{}],321:[function(require,module,exports){
  20666. // Copyright Joyent, Inc. and other Node contributors.
  20667. //
  20668. // Permission is hereby granted, free of charge, to any person obtaining a
  20669. // copy of this software and associated documentation files (the
  20670. // "Software"), to deal in the Software without restriction, including
  20671. // without limitation the rights to use, copy, modify, merge, publish,
  20672. // distribute, sublicense, and/or sell copies of the Software, and to permit
  20673. // persons to whom the Software is furnished to do so, subject to the
  20674. // following conditions:
  20675. //
  20676. // The above copyright notice and this permission notice shall be included
  20677. // in all copies or substantial portions of the Software.
  20678. //
  20679. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  20680. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20681. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  20682. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  20683. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  20684. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  20685. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  20686. 'use strict';
  20687. // If obj.hasOwnProperty has been overridden, then calling
  20688. // obj.hasOwnProperty(prop) will break.
  20689. // See: https://github.com/joyent/node/issues/1707
  20690. function hasOwnProperty(obj, prop) {
  20691. return Object.prototype.hasOwnProperty.call(obj, prop);
  20692. }
  20693. module.exports = function(qs, sep, eq, options) {
  20694. sep = sep || '&';
  20695. eq = eq || '=';
  20696. var obj = {};
  20697. if (typeof qs !== 'string' || qs.length === 0) {
  20698. return obj;
  20699. }
  20700. var regexp = /\+/g;
  20701. qs = qs.split(sep);
  20702. var maxKeys = 1000;
  20703. if (options && typeof options.maxKeys === 'number') {
  20704. maxKeys = options.maxKeys;
  20705. }
  20706. var len = qs.length;
  20707. // maxKeys <= 0 means that we should not limit keys count
  20708. if (maxKeys > 0 && len > maxKeys) {
  20709. len = maxKeys;
  20710. }
  20711. for (var i = 0; i < len; ++i) {
  20712. var x = qs[i].replace(regexp, '%20'),
  20713. idx = x.indexOf(eq),
  20714. kstr, vstr, k, v;
  20715. if (idx >= 0) {
  20716. kstr = x.substr(0, idx);
  20717. vstr = x.substr(idx + 1);
  20718. } else {
  20719. kstr = x;
  20720. vstr = '';
  20721. }
  20722. k = decodeURIComponent(kstr);
  20723. v = decodeURIComponent(vstr);
  20724. if (!hasOwnProperty(obj, k)) {
  20725. obj[k] = v;
  20726. } else if (isArray(obj[k])) {
  20727. obj[k].push(v);
  20728. } else {
  20729. obj[k] = [obj[k], v];
  20730. }
  20731. }
  20732. return obj;
  20733. };
  20734. var isArray = Array.isArray || function (xs) {
  20735. return Object.prototype.toString.call(xs) === '[object Array]';
  20736. };
  20737. },{}],322:[function(require,module,exports){
  20738. // Copyright Joyent, Inc. and other Node contributors.
  20739. //
  20740. // Permission is hereby granted, free of charge, to any person obtaining a
  20741. // copy of this software and associated documentation files (the
  20742. // "Software"), to deal in the Software without restriction, including
  20743. // without limitation the rights to use, copy, modify, merge, publish,
  20744. // distribute, sublicense, and/or sell copies of the Software, and to permit
  20745. // persons to whom the Software is furnished to do so, subject to the
  20746. // following conditions:
  20747. //
  20748. // The above copyright notice and this permission notice shall be included
  20749. // in all copies or substantial portions of the Software.
  20750. //
  20751. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  20752. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20753. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  20754. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  20755. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  20756. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  20757. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  20758. 'use strict';
  20759. var stringifyPrimitive = function(v) {
  20760. switch (typeof v) {
  20761. case 'string':
  20762. return v;
  20763. case 'boolean':
  20764. return v ? 'true' : 'false';
  20765. case 'number':
  20766. return isFinite(v) ? v : '';
  20767. default:
  20768. return '';
  20769. }
  20770. };
  20771. module.exports = function(obj, sep, eq, name) {
  20772. sep = sep || '&';
  20773. eq = eq || '=';
  20774. if (obj === null) {
  20775. obj = undefined;
  20776. }
  20777. if (typeof obj === 'object') {
  20778. return map(objectKeys(obj), function(k) {
  20779. var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
  20780. if (isArray(obj[k])) {
  20781. return map(obj[k], function(v) {
  20782. return ks + encodeURIComponent(stringifyPrimitive(v));
  20783. }).join(sep);
  20784. } else {
  20785. return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
  20786. }
  20787. }).join(sep);
  20788. }
  20789. if (!name) return '';
  20790. return encodeURIComponent(stringifyPrimitive(name)) + eq +
  20791. encodeURIComponent(stringifyPrimitive(obj));
  20792. };
  20793. var isArray = Array.isArray || function (xs) {
  20794. return Object.prototype.toString.call(xs) === '[object Array]';
  20795. };
  20796. function map (xs, f) {
  20797. if (xs.map) return xs.map(f);
  20798. var res = [];
  20799. for (var i = 0; i < xs.length; i++) {
  20800. res.push(f(xs[i], i));
  20801. }
  20802. return res;
  20803. }
  20804. var objectKeys = Object.keys || function (obj) {
  20805. var res = [];
  20806. for (var key in obj) {
  20807. if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
  20808. }
  20809. return res;
  20810. };
  20811. },{}],323:[function(require,module,exports){
  20812. 'use strict';
  20813. exports.decode = exports.parse = require('./decode');
  20814. exports.encode = exports.stringify = require('./encode');
  20815. },{"./decode":321,"./encode":322}],324:[function(require,module,exports){
  20816. module.exports = require('./lib/_stream_duplex.js');
  20817. },{"./lib/_stream_duplex.js":325}],325:[function(require,module,exports){
  20818. // Copyright Joyent, Inc. and other Node contributors.
  20819. //
  20820. // Permission is hereby granted, free of charge, to any person obtaining a
  20821. // copy of this software and associated documentation files (the
  20822. // "Software"), to deal in the Software without restriction, including
  20823. // without limitation the rights to use, copy, modify, merge, publish,
  20824. // distribute, sublicense, and/or sell copies of the Software, and to permit
  20825. // persons to whom the Software is furnished to do so, subject to the
  20826. // following conditions:
  20827. //
  20828. // The above copyright notice and this permission notice shall be included
  20829. // in all copies or substantial portions of the Software.
  20830. //
  20831. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  20832. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20833. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  20834. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  20835. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  20836. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  20837. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  20838. // a duplex stream is just a stream that is both readable and writable.
  20839. // Since JS doesn't have multiple prototypal inheritance, this class
  20840. // prototypally inherits from Readable, and then parasitically from
  20841. // Writable.
  20842. 'use strict';
  20843. /*<replacement>*/
  20844. var pna = require('process-nextick-args');
  20845. /*</replacement>*/
  20846. /*<replacement>*/
  20847. var objectKeys = Object.keys || function (obj) {
  20848. var keys = [];
  20849. for (var key in obj) {
  20850. keys.push(key);
  20851. }return keys;
  20852. };
  20853. /*</replacement>*/
  20854. module.exports = Duplex;
  20855. /*<replacement>*/
  20856. var util = Object.create(require('core-util-is'));
  20857. util.inherits = require('inherits');
  20858. /*</replacement>*/
  20859. var Readable = require('./_stream_readable');
  20860. var Writable = require('./_stream_writable');
  20861. util.inherits(Duplex, Readable);
  20862. {
  20863. // avoid scope creep, the keys array can then be collected
  20864. var keys = objectKeys(Writable.prototype);
  20865. for (var v = 0; v < keys.length; v++) {
  20866. var method = keys[v];
  20867. if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
  20868. }
  20869. }
  20870. function Duplex(options) {
  20871. if (!(this instanceof Duplex)) return new Duplex(options);
  20872. Readable.call(this, options);
  20873. Writable.call(this, options);
  20874. if (options && options.readable === false) this.readable = false;
  20875. if (options && options.writable === false) this.writable = false;
  20876. this.allowHalfOpen = true;
  20877. if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
  20878. this.once('end', onend);
  20879. }
  20880. Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
  20881. // making it explicit this property is not enumerable
  20882. // because otherwise some prototype manipulation in
  20883. // userland will fail
  20884. enumerable: false,
  20885. get: function () {
  20886. return this._writableState.highWaterMark;
  20887. }
  20888. });
  20889. // the no-half-open enforcer
  20890. function onend() {
  20891. // if we allow half-open state, or if the writable side ended,
  20892. // then we're ok.
  20893. if (this.allowHalfOpen || this._writableState.ended) return;
  20894. // no more data can be written.
  20895. // But allow more writes to happen in this tick.
  20896. pna.nextTick(onEndNT, this);
  20897. }
  20898. function onEndNT(self) {
  20899. self.end();
  20900. }
  20901. Object.defineProperty(Duplex.prototype, 'destroyed', {
  20902. get: function () {
  20903. if (this._readableState === undefined || this._writableState === undefined) {
  20904. return false;
  20905. }
  20906. return this._readableState.destroyed && this._writableState.destroyed;
  20907. },
  20908. set: function (value) {
  20909. // we ignore the value if the stream
  20910. // has not been initialized yet
  20911. if (this._readableState === undefined || this._writableState === undefined) {
  20912. return;
  20913. }
  20914. // backward compatibility, the user is explicitly
  20915. // managing destroyed
  20916. this._readableState.destroyed = value;
  20917. this._writableState.destroyed = value;
  20918. }
  20919. });
  20920. Duplex.prototype._destroy = function (err, cb) {
  20921. this.push(null);
  20922. this.end();
  20923. pna.nextTick(cb, err);
  20924. };
  20925. },{"./_stream_readable":327,"./_stream_writable":329,"core-util-is":294,"inherits":307,"process-nextick-args":318}],326:[function(require,module,exports){
  20926. // Copyright Joyent, Inc. and other Node contributors.
  20927. //
  20928. // Permission is hereby granted, free of charge, to any person obtaining a
  20929. // copy of this software and associated documentation files (the
  20930. // "Software"), to deal in the Software without restriction, including
  20931. // without limitation the rights to use, copy, modify, merge, publish,
  20932. // distribute, sublicense, and/or sell copies of the Software, and to permit
  20933. // persons to whom the Software is furnished to do so, subject to the
  20934. // following conditions:
  20935. //
  20936. // The above copyright notice and this permission notice shall be included
  20937. // in all copies or substantial portions of the Software.
  20938. //
  20939. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  20940. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20941. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  20942. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  20943. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  20944. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  20945. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  20946. // a passthrough stream.
  20947. // basically just the most minimal sort of Transform stream.
  20948. // Every written chunk gets output as-is.
  20949. 'use strict';
  20950. module.exports = PassThrough;
  20951. var Transform = require('./_stream_transform');
  20952. /*<replacement>*/
  20953. var util = Object.create(require('core-util-is'));
  20954. util.inherits = require('inherits');
  20955. /*</replacement>*/
  20956. util.inherits(PassThrough, Transform);
  20957. function PassThrough(options) {
  20958. if (!(this instanceof PassThrough)) return new PassThrough(options);
  20959. Transform.call(this, options);
  20960. }
  20961. PassThrough.prototype._transform = function (chunk, encoding, cb) {
  20962. cb(null, chunk);
  20963. };
  20964. },{"./_stream_transform":328,"core-util-is":294,"inherits":307}],327:[function(require,module,exports){
  20965. (function (process,global){
  20966. // Copyright Joyent, Inc. and other Node contributors.
  20967. //
  20968. // Permission is hereby granted, free of charge, to any person obtaining a
  20969. // copy of this software and associated documentation files (the
  20970. // "Software"), to deal in the Software without restriction, including
  20971. // without limitation the rights to use, copy, modify, merge, publish,
  20972. // distribute, sublicense, and/or sell copies of the Software, and to permit
  20973. // persons to whom the Software is furnished to do so, subject to the
  20974. // following conditions:
  20975. //
  20976. // The above copyright notice and this permission notice shall be included
  20977. // in all copies or substantial portions of the Software.
  20978. //
  20979. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  20980. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20981. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  20982. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  20983. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  20984. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  20985. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  20986. 'use strict';
  20987. /*<replacement>*/
  20988. var pna = require('process-nextick-args');
  20989. /*</replacement>*/
  20990. module.exports = Readable;
  20991. /*<replacement>*/
  20992. var isArray = require('isarray');
  20993. /*</replacement>*/
  20994. /*<replacement>*/
  20995. var Duplex;
  20996. /*</replacement>*/
  20997. Readable.ReadableState = ReadableState;
  20998. /*<replacement>*/
  20999. var EE = require('events').EventEmitter;
  21000. var EElistenerCount = function (emitter, type) {
  21001. return emitter.listeners(type).length;
  21002. };
  21003. /*</replacement>*/
  21004. /*<replacement>*/
  21005. var Stream = require('./internal/streams/stream');
  21006. /*</replacement>*/
  21007. /*<replacement>*/
  21008. var Buffer = require('safe-buffer').Buffer;
  21009. var OurUint8Array = global.Uint8Array || function () {};
  21010. function _uint8ArrayToBuffer(chunk) {
  21011. return Buffer.from(chunk);
  21012. }
  21013. function _isUint8Array(obj) {
  21014. return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
  21015. }
  21016. /*</replacement>*/
  21017. /*<replacement>*/
  21018. var util = Object.create(require('core-util-is'));
  21019. util.inherits = require('inherits');
  21020. /*</replacement>*/
  21021. /*<replacement>*/
  21022. var debugUtil = require('util');
  21023. var debug = void 0;
  21024. if (debugUtil && debugUtil.debuglog) {
  21025. debug = debugUtil.debuglog('stream');
  21026. } else {
  21027. debug = function () {};
  21028. }
  21029. /*</replacement>*/
  21030. var BufferList = require('./internal/streams/BufferList');
  21031. var destroyImpl = require('./internal/streams/destroy');
  21032. var StringDecoder;
  21033. util.inherits(Readable, Stream);
  21034. var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
  21035. function prependListener(emitter, event, fn) {
  21036. // Sadly this is not cacheable as some libraries bundle their own
  21037. // event emitter implementation with them.
  21038. if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);
  21039. // This is a hack to make sure that our error handler is attached before any
  21040. // userland ones. NEVER DO THIS. This is here only because this code needs
  21041. // to continue to work with older versions of Node.js that do not include
  21042. // the prependListener() method. The goal is to eventually remove this hack.
  21043. if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
  21044. }
  21045. function ReadableState(options, stream) {
  21046. Duplex = Duplex || require('./_stream_duplex');
  21047. options = options || {};
  21048. // Duplex streams are both readable and writable, but share
  21049. // the same options object.
  21050. // However, some cases require setting options to different
  21051. // values for the readable and the writable sides of the duplex stream.
  21052. // These options can be provided separately as readableXXX and writableXXX.
  21053. var isDuplex = stream instanceof Duplex;
  21054. // object stream flag. Used to make read(n) ignore n and to
  21055. // make all the buffer merging and length checks go away
  21056. this.objectMode = !!options.objectMode;
  21057. if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
  21058. // the point at which it stops calling _read() to fill the buffer
  21059. // Note: 0 is a valid value, means "don't call _read preemptively ever"
  21060. var hwm = options.highWaterMark;
  21061. var readableHwm = options.readableHighWaterMark;
  21062. var defaultHwm = this.objectMode ? 16 : 16 * 1024;
  21063. if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;
  21064. // cast to ints.
  21065. this.highWaterMark = Math.floor(this.highWaterMark);
  21066. // A linked list is used to store data chunks instead of an array because the
  21067. // linked list can remove elements from the beginning faster than
  21068. // array.shift()
  21069. this.buffer = new BufferList();
  21070. this.length = 0;
  21071. this.pipes = null;
  21072. this.pipesCount = 0;
  21073. this.flowing = null;
  21074. this.ended = false;
  21075. this.endEmitted = false;
  21076. this.reading = false;
  21077. // a flag to be able to tell if the event 'readable'/'data' is emitted
  21078. // immediately, or on a later tick. We set this to true at first, because
  21079. // any actions that shouldn't happen until "later" should generally also
  21080. // not happen before the first read call.
  21081. this.sync = true;
  21082. // whenever we return null, then we set a flag to say
  21083. // that we're awaiting a 'readable' event emission.
  21084. this.needReadable = false;
  21085. this.emittedReadable = false;
  21086. this.readableListening = false;
  21087. this.resumeScheduled = false;
  21088. // has it been destroyed
  21089. this.destroyed = false;
  21090. // Crypto is kind of old and crusty. Historically, its default string
  21091. // encoding is 'binary' so we have to make this configurable.
  21092. // Everything else in the universe uses 'utf8', though.
  21093. this.defaultEncoding = options.defaultEncoding || 'utf8';
  21094. // the number of writers that are awaiting a drain event in .pipe()s
  21095. this.awaitDrain = 0;
  21096. // if true, a maybeReadMore has been scheduled
  21097. this.readingMore = false;
  21098. this.decoder = null;
  21099. this.encoding = null;
  21100. if (options.encoding) {
  21101. if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
  21102. this.decoder = new StringDecoder(options.encoding);
  21103. this.encoding = options.encoding;
  21104. }
  21105. }
  21106. function Readable(options) {
  21107. Duplex = Duplex || require('./_stream_duplex');
  21108. if (!(this instanceof Readable)) return new Readable(options);
  21109. this._readableState = new ReadableState(options, this);
  21110. // legacy
  21111. this.readable = true;
  21112. if (options) {
  21113. if (typeof options.read === 'function') this._read = options.read;
  21114. if (typeof options.destroy === 'function') this._destroy = options.destroy;
  21115. }
  21116. Stream.call(this);
  21117. }
  21118. Object.defineProperty(Readable.prototype, 'destroyed', {
  21119. get: function () {
  21120. if (this._readableState === undefined) {
  21121. return false;
  21122. }
  21123. return this._readableState.destroyed;
  21124. },
  21125. set: function (value) {
  21126. // we ignore the value if the stream
  21127. // has not been initialized yet
  21128. if (!this._readableState) {
  21129. return;
  21130. }
  21131. // backward compatibility, the user is explicitly
  21132. // managing destroyed
  21133. this._readableState.destroyed = value;
  21134. }
  21135. });
  21136. Readable.prototype.destroy = destroyImpl.destroy;
  21137. Readable.prototype._undestroy = destroyImpl.undestroy;
  21138. Readable.prototype._destroy = function (err, cb) {
  21139. this.push(null);
  21140. cb(err);
  21141. };
  21142. // Manually shove something into the read() buffer.
  21143. // This returns true if the highWaterMark has not been hit yet,
  21144. // similar to how Writable.write() returns true if you should
  21145. // write() some more.
  21146. Readable.prototype.push = function (chunk, encoding) {
  21147. var state = this._readableState;
  21148. var skipChunkCheck;
  21149. if (!state.objectMode) {
  21150. if (typeof chunk === 'string') {
  21151. encoding = encoding || state.defaultEncoding;
  21152. if (encoding !== state.encoding) {
  21153. chunk = Buffer.from(chunk, encoding);
  21154. encoding = '';
  21155. }
  21156. skipChunkCheck = true;
  21157. }
  21158. } else {
  21159. skipChunkCheck = true;
  21160. }
  21161. return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
  21162. };
  21163. // Unshift should *always* be something directly out of read()
  21164. Readable.prototype.unshift = function (chunk) {
  21165. return readableAddChunk(this, chunk, null, true, false);
  21166. };
  21167. function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
  21168. var state = stream._readableState;
  21169. if (chunk === null) {
  21170. state.reading = false;
  21171. onEofChunk(stream, state);
  21172. } else {
  21173. var er;
  21174. if (!skipChunkCheck) er = chunkInvalid(state, chunk);
  21175. if (er) {
  21176. stream.emit('error', er);
  21177. } else if (state.objectMode || chunk && chunk.length > 0) {
  21178. if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
  21179. chunk = _uint8ArrayToBuffer(chunk);
  21180. }
  21181. if (addToFront) {
  21182. if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);
  21183. } else if (state.ended) {
  21184. stream.emit('error', new Error('stream.push() after EOF'));
  21185. } else {
  21186. state.reading = false;
  21187. if (state.decoder && !encoding) {
  21188. chunk = state.decoder.write(chunk);
  21189. if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
  21190. } else {
  21191. addChunk(stream, state, chunk, false);
  21192. }
  21193. }
  21194. } else if (!addToFront) {
  21195. state.reading = false;
  21196. }
  21197. }
  21198. return needMoreData(state);
  21199. }
  21200. function addChunk(stream, state, chunk, addToFront) {
  21201. if (state.flowing && state.length === 0 && !state.sync) {
  21202. stream.emit('data', chunk);
  21203. stream.read(0);
  21204. } else {
  21205. // update the buffer info.
  21206. state.length += state.objectMode ? 1 : chunk.length;
  21207. if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
  21208. if (state.needReadable) emitReadable(stream);
  21209. }
  21210. maybeReadMore(stream, state);
  21211. }
  21212. function chunkInvalid(state, chunk) {
  21213. var er;
  21214. if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
  21215. er = new TypeError('Invalid non-string/buffer chunk');
  21216. }
  21217. return er;
  21218. }
  21219. // if it's past the high water mark, we can push in some more.
  21220. // Also, if we have no data yet, we can stand some
  21221. // more bytes. This is to work around cases where hwm=0,
  21222. // such as the repl. Also, if the push() triggered a
  21223. // readable event, and the user called read(largeNumber) such that
  21224. // needReadable was set, then we ought to push more, so that another
  21225. // 'readable' event will be triggered.
  21226. function needMoreData(state) {
  21227. return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
  21228. }
  21229. Readable.prototype.isPaused = function () {
  21230. return this._readableState.flowing === false;
  21231. };
  21232. // backwards compatibility.
  21233. Readable.prototype.setEncoding = function (enc) {
  21234. if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
  21235. this._readableState.decoder = new StringDecoder(enc);
  21236. this._readableState.encoding = enc;
  21237. return this;
  21238. };
  21239. // Don't raise the hwm > 8MB
  21240. var MAX_HWM = 0x800000;
  21241. function computeNewHighWaterMark(n) {
  21242. if (n >= MAX_HWM) {
  21243. n = MAX_HWM;
  21244. } else {
  21245. // Get the next highest power of 2 to prevent increasing hwm excessively in
  21246. // tiny amounts
  21247. n--;
  21248. n |= n >>> 1;
  21249. n |= n >>> 2;
  21250. n |= n >>> 4;
  21251. n |= n >>> 8;
  21252. n |= n >>> 16;
  21253. n++;
  21254. }
  21255. return n;
  21256. }
  21257. // This function is designed to be inlinable, so please take care when making
  21258. // changes to the function body.
  21259. function howMuchToRead(n, state) {
  21260. if (n <= 0 || state.length === 0 && state.ended) return 0;
  21261. if (state.objectMode) return 1;
  21262. if (n !== n) {
  21263. // Only flow one buffer at a time
  21264. if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
  21265. }
  21266. // If we're asking for more than the current hwm, then raise the hwm.
  21267. if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
  21268. if (n <= state.length) return n;
  21269. // Don't have enough
  21270. if (!state.ended) {
  21271. state.needReadable = true;
  21272. return 0;
  21273. }
  21274. return state.length;
  21275. }
  21276. // you can override either this method, or the async _read(n) below.
  21277. Readable.prototype.read = function (n) {
  21278. debug('read', n);
  21279. n = parseInt(n, 10);
  21280. var state = this._readableState;
  21281. var nOrig = n;
  21282. if (n !== 0) state.emittedReadable = false;
  21283. // if we're doing read(0) to trigger a readable event, but we
  21284. // already have a bunch of data in the buffer, then just trigger
  21285. // the 'readable' event and move on.
  21286. if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
  21287. debug('read: emitReadable', state.length, state.ended);
  21288. if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
  21289. return null;
  21290. }
  21291. n = howMuchToRead(n, state);
  21292. // if we've ended, and we're now clear, then finish it up.
  21293. if (n === 0 && state.ended) {
  21294. if (state.length === 0) endReadable(this);
  21295. return null;
  21296. }
  21297. // All the actual chunk generation logic needs to be
  21298. // *below* the call to _read. The reason is that in certain
  21299. // synthetic stream cases, such as passthrough streams, _read
  21300. // may be a completely synchronous operation which may change
  21301. // the state of the read buffer, providing enough data when
  21302. // before there was *not* enough.
  21303. //
  21304. // So, the steps are:
  21305. // 1. Figure out what the state of things will be after we do
  21306. // a read from the buffer.
  21307. //
  21308. // 2. If that resulting state will trigger a _read, then call _read.
  21309. // Note that this may be asynchronous, or synchronous. Yes, it is
  21310. // deeply ugly to write APIs this way, but that still doesn't mean
  21311. // that the Readable class should behave improperly, as streams are
  21312. // designed to be sync/async agnostic.
  21313. // Take note if the _read call is sync or async (ie, if the read call
  21314. // has returned yet), so that we know whether or not it's safe to emit
  21315. // 'readable' etc.
  21316. //
  21317. // 3. Actually pull the requested chunks out of the buffer and return.
  21318. // if we need a readable event, then we need to do some reading.
  21319. var doRead = state.needReadable;
  21320. debug('need readable', doRead);
  21321. // if we currently have less than the highWaterMark, then also read some
  21322. if (state.length === 0 || state.length - n < state.highWaterMark) {
  21323. doRead = true;
  21324. debug('length less than watermark', doRead);
  21325. }
  21326. // however, if we've ended, then there's no point, and if we're already
  21327. // reading, then it's unnecessary.
  21328. if (state.ended || state.reading) {
  21329. doRead = false;
  21330. debug('reading or ended', doRead);
  21331. } else if (doRead) {
  21332. debug('do read');
  21333. state.reading = true;
  21334. state.sync = true;
  21335. // if the length is currently zero, then we *need* a readable event.
  21336. if (state.length === 0) state.needReadable = true;
  21337. // call internal read method
  21338. this._read(state.highWaterMark);
  21339. state.sync = false;
  21340. // If _read pushed data synchronously, then `reading` will be false,
  21341. // and we need to re-evaluate how much data we can return to the user.
  21342. if (!state.reading) n = howMuchToRead(nOrig, state);
  21343. }
  21344. var ret;
  21345. if (n > 0) ret = fromList(n, state);else ret = null;
  21346. if (ret === null) {
  21347. state.needReadable = true;
  21348. n = 0;
  21349. } else {
  21350. state.length -= n;
  21351. }
  21352. if (state.length === 0) {
  21353. // If we have nothing in the buffer, then we want to know
  21354. // as soon as we *do* get something into the buffer.
  21355. if (!state.ended) state.needReadable = true;
  21356. // If we tried to read() past the EOF, then emit end on the next tick.
  21357. if (nOrig !== n && state.ended) endReadable(this);
  21358. }
  21359. if (ret !== null) this.emit('data', ret);
  21360. return ret;
  21361. };
  21362. function onEofChunk(stream, state) {
  21363. if (state.ended) return;
  21364. if (state.decoder) {
  21365. var chunk = state.decoder.end();
  21366. if (chunk && chunk.length) {
  21367. state.buffer.push(chunk);
  21368. state.length += state.objectMode ? 1 : chunk.length;
  21369. }
  21370. }
  21371. state.ended = true;
  21372. // emit 'readable' now to make sure it gets picked up.
  21373. emitReadable(stream);
  21374. }
  21375. // Don't emit readable right away in sync mode, because this can trigger
  21376. // another read() call => stack overflow. This way, it might trigger
  21377. // a nextTick recursion warning, but that's not so bad.
  21378. function emitReadable(stream) {
  21379. var state = stream._readableState;
  21380. state.needReadable = false;
  21381. if (!state.emittedReadable) {
  21382. debug('emitReadable', state.flowing);
  21383. state.emittedReadable = true;
  21384. if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);
  21385. }
  21386. }
  21387. function emitReadable_(stream) {
  21388. debug('emit readable');
  21389. stream.emit('readable');
  21390. flow(stream);
  21391. }
  21392. // at this point, the user has presumably seen the 'readable' event,
  21393. // and called read() to consume some data. that may have triggered
  21394. // in turn another _read(n) call, in which case reading = true if
  21395. // it's in progress.
  21396. // However, if we're not ended, or reading, and the length < hwm,
  21397. // then go ahead and try to read some more preemptively.
  21398. function maybeReadMore(stream, state) {
  21399. if (!state.readingMore) {
  21400. state.readingMore = true;
  21401. pna.nextTick(maybeReadMore_, stream, state);
  21402. }
  21403. }
  21404. function maybeReadMore_(stream, state) {
  21405. var len = state.length;
  21406. while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
  21407. debug('maybeReadMore read 0');
  21408. stream.read(0);
  21409. if (len === state.length)
  21410. // didn't get any data, stop spinning.
  21411. break;else len = state.length;
  21412. }
  21413. state.readingMore = false;
  21414. }
  21415. // abstract method. to be overridden in specific implementation classes.
  21416. // call cb(er, data) where data is <= n in length.
  21417. // for virtual (non-string, non-buffer) streams, "length" is somewhat
  21418. // arbitrary, and perhaps not very meaningful.
  21419. Readable.prototype._read = function (n) {
  21420. this.emit('error', new Error('_read() is not implemented'));
  21421. };
  21422. Readable.prototype.pipe = function (dest, pipeOpts) {
  21423. var src = this;
  21424. var state = this._readableState;
  21425. switch (state.pipesCount) {
  21426. case 0:
  21427. state.pipes = dest;
  21428. break;
  21429. case 1:
  21430. state.pipes = [state.pipes, dest];
  21431. break;
  21432. default:
  21433. state.pipes.push(dest);
  21434. break;
  21435. }
  21436. state.pipesCount += 1;
  21437. debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
  21438. var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
  21439. var endFn = doEnd ? onend : unpipe;
  21440. if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);
  21441. dest.on('unpipe', onunpipe);
  21442. function onunpipe(readable, unpipeInfo) {
  21443. debug('onunpipe');
  21444. if (readable === src) {
  21445. if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
  21446. unpipeInfo.hasUnpiped = true;
  21447. cleanup();
  21448. }
  21449. }
  21450. }
  21451. function onend() {
  21452. debug('onend');
  21453. dest.end();
  21454. }
  21455. // when the dest drains, it reduces the awaitDrain counter
  21456. // on the source. This would be more elegant with a .once()
  21457. // handler in flow(), but adding and removing repeatedly is
  21458. // too slow.
  21459. var ondrain = pipeOnDrain(src);
  21460. dest.on('drain', ondrain);
  21461. var cleanedUp = false;
  21462. function cleanup() {
  21463. debug('cleanup');
  21464. // cleanup event handlers once the pipe is broken
  21465. dest.removeListener('close', onclose);
  21466. dest.removeListener('finish', onfinish);
  21467. dest.removeListener('drain', ondrain);
  21468. dest.removeListener('error', onerror);
  21469. dest.removeListener('unpipe', onunpipe);
  21470. src.removeListener('end', onend);
  21471. src.removeListener('end', unpipe);
  21472. src.removeListener('data', ondata);
  21473. cleanedUp = true;
  21474. // if the reader is waiting for a drain event from this
  21475. // specific writer, then it would cause it to never start
  21476. // flowing again.
  21477. // So, if this is awaiting a drain, then we just call it now.
  21478. // If we don't know, then assume that we are waiting for one.
  21479. if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
  21480. }
  21481. // If the user pushes more data while we're writing to dest then we'll end up
  21482. // in ondata again. However, we only want to increase awaitDrain once because
  21483. // dest will only emit one 'drain' event for the multiple writes.
  21484. // => Introduce a guard on increasing awaitDrain.
  21485. var increasedAwaitDrain = false;
  21486. src.on('data', ondata);
  21487. function ondata(chunk) {
  21488. debug('ondata');
  21489. increasedAwaitDrain = false;
  21490. var ret = dest.write(chunk);
  21491. if (false === ret && !increasedAwaitDrain) {
  21492. // If the user unpiped during `dest.write()`, it is possible
  21493. // to get stuck in a permanently paused state if that write
  21494. // also returned false.
  21495. // => Check whether `dest` is still a piping destination.
  21496. if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
  21497. debug('false write response, pause', src._readableState.awaitDrain);
  21498. src._readableState.awaitDrain++;
  21499. increasedAwaitDrain = true;
  21500. }
  21501. src.pause();
  21502. }
  21503. }
  21504. // if the dest has an error, then stop piping into it.
  21505. // however, don't suppress the throwing behavior for this.
  21506. function onerror(er) {
  21507. debug('onerror', er);
  21508. unpipe();
  21509. dest.removeListener('error', onerror);
  21510. if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
  21511. }
  21512. // Make sure our error handler is attached before userland ones.
  21513. prependListener(dest, 'error', onerror);
  21514. // Both close and finish should trigger unpipe, but only once.
  21515. function onclose() {
  21516. dest.removeListener('finish', onfinish);
  21517. unpipe();
  21518. }
  21519. dest.once('close', onclose);
  21520. function onfinish() {
  21521. debug('onfinish');
  21522. dest.removeListener('close', onclose);
  21523. unpipe();
  21524. }
  21525. dest.once('finish', onfinish);
  21526. function unpipe() {
  21527. debug('unpipe');
  21528. src.unpipe(dest);
  21529. }
  21530. // tell the dest that it's being piped to
  21531. dest.emit('pipe', src);
  21532. // start the flow if it hasn't been started already.
  21533. if (!state.flowing) {
  21534. debug('pipe resume');
  21535. src.resume();
  21536. }
  21537. return dest;
  21538. };
  21539. function pipeOnDrain(src) {
  21540. return function () {
  21541. var state = src._readableState;
  21542. debug('pipeOnDrain', state.awaitDrain);
  21543. if (state.awaitDrain) state.awaitDrain--;
  21544. if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
  21545. state.flowing = true;
  21546. flow(src);
  21547. }
  21548. };
  21549. }
  21550. Readable.prototype.unpipe = function (dest) {
  21551. var state = this._readableState;
  21552. var unpipeInfo = { hasUnpiped: false };
  21553. // if we're not piping anywhere, then do nothing.
  21554. if (state.pipesCount === 0) return this;
  21555. // just one destination. most common case.
  21556. if (state.pipesCount === 1) {
  21557. // passed in one, but it's not the right one.
  21558. if (dest && dest !== state.pipes) return this;
  21559. if (!dest) dest = state.pipes;
  21560. // got a match.
  21561. state.pipes = null;
  21562. state.pipesCount = 0;
  21563. state.flowing = false;
  21564. if (dest) dest.emit('unpipe', this, unpipeInfo);
  21565. return this;
  21566. }
  21567. // slow case. multiple pipe destinations.
  21568. if (!dest) {
  21569. // remove all.
  21570. var dests = state.pipes;
  21571. var len = state.pipesCount;
  21572. state.pipes = null;
  21573. state.pipesCount = 0;
  21574. state.flowing = false;
  21575. for (var i = 0; i < len; i++) {
  21576. dests[i].emit('unpipe', this, unpipeInfo);
  21577. }return this;
  21578. }
  21579. // try to find the right one.
  21580. var index = indexOf(state.pipes, dest);
  21581. if (index === -1) return this;
  21582. state.pipes.splice(index, 1);
  21583. state.pipesCount -= 1;
  21584. if (state.pipesCount === 1) state.pipes = state.pipes[0];
  21585. dest.emit('unpipe', this, unpipeInfo);
  21586. return this;
  21587. };
  21588. // set up data events if they are asked for
  21589. // Ensure readable listeners eventually get something
  21590. Readable.prototype.on = function (ev, fn) {
  21591. var res = Stream.prototype.on.call(this, ev, fn);
  21592. if (ev === 'data') {
  21593. // Start flowing on next tick if stream isn't explicitly paused
  21594. if (this._readableState.flowing !== false) this.resume();
  21595. } else if (ev === 'readable') {
  21596. var state = this._readableState;
  21597. if (!state.endEmitted && !state.readableListening) {
  21598. state.readableListening = state.needReadable = true;
  21599. state.emittedReadable = false;
  21600. if (!state.reading) {
  21601. pna.nextTick(nReadingNextTick, this);
  21602. } else if (state.length) {
  21603. emitReadable(this);
  21604. }
  21605. }
  21606. }
  21607. return res;
  21608. };
  21609. Readable.prototype.addListener = Readable.prototype.on;
  21610. function nReadingNextTick(self) {
  21611. debug('readable nexttick read 0');
  21612. self.read(0);
  21613. }
  21614. // pause() and resume() are remnants of the legacy readable stream API
  21615. // If the user uses them, then switch into old mode.
  21616. Readable.prototype.resume = function () {
  21617. var state = this._readableState;
  21618. if (!state.flowing) {
  21619. debug('resume');
  21620. state.flowing = true;
  21621. resume(this, state);
  21622. }
  21623. return this;
  21624. };
  21625. function resume(stream, state) {
  21626. if (!state.resumeScheduled) {
  21627. state.resumeScheduled = true;
  21628. pna.nextTick(resume_, stream, state);
  21629. }
  21630. }
  21631. function resume_(stream, state) {
  21632. if (!state.reading) {
  21633. debug('resume read 0');
  21634. stream.read(0);
  21635. }
  21636. state.resumeScheduled = false;
  21637. state.awaitDrain = 0;
  21638. stream.emit('resume');
  21639. flow(stream);
  21640. if (state.flowing && !state.reading) stream.read(0);
  21641. }
  21642. Readable.prototype.pause = function () {
  21643. debug('call pause flowing=%j', this._readableState.flowing);
  21644. if (false !== this._readableState.flowing) {
  21645. debug('pause');
  21646. this._readableState.flowing = false;
  21647. this.emit('pause');
  21648. }
  21649. return this;
  21650. };
  21651. function flow(stream) {
  21652. var state = stream._readableState;
  21653. debug('flow', state.flowing);
  21654. while (state.flowing && stream.read() !== null) {}
  21655. }
  21656. // wrap an old-style stream as the async data source.
  21657. // This is *not* part of the readable stream interface.
  21658. // It is an ugly unfortunate mess of history.
  21659. Readable.prototype.wrap = function (stream) {
  21660. var _this = this;
  21661. var state = this._readableState;
  21662. var paused = false;
  21663. stream.on('end', function () {
  21664. debug('wrapped end');
  21665. if (state.decoder && !state.ended) {
  21666. var chunk = state.decoder.end();
  21667. if (chunk && chunk.length) _this.push(chunk);
  21668. }
  21669. _this.push(null);
  21670. });
  21671. stream.on('data', function (chunk) {
  21672. debug('wrapped data');
  21673. if (state.decoder) chunk = state.decoder.write(chunk);
  21674. // don't skip over falsy values in objectMode
  21675. if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
  21676. var ret = _this.push(chunk);
  21677. if (!ret) {
  21678. paused = true;
  21679. stream.pause();
  21680. }
  21681. });
  21682. // proxy all the other methods.
  21683. // important when wrapping filters and duplexes.
  21684. for (var i in stream) {
  21685. if (this[i] === undefined && typeof stream[i] === 'function') {
  21686. this[i] = function (method) {
  21687. return function () {
  21688. return stream[method].apply(stream, arguments);
  21689. };
  21690. }(i);
  21691. }
  21692. }
  21693. // proxy certain important events.
  21694. for (var n = 0; n < kProxyEvents.length; n++) {
  21695. stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
  21696. }
  21697. // when we try to consume some more bytes, simply unpause the
  21698. // underlying stream.
  21699. this._read = function (n) {
  21700. debug('wrapped _read', n);
  21701. if (paused) {
  21702. paused = false;
  21703. stream.resume();
  21704. }
  21705. };
  21706. return this;
  21707. };
  21708. Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
  21709. // making it explicit this property is not enumerable
  21710. // because otherwise some prototype manipulation in
  21711. // userland will fail
  21712. enumerable: false,
  21713. get: function () {
  21714. return this._readableState.highWaterMark;
  21715. }
  21716. });
  21717. // exposed for testing purposes only.
  21718. Readable._fromList = fromList;
  21719. // Pluck off n bytes from an array of buffers.
  21720. // Length is the combined lengths of all the buffers in the list.
  21721. // This function is designed to be inlinable, so please take care when making
  21722. // changes to the function body.
  21723. function fromList(n, state) {
  21724. // nothing buffered
  21725. if (state.length === 0) return null;
  21726. var ret;
  21727. if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
  21728. // read it all, truncate the list
  21729. if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);
  21730. state.buffer.clear();
  21731. } else {
  21732. // read part of list
  21733. ret = fromListPartial(n, state.buffer, state.decoder);
  21734. }
  21735. return ret;
  21736. }
  21737. // Extracts only enough buffered data to satisfy the amount requested.
  21738. // This function is designed to be inlinable, so please take care when making
  21739. // changes to the function body.
  21740. function fromListPartial(n, list, hasStrings) {
  21741. var ret;
  21742. if (n < list.head.data.length) {
  21743. // slice is the same for buffers and strings
  21744. ret = list.head.data.slice(0, n);
  21745. list.head.data = list.head.data.slice(n);
  21746. } else if (n === list.head.data.length) {
  21747. // first chunk is a perfect match
  21748. ret = list.shift();
  21749. } else {
  21750. // result spans more than one buffer
  21751. ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
  21752. }
  21753. return ret;
  21754. }
  21755. // Copies a specified amount of characters from the list of buffered data
  21756. // chunks.
  21757. // This function is designed to be inlinable, so please take care when making
  21758. // changes to the function body.
  21759. function copyFromBufferString(n, list) {
  21760. var p = list.head;
  21761. var c = 1;
  21762. var ret = p.data;
  21763. n -= ret.length;
  21764. while (p = p.next) {
  21765. var str = p.data;
  21766. var nb = n > str.length ? str.length : n;
  21767. if (nb === str.length) ret += str;else ret += str.slice(0, n);
  21768. n -= nb;
  21769. if (n === 0) {
  21770. if (nb === str.length) {
  21771. ++c;
  21772. if (p.next) list.head = p.next;else list.head = list.tail = null;
  21773. } else {
  21774. list.head = p;
  21775. p.data = str.slice(nb);
  21776. }
  21777. break;
  21778. }
  21779. ++c;
  21780. }
  21781. list.length -= c;
  21782. return ret;
  21783. }
  21784. // Copies a specified amount of bytes from the list of buffered data chunks.
  21785. // This function is designed to be inlinable, so please take care when making
  21786. // changes to the function body.
  21787. function copyFromBuffer(n, list) {
  21788. var ret = Buffer.allocUnsafe(n);
  21789. var p = list.head;
  21790. var c = 1;
  21791. p.data.copy(ret);
  21792. n -= p.data.length;
  21793. while (p = p.next) {
  21794. var buf = p.data;
  21795. var nb = n > buf.length ? buf.length : n;
  21796. buf.copy(ret, ret.length - n, 0, nb);
  21797. n -= nb;
  21798. if (n === 0) {
  21799. if (nb === buf.length) {
  21800. ++c;
  21801. if (p.next) list.head = p.next;else list.head = list.tail = null;
  21802. } else {
  21803. list.head = p;
  21804. p.data = buf.slice(nb);
  21805. }
  21806. break;
  21807. }
  21808. ++c;
  21809. }
  21810. list.length -= c;
  21811. return ret;
  21812. }
  21813. function endReadable(stream) {
  21814. var state = stream._readableState;
  21815. // If we get here before consuming all the bytes, then that is a
  21816. // bug in node. Should never happen.
  21817. if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
  21818. if (!state.endEmitted) {
  21819. state.ended = true;
  21820. pna.nextTick(endReadableNT, state, stream);
  21821. }
  21822. }
  21823. function endReadableNT(state, stream) {
  21824. // Check that we didn't get one last unshift.
  21825. if (!state.endEmitted && state.length === 0) {
  21826. state.endEmitted = true;
  21827. stream.readable = false;
  21828. stream.emit('end');
  21829. }
  21830. }
  21831. function indexOf(xs, x) {
  21832. for (var i = 0, l = xs.length; i < l; i++) {
  21833. if (xs[i] === x) return i;
  21834. }
  21835. return -1;
  21836. }
  21837. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  21838. },{"./_stream_duplex":325,"./internal/streams/BufferList":330,"./internal/streams/destroy":331,"./internal/streams/stream":332,"_process":393,"core-util-is":294,"events":297,"inherits":307,"isarray":309,"process-nextick-args":318,"safe-buffer":338,"string_decoder/":341,"util":78}],328:[function(require,module,exports){
  21839. // Copyright Joyent, Inc. and other Node contributors.
  21840. //
  21841. // Permission is hereby granted, free of charge, to any person obtaining a
  21842. // copy of this software and associated documentation files (the
  21843. // "Software"), to deal in the Software without restriction, including
  21844. // without limitation the rights to use, copy, modify, merge, publish,
  21845. // distribute, sublicense, and/or sell copies of the Software, and to permit
  21846. // persons to whom the Software is furnished to do so, subject to the
  21847. // following conditions:
  21848. //
  21849. // The above copyright notice and this permission notice shall be included
  21850. // in all copies or substantial portions of the Software.
  21851. //
  21852. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  21853. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  21854. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  21855. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  21856. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  21857. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  21858. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  21859. // a transform stream is a readable/writable stream where you do
  21860. // something with the data. Sometimes it's called a "filter",
  21861. // but that's not a great name for it, since that implies a thing where
  21862. // some bits pass through, and others are simply ignored. (That would
  21863. // be a valid example of a transform, of course.)
  21864. //
  21865. // While the output is causally related to the input, it's not a
  21866. // necessarily symmetric or synchronous transformation. For example,
  21867. // a zlib stream might take multiple plain-text writes(), and then
  21868. // emit a single compressed chunk some time in the future.
  21869. //
  21870. // Here's how this works:
  21871. //
  21872. // The Transform stream has all the aspects of the readable and writable
  21873. // stream classes. When you write(chunk), that calls _write(chunk,cb)
  21874. // internally, and returns false if there's a lot of pending writes
  21875. // buffered up. When you call read(), that calls _read(n) until
  21876. // there's enough pending readable data buffered up.
  21877. //
  21878. // In a transform stream, the written data is placed in a buffer. When
  21879. // _read(n) is called, it transforms the queued up data, calling the
  21880. // buffered _write cb's as it consumes chunks. If consuming a single
  21881. // written chunk would result in multiple output chunks, then the first
  21882. // outputted bit calls the readcb, and subsequent chunks just go into
  21883. // the read buffer, and will cause it to emit 'readable' if necessary.
  21884. //
  21885. // This way, back-pressure is actually determined by the reading side,
  21886. // since _read has to be called to start processing a new chunk. However,
  21887. // a pathological inflate type of transform can cause excessive buffering
  21888. // here. For example, imagine a stream where every byte of input is
  21889. // interpreted as an integer from 0-255, and then results in that many
  21890. // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
  21891. // 1kb of data being output. In this case, you could write a very small
  21892. // amount of input, and end up with a very large amount of output. In
  21893. // such a pathological inflating mechanism, there'd be no way to tell
  21894. // the system to stop doing the transform. A single 4MB write could
  21895. // cause the system to run out of memory.
  21896. //
  21897. // However, even in such a pathological case, only a single written chunk
  21898. // would be consumed, and then the rest would wait (un-transformed) until
  21899. // the results of the previous transformed chunk were consumed.
  21900. 'use strict';
  21901. module.exports = Transform;
  21902. var Duplex = require('./_stream_duplex');
  21903. /*<replacement>*/
  21904. var util = Object.create(require('core-util-is'));
  21905. util.inherits = require('inherits');
  21906. /*</replacement>*/
  21907. util.inherits(Transform, Duplex);
  21908. function afterTransform(er, data) {
  21909. var ts = this._transformState;
  21910. ts.transforming = false;
  21911. var cb = ts.writecb;
  21912. if (!cb) {
  21913. return this.emit('error', new Error('write callback called multiple times'));
  21914. }
  21915. ts.writechunk = null;
  21916. ts.writecb = null;
  21917. if (data != null) // single equals check for both `null` and `undefined`
  21918. this.push(data);
  21919. cb(er);
  21920. var rs = this._readableState;
  21921. rs.reading = false;
  21922. if (rs.needReadable || rs.length < rs.highWaterMark) {
  21923. this._read(rs.highWaterMark);
  21924. }
  21925. }
  21926. function Transform(options) {
  21927. if (!(this instanceof Transform)) return new Transform(options);
  21928. Duplex.call(this, options);
  21929. this._transformState = {
  21930. afterTransform: afterTransform.bind(this),
  21931. needTransform: false,
  21932. transforming: false,
  21933. writecb: null,
  21934. writechunk: null,
  21935. writeencoding: null
  21936. };
  21937. // start out asking for a readable event once data is transformed.
  21938. this._readableState.needReadable = true;
  21939. // we have implemented the _read method, and done the other things
  21940. // that Readable wants before the first _read call, so unset the
  21941. // sync guard flag.
  21942. this._readableState.sync = false;
  21943. if (options) {
  21944. if (typeof options.transform === 'function') this._transform = options.transform;
  21945. if (typeof options.flush === 'function') this._flush = options.flush;
  21946. }
  21947. // When the writable side finishes, then flush out anything remaining.
  21948. this.on('prefinish', prefinish);
  21949. }
  21950. function prefinish() {
  21951. var _this = this;
  21952. if (typeof this._flush === 'function') {
  21953. this._flush(function (er, data) {
  21954. done(_this, er, data);
  21955. });
  21956. } else {
  21957. done(this, null, null);
  21958. }
  21959. }
  21960. Transform.prototype.push = function (chunk, encoding) {
  21961. this._transformState.needTransform = false;
  21962. return Duplex.prototype.push.call(this, chunk, encoding);
  21963. };
  21964. // This is the part where you do stuff!
  21965. // override this function in implementation classes.
  21966. // 'chunk' is an input chunk.
  21967. //
  21968. // Call `push(newChunk)` to pass along transformed output
  21969. // to the readable side. You may call 'push' zero or more times.
  21970. //
  21971. // Call `cb(err)` when you are done with this chunk. If you pass
  21972. // an error, then that'll put the hurt on the whole operation. If you
  21973. // never call cb(), then you'll never get another chunk.
  21974. Transform.prototype._transform = function (chunk, encoding, cb) {
  21975. throw new Error('_transform() is not implemented');
  21976. };
  21977. Transform.prototype._write = function (chunk, encoding, cb) {
  21978. var ts = this._transformState;
  21979. ts.writecb = cb;
  21980. ts.writechunk = chunk;
  21981. ts.writeencoding = encoding;
  21982. if (!ts.transforming) {
  21983. var rs = this._readableState;
  21984. if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
  21985. }
  21986. };
  21987. // Doesn't matter what the args are here.
  21988. // _transform does all the work.
  21989. // That we got here means that the readable side wants more data.
  21990. Transform.prototype._read = function (n) {
  21991. var ts = this._transformState;
  21992. if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
  21993. ts.transforming = true;
  21994. this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
  21995. } else {
  21996. // mark that we need a transform, so that any data that comes in
  21997. // will get processed, now that we've asked for it.
  21998. ts.needTransform = true;
  21999. }
  22000. };
  22001. Transform.prototype._destroy = function (err, cb) {
  22002. var _this2 = this;
  22003. Duplex.prototype._destroy.call(this, err, function (err2) {
  22004. cb(err2);
  22005. _this2.emit('close');
  22006. });
  22007. };
  22008. function done(stream, er, data) {
  22009. if (er) return stream.emit('error', er);
  22010. if (data != null) // single equals check for both `null` and `undefined`
  22011. stream.push(data);
  22012. // if there's nothing in the write buffer, then that means
  22013. // that nothing more will ever be provided
  22014. if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');
  22015. if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
  22016. return stream.push(null);
  22017. }
  22018. },{"./_stream_duplex":325,"core-util-is":294,"inherits":307}],329:[function(require,module,exports){
  22019. (function (process,global,setImmediate){
  22020. // Copyright Joyent, Inc. and other Node contributors.
  22021. //
  22022. // Permission is hereby granted, free of charge, to any person obtaining a
  22023. // copy of this software and associated documentation files (the
  22024. // "Software"), to deal in the Software without restriction, including
  22025. // without limitation the rights to use, copy, modify, merge, publish,
  22026. // distribute, sublicense, and/or sell copies of the Software, and to permit
  22027. // persons to whom the Software is furnished to do so, subject to the
  22028. // following conditions:
  22029. //
  22030. // The above copyright notice and this permission notice shall be included
  22031. // in all copies or substantial portions of the Software.
  22032. //
  22033. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  22034. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22035. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  22036. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  22037. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  22038. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  22039. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  22040. // A bit simpler than readable streams.
  22041. // Implement an async ._write(chunk, encoding, cb), and it'll handle all
  22042. // the drain event emission and buffering.
  22043. 'use strict';
  22044. /*<replacement>*/
  22045. var pna = require('process-nextick-args');
  22046. /*</replacement>*/
  22047. module.exports = Writable;
  22048. /* <replacement> */
  22049. function WriteReq(chunk, encoding, cb) {
  22050. this.chunk = chunk;
  22051. this.encoding = encoding;
  22052. this.callback = cb;
  22053. this.next = null;
  22054. }
  22055. // It seems a linked list but it is not
  22056. // there will be only 2 of these for each stream
  22057. function CorkedRequest(state) {
  22058. var _this = this;
  22059. this.next = null;
  22060. this.entry = null;
  22061. this.finish = function () {
  22062. onCorkedFinish(_this, state);
  22063. };
  22064. }
  22065. /* </replacement> */
  22066. /*<replacement>*/
  22067. var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
  22068. /*</replacement>*/
  22069. /*<replacement>*/
  22070. var Duplex;
  22071. /*</replacement>*/
  22072. Writable.WritableState = WritableState;
  22073. /*<replacement>*/
  22074. var util = Object.create(require('core-util-is'));
  22075. util.inherits = require('inherits');
  22076. /*</replacement>*/
  22077. /*<replacement>*/
  22078. var internalUtil = {
  22079. deprecate: require('util-deprecate')
  22080. };
  22081. /*</replacement>*/
  22082. /*<replacement>*/
  22083. var Stream = require('./internal/streams/stream');
  22084. /*</replacement>*/
  22085. /*<replacement>*/
  22086. var Buffer = require('safe-buffer').Buffer;
  22087. var OurUint8Array = global.Uint8Array || function () {};
  22088. function _uint8ArrayToBuffer(chunk) {
  22089. return Buffer.from(chunk);
  22090. }
  22091. function _isUint8Array(obj) {
  22092. return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
  22093. }
  22094. /*</replacement>*/
  22095. var destroyImpl = require('./internal/streams/destroy');
  22096. util.inherits(Writable, Stream);
  22097. function nop() {}
  22098. function WritableState(options, stream) {
  22099. Duplex = Duplex || require('./_stream_duplex');
  22100. options = options || {};
  22101. // Duplex streams are both readable and writable, but share
  22102. // the same options object.
  22103. // However, some cases require setting options to different
  22104. // values for the readable and the writable sides of the duplex stream.
  22105. // These options can be provided separately as readableXXX and writableXXX.
  22106. var isDuplex = stream instanceof Duplex;
  22107. // object stream flag to indicate whether or not this stream
  22108. // contains buffers or objects.
  22109. this.objectMode = !!options.objectMode;
  22110. if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
  22111. // the point at which write() starts returning false
  22112. // Note: 0 is a valid value, means that we always return false if
  22113. // the entire buffer is not flushed immediately on write()
  22114. var hwm = options.highWaterMark;
  22115. var writableHwm = options.writableHighWaterMark;
  22116. var defaultHwm = this.objectMode ? 16 : 16 * 1024;
  22117. if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;
  22118. // cast to ints.
  22119. this.highWaterMark = Math.floor(this.highWaterMark);
  22120. // if _final has been called
  22121. this.finalCalled = false;
  22122. // drain event flag.
  22123. this.needDrain = false;
  22124. // at the start of calling end()
  22125. this.ending = false;
  22126. // when end() has been called, and returned
  22127. this.ended = false;
  22128. // when 'finish' is emitted
  22129. this.finished = false;
  22130. // has it been destroyed
  22131. this.destroyed = false;
  22132. // should we decode strings into buffers before passing to _write?
  22133. // this is here so that some node-core streams can optimize string
  22134. // handling at a lower level.
  22135. var noDecode = options.decodeStrings === false;
  22136. this.decodeStrings = !noDecode;
  22137. // Crypto is kind of old and crusty. Historically, its default string
  22138. // encoding is 'binary' so we have to make this configurable.
  22139. // Everything else in the universe uses 'utf8', though.
  22140. this.defaultEncoding = options.defaultEncoding || 'utf8';
  22141. // not an actual buffer we keep track of, but a measurement
  22142. // of how much we're waiting to get pushed to some underlying
  22143. // socket or file.
  22144. this.length = 0;
  22145. // a flag to see when we're in the middle of a write.
  22146. this.writing = false;
  22147. // when true all writes will be buffered until .uncork() call
  22148. this.corked = 0;
  22149. // a flag to be able to tell if the onwrite cb is called immediately,
  22150. // or on a later tick. We set this to true at first, because any
  22151. // actions that shouldn't happen until "later" should generally also
  22152. // not happen before the first write call.
  22153. this.sync = true;
  22154. // a flag to know if we're processing previously buffered items, which
  22155. // may call the _write() callback in the same tick, so that we don't
  22156. // end up in an overlapped onwrite situation.
  22157. this.bufferProcessing = false;
  22158. // the callback that's passed to _write(chunk,cb)
  22159. this.onwrite = function (er) {
  22160. onwrite(stream, er);
  22161. };
  22162. // the callback that the user supplies to write(chunk,encoding,cb)
  22163. this.writecb = null;
  22164. // the amount that is being written when _write is called.
  22165. this.writelen = 0;
  22166. this.bufferedRequest = null;
  22167. this.lastBufferedRequest = null;
  22168. // number of pending user-supplied write callbacks
  22169. // this must be 0 before 'finish' can be emitted
  22170. this.pendingcb = 0;
  22171. // emit prefinish if the only thing we're waiting for is _write cbs
  22172. // This is relevant for synchronous Transform streams
  22173. this.prefinished = false;
  22174. // True if the error was already emitted and should not be thrown again
  22175. this.errorEmitted = false;
  22176. // count buffered requests
  22177. this.bufferedRequestCount = 0;
  22178. // allocate the first CorkedRequest, there is always
  22179. // one allocated and free to use, and we maintain at most two
  22180. this.corkedRequestsFree = new CorkedRequest(this);
  22181. }
  22182. WritableState.prototype.getBuffer = function getBuffer() {
  22183. var current = this.bufferedRequest;
  22184. var out = [];
  22185. while (current) {
  22186. out.push(current);
  22187. current = current.next;
  22188. }
  22189. return out;
  22190. };
  22191. (function () {
  22192. try {
  22193. Object.defineProperty(WritableState.prototype, 'buffer', {
  22194. get: internalUtil.deprecate(function () {
  22195. return this.getBuffer();
  22196. }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
  22197. });
  22198. } catch (_) {}
  22199. })();
  22200. // Test _writableState for inheritance to account for Duplex streams,
  22201. // whose prototype chain only points to Readable.
  22202. var realHasInstance;
  22203. if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
  22204. realHasInstance = Function.prototype[Symbol.hasInstance];
  22205. Object.defineProperty(Writable, Symbol.hasInstance, {
  22206. value: function (object) {
  22207. if (realHasInstance.call(this, object)) return true;
  22208. if (this !== Writable) return false;
  22209. return object && object._writableState instanceof WritableState;
  22210. }
  22211. });
  22212. } else {
  22213. realHasInstance = function (object) {
  22214. return object instanceof this;
  22215. };
  22216. }
  22217. function Writable(options) {
  22218. Duplex = Duplex || require('./_stream_duplex');
  22219. // Writable ctor is applied to Duplexes, too.
  22220. // `realHasInstance` is necessary because using plain `instanceof`
  22221. // would return false, as no `_writableState` property is attached.
  22222. // Trying to use the custom `instanceof` for Writable here will also break the
  22223. // Node.js LazyTransform implementation, which has a non-trivial getter for
  22224. // `_writableState` that would lead to infinite recursion.
  22225. if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
  22226. return new Writable(options);
  22227. }
  22228. this._writableState = new WritableState(options, this);
  22229. // legacy.
  22230. this.writable = true;
  22231. if (options) {
  22232. if (typeof options.write === 'function') this._write = options.write;
  22233. if (typeof options.writev === 'function') this._writev = options.writev;
  22234. if (typeof options.destroy === 'function') this._destroy = options.destroy;
  22235. if (typeof options.final === 'function') this._final = options.final;
  22236. }
  22237. Stream.call(this);
  22238. }
  22239. // Otherwise people can pipe Writable streams, which is just wrong.
  22240. Writable.prototype.pipe = function () {
  22241. this.emit('error', new Error('Cannot pipe, not readable'));
  22242. };
  22243. function writeAfterEnd(stream, cb) {
  22244. var er = new Error('write after end');
  22245. // TODO: defer error events consistently everywhere, not just the cb
  22246. stream.emit('error', er);
  22247. pna.nextTick(cb, er);
  22248. }
  22249. // Checks that a user-supplied chunk is valid, especially for the particular
  22250. // mode the stream is in. Currently this means that `null` is never accepted
  22251. // and undefined/non-string values are only allowed in object mode.
  22252. function validChunk(stream, state, chunk, cb) {
  22253. var valid = true;
  22254. var er = false;
  22255. if (chunk === null) {
  22256. er = new TypeError('May not write null values to stream');
  22257. } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
  22258. er = new TypeError('Invalid non-string/buffer chunk');
  22259. }
  22260. if (er) {
  22261. stream.emit('error', er);
  22262. pna.nextTick(cb, er);
  22263. valid = false;
  22264. }
  22265. return valid;
  22266. }
  22267. Writable.prototype.write = function (chunk, encoding, cb) {
  22268. var state = this._writableState;
  22269. var ret = false;
  22270. var isBuf = !state.objectMode && _isUint8Array(chunk);
  22271. if (isBuf && !Buffer.isBuffer(chunk)) {
  22272. chunk = _uint8ArrayToBuffer(chunk);
  22273. }
  22274. if (typeof encoding === 'function') {
  22275. cb = encoding;
  22276. encoding = null;
  22277. }
  22278. if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
  22279. if (typeof cb !== 'function') cb = nop;
  22280. if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
  22281. state.pendingcb++;
  22282. ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
  22283. }
  22284. return ret;
  22285. };
  22286. Writable.prototype.cork = function () {
  22287. var state = this._writableState;
  22288. state.corked++;
  22289. };
  22290. Writable.prototype.uncork = function () {
  22291. var state = this._writableState;
  22292. if (state.corked) {
  22293. state.corked--;
  22294. if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
  22295. }
  22296. };
  22297. Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
  22298. // node::ParseEncoding() requires lower case.
  22299. if (typeof encoding === 'string') encoding = encoding.toLowerCase();
  22300. if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);
  22301. this._writableState.defaultEncoding = encoding;
  22302. return this;
  22303. };
  22304. function decodeChunk(state, chunk, encoding) {
  22305. if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
  22306. chunk = Buffer.from(chunk, encoding);
  22307. }
  22308. return chunk;
  22309. }
  22310. Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
  22311. // making it explicit this property is not enumerable
  22312. // because otherwise some prototype manipulation in
  22313. // userland will fail
  22314. enumerable: false,
  22315. get: function () {
  22316. return this._writableState.highWaterMark;
  22317. }
  22318. });
  22319. // if we're already writing something, then just put this
  22320. // in the queue, and wait our turn. Otherwise, call _write
  22321. // If we return false, then we need a drain event, so set that flag.
  22322. function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
  22323. if (!isBuf) {
  22324. var newChunk = decodeChunk(state, chunk, encoding);
  22325. if (chunk !== newChunk) {
  22326. isBuf = true;
  22327. encoding = 'buffer';
  22328. chunk = newChunk;
  22329. }
  22330. }
  22331. var len = state.objectMode ? 1 : chunk.length;
  22332. state.length += len;
  22333. var ret = state.length < state.highWaterMark;
  22334. // we must ensure that previous needDrain will not be reset to false.
  22335. if (!ret) state.needDrain = true;
  22336. if (state.writing || state.corked) {
  22337. var last = state.lastBufferedRequest;
  22338. state.lastBufferedRequest = {
  22339. chunk: chunk,
  22340. encoding: encoding,
  22341. isBuf: isBuf,
  22342. callback: cb,
  22343. next: null
  22344. };
  22345. if (last) {
  22346. last.next = state.lastBufferedRequest;
  22347. } else {
  22348. state.bufferedRequest = state.lastBufferedRequest;
  22349. }
  22350. state.bufferedRequestCount += 1;
  22351. } else {
  22352. doWrite(stream, state, false, len, chunk, encoding, cb);
  22353. }
  22354. return ret;
  22355. }
  22356. function doWrite(stream, state, writev, len, chunk, encoding, cb) {
  22357. state.writelen = len;
  22358. state.writecb = cb;
  22359. state.writing = true;
  22360. state.sync = true;
  22361. if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
  22362. state.sync = false;
  22363. }
  22364. function onwriteError(stream, state, sync, er, cb) {
  22365. --state.pendingcb;
  22366. if (sync) {
  22367. // defer the callback if we are being called synchronously
  22368. // to avoid piling up things on the stack
  22369. pna.nextTick(cb, er);
  22370. // this can emit finish, and it will always happen
  22371. // after error
  22372. pna.nextTick(finishMaybe, stream, state);
  22373. stream._writableState.errorEmitted = true;
  22374. stream.emit('error', er);
  22375. } else {
  22376. // the caller expect this to happen before if
  22377. // it is async
  22378. cb(er);
  22379. stream._writableState.errorEmitted = true;
  22380. stream.emit('error', er);
  22381. // this can emit finish, but finish must
  22382. // always follow error
  22383. finishMaybe(stream, state);
  22384. }
  22385. }
  22386. function onwriteStateUpdate(state) {
  22387. state.writing = false;
  22388. state.writecb = null;
  22389. state.length -= state.writelen;
  22390. state.writelen = 0;
  22391. }
  22392. function onwrite(stream, er) {
  22393. var state = stream._writableState;
  22394. var sync = state.sync;
  22395. var cb = state.writecb;
  22396. onwriteStateUpdate(state);
  22397. if (er) onwriteError(stream, state, sync, er, cb);else {
  22398. // Check if we're actually ready to finish, but don't emit yet
  22399. var finished = needFinish(state);
  22400. if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
  22401. clearBuffer(stream, state);
  22402. }
  22403. if (sync) {
  22404. /*<replacement>*/
  22405. asyncWrite(afterWrite, stream, state, finished, cb);
  22406. /*</replacement>*/
  22407. } else {
  22408. afterWrite(stream, state, finished, cb);
  22409. }
  22410. }
  22411. }
  22412. function afterWrite(stream, state, finished, cb) {
  22413. if (!finished) onwriteDrain(stream, state);
  22414. state.pendingcb--;
  22415. cb();
  22416. finishMaybe(stream, state);
  22417. }
  22418. // Must force callback to be called on nextTick, so that we don't
  22419. // emit 'drain' before the write() consumer gets the 'false' return
  22420. // value, and has a chance to attach a 'drain' listener.
  22421. function onwriteDrain(stream, state) {
  22422. if (state.length === 0 && state.needDrain) {
  22423. state.needDrain = false;
  22424. stream.emit('drain');
  22425. }
  22426. }
  22427. // if there's something in the buffer waiting, then process it
  22428. function clearBuffer(stream, state) {
  22429. state.bufferProcessing = true;
  22430. var entry = state.bufferedRequest;
  22431. if (stream._writev && entry && entry.next) {
  22432. // Fast case, write everything using _writev()
  22433. var l = state.bufferedRequestCount;
  22434. var buffer = new Array(l);
  22435. var holder = state.corkedRequestsFree;
  22436. holder.entry = entry;
  22437. var count = 0;
  22438. var allBuffers = true;
  22439. while (entry) {
  22440. buffer[count] = entry;
  22441. if (!entry.isBuf) allBuffers = false;
  22442. entry = entry.next;
  22443. count += 1;
  22444. }
  22445. buffer.allBuffers = allBuffers;
  22446. doWrite(stream, state, true, state.length, buffer, '', holder.finish);
  22447. // doWrite is almost always async, defer these to save a bit of time
  22448. // as the hot path ends with doWrite
  22449. state.pendingcb++;
  22450. state.lastBufferedRequest = null;
  22451. if (holder.next) {
  22452. state.corkedRequestsFree = holder.next;
  22453. holder.next = null;
  22454. } else {
  22455. state.corkedRequestsFree = new CorkedRequest(state);
  22456. }
  22457. state.bufferedRequestCount = 0;
  22458. } else {
  22459. // Slow case, write chunks one-by-one
  22460. while (entry) {
  22461. var chunk = entry.chunk;
  22462. var encoding = entry.encoding;
  22463. var cb = entry.callback;
  22464. var len = state.objectMode ? 1 : chunk.length;
  22465. doWrite(stream, state, false, len, chunk, encoding, cb);
  22466. entry = entry.next;
  22467. state.bufferedRequestCount--;
  22468. // if we didn't call the onwrite immediately, then
  22469. // it means that we need to wait until it does.
  22470. // also, that means that the chunk and cb are currently
  22471. // being processed, so move the buffer counter past them.
  22472. if (state.writing) {
  22473. break;
  22474. }
  22475. }
  22476. if (entry === null) state.lastBufferedRequest = null;
  22477. }
  22478. state.bufferedRequest = entry;
  22479. state.bufferProcessing = false;
  22480. }
  22481. Writable.prototype._write = function (chunk, encoding, cb) {
  22482. cb(new Error('_write() is not implemented'));
  22483. };
  22484. Writable.prototype._writev = null;
  22485. Writable.prototype.end = function (chunk, encoding, cb) {
  22486. var state = this._writableState;
  22487. if (typeof chunk === 'function') {
  22488. cb = chunk;
  22489. chunk = null;
  22490. encoding = null;
  22491. } else if (typeof encoding === 'function') {
  22492. cb = encoding;
  22493. encoding = null;
  22494. }
  22495. if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
  22496. // .end() fully uncorks
  22497. if (state.corked) {
  22498. state.corked = 1;
  22499. this.uncork();
  22500. }
  22501. // ignore unnecessary end() calls.
  22502. if (!state.ending && !state.finished) endWritable(this, state, cb);
  22503. };
  22504. function needFinish(state) {
  22505. return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
  22506. }
  22507. function callFinal(stream, state) {
  22508. stream._final(function (err) {
  22509. state.pendingcb--;
  22510. if (err) {
  22511. stream.emit('error', err);
  22512. }
  22513. state.prefinished = true;
  22514. stream.emit('prefinish');
  22515. finishMaybe(stream, state);
  22516. });
  22517. }
  22518. function prefinish(stream, state) {
  22519. if (!state.prefinished && !state.finalCalled) {
  22520. if (typeof stream._final === 'function') {
  22521. state.pendingcb++;
  22522. state.finalCalled = true;
  22523. pna.nextTick(callFinal, stream, state);
  22524. } else {
  22525. state.prefinished = true;
  22526. stream.emit('prefinish');
  22527. }
  22528. }
  22529. }
  22530. function finishMaybe(stream, state) {
  22531. var need = needFinish(state);
  22532. if (need) {
  22533. prefinish(stream, state);
  22534. if (state.pendingcb === 0) {
  22535. state.finished = true;
  22536. stream.emit('finish');
  22537. }
  22538. }
  22539. return need;
  22540. }
  22541. function endWritable(stream, state, cb) {
  22542. state.ending = true;
  22543. finishMaybe(stream, state);
  22544. if (cb) {
  22545. if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);
  22546. }
  22547. state.ended = true;
  22548. stream.writable = false;
  22549. }
  22550. function onCorkedFinish(corkReq, state, err) {
  22551. var entry = corkReq.entry;
  22552. corkReq.entry = null;
  22553. while (entry) {
  22554. var cb = entry.callback;
  22555. state.pendingcb--;
  22556. cb(err);
  22557. entry = entry.next;
  22558. }
  22559. if (state.corkedRequestsFree) {
  22560. state.corkedRequestsFree.next = corkReq;
  22561. } else {
  22562. state.corkedRequestsFree = corkReq;
  22563. }
  22564. }
  22565. Object.defineProperty(Writable.prototype, 'destroyed', {
  22566. get: function () {
  22567. if (this._writableState === undefined) {
  22568. return false;
  22569. }
  22570. return this._writableState.destroyed;
  22571. },
  22572. set: function (value) {
  22573. // we ignore the value if the stream
  22574. // has not been initialized yet
  22575. if (!this._writableState) {
  22576. return;
  22577. }
  22578. // backward compatibility, the user is explicitly
  22579. // managing destroyed
  22580. this._writableState.destroyed = value;
  22581. }
  22582. });
  22583. Writable.prototype.destroy = destroyImpl.destroy;
  22584. Writable.prototype._undestroy = destroyImpl.undestroy;
  22585. Writable.prototype._destroy = function (err, cb) {
  22586. this.end();
  22587. cb(err);
  22588. };
  22589. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("timers").setImmediate)
  22590. },{"./_stream_duplex":325,"./internal/streams/destroy":331,"./internal/streams/stream":332,"_process":393,"core-util-is":294,"inherits":307,"process-nextick-args":318,"safe-buffer":338,"timers":342,"util-deprecate":343}],330:[function(require,module,exports){
  22591. 'use strict';
  22592. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  22593. var Buffer = require('safe-buffer').Buffer;
  22594. var util = require('util');
  22595. function copyBuffer(src, target, offset) {
  22596. src.copy(target, offset);
  22597. }
  22598. module.exports = function () {
  22599. function BufferList() {
  22600. _classCallCheck(this, BufferList);
  22601. this.head = null;
  22602. this.tail = null;
  22603. this.length = 0;
  22604. }
  22605. BufferList.prototype.push = function push(v) {
  22606. var entry = { data: v, next: null };
  22607. if (this.length > 0) this.tail.next = entry;else this.head = entry;
  22608. this.tail = entry;
  22609. ++this.length;
  22610. };
  22611. BufferList.prototype.unshift = function unshift(v) {
  22612. var entry = { data: v, next: this.head };
  22613. if (this.length === 0) this.tail = entry;
  22614. this.head = entry;
  22615. ++this.length;
  22616. };
  22617. BufferList.prototype.shift = function shift() {
  22618. if (this.length === 0) return;
  22619. var ret = this.head.data;
  22620. if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
  22621. --this.length;
  22622. return ret;
  22623. };
  22624. BufferList.prototype.clear = function clear() {
  22625. this.head = this.tail = null;
  22626. this.length = 0;
  22627. };
  22628. BufferList.prototype.join = function join(s) {
  22629. if (this.length === 0) return '';
  22630. var p = this.head;
  22631. var ret = '' + p.data;
  22632. while (p = p.next) {
  22633. ret += s + p.data;
  22634. }return ret;
  22635. };
  22636. BufferList.prototype.concat = function concat(n) {
  22637. if (this.length === 0) return Buffer.alloc(0);
  22638. if (this.length === 1) return this.head.data;
  22639. var ret = Buffer.allocUnsafe(n >>> 0);
  22640. var p = this.head;
  22641. var i = 0;
  22642. while (p) {
  22643. copyBuffer(p.data, ret, i);
  22644. i += p.data.length;
  22645. p = p.next;
  22646. }
  22647. return ret;
  22648. };
  22649. return BufferList;
  22650. }();
  22651. if (util && util.inspect && util.inspect.custom) {
  22652. module.exports.prototype[util.inspect.custom] = function () {
  22653. var obj = util.inspect({ length: this.length });
  22654. return this.constructor.name + ' ' + obj;
  22655. };
  22656. }
  22657. },{"safe-buffer":338,"util":78}],331:[function(require,module,exports){
  22658. 'use strict';
  22659. /*<replacement>*/
  22660. var pna = require('process-nextick-args');
  22661. /*</replacement>*/
  22662. // undocumented cb() API, needed for core, not for public API
  22663. function destroy(err, cb) {
  22664. var _this = this;
  22665. var readableDestroyed = this._readableState && this._readableState.destroyed;
  22666. var writableDestroyed = this._writableState && this._writableState.destroyed;
  22667. if (readableDestroyed || writableDestroyed) {
  22668. if (cb) {
  22669. cb(err);
  22670. } else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
  22671. pna.nextTick(emitErrorNT, this, err);
  22672. }
  22673. return this;
  22674. }
  22675. // we set destroyed to true before firing error callbacks in order
  22676. // to make it re-entrance safe in case destroy() is called within callbacks
  22677. if (this._readableState) {
  22678. this._readableState.destroyed = true;
  22679. }
  22680. // if this is a duplex stream mark the writable part as destroyed as well
  22681. if (this._writableState) {
  22682. this._writableState.destroyed = true;
  22683. }
  22684. this._destroy(err || null, function (err) {
  22685. if (!cb && err) {
  22686. pna.nextTick(emitErrorNT, _this, err);
  22687. if (_this._writableState) {
  22688. _this._writableState.errorEmitted = true;
  22689. }
  22690. } else if (cb) {
  22691. cb(err);
  22692. }
  22693. });
  22694. return this;
  22695. }
  22696. function undestroy() {
  22697. if (this._readableState) {
  22698. this._readableState.destroyed = false;
  22699. this._readableState.reading = false;
  22700. this._readableState.ended = false;
  22701. this._readableState.endEmitted = false;
  22702. }
  22703. if (this._writableState) {
  22704. this._writableState.destroyed = false;
  22705. this._writableState.ended = false;
  22706. this._writableState.ending = false;
  22707. this._writableState.finished = false;
  22708. this._writableState.errorEmitted = false;
  22709. }
  22710. }
  22711. function emitErrorNT(self, err) {
  22712. self.emit('error', err);
  22713. }
  22714. module.exports = {
  22715. destroy: destroy,
  22716. undestroy: undestroy
  22717. };
  22718. },{"process-nextick-args":318}],332:[function(require,module,exports){
  22719. arguments[4][96][0].apply(exports,arguments)
  22720. },{"dup":96,"events":297}],333:[function(require,module,exports){
  22721. module.exports = require('./readable').PassThrough
  22722. },{"./readable":334}],334:[function(require,module,exports){
  22723. exports = module.exports = require('./lib/_stream_readable.js');
  22724. exports.Stream = exports;
  22725. exports.Readable = exports;
  22726. exports.Writable = require('./lib/_stream_writable.js');
  22727. exports.Duplex = require('./lib/_stream_duplex.js');
  22728. exports.Transform = require('./lib/_stream_transform.js');
  22729. exports.PassThrough = require('./lib/_stream_passthrough.js');
  22730. },{"./lib/_stream_duplex.js":325,"./lib/_stream_passthrough.js":326,"./lib/_stream_readable.js":327,"./lib/_stream_transform.js":328,"./lib/_stream_writable.js":329}],335:[function(require,module,exports){
  22731. module.exports = require('./readable').Transform
  22732. },{"./readable":334}],336:[function(require,module,exports){
  22733. module.exports = require('./lib/_stream_writable.js');
  22734. },{"./lib/_stream_writable.js":329}],337:[function(require,module,exports){
  22735. /**
  22736. * Copyright (c) 2014-present, Facebook, Inc.
  22737. *
  22738. * This source code is licensed under the MIT license found in the
  22739. * LICENSE file in the root directory of this source tree.
  22740. */
  22741. !(function(global) {
  22742. "use strict";
  22743. var Op = Object.prototype;
  22744. var hasOwn = Op.hasOwnProperty;
  22745. var undefined; // More compressible than void 0.
  22746. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  22747. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  22748. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  22749. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  22750. var inModule = typeof module === "object";
  22751. var runtime = global.regeneratorRuntime;
  22752. if (runtime) {
  22753. if (inModule) {
  22754. // If regeneratorRuntime is defined globally and we're in a module,
  22755. // make the exports object identical to regeneratorRuntime.
  22756. module.exports = runtime;
  22757. }
  22758. // Don't bother evaluating the rest of this file if the runtime was
  22759. // already defined globally.
  22760. return;
  22761. }
  22762. // Define the runtime globally (as expected by generated code) as either
  22763. // module.exports (if we're in a module) or a new, empty object.
  22764. runtime = global.regeneratorRuntime = inModule ? module.exports : {};
  22765. function wrap(innerFn, outerFn, self, tryLocsList) {
  22766. // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
  22767. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  22768. var generator = Object.create(protoGenerator.prototype);
  22769. var context = new Context(tryLocsList || []);
  22770. // The ._invoke method unifies the implementations of the .next,
  22771. // .throw, and .return methods.
  22772. generator._invoke = makeInvokeMethod(innerFn, self, context);
  22773. return generator;
  22774. }
  22775. runtime.wrap = wrap;
  22776. // Try/catch helper to minimize deoptimizations. Returns a completion
  22777. // record like context.tryEntries[i].completion. This interface could
  22778. // have been (and was previously) designed to take a closure to be
  22779. // invoked without arguments, but in all the cases we care about we
  22780. // already have an existing method we want to call, so there's no need
  22781. // to create a new function object. We can even get away with assuming
  22782. // the method takes exactly one argument, since that happens to be true
  22783. // in every case, so we don't have to touch the arguments object. The
  22784. // only additional allocation required is the completion record, which
  22785. // has a stable shape and so hopefully should be cheap to allocate.
  22786. function tryCatch(fn, obj, arg) {
  22787. try {
  22788. return { type: "normal", arg: fn.call(obj, arg) };
  22789. } catch (err) {
  22790. return { type: "throw", arg: err };
  22791. }
  22792. }
  22793. var GenStateSuspendedStart = "suspendedStart";
  22794. var GenStateSuspendedYield = "suspendedYield";
  22795. var GenStateExecuting = "executing";
  22796. var GenStateCompleted = "completed";
  22797. // Returning this object from the innerFn has the same effect as
  22798. // breaking out of the dispatch switch statement.
  22799. var ContinueSentinel = {};
  22800. // Dummy constructor functions that we use as the .constructor and
  22801. // .constructor.prototype properties for functions that return Generator
  22802. // objects. For full spec compliance, you may wish to configure your
  22803. // minifier not to mangle the names of these two functions.
  22804. function Generator() {}
  22805. function GeneratorFunction() {}
  22806. function GeneratorFunctionPrototype() {}
  22807. // This is a polyfill for %IteratorPrototype% for environments that
  22808. // don't natively support it.
  22809. var IteratorPrototype = {};
  22810. IteratorPrototype[iteratorSymbol] = function () {
  22811. return this;
  22812. };
  22813. var getProto = Object.getPrototypeOf;
  22814. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  22815. if (NativeIteratorPrototype &&
  22816. NativeIteratorPrototype !== Op &&
  22817. hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  22818. // This environment has a native %IteratorPrototype%; use it instead
  22819. // of the polyfill.
  22820. IteratorPrototype = NativeIteratorPrototype;
  22821. }
  22822. var Gp = GeneratorFunctionPrototype.prototype =
  22823. Generator.prototype = Object.create(IteratorPrototype);
  22824. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  22825. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  22826. GeneratorFunctionPrototype[toStringTagSymbol] =
  22827. GeneratorFunction.displayName = "GeneratorFunction";
  22828. // Helper for defining the .next, .throw, and .return methods of the
  22829. // Iterator interface in terms of a single ._invoke method.
  22830. function defineIteratorMethods(prototype) {
  22831. ["next", "throw", "return"].forEach(function(method) {
  22832. prototype[method] = function(arg) {
  22833. return this._invoke(method, arg);
  22834. };
  22835. });
  22836. }
  22837. runtime.isGeneratorFunction = function(genFun) {
  22838. var ctor = typeof genFun === "function" && genFun.constructor;
  22839. return ctor
  22840. ? ctor === GeneratorFunction ||
  22841. // For the native GeneratorFunction constructor, the best we can
  22842. // do is to check its .name property.
  22843. (ctor.displayName || ctor.name) === "GeneratorFunction"
  22844. : false;
  22845. };
  22846. runtime.mark = function(genFun) {
  22847. if (Object.setPrototypeOf) {
  22848. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  22849. } else {
  22850. genFun.__proto__ = GeneratorFunctionPrototype;
  22851. if (!(toStringTagSymbol in genFun)) {
  22852. genFun[toStringTagSymbol] = "GeneratorFunction";
  22853. }
  22854. }
  22855. genFun.prototype = Object.create(Gp);
  22856. return genFun;
  22857. };
  22858. // Within the body of any async function, `await x` is transformed to
  22859. // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
  22860. // `hasOwn.call(value, "__await")` to determine if the yielded value is
  22861. // meant to be awaited.
  22862. runtime.awrap = function(arg) {
  22863. return { __await: arg };
  22864. };
  22865. function AsyncIterator(generator) {
  22866. function invoke(method, arg, resolve, reject) {
  22867. var record = tryCatch(generator[method], generator, arg);
  22868. if (record.type === "throw") {
  22869. reject(record.arg);
  22870. } else {
  22871. var result = record.arg;
  22872. var value = result.value;
  22873. if (value &&
  22874. typeof value === "object" &&
  22875. hasOwn.call(value, "__await")) {
  22876. return Promise.resolve(value.__await).then(function(value) {
  22877. invoke("next", value, resolve, reject);
  22878. }, function(err) {
  22879. invoke("throw", err, resolve, reject);
  22880. });
  22881. }
  22882. return Promise.resolve(value).then(function(unwrapped) {
  22883. // When a yielded Promise is resolved, its final value becomes
  22884. // the .value of the Promise<{value,done}> result for the
  22885. // current iteration. If the Promise is rejected, however, the
  22886. // result for this iteration will be rejected with the same
  22887. // reason. Note that rejections of yielded Promises are not
  22888. // thrown back into the generator function, as is the case
  22889. // when an awaited Promise is rejected. This difference in
  22890. // behavior between yield and await is important, because it
  22891. // allows the consumer to decide what to do with the yielded
  22892. // rejection (swallow it and continue, manually .throw it back
  22893. // into the generator, abandon iteration, whatever). With
  22894. // await, by contrast, there is no opportunity to examine the
  22895. // rejection reason outside the generator function, so the
  22896. // only option is to throw it from the await expression, and
  22897. // let the generator function handle the exception.
  22898. result.value = unwrapped;
  22899. resolve(result);
  22900. }, reject);
  22901. }
  22902. }
  22903. var previousPromise;
  22904. function enqueue(method, arg) {
  22905. function callInvokeWithMethodAndArg() {
  22906. return new Promise(function(resolve, reject) {
  22907. invoke(method, arg, resolve, reject);
  22908. });
  22909. }
  22910. return previousPromise =
  22911. // If enqueue has been called before, then we want to wait until
  22912. // all previous Promises have been resolved before calling invoke,
  22913. // so that results are always delivered in the correct order. If
  22914. // enqueue has not been called before, then it is important to
  22915. // call invoke immediately, without waiting on a callback to fire,
  22916. // so that the async generator function has the opportunity to do
  22917. // any necessary setup in a predictable way. This predictability
  22918. // is why the Promise constructor synchronously invokes its
  22919. // executor callback, and why async functions synchronously
  22920. // execute code before the first await. Since we implement simple
  22921. // async functions in terms of async generators, it is especially
  22922. // important to get this right, even though it requires care.
  22923. previousPromise ? previousPromise.then(
  22924. callInvokeWithMethodAndArg,
  22925. // Avoid propagating failures to Promises returned by later
  22926. // invocations of the iterator.
  22927. callInvokeWithMethodAndArg
  22928. ) : callInvokeWithMethodAndArg();
  22929. }
  22930. // Define the unified helper method that is used to implement .next,
  22931. // .throw, and .return (see defineIteratorMethods).
  22932. this._invoke = enqueue;
  22933. }
  22934. defineIteratorMethods(AsyncIterator.prototype);
  22935. AsyncIterator.prototype[asyncIteratorSymbol] = function () {
  22936. return this;
  22937. };
  22938. runtime.AsyncIterator = AsyncIterator;
  22939. // Note that simple async functions are implemented on top of
  22940. // AsyncIterator objects; they just return a Promise for the value of
  22941. // the final result produced by the iterator.
  22942. runtime.async = function(innerFn, outerFn, self, tryLocsList) {
  22943. var iter = new AsyncIterator(
  22944. wrap(innerFn, outerFn, self, tryLocsList)
  22945. );
  22946. return runtime.isGeneratorFunction(outerFn)
  22947. ? iter // If outerFn is a generator, return the full iterator.
  22948. : iter.next().then(function(result) {
  22949. return result.done ? result.value : iter.next();
  22950. });
  22951. };
  22952. function makeInvokeMethod(innerFn, self, context) {
  22953. var state = GenStateSuspendedStart;
  22954. return function invoke(method, arg) {
  22955. if (state === GenStateExecuting) {
  22956. throw new Error("Generator is already running");
  22957. }
  22958. if (state === GenStateCompleted) {
  22959. if (method === "throw") {
  22960. throw arg;
  22961. }
  22962. // Be forgiving, per 25.3.3.3.3 of the spec:
  22963. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
  22964. return doneResult();
  22965. }
  22966. context.method = method;
  22967. context.arg = arg;
  22968. while (true) {
  22969. var delegate = context.delegate;
  22970. if (delegate) {
  22971. var delegateResult = maybeInvokeDelegate(delegate, context);
  22972. if (delegateResult) {
  22973. if (delegateResult === ContinueSentinel) continue;
  22974. return delegateResult;
  22975. }
  22976. }
  22977. if (context.method === "next") {
  22978. // Setting context._sent for legacy support of Babel's
  22979. // function.sent implementation.
  22980. context.sent = context._sent = context.arg;
  22981. } else if (context.method === "throw") {
  22982. if (state === GenStateSuspendedStart) {
  22983. state = GenStateCompleted;
  22984. throw context.arg;
  22985. }
  22986. context.dispatchException(context.arg);
  22987. } else if (context.method === "return") {
  22988. context.abrupt("return", context.arg);
  22989. }
  22990. state = GenStateExecuting;
  22991. var record = tryCatch(innerFn, self, context);
  22992. if (record.type === "normal") {
  22993. // If an exception is thrown from innerFn, we leave state ===
  22994. // GenStateExecuting and loop back for another invocation.
  22995. state = context.done
  22996. ? GenStateCompleted
  22997. : GenStateSuspendedYield;
  22998. if (record.arg === ContinueSentinel) {
  22999. continue;
  23000. }
  23001. return {
  23002. value: record.arg,
  23003. done: context.done
  23004. };
  23005. } else if (record.type === "throw") {
  23006. state = GenStateCompleted;
  23007. // Dispatch the exception by looping back around to the
  23008. // context.dispatchException(context.arg) call above.
  23009. context.method = "throw";
  23010. context.arg = record.arg;
  23011. }
  23012. }
  23013. };
  23014. }
  23015. // Call delegate.iterator[context.method](context.arg) and handle the
  23016. // result, either by returning a { value, done } result from the
  23017. // delegate iterator, or by modifying context.method and context.arg,
  23018. // setting context.delegate to null, and returning the ContinueSentinel.
  23019. function maybeInvokeDelegate(delegate, context) {
  23020. var method = delegate.iterator[context.method];
  23021. if (method === undefined) {
  23022. // A .throw or .return when the delegate iterator has no .throw
  23023. // method always terminates the yield* loop.
  23024. context.delegate = null;
  23025. if (context.method === "throw") {
  23026. if (delegate.iterator.return) {
  23027. // If the delegate iterator has a return method, give it a
  23028. // chance to clean up.
  23029. context.method = "return";
  23030. context.arg = undefined;
  23031. maybeInvokeDelegate(delegate, context);
  23032. if (context.method === "throw") {
  23033. // If maybeInvokeDelegate(context) changed context.method from
  23034. // "return" to "throw", let that override the TypeError below.
  23035. return ContinueSentinel;
  23036. }
  23037. }
  23038. context.method = "throw";
  23039. context.arg = new TypeError(
  23040. "The iterator does not provide a 'throw' method");
  23041. }
  23042. return ContinueSentinel;
  23043. }
  23044. var record = tryCatch(method, delegate.iterator, context.arg);
  23045. if (record.type === "throw") {
  23046. context.method = "throw";
  23047. context.arg = record.arg;
  23048. context.delegate = null;
  23049. return ContinueSentinel;
  23050. }
  23051. var info = record.arg;
  23052. if (! info) {
  23053. context.method = "throw";
  23054. context.arg = new TypeError("iterator result is not an object");
  23055. context.delegate = null;
  23056. return ContinueSentinel;
  23057. }
  23058. if (info.done) {
  23059. // Assign the result of the finished delegate to the temporary
  23060. // variable specified by delegate.resultName (see delegateYield).
  23061. context[delegate.resultName] = info.value;
  23062. // Resume execution at the desired location (see delegateYield).
  23063. context.next = delegate.nextLoc;
  23064. // If context.method was "throw" but the delegate handled the
  23065. // exception, let the outer generator proceed normally. If
  23066. // context.method was "next", forget context.arg since it has been
  23067. // "consumed" by the delegate iterator. If context.method was
  23068. // "return", allow the original .return call to continue in the
  23069. // outer generator.
  23070. if (context.method !== "return") {
  23071. context.method = "next";
  23072. context.arg = undefined;
  23073. }
  23074. } else {
  23075. // Re-yield the result returned by the delegate method.
  23076. return info;
  23077. }
  23078. // The delegate iterator is finished, so forget it and continue with
  23079. // the outer generator.
  23080. context.delegate = null;
  23081. return ContinueSentinel;
  23082. }
  23083. // Define Generator.prototype.{next,throw,return} in terms of the
  23084. // unified ._invoke helper method.
  23085. defineIteratorMethods(Gp);
  23086. Gp[toStringTagSymbol] = "Generator";
  23087. // A Generator should always return itself as the iterator object when the
  23088. // @@iterator function is called on it. Some browsers' implementations of the
  23089. // iterator prototype chain incorrectly implement this, causing the Generator
  23090. // object to not be returned from this call. This ensures that doesn't happen.
  23091. // See https://github.com/facebook/regenerator/issues/274 for more details.
  23092. Gp[iteratorSymbol] = function() {
  23093. return this;
  23094. };
  23095. Gp.toString = function() {
  23096. return "[object Generator]";
  23097. };
  23098. function pushTryEntry(locs) {
  23099. var entry = { tryLoc: locs[0] };
  23100. if (1 in locs) {
  23101. entry.catchLoc = locs[1];
  23102. }
  23103. if (2 in locs) {
  23104. entry.finallyLoc = locs[2];
  23105. entry.afterLoc = locs[3];
  23106. }
  23107. this.tryEntries.push(entry);
  23108. }
  23109. function resetTryEntry(entry) {
  23110. var record = entry.completion || {};
  23111. record.type = "normal";
  23112. delete record.arg;
  23113. entry.completion = record;
  23114. }
  23115. function Context(tryLocsList) {
  23116. // The root entry object (effectively a try statement without a catch
  23117. // or a finally block) gives us a place to store values thrown from
  23118. // locations where there is no enclosing try statement.
  23119. this.tryEntries = [{ tryLoc: "root" }];
  23120. tryLocsList.forEach(pushTryEntry, this);
  23121. this.reset(true);
  23122. }
  23123. runtime.keys = function(object) {
  23124. var keys = [];
  23125. for (var key in object) {
  23126. keys.push(key);
  23127. }
  23128. keys.reverse();
  23129. // Rather than returning an object with a next method, we keep
  23130. // things simple and return the next function itself.
  23131. return function next() {
  23132. while (keys.length) {
  23133. var key = keys.pop();
  23134. if (key in object) {
  23135. next.value = key;
  23136. next.done = false;
  23137. return next;
  23138. }
  23139. }
  23140. // To avoid creating an additional object, we just hang the .value
  23141. // and .done properties off the next function object itself. This
  23142. // also ensures that the minifier will not anonymize the function.
  23143. next.done = true;
  23144. return next;
  23145. };
  23146. };
  23147. function values(iterable) {
  23148. if (iterable) {
  23149. var iteratorMethod = iterable[iteratorSymbol];
  23150. if (iteratorMethod) {
  23151. return iteratorMethod.call(iterable);
  23152. }
  23153. if (typeof iterable.next === "function") {
  23154. return iterable;
  23155. }
  23156. if (!isNaN(iterable.length)) {
  23157. var i = -1, next = function next() {
  23158. while (++i < iterable.length) {
  23159. if (hasOwn.call(iterable, i)) {
  23160. next.value = iterable[i];
  23161. next.done = false;
  23162. return next;
  23163. }
  23164. }
  23165. next.value = undefined;
  23166. next.done = true;
  23167. return next;
  23168. };
  23169. return next.next = next;
  23170. }
  23171. }
  23172. // Return an iterator with no values.
  23173. return { next: doneResult };
  23174. }
  23175. runtime.values = values;
  23176. function doneResult() {
  23177. return { value: undefined, done: true };
  23178. }
  23179. Context.prototype = {
  23180. constructor: Context,
  23181. reset: function(skipTempReset) {
  23182. this.prev = 0;
  23183. this.next = 0;
  23184. // Resetting context._sent for legacy support of Babel's
  23185. // function.sent implementation.
  23186. this.sent = this._sent = undefined;
  23187. this.done = false;
  23188. this.delegate = null;
  23189. this.method = "next";
  23190. this.arg = undefined;
  23191. this.tryEntries.forEach(resetTryEntry);
  23192. if (!skipTempReset) {
  23193. for (var name in this) {
  23194. // Not sure about the optimal order of these conditions:
  23195. if (name.charAt(0) === "t" &&
  23196. hasOwn.call(this, name) &&
  23197. !isNaN(+name.slice(1))) {
  23198. this[name] = undefined;
  23199. }
  23200. }
  23201. }
  23202. },
  23203. stop: function() {
  23204. this.done = true;
  23205. var rootEntry = this.tryEntries[0];
  23206. var rootRecord = rootEntry.completion;
  23207. if (rootRecord.type === "throw") {
  23208. throw rootRecord.arg;
  23209. }
  23210. return this.rval;
  23211. },
  23212. dispatchException: function(exception) {
  23213. if (this.done) {
  23214. throw exception;
  23215. }
  23216. var context = this;
  23217. function handle(loc, caught) {
  23218. record.type = "throw";
  23219. record.arg = exception;
  23220. context.next = loc;
  23221. if (caught) {
  23222. // If the dispatched exception was caught by a catch block,
  23223. // then let that catch block handle the exception normally.
  23224. context.method = "next";
  23225. context.arg = undefined;
  23226. }
  23227. return !! caught;
  23228. }
  23229. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  23230. var entry = this.tryEntries[i];
  23231. var record = entry.completion;
  23232. if (entry.tryLoc === "root") {
  23233. // Exception thrown outside of any try block that could handle
  23234. // it, so set the completion value of the entire function to
  23235. // throw the exception.
  23236. return handle("end");
  23237. }
  23238. if (entry.tryLoc <= this.prev) {
  23239. var hasCatch = hasOwn.call(entry, "catchLoc");
  23240. var hasFinally = hasOwn.call(entry, "finallyLoc");
  23241. if (hasCatch && hasFinally) {
  23242. if (this.prev < entry.catchLoc) {
  23243. return handle(entry.catchLoc, true);
  23244. } else if (this.prev < entry.finallyLoc) {
  23245. return handle(entry.finallyLoc);
  23246. }
  23247. } else if (hasCatch) {
  23248. if (this.prev < entry.catchLoc) {
  23249. return handle(entry.catchLoc, true);
  23250. }
  23251. } else if (hasFinally) {
  23252. if (this.prev < entry.finallyLoc) {
  23253. return handle(entry.finallyLoc);
  23254. }
  23255. } else {
  23256. throw new Error("try statement without catch or finally");
  23257. }
  23258. }
  23259. }
  23260. },
  23261. abrupt: function(type, arg) {
  23262. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  23263. var entry = this.tryEntries[i];
  23264. if (entry.tryLoc <= this.prev &&
  23265. hasOwn.call(entry, "finallyLoc") &&
  23266. this.prev < entry.finallyLoc) {
  23267. var finallyEntry = entry;
  23268. break;
  23269. }
  23270. }
  23271. if (finallyEntry &&
  23272. (type === "break" ||
  23273. type === "continue") &&
  23274. finallyEntry.tryLoc <= arg &&
  23275. arg <= finallyEntry.finallyLoc) {
  23276. // Ignore the finally entry if control is not jumping to a
  23277. // location outside the try/catch block.
  23278. finallyEntry = null;
  23279. }
  23280. var record = finallyEntry ? finallyEntry.completion : {};
  23281. record.type = type;
  23282. record.arg = arg;
  23283. if (finallyEntry) {
  23284. this.method = "next";
  23285. this.next = finallyEntry.finallyLoc;
  23286. return ContinueSentinel;
  23287. }
  23288. return this.complete(record);
  23289. },
  23290. complete: function(record, afterLoc) {
  23291. if (record.type === "throw") {
  23292. throw record.arg;
  23293. }
  23294. if (record.type === "break" ||
  23295. record.type === "continue") {
  23296. this.next = record.arg;
  23297. } else if (record.type === "return") {
  23298. this.rval = this.arg = record.arg;
  23299. this.method = "return";
  23300. this.next = "end";
  23301. } else if (record.type === "normal" && afterLoc) {
  23302. this.next = afterLoc;
  23303. }
  23304. return ContinueSentinel;
  23305. },
  23306. finish: function(finallyLoc) {
  23307. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  23308. var entry = this.tryEntries[i];
  23309. if (entry.finallyLoc === finallyLoc) {
  23310. this.complete(entry.completion, entry.afterLoc);
  23311. resetTryEntry(entry);
  23312. return ContinueSentinel;
  23313. }
  23314. }
  23315. },
  23316. "catch": function(tryLoc) {
  23317. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  23318. var entry = this.tryEntries[i];
  23319. if (entry.tryLoc === tryLoc) {
  23320. var record = entry.completion;
  23321. if (record.type === "throw") {
  23322. var thrown = record.arg;
  23323. resetTryEntry(entry);
  23324. }
  23325. return thrown;
  23326. }
  23327. }
  23328. // The context.catch method must only be called with a location
  23329. // argument that corresponds to a known catch block.
  23330. throw new Error("illegal catch attempt");
  23331. },
  23332. delegateYield: function(iterable, resultName, nextLoc) {
  23333. this.delegate = {
  23334. iterator: values(iterable),
  23335. resultName: resultName,
  23336. nextLoc: nextLoc
  23337. };
  23338. if (this.method === "next") {
  23339. // Deliberately forget the last sent value so that we don't
  23340. // accidentally pass it on to the delegate.
  23341. this.arg = undefined;
  23342. }
  23343. return ContinueSentinel;
  23344. }
  23345. };
  23346. })(
  23347. // In sloppy mode, unbound `this` refers to the global object, fallback to
  23348. // Function constructor if we're in global strict mode. That is sadly a form
  23349. // of indirect eval which violates Content Security Policy.
  23350. (function() { return this })() || Function("return this")()
  23351. );
  23352. },{}],338:[function(require,module,exports){
  23353. /* eslint-disable node/no-deprecated-api */
  23354. var buffer = require('buffer')
  23355. var Buffer = buffer.Buffer
  23356. // alternative to using Object.keys for old browsers
  23357. function copyProps (src, dst) {
  23358. for (var key in src) {
  23359. dst[key] = src[key]
  23360. }
  23361. }
  23362. if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
  23363. module.exports = buffer
  23364. } else {
  23365. // Copy properties from require('buffer')
  23366. copyProps(buffer, exports)
  23367. exports.Buffer = SafeBuffer
  23368. }
  23369. function SafeBuffer (arg, encodingOrOffset, length) {
  23370. return Buffer(arg, encodingOrOffset, length)
  23371. }
  23372. // Copy static methods from Buffer
  23373. copyProps(Buffer, SafeBuffer)
  23374. SafeBuffer.from = function (arg, encodingOrOffset, length) {
  23375. if (typeof arg === 'number') {
  23376. throw new TypeError('Argument must not be a number')
  23377. }
  23378. return Buffer(arg, encodingOrOffset, length)
  23379. }
  23380. SafeBuffer.alloc = function (size, fill, encoding) {
  23381. if (typeof size !== 'number') {
  23382. throw new TypeError('Argument must be a number')
  23383. }
  23384. var buf = Buffer(size)
  23385. if (fill !== undefined) {
  23386. if (typeof encoding === 'string') {
  23387. buf.fill(fill, encoding)
  23388. } else {
  23389. buf.fill(fill)
  23390. }
  23391. } else {
  23392. buf.fill(0)
  23393. }
  23394. return buf
  23395. }
  23396. SafeBuffer.allocUnsafe = function (size) {
  23397. if (typeof size !== 'number') {
  23398. throw new TypeError('Argument must be a number')
  23399. }
  23400. return Buffer(size)
  23401. }
  23402. SafeBuffer.allocUnsafeSlow = function (size) {
  23403. if (typeof size !== 'number') {
  23404. throw new TypeError('Argument must be a number')
  23405. }
  23406. return buffer.SlowBuffer(size)
  23407. }
  23408. },{"buffer":98}],339:[function(require,module,exports){
  23409. (function (Buffer){
  23410. ;(function (sax) { // wrapper for non-node envs
  23411. sax.parser = function (strict, opt) { return new SAXParser(strict, opt) }
  23412. sax.SAXParser = SAXParser
  23413. sax.SAXStream = SAXStream
  23414. sax.createStream = createStream
  23415. // When we pass the MAX_BUFFER_LENGTH position, start checking for buffer overruns.
  23416. // When we check, schedule the next check for MAX_BUFFER_LENGTH - (max(buffer lengths)),
  23417. // since that's the earliest that a buffer overrun could occur. This way, checks are
  23418. // as rare as required, but as often as necessary to ensure never crossing this bound.
  23419. // Furthermore, buffers are only tested at most once per write(), so passing a very
  23420. // large string into write() might have undesirable effects, but this is manageable by
  23421. // the caller, so it is assumed to be safe. Thus, a call to write() may, in the extreme
  23422. // edge case, result in creating at most one complete copy of the string passed in.
  23423. // Set to Infinity to have unlimited buffers.
  23424. sax.MAX_BUFFER_LENGTH = 64 * 1024
  23425. var buffers = [
  23426. 'comment', 'sgmlDecl', 'textNode', 'tagName', 'doctype',
  23427. 'procInstName', 'procInstBody', 'entity', 'attribName',
  23428. 'attribValue', 'cdata', 'script'
  23429. ]
  23430. sax.EVENTS = [
  23431. 'text',
  23432. 'processinginstruction',
  23433. 'sgmldeclaration',
  23434. 'doctype',
  23435. 'comment',
  23436. 'opentagstart',
  23437. 'attribute',
  23438. 'opentag',
  23439. 'closetag',
  23440. 'opencdata',
  23441. 'cdata',
  23442. 'closecdata',
  23443. 'error',
  23444. 'end',
  23445. 'ready',
  23446. 'script',
  23447. 'opennamespace',
  23448. 'closenamespace'
  23449. ]
  23450. function SAXParser (strict, opt) {
  23451. if (!(this instanceof SAXParser)) {
  23452. return new SAXParser(strict, opt)
  23453. }
  23454. var parser = this
  23455. clearBuffers(parser)
  23456. parser.q = parser.c = ''
  23457. parser.bufferCheckPosition = sax.MAX_BUFFER_LENGTH
  23458. parser.opt = opt || {}
  23459. parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags
  23460. parser.looseCase = parser.opt.lowercase ? 'toLowerCase' : 'toUpperCase'
  23461. parser.tags = []
  23462. parser.closed = parser.closedRoot = parser.sawRoot = false
  23463. parser.tag = parser.error = null
  23464. parser.strict = !!strict
  23465. parser.noscript = !!(strict || parser.opt.noscript)
  23466. parser.state = S.BEGIN
  23467. parser.strictEntities = parser.opt.strictEntities
  23468. parser.ENTITIES = parser.strictEntities ? Object.create(sax.XML_ENTITIES) : Object.create(sax.ENTITIES)
  23469. parser.attribList = []
  23470. // namespaces form a prototype chain.
  23471. // it always points at the current tag,
  23472. // which protos to its parent tag.
  23473. if (parser.opt.xmlns) {
  23474. parser.ns = Object.create(rootNS)
  23475. }
  23476. // mostly just for error reporting
  23477. parser.trackPosition = parser.opt.position !== false
  23478. if (parser.trackPosition) {
  23479. parser.position = parser.line = parser.column = 0
  23480. }
  23481. emit(parser, 'onready')
  23482. }
  23483. if (!Object.create) {
  23484. Object.create = function (o) {
  23485. function F () {}
  23486. F.prototype = o
  23487. var newf = new F()
  23488. return newf
  23489. }
  23490. }
  23491. if (!Object.keys) {
  23492. Object.keys = function (o) {
  23493. var a = []
  23494. for (var i in o) if (o.hasOwnProperty(i)) a.push(i)
  23495. return a
  23496. }
  23497. }
  23498. function checkBufferLength (parser) {
  23499. var maxAllowed = Math.max(sax.MAX_BUFFER_LENGTH, 10)
  23500. var maxActual = 0
  23501. for (var i = 0, l = buffers.length; i < l; i++) {
  23502. var len = parser[buffers[i]].length
  23503. if (len > maxAllowed) {
  23504. // Text/cdata nodes can get big, and since they're buffered,
  23505. // we can get here under normal conditions.
  23506. // Avoid issues by emitting the text node now,
  23507. // so at least it won't get any bigger.
  23508. switch (buffers[i]) {
  23509. case 'textNode':
  23510. closeText(parser)
  23511. break
  23512. case 'cdata':
  23513. emitNode(parser, 'oncdata', parser.cdata)
  23514. parser.cdata = ''
  23515. break
  23516. case 'script':
  23517. emitNode(parser, 'onscript', parser.script)
  23518. parser.script = ''
  23519. break
  23520. default:
  23521. error(parser, 'Max buffer length exceeded: ' + buffers[i])
  23522. }
  23523. }
  23524. maxActual = Math.max(maxActual, len)
  23525. }
  23526. // schedule the next check for the earliest possible buffer overrun.
  23527. var m = sax.MAX_BUFFER_LENGTH - maxActual
  23528. parser.bufferCheckPosition = m + parser.position
  23529. }
  23530. function clearBuffers (parser) {
  23531. for (var i = 0, l = buffers.length; i < l; i++) {
  23532. parser[buffers[i]] = ''
  23533. }
  23534. }
  23535. function flushBuffers (parser) {
  23536. closeText(parser)
  23537. if (parser.cdata !== '') {
  23538. emitNode(parser, 'oncdata', parser.cdata)
  23539. parser.cdata = ''
  23540. }
  23541. if (parser.script !== '') {
  23542. emitNode(parser, 'onscript', parser.script)
  23543. parser.script = ''
  23544. }
  23545. }
  23546. SAXParser.prototype = {
  23547. end: function () { end(this) },
  23548. write: write,
  23549. resume: function () { this.error = null; return this },
  23550. close: function () { return this.write(null) },
  23551. flush: function () { flushBuffers(this) }
  23552. }
  23553. var Stream
  23554. try {
  23555. Stream = require('stream').Stream
  23556. } catch (ex) {
  23557. Stream = function () {}
  23558. }
  23559. var streamWraps = sax.EVENTS.filter(function (ev) {
  23560. return ev !== 'error' && ev !== 'end'
  23561. })
  23562. function createStream (strict, opt) {
  23563. return new SAXStream(strict, opt)
  23564. }
  23565. function SAXStream (strict, opt) {
  23566. if (!(this instanceof SAXStream)) {
  23567. return new SAXStream(strict, opt)
  23568. }
  23569. Stream.apply(this)
  23570. this._parser = new SAXParser(strict, opt)
  23571. this.writable = true
  23572. this.readable = true
  23573. var me = this
  23574. this._parser.onend = function () {
  23575. me.emit('end')
  23576. }
  23577. this._parser.onerror = function (er) {
  23578. me.emit('error', er)
  23579. // if didn't throw, then means error was handled.
  23580. // go ahead and clear error, so we can write again.
  23581. me._parser.error = null
  23582. }
  23583. this._decoder = null
  23584. streamWraps.forEach(function (ev) {
  23585. Object.defineProperty(me, 'on' + ev, {
  23586. get: function () {
  23587. return me._parser['on' + ev]
  23588. },
  23589. set: function (h) {
  23590. if (!h) {
  23591. me.removeAllListeners(ev)
  23592. me._parser['on' + ev] = h
  23593. return h
  23594. }
  23595. me.on(ev, h)
  23596. },
  23597. enumerable: true,
  23598. configurable: false
  23599. })
  23600. })
  23601. }
  23602. SAXStream.prototype = Object.create(Stream.prototype, {
  23603. constructor: {
  23604. value: SAXStream
  23605. }
  23606. })
  23607. SAXStream.prototype.write = function (data) {
  23608. if (typeof Buffer === 'function' &&
  23609. typeof Buffer.isBuffer === 'function' &&
  23610. Buffer.isBuffer(data)) {
  23611. if (!this._decoder) {
  23612. var SD = require('string_decoder').StringDecoder
  23613. this._decoder = new SD('utf8')
  23614. }
  23615. data = this._decoder.write(data)
  23616. }
  23617. this._parser.write(data.toString())
  23618. this.emit('data', data)
  23619. return true
  23620. }
  23621. SAXStream.prototype.end = function (chunk) {
  23622. if (chunk && chunk.length) {
  23623. this.write(chunk)
  23624. }
  23625. this._parser.end()
  23626. return true
  23627. }
  23628. SAXStream.prototype.on = function (ev, handler) {
  23629. var me = this
  23630. if (!me._parser['on' + ev] && streamWraps.indexOf(ev) !== -1) {
  23631. me._parser['on' + ev] = function () {
  23632. var args = arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments)
  23633. args.splice(0, 0, ev)
  23634. me.emit.apply(me, args)
  23635. }
  23636. }
  23637. return Stream.prototype.on.call(me, ev, handler)
  23638. }
  23639. // this really needs to be replaced with character classes.
  23640. // XML allows all manner of ridiculous numbers and digits.
  23641. var CDATA = '[CDATA['
  23642. var DOCTYPE = 'DOCTYPE'
  23643. var XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace'
  23644. var XMLNS_NAMESPACE = 'http://www.w3.org/2000/xmlns/'
  23645. var rootNS = { xml: XML_NAMESPACE, xmlns: XMLNS_NAMESPACE }
  23646. // http://www.w3.org/TR/REC-xml/#NT-NameStartChar
  23647. // This implementation works on strings, a single character at a time
  23648. // as such, it cannot ever support astral-plane characters (10000-EFFFF)
  23649. // without a significant breaking change to either this parser, or the
  23650. // JavaScript language. Implementation of an emoji-capable xml parser
  23651. // is left as an exercise for the reader.
  23652. var nameStart = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/
  23653. var nameBody = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/
  23654. var entityStart = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/
  23655. var entityBody = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/
  23656. function isWhitespace (c) {
  23657. return c === ' ' || c === '\n' || c === '\r' || c === '\t'
  23658. }
  23659. function isQuote (c) {
  23660. return c === '"' || c === '\''
  23661. }
  23662. function isAttribEnd (c) {
  23663. return c === '>' || isWhitespace(c)
  23664. }
  23665. function isMatch (regex, c) {
  23666. return regex.test(c)
  23667. }
  23668. function notMatch (regex, c) {
  23669. return !isMatch(regex, c)
  23670. }
  23671. var S = 0
  23672. sax.STATE = {
  23673. BEGIN: S++, // leading byte order mark or whitespace
  23674. BEGIN_WHITESPACE: S++, // leading whitespace
  23675. TEXT: S++, // general stuff
  23676. TEXT_ENTITY: S++, // &amp and such.
  23677. OPEN_WAKA: S++, // <
  23678. SGML_DECL: S++, // <!BLARG
  23679. SGML_DECL_QUOTED: S++, // <!BLARG foo "bar
  23680. DOCTYPE: S++, // <!DOCTYPE
  23681. DOCTYPE_QUOTED: S++, // <!DOCTYPE "//blah
  23682. DOCTYPE_DTD: S++, // <!DOCTYPE "//blah" [ ...
  23683. DOCTYPE_DTD_QUOTED: S++, // <!DOCTYPE "//blah" [ "foo
  23684. COMMENT_STARTING: S++, // <!-
  23685. COMMENT: S++, // <!--
  23686. COMMENT_ENDING: S++, // <!-- blah -
  23687. COMMENT_ENDED: S++, // <!-- blah --
  23688. CDATA: S++, // <![CDATA[ something
  23689. CDATA_ENDING: S++, // ]
  23690. CDATA_ENDING_2: S++, // ]]
  23691. PROC_INST: S++, // <?hi
  23692. PROC_INST_BODY: S++, // <?hi there
  23693. PROC_INST_ENDING: S++, // <?hi "there" ?
  23694. OPEN_TAG: S++, // <strong
  23695. OPEN_TAG_SLASH: S++, // <strong /
  23696. ATTRIB: S++, // <a
  23697. ATTRIB_NAME: S++, // <a foo
  23698. ATTRIB_NAME_SAW_WHITE: S++, // <a foo _
  23699. ATTRIB_VALUE: S++, // <a foo=
  23700. ATTRIB_VALUE_QUOTED: S++, // <a foo="bar
  23701. ATTRIB_VALUE_CLOSED: S++, // <a foo="bar"
  23702. ATTRIB_VALUE_UNQUOTED: S++, // <a foo=bar
  23703. ATTRIB_VALUE_ENTITY_Q: S++, // <foo bar="&quot;"
  23704. ATTRIB_VALUE_ENTITY_U: S++, // <foo bar=&quot
  23705. CLOSE_TAG: S++, // </a
  23706. CLOSE_TAG_SAW_WHITE: S++, // </a >
  23707. SCRIPT: S++, // <script> ...
  23708. SCRIPT_ENDING: S++ // <script> ... <
  23709. }
  23710. sax.XML_ENTITIES = {
  23711. 'amp': '&',
  23712. 'gt': '>',
  23713. 'lt': '<',
  23714. 'quot': '"',
  23715. 'apos': "'"
  23716. }
  23717. sax.ENTITIES = {
  23718. 'amp': '&',
  23719. 'gt': '>',
  23720. 'lt': '<',
  23721. 'quot': '"',
  23722. 'apos': "'",
  23723. 'AElig': 198,
  23724. 'Aacute': 193,
  23725. 'Acirc': 194,
  23726. 'Agrave': 192,
  23727. 'Aring': 197,
  23728. 'Atilde': 195,
  23729. 'Auml': 196,
  23730. 'Ccedil': 199,
  23731. 'ETH': 208,
  23732. 'Eacute': 201,
  23733. 'Ecirc': 202,
  23734. 'Egrave': 200,
  23735. 'Euml': 203,
  23736. 'Iacute': 205,
  23737. 'Icirc': 206,
  23738. 'Igrave': 204,
  23739. 'Iuml': 207,
  23740. 'Ntilde': 209,
  23741. 'Oacute': 211,
  23742. 'Ocirc': 212,
  23743. 'Ograve': 210,
  23744. 'Oslash': 216,
  23745. 'Otilde': 213,
  23746. 'Ouml': 214,
  23747. 'THORN': 222,
  23748. 'Uacute': 218,
  23749. 'Ucirc': 219,
  23750. 'Ugrave': 217,
  23751. 'Uuml': 220,
  23752. 'Yacute': 221,
  23753. 'aacute': 225,
  23754. 'acirc': 226,
  23755. 'aelig': 230,
  23756. 'agrave': 224,
  23757. 'aring': 229,
  23758. 'atilde': 227,
  23759. 'auml': 228,
  23760. 'ccedil': 231,
  23761. 'eacute': 233,
  23762. 'ecirc': 234,
  23763. 'egrave': 232,
  23764. 'eth': 240,
  23765. 'euml': 235,
  23766. 'iacute': 237,
  23767. 'icirc': 238,
  23768. 'igrave': 236,
  23769. 'iuml': 239,
  23770. 'ntilde': 241,
  23771. 'oacute': 243,
  23772. 'ocirc': 244,
  23773. 'ograve': 242,
  23774. 'oslash': 248,
  23775. 'otilde': 245,
  23776. 'ouml': 246,
  23777. 'szlig': 223,
  23778. 'thorn': 254,
  23779. 'uacute': 250,
  23780. 'ucirc': 251,
  23781. 'ugrave': 249,
  23782. 'uuml': 252,
  23783. 'yacute': 253,
  23784. 'yuml': 255,
  23785. 'copy': 169,
  23786. 'reg': 174,
  23787. 'nbsp': 160,
  23788. 'iexcl': 161,
  23789. 'cent': 162,
  23790. 'pound': 163,
  23791. 'curren': 164,
  23792. 'yen': 165,
  23793. 'brvbar': 166,
  23794. 'sect': 167,
  23795. 'uml': 168,
  23796. 'ordf': 170,
  23797. 'laquo': 171,
  23798. 'not': 172,
  23799. 'shy': 173,
  23800. 'macr': 175,
  23801. 'deg': 176,
  23802. 'plusmn': 177,
  23803. 'sup1': 185,
  23804. 'sup2': 178,
  23805. 'sup3': 179,
  23806. 'acute': 180,
  23807. 'micro': 181,
  23808. 'para': 182,
  23809. 'middot': 183,
  23810. 'cedil': 184,
  23811. 'ordm': 186,
  23812. 'raquo': 187,
  23813. 'frac14': 188,
  23814. 'frac12': 189,
  23815. 'frac34': 190,
  23816. 'iquest': 191,
  23817. 'times': 215,
  23818. 'divide': 247,
  23819. 'OElig': 338,
  23820. 'oelig': 339,
  23821. 'Scaron': 352,
  23822. 'scaron': 353,
  23823. 'Yuml': 376,
  23824. 'fnof': 402,
  23825. 'circ': 710,
  23826. 'tilde': 732,
  23827. 'Alpha': 913,
  23828. 'Beta': 914,
  23829. 'Gamma': 915,
  23830. 'Delta': 916,
  23831. 'Epsilon': 917,
  23832. 'Zeta': 918,
  23833. 'Eta': 919,
  23834. 'Theta': 920,
  23835. 'Iota': 921,
  23836. 'Kappa': 922,
  23837. 'Lambda': 923,
  23838. 'Mu': 924,
  23839. 'Nu': 925,
  23840. 'Xi': 926,
  23841. 'Omicron': 927,
  23842. 'Pi': 928,
  23843. 'Rho': 929,
  23844. 'Sigma': 931,
  23845. 'Tau': 932,
  23846. 'Upsilon': 933,
  23847. 'Phi': 934,
  23848. 'Chi': 935,
  23849. 'Psi': 936,
  23850. 'Omega': 937,
  23851. 'alpha': 945,
  23852. 'beta': 946,
  23853. 'gamma': 947,
  23854. 'delta': 948,
  23855. 'epsilon': 949,
  23856. 'zeta': 950,
  23857. 'eta': 951,
  23858. 'theta': 952,
  23859. 'iota': 953,
  23860. 'kappa': 954,
  23861. 'lambda': 955,
  23862. 'mu': 956,
  23863. 'nu': 957,
  23864. 'xi': 958,
  23865. 'omicron': 959,
  23866. 'pi': 960,
  23867. 'rho': 961,
  23868. 'sigmaf': 962,
  23869. 'sigma': 963,
  23870. 'tau': 964,
  23871. 'upsilon': 965,
  23872. 'phi': 966,
  23873. 'chi': 967,
  23874. 'psi': 968,
  23875. 'omega': 969,
  23876. 'thetasym': 977,
  23877. 'upsih': 978,
  23878. 'piv': 982,
  23879. 'ensp': 8194,
  23880. 'emsp': 8195,
  23881. 'thinsp': 8201,
  23882. 'zwnj': 8204,
  23883. 'zwj': 8205,
  23884. 'lrm': 8206,
  23885. 'rlm': 8207,
  23886. 'ndash': 8211,
  23887. 'mdash': 8212,
  23888. 'lsquo': 8216,
  23889. 'rsquo': 8217,
  23890. 'sbquo': 8218,
  23891. 'ldquo': 8220,
  23892. 'rdquo': 8221,
  23893. 'bdquo': 8222,
  23894. 'dagger': 8224,
  23895. 'Dagger': 8225,
  23896. 'bull': 8226,
  23897. 'hellip': 8230,
  23898. 'permil': 8240,
  23899. 'prime': 8242,
  23900. 'Prime': 8243,
  23901. 'lsaquo': 8249,
  23902. 'rsaquo': 8250,
  23903. 'oline': 8254,
  23904. 'frasl': 8260,
  23905. 'euro': 8364,
  23906. 'image': 8465,
  23907. 'weierp': 8472,
  23908. 'real': 8476,
  23909. 'trade': 8482,
  23910. 'alefsym': 8501,
  23911. 'larr': 8592,
  23912. 'uarr': 8593,
  23913. 'rarr': 8594,
  23914. 'darr': 8595,
  23915. 'harr': 8596,
  23916. 'crarr': 8629,
  23917. 'lArr': 8656,
  23918. 'uArr': 8657,
  23919. 'rArr': 8658,
  23920. 'dArr': 8659,
  23921. 'hArr': 8660,
  23922. 'forall': 8704,
  23923. 'part': 8706,
  23924. 'exist': 8707,
  23925. 'empty': 8709,
  23926. 'nabla': 8711,
  23927. 'isin': 8712,
  23928. 'notin': 8713,
  23929. 'ni': 8715,
  23930. 'prod': 8719,
  23931. 'sum': 8721,
  23932. 'minus': 8722,
  23933. 'lowast': 8727,
  23934. 'radic': 8730,
  23935. 'prop': 8733,
  23936. 'infin': 8734,
  23937. 'ang': 8736,
  23938. 'and': 8743,
  23939. 'or': 8744,
  23940. 'cap': 8745,
  23941. 'cup': 8746,
  23942. 'int': 8747,
  23943. 'there4': 8756,
  23944. 'sim': 8764,
  23945. 'cong': 8773,
  23946. 'asymp': 8776,
  23947. 'ne': 8800,
  23948. 'equiv': 8801,
  23949. 'le': 8804,
  23950. 'ge': 8805,
  23951. 'sub': 8834,
  23952. 'sup': 8835,
  23953. 'nsub': 8836,
  23954. 'sube': 8838,
  23955. 'supe': 8839,
  23956. 'oplus': 8853,
  23957. 'otimes': 8855,
  23958. 'perp': 8869,
  23959. 'sdot': 8901,
  23960. 'lceil': 8968,
  23961. 'rceil': 8969,
  23962. 'lfloor': 8970,
  23963. 'rfloor': 8971,
  23964. 'lang': 9001,
  23965. 'rang': 9002,
  23966. 'loz': 9674,
  23967. 'spades': 9824,
  23968. 'clubs': 9827,
  23969. 'hearts': 9829,
  23970. 'diams': 9830
  23971. }
  23972. Object.keys(sax.ENTITIES).forEach(function (key) {
  23973. var e = sax.ENTITIES[key]
  23974. var s = typeof e === 'number' ? String.fromCharCode(e) : e
  23975. sax.ENTITIES[key] = s
  23976. })
  23977. for (var s in sax.STATE) {
  23978. sax.STATE[sax.STATE[s]] = s
  23979. }
  23980. // shorthand
  23981. S = sax.STATE
  23982. function emit (parser, event, data) {
  23983. parser[event] && parser[event](data)
  23984. }
  23985. function emitNode (parser, nodeType, data) {
  23986. if (parser.textNode) closeText(parser)
  23987. emit(parser, nodeType, data)
  23988. }
  23989. function closeText (parser) {
  23990. parser.textNode = textopts(parser.opt, parser.textNode)
  23991. if (parser.textNode) emit(parser, 'ontext', parser.textNode)
  23992. parser.textNode = ''
  23993. }
  23994. function textopts (opt, text) {
  23995. if (opt.trim) text = text.trim()
  23996. if (opt.normalize) text = text.replace(/\s+/g, ' ')
  23997. return text
  23998. }
  23999. function error (parser, er) {
  24000. closeText(parser)
  24001. if (parser.trackPosition) {
  24002. er += '\nLine: ' + parser.line +
  24003. '\nColumn: ' + parser.column +
  24004. '\nChar: ' + parser.c
  24005. }
  24006. er = new Error(er)
  24007. parser.error = er
  24008. emit(parser, 'onerror', er)
  24009. return parser
  24010. }
  24011. function end (parser) {
  24012. if (parser.sawRoot && !parser.closedRoot) strictFail(parser, 'Unclosed root tag')
  24013. if ((parser.state !== S.BEGIN) &&
  24014. (parser.state !== S.BEGIN_WHITESPACE) &&
  24015. (parser.state !== S.TEXT)) {
  24016. error(parser, 'Unexpected end')
  24017. }
  24018. closeText(parser)
  24019. parser.c = ''
  24020. parser.closed = true
  24021. emit(parser, 'onend')
  24022. SAXParser.call(parser, parser.strict, parser.opt)
  24023. return parser
  24024. }
  24025. function strictFail (parser, message) {
  24026. if (typeof parser !== 'object' || !(parser instanceof SAXParser)) {
  24027. throw new Error('bad call to strictFail')
  24028. }
  24029. if (parser.strict) {
  24030. error(parser, message)
  24031. }
  24032. }
  24033. function newTag (parser) {
  24034. if (!parser.strict) parser.tagName = parser.tagName[parser.looseCase]()
  24035. var parent = parser.tags[parser.tags.length - 1] || parser
  24036. var tag = parser.tag = { name: parser.tagName, attributes: {} }
  24037. // will be overridden if tag contails an xmlns="foo" or xmlns:foo="bar"
  24038. if (parser.opt.xmlns) {
  24039. tag.ns = parent.ns
  24040. }
  24041. parser.attribList.length = 0
  24042. emitNode(parser, 'onopentagstart', tag)
  24043. }
  24044. function qname (name, attribute) {
  24045. var i = name.indexOf(':')
  24046. var qualName = i < 0 ? [ '', name ] : name.split(':')
  24047. var prefix = qualName[0]
  24048. var local = qualName[1]
  24049. // <x "xmlns"="http://foo">
  24050. if (attribute && name === 'xmlns') {
  24051. prefix = 'xmlns'
  24052. local = ''
  24053. }
  24054. return { prefix: prefix, local: local }
  24055. }
  24056. function attrib (parser) {
  24057. if (!parser.strict) {
  24058. parser.attribName = parser.attribName[parser.looseCase]()
  24059. }
  24060. if (parser.attribList.indexOf(parser.attribName) !== -1 ||
  24061. parser.tag.attributes.hasOwnProperty(parser.attribName)) {
  24062. parser.attribName = parser.attribValue = ''
  24063. return
  24064. }
  24065. if (parser.opt.xmlns) {
  24066. var qn = qname(parser.attribName, true)
  24067. var prefix = qn.prefix
  24068. var local = qn.local
  24069. if (prefix === 'xmlns') {
  24070. // namespace binding attribute. push the binding into scope
  24071. if (local === 'xml' && parser.attribValue !== XML_NAMESPACE) {
  24072. strictFail(parser,
  24073. 'xml: prefix must be bound to ' + XML_NAMESPACE + '\n' +
  24074. 'Actual: ' + parser.attribValue)
  24075. } else if (local === 'xmlns' && parser.attribValue !== XMLNS_NAMESPACE) {
  24076. strictFail(parser,
  24077. 'xmlns: prefix must be bound to ' + XMLNS_NAMESPACE + '\n' +
  24078. 'Actual: ' + parser.attribValue)
  24079. } else {
  24080. var tag = parser.tag
  24081. var parent = parser.tags[parser.tags.length - 1] || parser
  24082. if (tag.ns === parent.ns) {
  24083. tag.ns = Object.create(parent.ns)
  24084. }
  24085. tag.ns[local] = parser.attribValue
  24086. }
  24087. }
  24088. // defer onattribute events until all attributes have been seen
  24089. // so any new bindings can take effect. preserve attribute order
  24090. // so deferred events can be emitted in document order
  24091. parser.attribList.push([parser.attribName, parser.attribValue])
  24092. } else {
  24093. // in non-xmlns mode, we can emit the event right away
  24094. parser.tag.attributes[parser.attribName] = parser.attribValue
  24095. emitNode(parser, 'onattribute', {
  24096. name: parser.attribName,
  24097. value: parser.attribValue
  24098. })
  24099. }
  24100. parser.attribName = parser.attribValue = ''
  24101. }
  24102. function openTag (parser, selfClosing) {
  24103. if (parser.opt.xmlns) {
  24104. // emit namespace binding events
  24105. var tag = parser.tag
  24106. // add namespace info to tag
  24107. var qn = qname(parser.tagName)
  24108. tag.prefix = qn.prefix
  24109. tag.local = qn.local
  24110. tag.uri = tag.ns[qn.prefix] || ''
  24111. if (tag.prefix && !tag.uri) {
  24112. strictFail(parser, 'Unbound namespace prefix: ' +
  24113. JSON.stringify(parser.tagName))
  24114. tag.uri = qn.prefix
  24115. }
  24116. var parent = parser.tags[parser.tags.length - 1] || parser
  24117. if (tag.ns && parent.ns !== tag.ns) {
  24118. Object.keys(tag.ns).forEach(function (p) {
  24119. emitNode(parser, 'onopennamespace', {
  24120. prefix: p,
  24121. uri: tag.ns[p]
  24122. })
  24123. })
  24124. }
  24125. // handle deferred onattribute events
  24126. // Note: do not apply default ns to attributes:
  24127. // http://www.w3.org/TR/REC-xml-names/#defaulting
  24128. for (var i = 0, l = parser.attribList.length; i < l; i++) {
  24129. var nv = parser.attribList[i]
  24130. var name = nv[0]
  24131. var value = nv[1]
  24132. var qualName = qname(name, true)
  24133. var prefix = qualName.prefix
  24134. var local = qualName.local
  24135. var uri = prefix === '' ? '' : (tag.ns[prefix] || '')
  24136. var a = {
  24137. name: name,
  24138. value: value,
  24139. prefix: prefix,
  24140. local: local,
  24141. uri: uri
  24142. }
  24143. // if there's any attributes with an undefined namespace,
  24144. // then fail on them now.
  24145. if (prefix && prefix !== 'xmlns' && !uri) {
  24146. strictFail(parser, 'Unbound namespace prefix: ' +
  24147. JSON.stringify(prefix))
  24148. a.uri = prefix
  24149. }
  24150. parser.tag.attributes[name] = a
  24151. emitNode(parser, 'onattribute', a)
  24152. }
  24153. parser.attribList.length = 0
  24154. }
  24155. parser.tag.isSelfClosing = !!selfClosing
  24156. // process the tag
  24157. parser.sawRoot = true
  24158. parser.tags.push(parser.tag)
  24159. emitNode(parser, 'onopentag', parser.tag)
  24160. if (!selfClosing) {
  24161. // special case for <script> in non-strict mode.
  24162. if (!parser.noscript && parser.tagName.toLowerCase() === 'script') {
  24163. parser.state = S.SCRIPT
  24164. } else {
  24165. parser.state = S.TEXT
  24166. }
  24167. parser.tag = null
  24168. parser.tagName = ''
  24169. }
  24170. parser.attribName = parser.attribValue = ''
  24171. parser.attribList.length = 0
  24172. }
  24173. function closeTag (parser) {
  24174. if (!parser.tagName) {
  24175. strictFail(parser, 'Weird empty close tag.')
  24176. parser.textNode += '</>'
  24177. parser.state = S.TEXT
  24178. return
  24179. }
  24180. if (parser.script) {
  24181. if (parser.tagName !== 'script') {
  24182. parser.script += '</' + parser.tagName + '>'
  24183. parser.tagName = ''
  24184. parser.state = S.SCRIPT
  24185. return
  24186. }
  24187. emitNode(parser, 'onscript', parser.script)
  24188. parser.script = ''
  24189. }
  24190. // first make sure that the closing tag actually exists.
  24191. // <a><b></c></b></a> will close everything, otherwise.
  24192. var t = parser.tags.length
  24193. var tagName = parser.tagName
  24194. if (!parser.strict) {
  24195. tagName = tagName[parser.looseCase]()
  24196. }
  24197. var closeTo = tagName
  24198. while (t--) {
  24199. var close = parser.tags[t]
  24200. if (close.name !== closeTo) {
  24201. // fail the first time in strict mode
  24202. strictFail(parser, 'Unexpected close tag')
  24203. } else {
  24204. break
  24205. }
  24206. }
  24207. // didn't find it. we already failed for strict, so just abort.
  24208. if (t < 0) {
  24209. strictFail(parser, 'Unmatched closing tag: ' + parser.tagName)
  24210. parser.textNode += '</' + parser.tagName + '>'
  24211. parser.state = S.TEXT
  24212. return
  24213. }
  24214. parser.tagName = tagName
  24215. var s = parser.tags.length
  24216. while (s-- > t) {
  24217. var tag = parser.tag = parser.tags.pop()
  24218. parser.tagName = parser.tag.name
  24219. emitNode(parser, 'onclosetag', parser.tagName)
  24220. var x = {}
  24221. for (var i in tag.ns) {
  24222. x[i] = tag.ns[i]
  24223. }
  24224. var parent = parser.tags[parser.tags.length - 1] || parser
  24225. if (parser.opt.xmlns && tag.ns !== parent.ns) {
  24226. // remove namespace bindings introduced by tag
  24227. Object.keys(tag.ns).forEach(function (p) {
  24228. var n = tag.ns[p]
  24229. emitNode(parser, 'onclosenamespace', { prefix: p, uri: n })
  24230. })
  24231. }
  24232. }
  24233. if (t === 0) parser.closedRoot = true
  24234. parser.tagName = parser.attribValue = parser.attribName = ''
  24235. parser.attribList.length = 0
  24236. parser.state = S.TEXT
  24237. }
  24238. function parseEntity (parser) {
  24239. var entity = parser.entity
  24240. var entityLC = entity.toLowerCase()
  24241. var num
  24242. var numStr = ''
  24243. if (parser.ENTITIES[entity]) {
  24244. return parser.ENTITIES[entity]
  24245. }
  24246. if (parser.ENTITIES[entityLC]) {
  24247. return parser.ENTITIES[entityLC]
  24248. }
  24249. entity = entityLC
  24250. if (entity.charAt(0) === '#') {
  24251. if (entity.charAt(1) === 'x') {
  24252. entity = entity.slice(2)
  24253. num = parseInt(entity, 16)
  24254. numStr = num.toString(16)
  24255. } else {
  24256. entity = entity.slice(1)
  24257. num = parseInt(entity, 10)
  24258. numStr = num.toString(10)
  24259. }
  24260. }
  24261. entity = entity.replace(/^0+/, '')
  24262. if (isNaN(num) || numStr.toLowerCase() !== entity) {
  24263. strictFail(parser, 'Invalid character entity')
  24264. return '&' + parser.entity + ';'
  24265. }
  24266. return String.fromCodePoint(num)
  24267. }
  24268. function beginWhiteSpace (parser, c) {
  24269. if (c === '<') {
  24270. parser.state = S.OPEN_WAKA
  24271. parser.startTagPosition = parser.position
  24272. } else if (!isWhitespace(c)) {
  24273. // have to process this as a text node.
  24274. // weird, but happens.
  24275. strictFail(parser, 'Non-whitespace before first tag.')
  24276. parser.textNode = c
  24277. parser.state = S.TEXT
  24278. }
  24279. }
  24280. function charAt (chunk, i) {
  24281. var result = ''
  24282. if (i < chunk.length) {
  24283. result = chunk.charAt(i)
  24284. }
  24285. return result
  24286. }
  24287. function write (chunk) {
  24288. var parser = this
  24289. if (this.error) {
  24290. throw this.error
  24291. }
  24292. if (parser.closed) {
  24293. return error(parser,
  24294. 'Cannot write after close. Assign an onready handler.')
  24295. }
  24296. if (chunk === null) {
  24297. return end(parser)
  24298. }
  24299. if (typeof chunk === 'object') {
  24300. chunk = chunk.toString()
  24301. }
  24302. var i = 0
  24303. var c = ''
  24304. while (true) {
  24305. c = charAt(chunk, i++)
  24306. parser.c = c
  24307. if (!c) {
  24308. break
  24309. }
  24310. if (parser.trackPosition) {
  24311. parser.position++
  24312. if (c === '\n') {
  24313. parser.line++
  24314. parser.column = 0
  24315. } else {
  24316. parser.column++
  24317. }
  24318. }
  24319. switch (parser.state) {
  24320. case S.BEGIN:
  24321. parser.state = S.BEGIN_WHITESPACE
  24322. if (c === '\uFEFF') {
  24323. continue
  24324. }
  24325. beginWhiteSpace(parser, c)
  24326. continue
  24327. case S.BEGIN_WHITESPACE:
  24328. beginWhiteSpace(parser, c)
  24329. continue
  24330. case S.TEXT:
  24331. if (parser.sawRoot && !parser.closedRoot) {
  24332. var starti = i - 1
  24333. while (c && c !== '<' && c !== '&') {
  24334. c = charAt(chunk, i++)
  24335. if (c && parser.trackPosition) {
  24336. parser.position++
  24337. if (c === '\n') {
  24338. parser.line++
  24339. parser.column = 0
  24340. } else {
  24341. parser.column++
  24342. }
  24343. }
  24344. }
  24345. parser.textNode += chunk.substring(starti, i - 1)
  24346. }
  24347. if (c === '<' && !(parser.sawRoot && parser.closedRoot && !parser.strict)) {
  24348. parser.state = S.OPEN_WAKA
  24349. parser.startTagPosition = parser.position
  24350. } else {
  24351. if (!isWhitespace(c) && (!parser.sawRoot || parser.closedRoot)) {
  24352. strictFail(parser, 'Text data outside of root node.')
  24353. }
  24354. if (c === '&') {
  24355. parser.state = S.TEXT_ENTITY
  24356. } else {
  24357. parser.textNode += c
  24358. }
  24359. }
  24360. continue
  24361. case S.SCRIPT:
  24362. // only non-strict
  24363. if (c === '<') {
  24364. parser.state = S.SCRIPT_ENDING
  24365. } else {
  24366. parser.script += c
  24367. }
  24368. continue
  24369. case S.SCRIPT_ENDING:
  24370. if (c === '/') {
  24371. parser.state = S.CLOSE_TAG
  24372. } else {
  24373. parser.script += '<' + c
  24374. parser.state = S.SCRIPT
  24375. }
  24376. continue
  24377. case S.OPEN_WAKA:
  24378. // either a /, ?, !, or text is coming next.
  24379. if (c === '!') {
  24380. parser.state = S.SGML_DECL
  24381. parser.sgmlDecl = ''
  24382. } else if (isWhitespace(c)) {
  24383. // wait for it...
  24384. } else if (isMatch(nameStart, c)) {
  24385. parser.state = S.OPEN_TAG
  24386. parser.tagName = c
  24387. } else if (c === '/') {
  24388. parser.state = S.CLOSE_TAG
  24389. parser.tagName = ''
  24390. } else if (c === '?') {
  24391. parser.state = S.PROC_INST
  24392. parser.procInstName = parser.procInstBody = ''
  24393. } else {
  24394. strictFail(parser, 'Unencoded <')
  24395. // if there was some whitespace, then add that in.
  24396. if (parser.startTagPosition + 1 < parser.position) {
  24397. var pad = parser.position - parser.startTagPosition
  24398. c = new Array(pad).join(' ') + c
  24399. }
  24400. parser.textNode += '<' + c
  24401. parser.state = S.TEXT
  24402. }
  24403. continue
  24404. case S.SGML_DECL:
  24405. if ((parser.sgmlDecl + c).toUpperCase() === CDATA) {
  24406. emitNode(parser, 'onopencdata')
  24407. parser.state = S.CDATA
  24408. parser.sgmlDecl = ''
  24409. parser.cdata = ''
  24410. } else if (parser.sgmlDecl + c === '--') {
  24411. parser.state = S.COMMENT
  24412. parser.comment = ''
  24413. parser.sgmlDecl = ''
  24414. } else if ((parser.sgmlDecl + c).toUpperCase() === DOCTYPE) {
  24415. parser.state = S.DOCTYPE
  24416. if (parser.doctype || parser.sawRoot) {
  24417. strictFail(parser,
  24418. 'Inappropriately located doctype declaration')
  24419. }
  24420. parser.doctype = ''
  24421. parser.sgmlDecl = ''
  24422. } else if (c === '>') {
  24423. emitNode(parser, 'onsgmldeclaration', parser.sgmlDecl)
  24424. parser.sgmlDecl = ''
  24425. parser.state = S.TEXT
  24426. } else if (isQuote(c)) {
  24427. parser.state = S.SGML_DECL_QUOTED
  24428. parser.sgmlDecl += c
  24429. } else {
  24430. parser.sgmlDecl += c
  24431. }
  24432. continue
  24433. case S.SGML_DECL_QUOTED:
  24434. if (c === parser.q) {
  24435. parser.state = S.SGML_DECL
  24436. parser.q = ''
  24437. }
  24438. parser.sgmlDecl += c
  24439. continue
  24440. case S.DOCTYPE:
  24441. if (c === '>') {
  24442. parser.state = S.TEXT
  24443. emitNode(parser, 'ondoctype', parser.doctype)
  24444. parser.doctype = true // just remember that we saw it.
  24445. } else {
  24446. parser.doctype += c
  24447. if (c === '[') {
  24448. parser.state = S.DOCTYPE_DTD
  24449. } else if (isQuote(c)) {
  24450. parser.state = S.DOCTYPE_QUOTED
  24451. parser.q = c
  24452. }
  24453. }
  24454. continue
  24455. case S.DOCTYPE_QUOTED:
  24456. parser.doctype += c
  24457. if (c === parser.q) {
  24458. parser.q = ''
  24459. parser.state = S.DOCTYPE
  24460. }
  24461. continue
  24462. case S.DOCTYPE_DTD:
  24463. parser.doctype += c
  24464. if (c === ']') {
  24465. parser.state = S.DOCTYPE
  24466. } else if (isQuote(c)) {
  24467. parser.state = S.DOCTYPE_DTD_QUOTED
  24468. parser.q = c
  24469. }
  24470. continue
  24471. case S.DOCTYPE_DTD_QUOTED:
  24472. parser.doctype += c
  24473. if (c === parser.q) {
  24474. parser.state = S.DOCTYPE_DTD
  24475. parser.q = ''
  24476. }
  24477. continue
  24478. case S.COMMENT:
  24479. if (c === '-') {
  24480. parser.state = S.COMMENT_ENDING
  24481. } else {
  24482. parser.comment += c
  24483. }
  24484. continue
  24485. case S.COMMENT_ENDING:
  24486. if (c === '-') {
  24487. parser.state = S.COMMENT_ENDED
  24488. parser.comment = textopts(parser.opt, parser.comment)
  24489. if (parser.comment) {
  24490. emitNode(parser, 'oncomment', parser.comment)
  24491. }
  24492. parser.comment = ''
  24493. } else {
  24494. parser.comment += '-' + c
  24495. parser.state = S.COMMENT
  24496. }
  24497. continue
  24498. case S.COMMENT_ENDED:
  24499. if (c !== '>') {
  24500. strictFail(parser, 'Malformed comment')
  24501. // allow <!-- blah -- bloo --> in non-strict mode,
  24502. // which is a comment of " blah -- bloo "
  24503. parser.comment += '--' + c
  24504. parser.state = S.COMMENT
  24505. } else {
  24506. parser.state = S.TEXT
  24507. }
  24508. continue
  24509. case S.CDATA:
  24510. if (c === ']') {
  24511. parser.state = S.CDATA_ENDING
  24512. } else {
  24513. parser.cdata += c
  24514. }
  24515. continue
  24516. case S.CDATA_ENDING:
  24517. if (c === ']') {
  24518. parser.state = S.CDATA_ENDING_2
  24519. } else {
  24520. parser.cdata += ']' + c
  24521. parser.state = S.CDATA
  24522. }
  24523. continue
  24524. case S.CDATA_ENDING_2:
  24525. if (c === '>') {
  24526. if (parser.cdata) {
  24527. emitNode(parser, 'oncdata', parser.cdata)
  24528. }
  24529. emitNode(parser, 'onclosecdata')
  24530. parser.cdata = ''
  24531. parser.state = S.TEXT
  24532. } else if (c === ']') {
  24533. parser.cdata += ']'
  24534. } else {
  24535. parser.cdata += ']]' + c
  24536. parser.state = S.CDATA
  24537. }
  24538. continue
  24539. case S.PROC_INST:
  24540. if (c === '?') {
  24541. parser.state = S.PROC_INST_ENDING
  24542. } else if (isWhitespace(c)) {
  24543. parser.state = S.PROC_INST_BODY
  24544. } else {
  24545. parser.procInstName += c
  24546. }
  24547. continue
  24548. case S.PROC_INST_BODY:
  24549. if (!parser.procInstBody && isWhitespace(c)) {
  24550. continue
  24551. } else if (c === '?') {
  24552. parser.state = S.PROC_INST_ENDING
  24553. } else {
  24554. parser.procInstBody += c
  24555. }
  24556. continue
  24557. case S.PROC_INST_ENDING:
  24558. if (c === '>') {
  24559. emitNode(parser, 'onprocessinginstruction', {
  24560. name: parser.procInstName,
  24561. body: parser.procInstBody
  24562. })
  24563. parser.procInstName = parser.procInstBody = ''
  24564. parser.state = S.TEXT
  24565. } else {
  24566. parser.procInstBody += '?' + c
  24567. parser.state = S.PROC_INST_BODY
  24568. }
  24569. continue
  24570. case S.OPEN_TAG:
  24571. if (isMatch(nameBody, c)) {
  24572. parser.tagName += c
  24573. } else {
  24574. newTag(parser)
  24575. if (c === '>') {
  24576. openTag(parser)
  24577. } else if (c === '/') {
  24578. parser.state = S.OPEN_TAG_SLASH
  24579. } else {
  24580. if (!isWhitespace(c)) {
  24581. strictFail(parser, 'Invalid character in tag name')
  24582. }
  24583. parser.state = S.ATTRIB
  24584. }
  24585. }
  24586. continue
  24587. case S.OPEN_TAG_SLASH:
  24588. if (c === '>') {
  24589. openTag(parser, true)
  24590. closeTag(parser)
  24591. } else {
  24592. strictFail(parser, 'Forward-slash in opening tag not followed by >')
  24593. parser.state = S.ATTRIB
  24594. }
  24595. continue
  24596. case S.ATTRIB:
  24597. // haven't read the attribute name yet.
  24598. if (isWhitespace(c)) {
  24599. continue
  24600. } else if (c === '>') {
  24601. openTag(parser)
  24602. } else if (c === '/') {
  24603. parser.state = S.OPEN_TAG_SLASH
  24604. } else if (isMatch(nameStart, c)) {
  24605. parser.attribName = c
  24606. parser.attribValue = ''
  24607. parser.state = S.ATTRIB_NAME
  24608. } else {
  24609. strictFail(parser, 'Invalid attribute name')
  24610. }
  24611. continue
  24612. case S.ATTRIB_NAME:
  24613. if (c === '=') {
  24614. parser.state = S.ATTRIB_VALUE
  24615. } else if (c === '>') {
  24616. strictFail(parser, 'Attribute without value')
  24617. parser.attribValue = parser.attribName
  24618. attrib(parser)
  24619. openTag(parser)
  24620. } else if (isWhitespace(c)) {
  24621. parser.state = S.ATTRIB_NAME_SAW_WHITE
  24622. } else if (isMatch(nameBody, c)) {
  24623. parser.attribName += c
  24624. } else {
  24625. strictFail(parser, 'Invalid attribute name')
  24626. }
  24627. continue
  24628. case S.ATTRIB_NAME_SAW_WHITE:
  24629. if (c === '=') {
  24630. parser.state = S.ATTRIB_VALUE
  24631. } else if (isWhitespace(c)) {
  24632. continue
  24633. } else {
  24634. strictFail(parser, 'Attribute without value')
  24635. parser.tag.attributes[parser.attribName] = ''
  24636. parser.attribValue = ''
  24637. emitNode(parser, 'onattribute', {
  24638. name: parser.attribName,
  24639. value: ''
  24640. })
  24641. parser.attribName = ''
  24642. if (c === '>') {
  24643. openTag(parser)
  24644. } else if (isMatch(nameStart, c)) {
  24645. parser.attribName = c
  24646. parser.state = S.ATTRIB_NAME
  24647. } else {
  24648. strictFail(parser, 'Invalid attribute name')
  24649. parser.state = S.ATTRIB
  24650. }
  24651. }
  24652. continue
  24653. case S.ATTRIB_VALUE:
  24654. if (isWhitespace(c)) {
  24655. continue
  24656. } else if (isQuote(c)) {
  24657. parser.q = c
  24658. parser.state = S.ATTRIB_VALUE_QUOTED
  24659. } else {
  24660. strictFail(parser, 'Unquoted attribute value')
  24661. parser.state = S.ATTRIB_VALUE_UNQUOTED
  24662. parser.attribValue = c
  24663. }
  24664. continue
  24665. case S.ATTRIB_VALUE_QUOTED:
  24666. if (c !== parser.q) {
  24667. if (c === '&') {
  24668. parser.state = S.ATTRIB_VALUE_ENTITY_Q
  24669. } else {
  24670. parser.attribValue += c
  24671. }
  24672. continue
  24673. }
  24674. attrib(parser)
  24675. parser.q = ''
  24676. parser.state = S.ATTRIB_VALUE_CLOSED
  24677. continue
  24678. case S.ATTRIB_VALUE_CLOSED:
  24679. if (isWhitespace(c)) {
  24680. parser.state = S.ATTRIB
  24681. } else if (c === '>') {
  24682. openTag(parser)
  24683. } else if (c === '/') {
  24684. parser.state = S.OPEN_TAG_SLASH
  24685. } else if (isMatch(nameStart, c)) {
  24686. strictFail(parser, 'No whitespace between attributes')
  24687. parser.attribName = c
  24688. parser.attribValue = ''
  24689. parser.state = S.ATTRIB_NAME
  24690. } else {
  24691. strictFail(parser, 'Invalid attribute name')
  24692. }
  24693. continue
  24694. case S.ATTRIB_VALUE_UNQUOTED:
  24695. if (!isAttribEnd(c)) {
  24696. if (c === '&') {
  24697. parser.state = S.ATTRIB_VALUE_ENTITY_U
  24698. } else {
  24699. parser.attribValue += c
  24700. }
  24701. continue
  24702. }
  24703. attrib(parser)
  24704. if (c === '>') {
  24705. openTag(parser)
  24706. } else {
  24707. parser.state = S.ATTRIB
  24708. }
  24709. continue
  24710. case S.CLOSE_TAG:
  24711. if (!parser.tagName) {
  24712. if (isWhitespace(c)) {
  24713. continue
  24714. } else if (notMatch(nameStart, c)) {
  24715. if (parser.script) {
  24716. parser.script += '</' + c
  24717. parser.state = S.SCRIPT
  24718. } else {
  24719. strictFail(parser, 'Invalid tagname in closing tag.')
  24720. }
  24721. } else {
  24722. parser.tagName = c
  24723. }
  24724. } else if (c === '>') {
  24725. closeTag(parser)
  24726. } else if (isMatch(nameBody, c)) {
  24727. parser.tagName += c
  24728. } else if (parser.script) {
  24729. parser.script += '</' + parser.tagName
  24730. parser.tagName = ''
  24731. parser.state = S.SCRIPT
  24732. } else {
  24733. if (!isWhitespace(c)) {
  24734. strictFail(parser, 'Invalid tagname in closing tag')
  24735. }
  24736. parser.state = S.CLOSE_TAG_SAW_WHITE
  24737. }
  24738. continue
  24739. case S.CLOSE_TAG_SAW_WHITE:
  24740. if (isWhitespace(c)) {
  24741. continue
  24742. }
  24743. if (c === '>') {
  24744. closeTag(parser)
  24745. } else {
  24746. strictFail(parser, 'Invalid characters in closing tag')
  24747. }
  24748. continue
  24749. case S.TEXT_ENTITY:
  24750. case S.ATTRIB_VALUE_ENTITY_Q:
  24751. case S.ATTRIB_VALUE_ENTITY_U:
  24752. var returnState
  24753. var buffer
  24754. switch (parser.state) {
  24755. case S.TEXT_ENTITY:
  24756. returnState = S.TEXT
  24757. buffer = 'textNode'
  24758. break
  24759. case S.ATTRIB_VALUE_ENTITY_Q:
  24760. returnState = S.ATTRIB_VALUE_QUOTED
  24761. buffer = 'attribValue'
  24762. break
  24763. case S.ATTRIB_VALUE_ENTITY_U:
  24764. returnState = S.ATTRIB_VALUE_UNQUOTED
  24765. buffer = 'attribValue'
  24766. break
  24767. }
  24768. if (c === ';') {
  24769. parser[buffer] += parseEntity(parser)
  24770. parser.entity = ''
  24771. parser.state = returnState
  24772. } else if (isMatch(parser.entity.length ? entityBody : entityStart, c)) {
  24773. parser.entity += c
  24774. } else {
  24775. strictFail(parser, 'Invalid character in entity name')
  24776. parser[buffer] += '&' + parser.entity + c
  24777. parser.entity = ''
  24778. parser.state = returnState
  24779. }
  24780. continue
  24781. default:
  24782. throw new Error(parser, 'Unknown state: ' + parser.state)
  24783. }
  24784. } // while
  24785. if (parser.position >= parser.bufferCheckPosition) {
  24786. checkBufferLength(parser)
  24787. }
  24788. return parser
  24789. }
  24790. /*! http://mths.be/fromcodepoint v0.1.0 by @mathias */
  24791. /* istanbul ignore next */
  24792. if (!String.fromCodePoint) {
  24793. (function () {
  24794. var stringFromCharCode = String.fromCharCode
  24795. var floor = Math.floor
  24796. var fromCodePoint = function () {
  24797. var MAX_SIZE = 0x4000
  24798. var codeUnits = []
  24799. var highSurrogate
  24800. var lowSurrogate
  24801. var index = -1
  24802. var length = arguments.length
  24803. if (!length) {
  24804. return ''
  24805. }
  24806. var result = ''
  24807. while (++index < length) {
  24808. var codePoint = Number(arguments[index])
  24809. if (
  24810. !isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity`
  24811. codePoint < 0 || // not a valid Unicode code point
  24812. codePoint > 0x10FFFF || // not a valid Unicode code point
  24813. floor(codePoint) !== codePoint // not an integer
  24814. ) {
  24815. throw RangeError('Invalid code point: ' + codePoint)
  24816. }
  24817. if (codePoint <= 0xFFFF) { // BMP code point
  24818. codeUnits.push(codePoint)
  24819. } else { // Astral code point; split in surrogate halves
  24820. // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
  24821. codePoint -= 0x10000
  24822. highSurrogate = (codePoint >> 10) + 0xD800
  24823. lowSurrogate = (codePoint % 0x400) + 0xDC00
  24824. codeUnits.push(highSurrogate, lowSurrogate)
  24825. }
  24826. if (index + 1 === length || codeUnits.length > MAX_SIZE) {
  24827. result += stringFromCharCode.apply(null, codeUnits)
  24828. codeUnits.length = 0
  24829. }
  24830. }
  24831. return result
  24832. }
  24833. /* istanbul ignore next */
  24834. if (Object.defineProperty) {
  24835. Object.defineProperty(String, 'fromCodePoint', {
  24836. value: fromCodePoint,
  24837. configurable: true,
  24838. writable: true
  24839. })
  24840. } else {
  24841. String.fromCodePoint = fromCodePoint
  24842. }
  24843. }())
  24844. }
  24845. })(typeof exports === 'undefined' ? this.sax = {} : exports)
  24846. }).call(this,require("buffer").Buffer)
  24847. },{"buffer":98,"stream":340,"string_decoder":341}],340:[function(require,module,exports){
  24848. // Copyright Joyent, Inc. and other Node contributors.
  24849. //
  24850. // Permission is hereby granted, free of charge, to any person obtaining a
  24851. // copy of this software and associated documentation files (the
  24852. // "Software"), to deal in the Software without restriction, including
  24853. // without limitation the rights to use, copy, modify, merge, publish,
  24854. // distribute, sublicense, and/or sell copies of the Software, and to permit
  24855. // persons to whom the Software is furnished to do so, subject to the
  24856. // following conditions:
  24857. //
  24858. // The above copyright notice and this permission notice shall be included
  24859. // in all copies or substantial portions of the Software.
  24860. //
  24861. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  24862. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  24863. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  24864. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  24865. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  24866. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  24867. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  24868. module.exports = Stream;
  24869. var EE = require('events').EventEmitter;
  24870. var inherits = require('inherits');
  24871. inherits(Stream, EE);
  24872. Stream.Readable = require('readable-stream/readable.js');
  24873. Stream.Writable = require('readable-stream/writable.js');
  24874. Stream.Duplex = require('readable-stream/duplex.js');
  24875. Stream.Transform = require('readable-stream/transform.js');
  24876. Stream.PassThrough = require('readable-stream/passthrough.js');
  24877. // Backwards-compat with node 0.4.x
  24878. Stream.Stream = Stream;
  24879. // old-style streams. Note that the pipe method (the only relevant
  24880. // part of this class) is overridden in the Readable class.
  24881. function Stream() {
  24882. EE.call(this);
  24883. }
  24884. Stream.prototype.pipe = function(dest, options) {
  24885. var source = this;
  24886. function ondata(chunk) {
  24887. if (dest.writable) {
  24888. if (false === dest.write(chunk) && source.pause) {
  24889. source.pause();
  24890. }
  24891. }
  24892. }
  24893. source.on('data', ondata);
  24894. function ondrain() {
  24895. if (source.readable && source.resume) {
  24896. source.resume();
  24897. }
  24898. }
  24899. dest.on('drain', ondrain);
  24900. // If the 'end' option is not supplied, dest.end() will be called when
  24901. // source gets the 'end' or 'close' events. Only dest.end() once.
  24902. if (!dest._isStdio && (!options || options.end !== false)) {
  24903. source.on('end', onend);
  24904. source.on('close', onclose);
  24905. }
  24906. var didOnEnd = false;
  24907. function onend() {
  24908. if (didOnEnd) return;
  24909. didOnEnd = true;
  24910. dest.end();
  24911. }
  24912. function onclose() {
  24913. if (didOnEnd) return;
  24914. didOnEnd = true;
  24915. if (typeof dest.destroy === 'function') dest.destroy();
  24916. }
  24917. // don't leave dangling pipes when there are errors.
  24918. function onerror(er) {
  24919. cleanup();
  24920. if (EE.listenerCount(this, 'error') === 0) {
  24921. throw er; // Unhandled stream error in pipe.
  24922. }
  24923. }
  24924. source.on('error', onerror);
  24925. dest.on('error', onerror);
  24926. // remove all the event listeners that were added.
  24927. function cleanup() {
  24928. source.removeListener('data', ondata);
  24929. dest.removeListener('drain', ondrain);
  24930. source.removeListener('end', onend);
  24931. source.removeListener('close', onclose);
  24932. source.removeListener('error', onerror);
  24933. dest.removeListener('error', onerror);
  24934. source.removeListener('end', cleanup);
  24935. source.removeListener('close', cleanup);
  24936. dest.removeListener('close', cleanup);
  24937. }
  24938. source.on('end', cleanup);
  24939. source.on('close', cleanup);
  24940. dest.on('close', cleanup);
  24941. dest.emit('pipe', source);
  24942. // Allow for unix-like usage: A.pipe(B).pipe(C)
  24943. return dest;
  24944. };
  24945. },{"events":297,"inherits":307,"readable-stream/duplex.js":324,"readable-stream/passthrough.js":333,"readable-stream/readable.js":334,"readable-stream/transform.js":335,"readable-stream/writable.js":336}],341:[function(require,module,exports){
  24946. // Copyright Joyent, Inc. and other Node contributors.
  24947. //
  24948. // Permission is hereby granted, free of charge, to any person obtaining a
  24949. // copy of this software and associated documentation files (the
  24950. // "Software"), to deal in the Software without restriction, including
  24951. // without limitation the rights to use, copy, modify, merge, publish,
  24952. // distribute, sublicense, and/or sell copies of the Software, and to permit
  24953. // persons to whom the Software is furnished to do so, subject to the
  24954. // following conditions:
  24955. //
  24956. // The above copyright notice and this permission notice shall be included
  24957. // in all copies or substantial portions of the Software.
  24958. //
  24959. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  24960. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  24961. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  24962. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  24963. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  24964. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  24965. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  24966. 'use strict';
  24967. /*<replacement>*/
  24968. var Buffer = require('safe-buffer').Buffer;
  24969. /*</replacement>*/
  24970. var isEncoding = Buffer.isEncoding || function (encoding) {
  24971. encoding = '' + encoding;
  24972. switch (encoding && encoding.toLowerCase()) {
  24973. case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':
  24974. return true;
  24975. default:
  24976. return false;
  24977. }
  24978. };
  24979. function _normalizeEncoding(enc) {
  24980. if (!enc) return 'utf8';
  24981. var retried;
  24982. while (true) {
  24983. switch (enc) {
  24984. case 'utf8':
  24985. case 'utf-8':
  24986. return 'utf8';
  24987. case 'ucs2':
  24988. case 'ucs-2':
  24989. case 'utf16le':
  24990. case 'utf-16le':
  24991. return 'utf16le';
  24992. case 'latin1':
  24993. case 'binary':
  24994. return 'latin1';
  24995. case 'base64':
  24996. case 'ascii':
  24997. case 'hex':
  24998. return enc;
  24999. default:
  25000. if (retried) return; // undefined
  25001. enc = ('' + enc).toLowerCase();
  25002. retried = true;
  25003. }
  25004. }
  25005. };
  25006. // Do not cache `Buffer.isEncoding` when checking encoding names as some
  25007. // modules monkey-patch it to support additional encodings
  25008. function normalizeEncoding(enc) {
  25009. var nenc = _normalizeEncoding(enc);
  25010. if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
  25011. return nenc || enc;
  25012. }
  25013. // StringDecoder provides an interface for efficiently splitting a series of
  25014. // buffers into a series of JS strings without breaking apart multi-byte
  25015. // characters.
  25016. exports.StringDecoder = StringDecoder;
  25017. function StringDecoder(encoding) {
  25018. this.encoding = normalizeEncoding(encoding);
  25019. var nb;
  25020. switch (this.encoding) {
  25021. case 'utf16le':
  25022. this.text = utf16Text;
  25023. this.end = utf16End;
  25024. nb = 4;
  25025. break;
  25026. case 'utf8':
  25027. this.fillLast = utf8FillLast;
  25028. nb = 4;
  25029. break;
  25030. case 'base64':
  25031. this.text = base64Text;
  25032. this.end = base64End;
  25033. nb = 3;
  25034. break;
  25035. default:
  25036. this.write = simpleWrite;
  25037. this.end = simpleEnd;
  25038. return;
  25039. }
  25040. this.lastNeed = 0;
  25041. this.lastTotal = 0;
  25042. this.lastChar = Buffer.allocUnsafe(nb);
  25043. }
  25044. StringDecoder.prototype.write = function (buf) {
  25045. if (buf.length === 0) return '';
  25046. var r;
  25047. var i;
  25048. if (this.lastNeed) {
  25049. r = this.fillLast(buf);
  25050. if (r === undefined) return '';
  25051. i = this.lastNeed;
  25052. this.lastNeed = 0;
  25053. } else {
  25054. i = 0;
  25055. }
  25056. if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
  25057. return r || '';
  25058. };
  25059. StringDecoder.prototype.end = utf8End;
  25060. // Returns only complete characters in a Buffer
  25061. StringDecoder.prototype.text = utf8Text;
  25062. // Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
  25063. StringDecoder.prototype.fillLast = function (buf) {
  25064. if (this.lastNeed <= buf.length) {
  25065. buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
  25066. return this.lastChar.toString(this.encoding, 0, this.lastTotal);
  25067. }
  25068. buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
  25069. this.lastNeed -= buf.length;
  25070. };
  25071. // Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
  25072. // continuation byte. If an invalid byte is detected, -2 is returned.
  25073. function utf8CheckByte(byte) {
  25074. if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;
  25075. return byte >> 6 === 0x02 ? -1 : -2;
  25076. }
  25077. // Checks at most 3 bytes at the end of a Buffer in order to detect an
  25078. // incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
  25079. // needed to complete the UTF-8 character (if applicable) are returned.
  25080. function utf8CheckIncomplete(self, buf, i) {
  25081. var j = buf.length - 1;
  25082. if (j < i) return 0;
  25083. var nb = utf8CheckByte(buf[j]);
  25084. if (nb >= 0) {
  25085. if (nb > 0) self.lastNeed = nb - 1;
  25086. return nb;
  25087. }
  25088. if (--j < i || nb === -2) return 0;
  25089. nb = utf8CheckByte(buf[j]);
  25090. if (nb >= 0) {
  25091. if (nb > 0) self.lastNeed = nb - 2;
  25092. return nb;
  25093. }
  25094. if (--j < i || nb === -2) return 0;
  25095. nb = utf8CheckByte(buf[j]);
  25096. if (nb >= 0) {
  25097. if (nb > 0) {
  25098. if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
  25099. }
  25100. return nb;
  25101. }
  25102. return 0;
  25103. }
  25104. // Validates as many continuation bytes for a multi-byte UTF-8 character as
  25105. // needed or are available. If we see a non-continuation byte where we expect
  25106. // one, we "replace" the validated continuation bytes we've seen so far with
  25107. // a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
  25108. // behavior. The continuation byte check is included three times in the case
  25109. // where all of the continuation bytes for a character exist in the same buffer.
  25110. // It is also done this way as a slight performance increase instead of using a
  25111. // loop.
  25112. function utf8CheckExtraBytes(self, buf, p) {
  25113. if ((buf[0] & 0xC0) !== 0x80) {
  25114. self.lastNeed = 0;
  25115. return '\ufffd';
  25116. }
  25117. if (self.lastNeed > 1 && buf.length > 1) {
  25118. if ((buf[1] & 0xC0) !== 0x80) {
  25119. self.lastNeed = 1;
  25120. return '\ufffd';
  25121. }
  25122. if (self.lastNeed > 2 && buf.length > 2) {
  25123. if ((buf[2] & 0xC0) !== 0x80) {
  25124. self.lastNeed = 2;
  25125. return '\ufffd';
  25126. }
  25127. }
  25128. }
  25129. }
  25130. // Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
  25131. function utf8FillLast(buf) {
  25132. var p = this.lastTotal - this.lastNeed;
  25133. var r = utf8CheckExtraBytes(this, buf, p);
  25134. if (r !== undefined) return r;
  25135. if (this.lastNeed <= buf.length) {
  25136. buf.copy(this.lastChar, p, 0, this.lastNeed);
  25137. return this.lastChar.toString(this.encoding, 0, this.lastTotal);
  25138. }
  25139. buf.copy(this.lastChar, p, 0, buf.length);
  25140. this.lastNeed -= buf.length;
  25141. }
  25142. // Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
  25143. // partial character, the character's bytes are buffered until the required
  25144. // number of bytes are available.
  25145. function utf8Text(buf, i) {
  25146. var total = utf8CheckIncomplete(this, buf, i);
  25147. if (!this.lastNeed) return buf.toString('utf8', i);
  25148. this.lastTotal = total;
  25149. var end = buf.length - (total - this.lastNeed);
  25150. buf.copy(this.lastChar, 0, end);
  25151. return buf.toString('utf8', i, end);
  25152. }
  25153. // For UTF-8, a replacement character is added when ending on a partial
  25154. // character.
  25155. function utf8End(buf) {
  25156. var r = buf && buf.length ? this.write(buf) : '';
  25157. if (this.lastNeed) return r + '\ufffd';
  25158. return r;
  25159. }
  25160. // UTF-16LE typically needs two bytes per character, but even if we have an even
  25161. // number of bytes available, we need to check if we end on a leading/high
  25162. // surrogate. In that case, we need to wait for the next two bytes in order to
  25163. // decode the last character properly.
  25164. function utf16Text(buf, i) {
  25165. if ((buf.length - i) % 2 === 0) {
  25166. var r = buf.toString('utf16le', i);
  25167. if (r) {
  25168. var c = r.charCodeAt(r.length - 1);
  25169. if (c >= 0xD800 && c <= 0xDBFF) {
  25170. this.lastNeed = 2;
  25171. this.lastTotal = 4;
  25172. this.lastChar[0] = buf[buf.length - 2];
  25173. this.lastChar[1] = buf[buf.length - 1];
  25174. return r.slice(0, -1);
  25175. }
  25176. }
  25177. return r;
  25178. }
  25179. this.lastNeed = 1;
  25180. this.lastTotal = 2;
  25181. this.lastChar[0] = buf[buf.length - 1];
  25182. return buf.toString('utf16le', i, buf.length - 1);
  25183. }
  25184. // For UTF-16LE we do not explicitly append special replacement characters if we
  25185. // end on a partial character, we simply let v8 handle that.
  25186. function utf16End(buf) {
  25187. var r = buf && buf.length ? this.write(buf) : '';
  25188. if (this.lastNeed) {
  25189. var end = this.lastTotal - this.lastNeed;
  25190. return r + this.lastChar.toString('utf16le', 0, end);
  25191. }
  25192. return r;
  25193. }
  25194. function base64Text(buf, i) {
  25195. var n = (buf.length - i) % 3;
  25196. if (n === 0) return buf.toString('base64', i);
  25197. this.lastNeed = 3 - n;
  25198. this.lastTotal = 3;
  25199. if (n === 1) {
  25200. this.lastChar[0] = buf[buf.length - 1];
  25201. } else {
  25202. this.lastChar[0] = buf[buf.length - 2];
  25203. this.lastChar[1] = buf[buf.length - 1];
  25204. }
  25205. return buf.toString('base64', i, buf.length - n);
  25206. }
  25207. function base64End(buf) {
  25208. var r = buf && buf.length ? this.write(buf) : '';
  25209. if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
  25210. return r;
  25211. }
  25212. // Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
  25213. function simpleWrite(buf) {
  25214. return buf.toString(this.encoding);
  25215. }
  25216. function simpleEnd(buf) {
  25217. return buf && buf.length ? this.write(buf) : '';
  25218. }
  25219. },{"safe-buffer":338}],342:[function(require,module,exports){
  25220. (function (setImmediate,clearImmediate){
  25221. var nextTick = require('process/browser.js').nextTick;
  25222. var apply = Function.prototype.apply;
  25223. var slice = Array.prototype.slice;
  25224. var immediateIds = {};
  25225. var nextImmediateId = 0;
  25226. // DOM APIs, for completeness
  25227. exports.setTimeout = function() {
  25228. return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
  25229. };
  25230. exports.setInterval = function() {
  25231. return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
  25232. };
  25233. exports.clearTimeout =
  25234. exports.clearInterval = function(timeout) { timeout.close(); };
  25235. function Timeout(id, clearFn) {
  25236. this._id = id;
  25237. this._clearFn = clearFn;
  25238. }
  25239. Timeout.prototype.unref = Timeout.prototype.ref = function() {};
  25240. Timeout.prototype.close = function() {
  25241. this._clearFn.call(window, this._id);
  25242. };
  25243. // Does not start the time, just sets up the members needed.
  25244. exports.enroll = function(item, msecs) {
  25245. clearTimeout(item._idleTimeoutId);
  25246. item._idleTimeout = msecs;
  25247. };
  25248. exports.unenroll = function(item) {
  25249. clearTimeout(item._idleTimeoutId);
  25250. item._idleTimeout = -1;
  25251. };
  25252. exports._unrefActive = exports.active = function(item) {
  25253. clearTimeout(item._idleTimeoutId);
  25254. var msecs = item._idleTimeout;
  25255. if (msecs >= 0) {
  25256. item._idleTimeoutId = setTimeout(function onTimeout() {
  25257. if (item._onTimeout)
  25258. item._onTimeout();
  25259. }, msecs);
  25260. }
  25261. };
  25262. // That's not how node.js implements it but the exposed api is the same.
  25263. exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) {
  25264. var id = nextImmediateId++;
  25265. var args = arguments.length < 2 ? false : slice.call(arguments, 1);
  25266. immediateIds[id] = true;
  25267. nextTick(function onNextTick() {
  25268. if (immediateIds[id]) {
  25269. // fn.call() is faster so we optimize for the common use-case
  25270. // @see http://jsperf.com/call-apply-segu
  25271. if (args) {
  25272. fn.apply(null, args);
  25273. } else {
  25274. fn.call(null);
  25275. }
  25276. // Prevent ids from leaking
  25277. exports.clearImmediate(id);
  25278. }
  25279. });
  25280. return id;
  25281. };
  25282. exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) {
  25283. delete immediateIds[id];
  25284. };
  25285. }).call(this,require("timers").setImmediate,require("timers").clearImmediate)
  25286. },{"process/browser.js":319,"timers":342}],343:[function(require,module,exports){
  25287. (function (global){
  25288. /**
  25289. * Module exports.
  25290. */
  25291. module.exports = deprecate;
  25292. /**
  25293. * Mark that a method should not be used.
  25294. * Returns a modified function which warns once by default.
  25295. *
  25296. * If `localStorage.noDeprecation = true` is set, then it is a no-op.
  25297. *
  25298. * If `localStorage.throwDeprecation = true` is set, then deprecated functions
  25299. * will throw an Error when invoked.
  25300. *
  25301. * If `localStorage.traceDeprecation = true` is set, then deprecated functions
  25302. * will invoke `console.trace()` instead of `console.error()`.
  25303. *
  25304. * @param {Function} fn - the function to deprecate
  25305. * @param {String} msg - the string to print to the console when `fn` is invoked
  25306. * @returns {Function} a new "deprecated" version of `fn`
  25307. * @api public
  25308. */
  25309. function deprecate (fn, msg) {
  25310. if (config('noDeprecation')) {
  25311. return fn;
  25312. }
  25313. var warned = false;
  25314. function deprecated() {
  25315. if (!warned) {
  25316. if (config('throwDeprecation')) {
  25317. throw new Error(msg);
  25318. } else if (config('traceDeprecation')) {
  25319. console.trace(msg);
  25320. } else {
  25321. console.warn(msg);
  25322. }
  25323. warned = true;
  25324. }
  25325. return fn.apply(this, arguments);
  25326. }
  25327. return deprecated;
  25328. }
  25329. /**
  25330. * Checks `localStorage` for boolean values for the given `name`.
  25331. *
  25332. * @param {String} name
  25333. * @returns {Boolean}
  25334. * @api private
  25335. */
  25336. function config (name) {
  25337. // accessing global.localStorage can trigger a DOMException in sandboxed iframes
  25338. try {
  25339. if (!global.localStorage) return false;
  25340. } catch (_) {
  25341. return false;
  25342. }
  25343. var val = global.localStorage[name];
  25344. if (null == val) return false;
  25345. return String(val).toLowerCase() === 'true';
  25346. }
  25347. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  25348. },{}],344:[function(require,module,exports){
  25349. if (typeof Object.create === 'function') {
  25350. // implementation from standard node.js 'util' module
  25351. module.exports = function inherits(ctor, superCtor) {
  25352. ctor.super_ = superCtor
  25353. ctor.prototype = Object.create(superCtor.prototype, {
  25354. constructor: {
  25355. value: ctor,
  25356. enumerable: false,
  25357. writable: true,
  25358. configurable: true
  25359. }
  25360. });
  25361. };
  25362. } else {
  25363. // old school shim for old browsers
  25364. module.exports = function inherits(ctor, superCtor) {
  25365. ctor.super_ = superCtor
  25366. var TempCtor = function () {}
  25367. TempCtor.prototype = superCtor.prototype
  25368. ctor.prototype = new TempCtor()
  25369. ctor.prototype.constructor = ctor
  25370. }
  25371. }
  25372. },{}],345:[function(require,module,exports){
  25373. module.exports = function isBuffer(arg) {
  25374. return arg && typeof arg === 'object'
  25375. && typeof arg.copy === 'function'
  25376. && typeof arg.fill === 'function'
  25377. && typeof arg.readUInt8 === 'function';
  25378. }
  25379. },{}],346:[function(require,module,exports){
  25380. (function (process,global){
  25381. // Copyright Joyent, Inc. and other Node contributors.
  25382. //
  25383. // Permission is hereby granted, free of charge, to any person obtaining a
  25384. // copy of this software and associated documentation files (the
  25385. // "Software"), to deal in the Software without restriction, including
  25386. // without limitation the rights to use, copy, modify, merge, publish,
  25387. // distribute, sublicense, and/or sell copies of the Software, and to permit
  25388. // persons to whom the Software is furnished to do so, subject to the
  25389. // following conditions:
  25390. //
  25391. // The above copyright notice and this permission notice shall be included
  25392. // in all copies or substantial portions of the Software.
  25393. //
  25394. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  25395. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25396. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  25397. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  25398. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  25399. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  25400. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  25401. var formatRegExp = /%[sdj%]/g;
  25402. exports.format = function(f) {
  25403. if (!isString(f)) {
  25404. var objects = [];
  25405. for (var i = 0; i < arguments.length; i++) {
  25406. objects.push(inspect(arguments[i]));
  25407. }
  25408. return objects.join(' ');
  25409. }
  25410. var i = 1;
  25411. var args = arguments;
  25412. var len = args.length;
  25413. var str = String(f).replace(formatRegExp, function(x) {
  25414. if (x === '%%') return '%';
  25415. if (i >= len) return x;
  25416. switch (x) {
  25417. case '%s': return String(args[i++]);
  25418. case '%d': return Number(args[i++]);
  25419. case '%j':
  25420. try {
  25421. return JSON.stringify(args[i++]);
  25422. } catch (_) {
  25423. return '[Circular]';
  25424. }
  25425. default:
  25426. return x;
  25427. }
  25428. });
  25429. for (var x = args[i]; i < len; x = args[++i]) {
  25430. if (isNull(x) || !isObject(x)) {
  25431. str += ' ' + x;
  25432. } else {
  25433. str += ' ' + inspect(x);
  25434. }
  25435. }
  25436. return str;
  25437. };
  25438. // Mark that a method should not be used.
  25439. // Returns a modified function which warns once by default.
  25440. // If --no-deprecation is set, then it is a no-op.
  25441. exports.deprecate = function(fn, msg) {
  25442. // Allow for deprecating things in the process of starting up.
  25443. if (isUndefined(global.process)) {
  25444. return function() {
  25445. return exports.deprecate(fn, msg).apply(this, arguments);
  25446. };
  25447. }
  25448. if (process.noDeprecation === true) {
  25449. return fn;
  25450. }
  25451. var warned = false;
  25452. function deprecated() {
  25453. if (!warned) {
  25454. if (process.throwDeprecation) {
  25455. throw new Error(msg);
  25456. } else if (process.traceDeprecation) {
  25457. console.trace(msg);
  25458. } else {
  25459. console.error(msg);
  25460. }
  25461. warned = true;
  25462. }
  25463. return fn.apply(this, arguments);
  25464. }
  25465. return deprecated;
  25466. };
  25467. var debugs = {};
  25468. var debugEnviron;
  25469. exports.debuglog = function(set) {
  25470. if (isUndefined(debugEnviron))
  25471. debugEnviron = process.env.NODE_DEBUG || '';
  25472. set = set.toUpperCase();
  25473. if (!debugs[set]) {
  25474. if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
  25475. var pid = process.pid;
  25476. debugs[set] = function() {
  25477. var msg = exports.format.apply(exports, arguments);
  25478. console.error('%s %d: %s', set, pid, msg);
  25479. };
  25480. } else {
  25481. debugs[set] = function() {};
  25482. }
  25483. }
  25484. return debugs[set];
  25485. };
  25486. /**
  25487. * Echos the value of a value. Trys to print the value out
  25488. * in the best way possible given the different types.
  25489. *
  25490. * @param {Object} obj The object to print out.
  25491. * @param {Object} opts Optional options object that alters the output.
  25492. */
  25493. /* legacy: obj, showHidden, depth, colors*/
  25494. function inspect(obj, opts) {
  25495. // default options
  25496. var ctx = {
  25497. seen: [],
  25498. stylize: stylizeNoColor
  25499. };
  25500. // legacy...
  25501. if (arguments.length >= 3) ctx.depth = arguments[2];
  25502. if (arguments.length >= 4) ctx.colors = arguments[3];
  25503. if (isBoolean(opts)) {
  25504. // legacy...
  25505. ctx.showHidden = opts;
  25506. } else if (opts) {
  25507. // got an "options" object
  25508. exports._extend(ctx, opts);
  25509. }
  25510. // set default options
  25511. if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
  25512. if (isUndefined(ctx.depth)) ctx.depth = 2;
  25513. if (isUndefined(ctx.colors)) ctx.colors = false;
  25514. if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
  25515. if (ctx.colors) ctx.stylize = stylizeWithColor;
  25516. return formatValue(ctx, obj, ctx.depth);
  25517. }
  25518. exports.inspect = inspect;
  25519. // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
  25520. inspect.colors = {
  25521. 'bold' : [1, 22],
  25522. 'italic' : [3, 23],
  25523. 'underline' : [4, 24],
  25524. 'inverse' : [7, 27],
  25525. 'white' : [37, 39],
  25526. 'grey' : [90, 39],
  25527. 'black' : [30, 39],
  25528. 'blue' : [34, 39],
  25529. 'cyan' : [36, 39],
  25530. 'green' : [32, 39],
  25531. 'magenta' : [35, 39],
  25532. 'red' : [31, 39],
  25533. 'yellow' : [33, 39]
  25534. };
  25535. // Don't use 'blue' not visible on cmd.exe
  25536. inspect.styles = {
  25537. 'special': 'cyan',
  25538. 'number': 'yellow',
  25539. 'boolean': 'yellow',
  25540. 'undefined': 'grey',
  25541. 'null': 'bold',
  25542. 'string': 'green',
  25543. 'date': 'magenta',
  25544. // "name": intentionally not styling
  25545. 'regexp': 'red'
  25546. };
  25547. function stylizeWithColor(str, styleType) {
  25548. var style = inspect.styles[styleType];
  25549. if (style) {
  25550. return '\u001b[' + inspect.colors[style][0] + 'm' + str +
  25551. '\u001b[' + inspect.colors[style][1] + 'm';
  25552. } else {
  25553. return str;
  25554. }
  25555. }
  25556. function stylizeNoColor(str, styleType) {
  25557. return str;
  25558. }
  25559. function arrayToHash(array) {
  25560. var hash = {};
  25561. array.forEach(function(val, idx) {
  25562. hash[val] = true;
  25563. });
  25564. return hash;
  25565. }
  25566. function formatValue(ctx, value, recurseTimes) {
  25567. // Provide a hook for user-specified inspect functions.
  25568. // Check that value is an object with an inspect function on it
  25569. if (ctx.customInspect &&
  25570. value &&
  25571. isFunction(value.inspect) &&
  25572. // Filter out the util module, it's inspect function is special
  25573. value.inspect !== exports.inspect &&
  25574. // Also filter out any prototype objects using the circular check.
  25575. !(value.constructor && value.constructor.prototype === value)) {
  25576. var ret = value.inspect(recurseTimes, ctx);
  25577. if (!isString(ret)) {
  25578. ret = formatValue(ctx, ret, recurseTimes);
  25579. }
  25580. return ret;
  25581. }
  25582. // Primitive types cannot have properties
  25583. var primitive = formatPrimitive(ctx, value);
  25584. if (primitive) {
  25585. return primitive;
  25586. }
  25587. // Look up the keys of the object.
  25588. var keys = Object.keys(value);
  25589. var visibleKeys = arrayToHash(keys);
  25590. if (ctx.showHidden) {
  25591. keys = Object.getOwnPropertyNames(value);
  25592. }
  25593. // IE doesn't make error fields non-enumerable
  25594. // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
  25595. if (isError(value)
  25596. && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
  25597. return formatError(value);
  25598. }
  25599. // Some type of object without properties can be shortcutted.
  25600. if (keys.length === 0) {
  25601. if (isFunction(value)) {
  25602. var name = value.name ? ': ' + value.name : '';
  25603. return ctx.stylize('[Function' + name + ']', 'special');
  25604. }
  25605. if (isRegExp(value)) {
  25606. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  25607. }
  25608. if (isDate(value)) {
  25609. return ctx.stylize(Date.prototype.toString.call(value), 'date');
  25610. }
  25611. if (isError(value)) {
  25612. return formatError(value);
  25613. }
  25614. }
  25615. var base = '', array = false, braces = ['{', '}'];
  25616. // Make Array say that they are Array
  25617. if (isArray(value)) {
  25618. array = true;
  25619. braces = ['[', ']'];
  25620. }
  25621. // Make functions say that they are functions
  25622. if (isFunction(value)) {
  25623. var n = value.name ? ': ' + value.name : '';
  25624. base = ' [Function' + n + ']';
  25625. }
  25626. // Make RegExps say that they are RegExps
  25627. if (isRegExp(value)) {
  25628. base = ' ' + RegExp.prototype.toString.call(value);
  25629. }
  25630. // Make dates with properties first say the date
  25631. if (isDate(value)) {
  25632. base = ' ' + Date.prototype.toUTCString.call(value);
  25633. }
  25634. // Make error with message first say the error
  25635. if (isError(value)) {
  25636. base = ' ' + formatError(value);
  25637. }
  25638. if (keys.length === 0 && (!array || value.length == 0)) {
  25639. return braces[0] + base + braces[1];
  25640. }
  25641. if (recurseTimes < 0) {
  25642. if (isRegExp(value)) {
  25643. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  25644. } else {
  25645. return ctx.stylize('[Object]', 'special');
  25646. }
  25647. }
  25648. ctx.seen.push(value);
  25649. var output;
  25650. if (array) {
  25651. output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
  25652. } else {
  25653. output = keys.map(function(key) {
  25654. return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
  25655. });
  25656. }
  25657. ctx.seen.pop();
  25658. return reduceToSingleString(output, base, braces);
  25659. }
  25660. function formatPrimitive(ctx, value) {
  25661. if (isUndefined(value))
  25662. return ctx.stylize('undefined', 'undefined');
  25663. if (isString(value)) {
  25664. var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
  25665. .replace(/'/g, "\\'")
  25666. .replace(/\\"/g, '"') + '\'';
  25667. return ctx.stylize(simple, 'string');
  25668. }
  25669. if (isNumber(value))
  25670. return ctx.stylize('' + value, 'number');
  25671. if (isBoolean(value))
  25672. return ctx.stylize('' + value, 'boolean');
  25673. // For some reason typeof null is "object", so special case here.
  25674. if (isNull(value))
  25675. return ctx.stylize('null', 'null');
  25676. }
  25677. function formatError(value) {
  25678. return '[' + Error.prototype.toString.call(value) + ']';
  25679. }
  25680. function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
  25681. var output = [];
  25682. for (var i = 0, l = value.length; i < l; ++i) {
  25683. if (hasOwnProperty(value, String(i))) {
  25684. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  25685. String(i), true));
  25686. } else {
  25687. output.push('');
  25688. }
  25689. }
  25690. keys.forEach(function(key) {
  25691. if (!key.match(/^\d+$/)) {
  25692. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  25693. key, true));
  25694. }
  25695. });
  25696. return output;
  25697. }
  25698. function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
  25699. var name, str, desc;
  25700. desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
  25701. if (desc.get) {
  25702. if (desc.set) {
  25703. str = ctx.stylize('[Getter/Setter]', 'special');
  25704. } else {
  25705. str = ctx.stylize('[Getter]', 'special');
  25706. }
  25707. } else {
  25708. if (desc.set) {
  25709. str = ctx.stylize('[Setter]', 'special');
  25710. }
  25711. }
  25712. if (!hasOwnProperty(visibleKeys, key)) {
  25713. name = '[' + key + ']';
  25714. }
  25715. if (!str) {
  25716. if (ctx.seen.indexOf(desc.value) < 0) {
  25717. if (isNull(recurseTimes)) {
  25718. str = formatValue(ctx, desc.value, null);
  25719. } else {
  25720. str = formatValue(ctx, desc.value, recurseTimes - 1);
  25721. }
  25722. if (str.indexOf('\n') > -1) {
  25723. if (array) {
  25724. str = str.split('\n').map(function(line) {
  25725. return ' ' + line;
  25726. }).join('\n').substr(2);
  25727. } else {
  25728. str = '\n' + str.split('\n').map(function(line) {
  25729. return ' ' + line;
  25730. }).join('\n');
  25731. }
  25732. }
  25733. } else {
  25734. str = ctx.stylize('[Circular]', 'special');
  25735. }
  25736. }
  25737. if (isUndefined(name)) {
  25738. if (array && key.match(/^\d+$/)) {
  25739. return str;
  25740. }
  25741. name = JSON.stringify('' + key);
  25742. if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
  25743. name = name.substr(1, name.length - 2);
  25744. name = ctx.stylize(name, 'name');
  25745. } else {
  25746. name = name.replace(/'/g, "\\'")
  25747. .replace(/\\"/g, '"')
  25748. .replace(/(^"|"$)/g, "'");
  25749. name = ctx.stylize(name, 'string');
  25750. }
  25751. }
  25752. return name + ': ' + str;
  25753. }
  25754. function reduceToSingleString(output, base, braces) {
  25755. var numLinesEst = 0;
  25756. var length = output.reduce(function(prev, cur) {
  25757. numLinesEst++;
  25758. if (cur.indexOf('\n') >= 0) numLinesEst++;
  25759. return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
  25760. }, 0);
  25761. if (length > 60) {
  25762. return braces[0] +
  25763. (base === '' ? '' : base + '\n ') +
  25764. ' ' +
  25765. output.join(',\n ') +
  25766. ' ' +
  25767. braces[1];
  25768. }
  25769. return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
  25770. }
  25771. // NOTE: These type checking functions intentionally don't use `instanceof`
  25772. // because it is fragile and can be easily faked with `Object.create()`.
  25773. function isArray(ar) {
  25774. return Array.isArray(ar);
  25775. }
  25776. exports.isArray = isArray;
  25777. function isBoolean(arg) {
  25778. return typeof arg === 'boolean';
  25779. }
  25780. exports.isBoolean = isBoolean;
  25781. function isNull(arg) {
  25782. return arg === null;
  25783. }
  25784. exports.isNull = isNull;
  25785. function isNullOrUndefined(arg) {
  25786. return arg == null;
  25787. }
  25788. exports.isNullOrUndefined = isNullOrUndefined;
  25789. function isNumber(arg) {
  25790. return typeof arg === 'number';
  25791. }
  25792. exports.isNumber = isNumber;
  25793. function isString(arg) {
  25794. return typeof arg === 'string';
  25795. }
  25796. exports.isString = isString;
  25797. function isSymbol(arg) {
  25798. return typeof arg === 'symbol';
  25799. }
  25800. exports.isSymbol = isSymbol;
  25801. function isUndefined(arg) {
  25802. return arg === void 0;
  25803. }
  25804. exports.isUndefined = isUndefined;
  25805. function isRegExp(re) {
  25806. return isObject(re) && objectToString(re) === '[object RegExp]';
  25807. }
  25808. exports.isRegExp = isRegExp;
  25809. function isObject(arg) {
  25810. return typeof arg === 'object' && arg !== null;
  25811. }
  25812. exports.isObject = isObject;
  25813. function isDate(d) {
  25814. return isObject(d) && objectToString(d) === '[object Date]';
  25815. }
  25816. exports.isDate = isDate;
  25817. function isError(e) {
  25818. return isObject(e) &&
  25819. (objectToString(e) === '[object Error]' || e instanceof Error);
  25820. }
  25821. exports.isError = isError;
  25822. function isFunction(arg) {
  25823. return typeof arg === 'function';
  25824. }
  25825. exports.isFunction = isFunction;
  25826. function isPrimitive(arg) {
  25827. return arg === null ||
  25828. typeof arg === 'boolean' ||
  25829. typeof arg === 'number' ||
  25830. typeof arg === 'string' ||
  25831. typeof arg === 'symbol' || // ES6 symbol
  25832. typeof arg === 'undefined';
  25833. }
  25834. exports.isPrimitive = isPrimitive;
  25835. exports.isBuffer = require('./support/isBuffer');
  25836. function objectToString(o) {
  25837. return Object.prototype.toString.call(o);
  25838. }
  25839. function pad(n) {
  25840. return n < 10 ? '0' + n.toString(10) : n.toString(10);
  25841. }
  25842. var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
  25843. 'Oct', 'Nov', 'Dec'];
  25844. // 26 Feb 16:19:34
  25845. function timestamp() {
  25846. var d = new Date();
  25847. var time = [pad(d.getHours()),
  25848. pad(d.getMinutes()),
  25849. pad(d.getSeconds())].join(':');
  25850. return [d.getDate(), months[d.getMonth()], time].join(' ');
  25851. }
  25852. // log is just a thin wrapper to console.log that prepends a timestamp
  25853. exports.log = function() {
  25854. console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
  25855. };
  25856. /**
  25857. * Inherit the prototype methods from one constructor into another.
  25858. *
  25859. * The Function.prototype.inherits from lang.js rewritten as a standalone
  25860. * function (not on Function.prototype). NOTE: If this file is to be loaded
  25861. * during bootstrapping this function needs to be rewritten using some native
  25862. * functions as prototype setup using normal JavaScript does not work as
  25863. * expected during bootstrapping (see mirror.js in r114903).
  25864. *
  25865. * @param {function} ctor Constructor function which needs to inherit the
  25866. * prototype.
  25867. * @param {function} superCtor Constructor function to inherit prototype from.
  25868. */
  25869. exports.inherits = require('inherits');
  25870. exports._extend = function(origin, add) {
  25871. // Don't do anything if add isn't an object
  25872. if (!add || !isObject(add)) return origin;
  25873. var keys = Object.keys(add);
  25874. var i = keys.length;
  25875. while (i--) {
  25876. origin[keys[i]] = add[keys[i]];
  25877. }
  25878. return origin;
  25879. };
  25880. function hasOwnProperty(obj, prop) {
  25881. return Object.prototype.hasOwnProperty.call(obj, prop);
  25882. }
  25883. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  25884. },{"./support/isBuffer":345,"_process":393,"inherits":344}],347:[function(require,module,exports){
  25885. // Generated by CoffeeScript 1.12.7
  25886. (function() {
  25887. "use strict";
  25888. exports.stripBOM = function(str) {
  25889. if (str[0] === '\uFEFF') {
  25890. return str.substring(1);
  25891. } else {
  25892. return str;
  25893. }
  25894. };
  25895. }).call(this);
  25896. },{}],348:[function(require,module,exports){
  25897. // Generated by CoffeeScript 1.12.7
  25898. (function() {
  25899. "use strict";
  25900. var builder, defaults, escapeCDATA, requiresCDATA, wrapCDATA,
  25901. hasProp = {}.hasOwnProperty;
  25902. builder = require('xmlbuilder');
  25903. defaults = require('./defaults').defaults;
  25904. requiresCDATA = function(entry) {
  25905. return typeof entry === "string" && (entry.indexOf('&') >= 0 || entry.indexOf('>') >= 0 || entry.indexOf('<') >= 0);
  25906. };
  25907. wrapCDATA = function(entry) {
  25908. return "<![CDATA[" + (escapeCDATA(entry)) + "]]>";
  25909. };
  25910. escapeCDATA = function(entry) {
  25911. return entry.replace(']]>', ']]]]><![CDATA[>');
  25912. };
  25913. exports.Builder = (function() {
  25914. function Builder(opts) {
  25915. var key, ref, value;
  25916. this.options = {};
  25917. ref = defaults["0.2"];
  25918. for (key in ref) {
  25919. if (!hasProp.call(ref, key)) continue;
  25920. value = ref[key];
  25921. this.options[key] = value;
  25922. }
  25923. for (key in opts) {
  25924. if (!hasProp.call(opts, key)) continue;
  25925. value = opts[key];
  25926. this.options[key] = value;
  25927. }
  25928. }
  25929. Builder.prototype.buildObject = function(rootObj) {
  25930. var attrkey, charkey, render, rootElement, rootName;
  25931. attrkey = this.options.attrkey;
  25932. charkey = this.options.charkey;
  25933. if ((Object.keys(rootObj).length === 1) && (this.options.rootName === defaults['0.2'].rootName)) {
  25934. rootName = Object.keys(rootObj)[0];
  25935. rootObj = rootObj[rootName];
  25936. } else {
  25937. rootName = this.options.rootName;
  25938. }
  25939. render = (function(_this) {
  25940. return function(element, obj) {
  25941. var attr, child, entry, index, key, value;
  25942. if (typeof obj !== 'object') {
  25943. if (_this.options.cdata && requiresCDATA(obj)) {
  25944. element.raw(wrapCDATA(obj));
  25945. } else {
  25946. element.txt(obj);
  25947. }
  25948. } else if (Array.isArray(obj)) {
  25949. for (index in obj) {
  25950. if (!hasProp.call(obj, index)) continue;
  25951. child = obj[index];
  25952. for (key in child) {
  25953. entry = child[key];
  25954. element = render(element.ele(key), entry).up();
  25955. }
  25956. }
  25957. } else {
  25958. for (key in obj) {
  25959. if (!hasProp.call(obj, key)) continue;
  25960. child = obj[key];
  25961. if (key === attrkey) {
  25962. if (typeof child === "object") {
  25963. for (attr in child) {
  25964. value = child[attr];
  25965. element = element.att(attr, value);
  25966. }
  25967. }
  25968. } else if (key === charkey) {
  25969. if (_this.options.cdata && requiresCDATA(child)) {
  25970. element = element.raw(wrapCDATA(child));
  25971. } else {
  25972. element = element.txt(child);
  25973. }
  25974. } else if (Array.isArray(child)) {
  25975. for (index in child) {
  25976. if (!hasProp.call(child, index)) continue;
  25977. entry = child[index];
  25978. if (typeof entry === 'string') {
  25979. if (_this.options.cdata && requiresCDATA(entry)) {
  25980. element = element.ele(key).raw(wrapCDATA(entry)).up();
  25981. } else {
  25982. element = element.ele(key, entry).up();
  25983. }
  25984. } else {
  25985. element = render(element.ele(key), entry).up();
  25986. }
  25987. }
  25988. } else if (typeof child === "object") {
  25989. element = render(element.ele(key), child).up();
  25990. } else {
  25991. if (typeof child === 'string' && _this.options.cdata && requiresCDATA(child)) {
  25992. element = element.ele(key).raw(wrapCDATA(child)).up();
  25993. } else {
  25994. if (child == null) {
  25995. child = '';
  25996. }
  25997. element = element.ele(key, child.toString()).up();
  25998. }
  25999. }
  26000. }
  26001. }
  26002. return element;
  26003. };
  26004. })(this);
  26005. rootElement = builder.create(rootName, this.options.xmldec, this.options.doctype, {
  26006. headless: this.options.headless,
  26007. allowSurrogateChars: this.options.allowSurrogateChars
  26008. });
  26009. return render(rootElement, rootObj).end(this.options.renderOpts);
  26010. };
  26011. return Builder;
  26012. })();
  26013. }).call(this);
  26014. },{"./defaults":349,"xmlbuilder":385}],349:[function(require,module,exports){
  26015. // Generated by CoffeeScript 1.12.7
  26016. (function() {
  26017. exports.defaults = {
  26018. "0.1": {
  26019. explicitCharkey: false,
  26020. trim: true,
  26021. normalize: true,
  26022. normalizeTags: false,
  26023. attrkey: "@",
  26024. charkey: "#",
  26025. explicitArray: false,
  26026. ignoreAttrs: false,
  26027. mergeAttrs: false,
  26028. explicitRoot: false,
  26029. validator: null,
  26030. xmlns: false,
  26031. explicitChildren: false,
  26032. childkey: '@@',
  26033. charsAsChildren: false,
  26034. includeWhiteChars: false,
  26035. async: false,
  26036. strict: true,
  26037. attrNameProcessors: null,
  26038. attrValueProcessors: null,
  26039. tagNameProcessors: null,
  26040. valueProcessors: null,
  26041. emptyTag: ''
  26042. },
  26043. "0.2": {
  26044. explicitCharkey: false,
  26045. trim: false,
  26046. normalize: false,
  26047. normalizeTags: false,
  26048. attrkey: "$",
  26049. charkey: "_",
  26050. explicitArray: true,
  26051. ignoreAttrs: false,
  26052. mergeAttrs: false,
  26053. explicitRoot: true,
  26054. validator: null,
  26055. xmlns: false,
  26056. explicitChildren: false,
  26057. preserveChildrenOrder: false,
  26058. childkey: '$$',
  26059. charsAsChildren: false,
  26060. includeWhiteChars: false,
  26061. async: false,
  26062. strict: true,
  26063. attrNameProcessors: null,
  26064. attrValueProcessors: null,
  26065. tagNameProcessors: null,
  26066. valueProcessors: null,
  26067. rootName: 'root',
  26068. xmldec: {
  26069. 'version': '1.0',
  26070. 'encoding': 'UTF-8',
  26071. 'standalone': true
  26072. },
  26073. doctype: null,
  26074. renderOpts: {
  26075. 'pretty': true,
  26076. 'indent': ' ',
  26077. 'newline': '\n'
  26078. },
  26079. headless: false,
  26080. chunkSize: 10000,
  26081. emptyTag: '',
  26082. cdata: false
  26083. }
  26084. };
  26085. }).call(this);
  26086. },{}],350:[function(require,module,exports){
  26087. // Generated by CoffeeScript 1.12.7
  26088. (function() {
  26089. "use strict";
  26090. var bom, defaults, events, isEmpty, processItem, processors, sax, setImmediate,
  26091. bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  26092. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  26093. hasProp = {}.hasOwnProperty;
  26094. sax = require('sax');
  26095. events = require('events');
  26096. bom = require('./bom');
  26097. processors = require('./processors');
  26098. setImmediate = require('timers').setImmediate;
  26099. defaults = require('./defaults').defaults;
  26100. isEmpty = function(thing) {
  26101. return typeof thing === "object" && (thing != null) && Object.keys(thing).length === 0;
  26102. };
  26103. processItem = function(processors, item, key) {
  26104. var i, len, process;
  26105. for (i = 0, len = processors.length; i < len; i++) {
  26106. process = processors[i];
  26107. item = process(item, key);
  26108. }
  26109. return item;
  26110. };
  26111. exports.Parser = (function(superClass) {
  26112. extend(Parser, superClass);
  26113. function Parser(opts) {
  26114. this.parseStringPromise = bind(this.parseStringPromise, this);
  26115. this.parseString = bind(this.parseString, this);
  26116. this.reset = bind(this.reset, this);
  26117. this.assignOrPush = bind(this.assignOrPush, this);
  26118. this.processAsync = bind(this.processAsync, this);
  26119. var key, ref, value;
  26120. if (!(this instanceof exports.Parser)) {
  26121. return new exports.Parser(opts);
  26122. }
  26123. this.options = {};
  26124. ref = defaults["0.2"];
  26125. for (key in ref) {
  26126. if (!hasProp.call(ref, key)) continue;
  26127. value = ref[key];
  26128. this.options[key] = value;
  26129. }
  26130. for (key in opts) {
  26131. if (!hasProp.call(opts, key)) continue;
  26132. value = opts[key];
  26133. this.options[key] = value;
  26134. }
  26135. if (this.options.xmlns) {
  26136. this.options.xmlnskey = this.options.attrkey + "ns";
  26137. }
  26138. if (this.options.normalizeTags) {
  26139. if (!this.options.tagNameProcessors) {
  26140. this.options.tagNameProcessors = [];
  26141. }
  26142. this.options.tagNameProcessors.unshift(processors.normalize);
  26143. }
  26144. this.reset();
  26145. }
  26146. Parser.prototype.processAsync = function() {
  26147. var chunk, err;
  26148. try {
  26149. if (this.remaining.length <= this.options.chunkSize) {
  26150. chunk = this.remaining;
  26151. this.remaining = '';
  26152. this.saxParser = this.saxParser.write(chunk);
  26153. return this.saxParser.close();
  26154. } else {
  26155. chunk = this.remaining.substr(0, this.options.chunkSize);
  26156. this.remaining = this.remaining.substr(this.options.chunkSize, this.remaining.length);
  26157. this.saxParser = this.saxParser.write(chunk);
  26158. return setImmediate(this.processAsync);
  26159. }
  26160. } catch (error1) {
  26161. err = error1;
  26162. if (!this.saxParser.errThrown) {
  26163. this.saxParser.errThrown = true;
  26164. return this.emit(err);
  26165. }
  26166. }
  26167. };
  26168. Parser.prototype.assignOrPush = function(obj, key, newValue) {
  26169. if (!(key in obj)) {
  26170. if (!this.options.explicitArray) {
  26171. return obj[key] = newValue;
  26172. } else {
  26173. return obj[key] = [newValue];
  26174. }
  26175. } else {
  26176. if (!(obj[key] instanceof Array)) {
  26177. obj[key] = [obj[key]];
  26178. }
  26179. return obj[key].push(newValue);
  26180. }
  26181. };
  26182. Parser.prototype.reset = function() {
  26183. var attrkey, charkey, ontext, stack;
  26184. this.removeAllListeners();
  26185. this.saxParser = sax.parser(this.options.strict, {
  26186. trim: false,
  26187. normalize: false,
  26188. xmlns: this.options.xmlns
  26189. });
  26190. this.saxParser.errThrown = false;
  26191. this.saxParser.onerror = (function(_this) {
  26192. return function(error) {
  26193. _this.saxParser.resume();
  26194. if (!_this.saxParser.errThrown) {
  26195. _this.saxParser.errThrown = true;
  26196. return _this.emit("error", error);
  26197. }
  26198. };
  26199. })(this);
  26200. this.saxParser.onend = (function(_this) {
  26201. return function() {
  26202. if (!_this.saxParser.ended) {
  26203. _this.saxParser.ended = true;
  26204. return _this.emit("end", _this.resultObject);
  26205. }
  26206. };
  26207. })(this);
  26208. this.saxParser.ended = false;
  26209. this.EXPLICIT_CHARKEY = this.options.explicitCharkey;
  26210. this.resultObject = null;
  26211. stack = [];
  26212. attrkey = this.options.attrkey;
  26213. charkey = this.options.charkey;
  26214. this.saxParser.onopentag = (function(_this) {
  26215. return function(node) {
  26216. var key, newValue, obj, processedKey, ref;
  26217. obj = {};
  26218. obj[charkey] = "";
  26219. if (!_this.options.ignoreAttrs) {
  26220. ref = node.attributes;
  26221. for (key in ref) {
  26222. if (!hasProp.call(ref, key)) continue;
  26223. if (!(attrkey in obj) && !_this.options.mergeAttrs) {
  26224. obj[attrkey] = {};
  26225. }
  26226. newValue = _this.options.attrValueProcessors ? processItem(_this.options.attrValueProcessors, node.attributes[key], key) : node.attributes[key];
  26227. processedKey = _this.options.attrNameProcessors ? processItem(_this.options.attrNameProcessors, key) : key;
  26228. if (_this.options.mergeAttrs) {
  26229. _this.assignOrPush(obj, processedKey, newValue);
  26230. } else {
  26231. obj[attrkey][processedKey] = newValue;
  26232. }
  26233. }
  26234. }
  26235. obj["#name"] = _this.options.tagNameProcessors ? processItem(_this.options.tagNameProcessors, node.name) : node.name;
  26236. if (_this.options.xmlns) {
  26237. obj[_this.options.xmlnskey] = {
  26238. uri: node.uri,
  26239. local: node.local
  26240. };
  26241. }
  26242. return stack.push(obj);
  26243. };
  26244. })(this);
  26245. this.saxParser.onclosetag = (function(_this) {
  26246. return function() {
  26247. var cdata, emptyStr, key, node, nodeName, obj, objClone, old, s, xpath;
  26248. obj = stack.pop();
  26249. nodeName = obj["#name"];
  26250. if (!_this.options.explicitChildren || !_this.options.preserveChildrenOrder) {
  26251. delete obj["#name"];
  26252. }
  26253. if (obj.cdata === true) {
  26254. cdata = obj.cdata;
  26255. delete obj.cdata;
  26256. }
  26257. s = stack[stack.length - 1];
  26258. if (obj[charkey].match(/^\s*$/) && !cdata) {
  26259. emptyStr = obj[charkey];
  26260. delete obj[charkey];
  26261. } else {
  26262. if (_this.options.trim) {
  26263. obj[charkey] = obj[charkey].trim();
  26264. }
  26265. if (_this.options.normalize) {
  26266. obj[charkey] = obj[charkey].replace(/\s{2,}/g, " ").trim();
  26267. }
  26268. obj[charkey] = _this.options.valueProcessors ? processItem(_this.options.valueProcessors, obj[charkey], nodeName) : obj[charkey];
  26269. if (Object.keys(obj).length === 1 && charkey in obj && !_this.EXPLICIT_CHARKEY) {
  26270. obj = obj[charkey];
  26271. }
  26272. }
  26273. if (isEmpty(obj)) {
  26274. obj = _this.options.emptyTag !== '' ? _this.options.emptyTag : emptyStr;
  26275. }
  26276. if (_this.options.validator != null) {
  26277. xpath = "/" + ((function() {
  26278. var i, len, results;
  26279. results = [];
  26280. for (i = 0, len = stack.length; i < len; i++) {
  26281. node = stack[i];
  26282. results.push(node["#name"]);
  26283. }
  26284. return results;
  26285. })()).concat(nodeName).join("/");
  26286. (function() {
  26287. var err;
  26288. try {
  26289. return obj = _this.options.validator(xpath, s && s[nodeName], obj);
  26290. } catch (error1) {
  26291. err = error1;
  26292. return _this.emit("error", err);
  26293. }
  26294. })();
  26295. }
  26296. if (_this.options.explicitChildren && !_this.options.mergeAttrs && typeof obj === 'object') {
  26297. if (!_this.options.preserveChildrenOrder) {
  26298. node = {};
  26299. if (_this.options.attrkey in obj) {
  26300. node[_this.options.attrkey] = obj[_this.options.attrkey];
  26301. delete obj[_this.options.attrkey];
  26302. }
  26303. if (!_this.options.charsAsChildren && _this.options.charkey in obj) {
  26304. node[_this.options.charkey] = obj[_this.options.charkey];
  26305. delete obj[_this.options.charkey];
  26306. }
  26307. if (Object.getOwnPropertyNames(obj).length > 0) {
  26308. node[_this.options.childkey] = obj;
  26309. }
  26310. obj = node;
  26311. } else if (s) {
  26312. s[_this.options.childkey] = s[_this.options.childkey] || [];
  26313. objClone = {};
  26314. for (key in obj) {
  26315. if (!hasProp.call(obj, key)) continue;
  26316. objClone[key] = obj[key];
  26317. }
  26318. s[_this.options.childkey].push(objClone);
  26319. delete obj["#name"];
  26320. if (Object.keys(obj).length === 1 && charkey in obj && !_this.EXPLICIT_CHARKEY) {
  26321. obj = obj[charkey];
  26322. }
  26323. }
  26324. }
  26325. if (stack.length > 0) {
  26326. return _this.assignOrPush(s, nodeName, obj);
  26327. } else {
  26328. if (_this.options.explicitRoot) {
  26329. old = obj;
  26330. obj = {};
  26331. obj[nodeName] = old;
  26332. }
  26333. _this.resultObject = obj;
  26334. _this.saxParser.ended = true;
  26335. return _this.emit("end", _this.resultObject);
  26336. }
  26337. };
  26338. })(this);
  26339. ontext = (function(_this) {
  26340. return function(text) {
  26341. var charChild, s;
  26342. s = stack[stack.length - 1];
  26343. if (s) {
  26344. s[charkey] += text;
  26345. if (_this.options.explicitChildren && _this.options.preserveChildrenOrder && _this.options.charsAsChildren && (_this.options.includeWhiteChars || text.replace(/\\n/g, '').trim() !== '')) {
  26346. s[_this.options.childkey] = s[_this.options.childkey] || [];
  26347. charChild = {
  26348. '#name': '__text__'
  26349. };
  26350. charChild[charkey] = text;
  26351. if (_this.options.normalize) {
  26352. charChild[charkey] = charChild[charkey].replace(/\s{2,}/g, " ").trim();
  26353. }
  26354. s[_this.options.childkey].push(charChild);
  26355. }
  26356. return s;
  26357. }
  26358. };
  26359. })(this);
  26360. this.saxParser.ontext = ontext;
  26361. return this.saxParser.oncdata = (function(_this) {
  26362. return function(text) {
  26363. var s;
  26364. s = ontext(text);
  26365. if (s) {
  26366. return s.cdata = true;
  26367. }
  26368. };
  26369. })(this);
  26370. };
  26371. Parser.prototype.parseString = function(str, cb) {
  26372. var err;
  26373. if ((cb != null) && typeof cb === "function") {
  26374. this.on("end", function(result) {
  26375. this.reset();
  26376. return cb(null, result);
  26377. });
  26378. this.on("error", function(err) {
  26379. this.reset();
  26380. return cb(err);
  26381. });
  26382. }
  26383. try {
  26384. str = str.toString();
  26385. if (str.trim() === '') {
  26386. this.emit("end", null);
  26387. return true;
  26388. }
  26389. str = bom.stripBOM(str);
  26390. if (this.options.async) {
  26391. this.remaining = str;
  26392. setImmediate(this.processAsync);
  26393. return this.saxParser;
  26394. }
  26395. return this.saxParser.write(str).close();
  26396. } catch (error1) {
  26397. err = error1;
  26398. if (!(this.saxParser.errThrown || this.saxParser.ended)) {
  26399. this.emit('error', err);
  26400. return this.saxParser.errThrown = true;
  26401. } else if (this.saxParser.ended) {
  26402. throw err;
  26403. }
  26404. }
  26405. };
  26406. Parser.prototype.parseStringPromise = function(str) {
  26407. return new Promise((function(_this) {
  26408. return function(resolve, reject) {
  26409. return _this.parseString(str, function(err, value) {
  26410. if (err) {
  26411. return reject(err);
  26412. } else {
  26413. return resolve(value);
  26414. }
  26415. });
  26416. };
  26417. })(this));
  26418. };
  26419. return Parser;
  26420. })(events);
  26421. exports.parseString = function(str, a, b) {
  26422. var cb, options, parser;
  26423. if (b != null) {
  26424. if (typeof b === 'function') {
  26425. cb = b;
  26426. }
  26427. if (typeof a === 'object') {
  26428. options = a;
  26429. }
  26430. } else {
  26431. if (typeof a === 'function') {
  26432. cb = a;
  26433. }
  26434. options = {};
  26435. }
  26436. parser = new exports.Parser(options);
  26437. return parser.parseString(str, cb);
  26438. };
  26439. exports.parseStringPromise = function(str, a) {
  26440. var options, parser;
  26441. if (typeof a === 'object') {
  26442. options = a;
  26443. }
  26444. parser = new exports.Parser(options);
  26445. return parser.parseStringPromise(str);
  26446. };
  26447. }).call(this);
  26448. },{"./bom":347,"./defaults":349,"./processors":351,"events":297,"sax":339,"timers":342}],351:[function(require,module,exports){
  26449. // Generated by CoffeeScript 1.12.7
  26450. (function() {
  26451. "use strict";
  26452. var prefixMatch;
  26453. prefixMatch = new RegExp(/(?!xmlns)^.*:/);
  26454. exports.normalize = function(str) {
  26455. return str.toLowerCase();
  26456. };
  26457. exports.firstCharLowerCase = function(str) {
  26458. return str.charAt(0).toLowerCase() + str.slice(1);
  26459. };
  26460. exports.stripPrefix = function(str) {
  26461. return str.replace(prefixMatch, '');
  26462. };
  26463. exports.parseNumbers = function(str) {
  26464. if (!isNaN(str)) {
  26465. str = str % 1 === 0 ? parseInt(str, 10) : parseFloat(str);
  26466. }
  26467. return str;
  26468. };
  26469. exports.parseBooleans = function(str) {
  26470. if (/^(?:true|false)$/i.test(str)) {
  26471. str = str.toLowerCase() === 'true';
  26472. }
  26473. return str;
  26474. };
  26475. }).call(this);
  26476. },{}],352:[function(require,module,exports){
  26477. // Generated by CoffeeScript 1.12.7
  26478. (function() {
  26479. "use strict";
  26480. var builder, defaults, parser, processors,
  26481. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  26482. hasProp = {}.hasOwnProperty;
  26483. defaults = require('./defaults');
  26484. builder = require('./builder');
  26485. parser = require('./parser');
  26486. processors = require('./processors');
  26487. exports.defaults = defaults.defaults;
  26488. exports.processors = processors;
  26489. exports.ValidationError = (function(superClass) {
  26490. extend(ValidationError, superClass);
  26491. function ValidationError(message) {
  26492. this.message = message;
  26493. }
  26494. return ValidationError;
  26495. })(Error);
  26496. exports.Builder = builder.Builder;
  26497. exports.Parser = parser.Parser;
  26498. exports.parseString = parser.parseString;
  26499. exports.parseStringPromise = parser.parseStringPromise;
  26500. }).call(this);
  26501. },{"./builder":348,"./defaults":349,"./parser":350,"./processors":351}],353:[function(require,module,exports){
  26502. // Generated by CoffeeScript 1.12.7
  26503. (function() {
  26504. module.exports = {
  26505. Disconnected: 1,
  26506. Preceding: 2,
  26507. Following: 4,
  26508. Contains: 8,
  26509. ContainedBy: 16,
  26510. ImplementationSpecific: 32
  26511. };
  26512. }).call(this);
  26513. },{}],354:[function(require,module,exports){
  26514. // Generated by CoffeeScript 1.12.7
  26515. (function() {
  26516. module.exports = {
  26517. Element: 1,
  26518. Attribute: 2,
  26519. Text: 3,
  26520. CData: 4,
  26521. EntityReference: 5,
  26522. EntityDeclaration: 6,
  26523. ProcessingInstruction: 7,
  26524. Comment: 8,
  26525. Document: 9,
  26526. DocType: 10,
  26527. DocumentFragment: 11,
  26528. NotationDeclaration: 12,
  26529. Declaration: 201,
  26530. Raw: 202,
  26531. AttributeDeclaration: 203,
  26532. ElementDeclaration: 204,
  26533. Dummy: 205
  26534. };
  26535. }).call(this);
  26536. },{}],355:[function(require,module,exports){
  26537. // Generated by CoffeeScript 1.12.7
  26538. (function() {
  26539. var assign, getValue, isArray, isEmpty, isFunction, isObject, isPlainObject,
  26540. slice = [].slice,
  26541. hasProp = {}.hasOwnProperty;
  26542. assign = function() {
  26543. var i, key, len, source, sources, target;
  26544. target = arguments[0], sources = 2 <= arguments.length ? slice.call(arguments, 1) : [];
  26545. if (isFunction(Object.assign)) {
  26546. Object.assign.apply(null, arguments);
  26547. } else {
  26548. for (i = 0, len = sources.length; i < len; i++) {
  26549. source = sources[i];
  26550. if (source != null) {
  26551. for (key in source) {
  26552. if (!hasProp.call(source, key)) continue;
  26553. target[key] = source[key];
  26554. }
  26555. }
  26556. }
  26557. }
  26558. return target;
  26559. };
  26560. isFunction = function(val) {
  26561. return !!val && Object.prototype.toString.call(val) === '[object Function]';
  26562. };
  26563. isObject = function(val) {
  26564. var ref;
  26565. return !!val && ((ref = typeof val) === 'function' || ref === 'object');
  26566. };
  26567. isArray = function(val) {
  26568. if (isFunction(Array.isArray)) {
  26569. return Array.isArray(val);
  26570. } else {
  26571. return Object.prototype.toString.call(val) === '[object Array]';
  26572. }
  26573. };
  26574. isEmpty = function(val) {
  26575. var key;
  26576. if (isArray(val)) {
  26577. return !val.length;
  26578. } else {
  26579. for (key in val) {
  26580. if (!hasProp.call(val, key)) continue;
  26581. return false;
  26582. }
  26583. return true;
  26584. }
  26585. };
  26586. isPlainObject = function(val) {
  26587. var ctor, proto;
  26588. return isObject(val) && (proto = Object.getPrototypeOf(val)) && (ctor = proto.constructor) && (typeof ctor === 'function') && (ctor instanceof ctor) && (Function.prototype.toString.call(ctor) === Function.prototype.toString.call(Object));
  26589. };
  26590. getValue = function(obj) {
  26591. if (isFunction(obj.valueOf)) {
  26592. return obj.valueOf();
  26593. } else {
  26594. return obj;
  26595. }
  26596. };
  26597. module.exports.assign = assign;
  26598. module.exports.isFunction = isFunction;
  26599. module.exports.isObject = isObject;
  26600. module.exports.isArray = isArray;
  26601. module.exports.isEmpty = isEmpty;
  26602. module.exports.isPlainObject = isPlainObject;
  26603. module.exports.getValue = getValue;
  26604. }).call(this);
  26605. },{}],356:[function(require,module,exports){
  26606. // Generated by CoffeeScript 1.12.7
  26607. (function() {
  26608. module.exports = {
  26609. None: 0,
  26610. OpenTag: 1,
  26611. InsideTag: 2,
  26612. CloseTag: 3
  26613. };
  26614. }).call(this);
  26615. },{}],357:[function(require,module,exports){
  26616. // Generated by CoffeeScript 1.12.7
  26617. (function() {
  26618. var NodeType, XMLAttribute, XMLNode;
  26619. NodeType = require('./NodeType');
  26620. XMLNode = require('./XMLNode');
  26621. module.exports = XMLAttribute = (function() {
  26622. function XMLAttribute(parent, name, value) {
  26623. this.parent = parent;
  26624. if (this.parent) {
  26625. this.options = this.parent.options;
  26626. this.stringify = this.parent.stringify;
  26627. }
  26628. if (name == null) {
  26629. throw new Error("Missing attribute name. " + this.debugInfo(name));
  26630. }
  26631. this.name = this.stringify.name(name);
  26632. this.value = this.stringify.attValue(value);
  26633. this.type = NodeType.Attribute;
  26634. this.isId = false;
  26635. this.schemaTypeInfo = null;
  26636. }
  26637. Object.defineProperty(XMLAttribute.prototype, 'nodeType', {
  26638. get: function() {
  26639. return this.type;
  26640. }
  26641. });
  26642. Object.defineProperty(XMLAttribute.prototype, 'ownerElement', {
  26643. get: function() {
  26644. return this.parent;
  26645. }
  26646. });
  26647. Object.defineProperty(XMLAttribute.prototype, 'textContent', {
  26648. get: function() {
  26649. return this.value;
  26650. },
  26651. set: function(value) {
  26652. return this.value = value || '';
  26653. }
  26654. });
  26655. Object.defineProperty(XMLAttribute.prototype, 'namespaceURI', {
  26656. get: function() {
  26657. return '';
  26658. }
  26659. });
  26660. Object.defineProperty(XMLAttribute.prototype, 'prefix', {
  26661. get: function() {
  26662. return '';
  26663. }
  26664. });
  26665. Object.defineProperty(XMLAttribute.prototype, 'localName', {
  26666. get: function() {
  26667. return this.name;
  26668. }
  26669. });
  26670. Object.defineProperty(XMLAttribute.prototype, 'specified', {
  26671. get: function() {
  26672. return true;
  26673. }
  26674. });
  26675. XMLAttribute.prototype.clone = function() {
  26676. return Object.create(this);
  26677. };
  26678. XMLAttribute.prototype.toString = function(options) {
  26679. return this.options.writer.attribute(this, this.options.writer.filterOptions(options));
  26680. };
  26681. XMLAttribute.prototype.debugInfo = function(name) {
  26682. name = name || this.name;
  26683. if (name == null) {
  26684. return "parent: <" + this.parent.name + ">";
  26685. } else {
  26686. return "attribute: {" + name + "}, parent: <" + this.parent.name + ">";
  26687. }
  26688. };
  26689. XMLAttribute.prototype.isEqualNode = function(node) {
  26690. if (node.namespaceURI !== this.namespaceURI) {
  26691. return false;
  26692. }
  26693. if (node.prefix !== this.prefix) {
  26694. return false;
  26695. }
  26696. if (node.localName !== this.localName) {
  26697. return false;
  26698. }
  26699. if (node.value !== this.value) {
  26700. return false;
  26701. }
  26702. return true;
  26703. };
  26704. return XMLAttribute;
  26705. })();
  26706. }).call(this);
  26707. },{"./NodeType":354,"./XMLNode":376}],358:[function(require,module,exports){
  26708. // Generated by CoffeeScript 1.12.7
  26709. (function() {
  26710. var NodeType, XMLCData, XMLCharacterData,
  26711. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  26712. hasProp = {}.hasOwnProperty;
  26713. NodeType = require('./NodeType');
  26714. XMLCharacterData = require('./XMLCharacterData');
  26715. module.exports = XMLCData = (function(superClass) {
  26716. extend(XMLCData, superClass);
  26717. function XMLCData(parent, text) {
  26718. XMLCData.__super__.constructor.call(this, parent);
  26719. if (text == null) {
  26720. throw new Error("Missing CDATA text. " + this.debugInfo());
  26721. }
  26722. this.name = "#cdata-section";
  26723. this.type = NodeType.CData;
  26724. this.value = this.stringify.cdata(text);
  26725. }
  26726. XMLCData.prototype.clone = function() {
  26727. return Object.create(this);
  26728. };
  26729. XMLCData.prototype.toString = function(options) {
  26730. return this.options.writer.cdata(this, this.options.writer.filterOptions(options));
  26731. };
  26732. return XMLCData;
  26733. })(XMLCharacterData);
  26734. }).call(this);
  26735. },{"./NodeType":354,"./XMLCharacterData":359}],359:[function(require,module,exports){
  26736. // Generated by CoffeeScript 1.12.7
  26737. (function() {
  26738. var XMLCharacterData, XMLNode,
  26739. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  26740. hasProp = {}.hasOwnProperty;
  26741. XMLNode = require('./XMLNode');
  26742. module.exports = XMLCharacterData = (function(superClass) {
  26743. extend(XMLCharacterData, superClass);
  26744. function XMLCharacterData(parent) {
  26745. XMLCharacterData.__super__.constructor.call(this, parent);
  26746. this.value = '';
  26747. }
  26748. Object.defineProperty(XMLCharacterData.prototype, 'data', {
  26749. get: function() {
  26750. return this.value;
  26751. },
  26752. set: function(value) {
  26753. return this.value = value || '';
  26754. }
  26755. });
  26756. Object.defineProperty(XMLCharacterData.prototype, 'length', {
  26757. get: function() {
  26758. return this.value.length;
  26759. }
  26760. });
  26761. Object.defineProperty(XMLCharacterData.prototype, 'textContent', {
  26762. get: function() {
  26763. return this.value;
  26764. },
  26765. set: function(value) {
  26766. return this.value = value || '';
  26767. }
  26768. });
  26769. XMLCharacterData.prototype.clone = function() {
  26770. return Object.create(this);
  26771. };
  26772. XMLCharacterData.prototype.substringData = function(offset, count) {
  26773. throw new Error("This DOM method is not implemented." + this.debugInfo());
  26774. };
  26775. XMLCharacterData.prototype.appendData = function(arg) {
  26776. throw new Error("This DOM method is not implemented." + this.debugInfo());
  26777. };
  26778. XMLCharacterData.prototype.insertData = function(offset, arg) {
  26779. throw new Error("This DOM method is not implemented." + this.debugInfo());
  26780. };
  26781. XMLCharacterData.prototype.deleteData = function(offset, count) {
  26782. throw new Error("This DOM method is not implemented." + this.debugInfo());
  26783. };
  26784. XMLCharacterData.prototype.replaceData = function(offset, count, arg) {
  26785. throw new Error("This DOM method is not implemented." + this.debugInfo());
  26786. };
  26787. XMLCharacterData.prototype.isEqualNode = function(node) {
  26788. if (!XMLCharacterData.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) {
  26789. return false;
  26790. }
  26791. if (node.data !== this.data) {
  26792. return false;
  26793. }
  26794. return true;
  26795. };
  26796. return XMLCharacterData;
  26797. })(XMLNode);
  26798. }).call(this);
  26799. },{"./XMLNode":376}],360:[function(require,module,exports){
  26800. // Generated by CoffeeScript 1.12.7
  26801. (function() {
  26802. var NodeType, XMLCharacterData, XMLComment,
  26803. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  26804. hasProp = {}.hasOwnProperty;
  26805. NodeType = require('./NodeType');
  26806. XMLCharacterData = require('./XMLCharacterData');
  26807. module.exports = XMLComment = (function(superClass) {
  26808. extend(XMLComment, superClass);
  26809. function XMLComment(parent, text) {
  26810. XMLComment.__super__.constructor.call(this, parent);
  26811. if (text == null) {
  26812. throw new Error("Missing comment text. " + this.debugInfo());
  26813. }
  26814. this.name = "#comment";
  26815. this.type = NodeType.Comment;
  26816. this.value = this.stringify.comment(text);
  26817. }
  26818. XMLComment.prototype.clone = function() {
  26819. return Object.create(this);
  26820. };
  26821. XMLComment.prototype.toString = function(options) {
  26822. return this.options.writer.comment(this, this.options.writer.filterOptions(options));
  26823. };
  26824. return XMLComment;
  26825. })(XMLCharacterData);
  26826. }).call(this);
  26827. },{"./NodeType":354,"./XMLCharacterData":359}],361:[function(require,module,exports){
  26828. // Generated by CoffeeScript 1.12.7
  26829. (function() {
  26830. var XMLDOMConfiguration, XMLDOMErrorHandler, XMLDOMStringList;
  26831. XMLDOMErrorHandler = require('./XMLDOMErrorHandler');
  26832. XMLDOMStringList = require('./XMLDOMStringList');
  26833. module.exports = XMLDOMConfiguration = (function() {
  26834. function XMLDOMConfiguration() {
  26835. var clonedSelf;
  26836. this.defaultParams = {
  26837. "canonical-form": false,
  26838. "cdata-sections": false,
  26839. "comments": false,
  26840. "datatype-normalization": false,
  26841. "element-content-whitespace": true,
  26842. "entities": true,
  26843. "error-handler": new XMLDOMErrorHandler(),
  26844. "infoset": true,
  26845. "validate-if-schema": false,
  26846. "namespaces": true,
  26847. "namespace-declarations": true,
  26848. "normalize-characters": false,
  26849. "schema-location": '',
  26850. "schema-type": '',
  26851. "split-cdata-sections": true,
  26852. "validate": false,
  26853. "well-formed": true
  26854. };
  26855. this.params = clonedSelf = Object.create(this.defaultParams);
  26856. }
  26857. Object.defineProperty(XMLDOMConfiguration.prototype, 'parameterNames', {
  26858. get: function() {
  26859. return new XMLDOMStringList(Object.keys(this.defaultParams));
  26860. }
  26861. });
  26862. XMLDOMConfiguration.prototype.getParameter = function(name) {
  26863. if (this.params.hasOwnProperty(name)) {
  26864. return this.params[name];
  26865. } else {
  26866. return null;
  26867. }
  26868. };
  26869. XMLDOMConfiguration.prototype.canSetParameter = function(name, value) {
  26870. return true;
  26871. };
  26872. XMLDOMConfiguration.prototype.setParameter = function(name, value) {
  26873. if (value != null) {
  26874. return this.params[name] = value;
  26875. } else {
  26876. return delete this.params[name];
  26877. }
  26878. };
  26879. return XMLDOMConfiguration;
  26880. })();
  26881. }).call(this);
  26882. },{"./XMLDOMErrorHandler":362,"./XMLDOMStringList":364}],362:[function(require,module,exports){
  26883. // Generated by CoffeeScript 1.12.7
  26884. (function() {
  26885. var XMLDOMErrorHandler;
  26886. module.exports = XMLDOMErrorHandler = (function() {
  26887. function XMLDOMErrorHandler() {}
  26888. XMLDOMErrorHandler.prototype.handleError = function(error) {
  26889. throw new Error(error);
  26890. };
  26891. return XMLDOMErrorHandler;
  26892. })();
  26893. }).call(this);
  26894. },{}],363:[function(require,module,exports){
  26895. // Generated by CoffeeScript 1.12.7
  26896. (function() {
  26897. var XMLDOMImplementation;
  26898. module.exports = XMLDOMImplementation = (function() {
  26899. function XMLDOMImplementation() {}
  26900. XMLDOMImplementation.prototype.hasFeature = function(feature, version) {
  26901. return true;
  26902. };
  26903. XMLDOMImplementation.prototype.createDocumentType = function(qualifiedName, publicId, systemId) {
  26904. throw new Error("This DOM method is not implemented.");
  26905. };
  26906. XMLDOMImplementation.prototype.createDocument = function(namespaceURI, qualifiedName, doctype) {
  26907. throw new Error("This DOM method is not implemented.");
  26908. };
  26909. XMLDOMImplementation.prototype.createHTMLDocument = function(title) {
  26910. throw new Error("This DOM method is not implemented.");
  26911. };
  26912. XMLDOMImplementation.prototype.getFeature = function(feature, version) {
  26913. throw new Error("This DOM method is not implemented.");
  26914. };
  26915. return XMLDOMImplementation;
  26916. })();
  26917. }).call(this);
  26918. },{}],364:[function(require,module,exports){
  26919. // Generated by CoffeeScript 1.12.7
  26920. (function() {
  26921. var XMLDOMStringList;
  26922. module.exports = XMLDOMStringList = (function() {
  26923. function XMLDOMStringList(arr) {
  26924. this.arr = arr || [];
  26925. }
  26926. Object.defineProperty(XMLDOMStringList.prototype, 'length', {
  26927. get: function() {
  26928. return this.arr.length;
  26929. }
  26930. });
  26931. XMLDOMStringList.prototype.item = function(index) {
  26932. return this.arr[index] || null;
  26933. };
  26934. XMLDOMStringList.prototype.contains = function(str) {
  26935. return this.arr.indexOf(str) !== -1;
  26936. };
  26937. return XMLDOMStringList;
  26938. })();
  26939. }).call(this);
  26940. },{}],365:[function(require,module,exports){
  26941. // Generated by CoffeeScript 1.12.7
  26942. (function() {
  26943. var NodeType, XMLDTDAttList, XMLNode,
  26944. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  26945. hasProp = {}.hasOwnProperty;
  26946. XMLNode = require('./XMLNode');
  26947. NodeType = require('./NodeType');
  26948. module.exports = XMLDTDAttList = (function(superClass) {
  26949. extend(XMLDTDAttList, superClass);
  26950. function XMLDTDAttList(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) {
  26951. XMLDTDAttList.__super__.constructor.call(this, parent);
  26952. if (elementName == null) {
  26953. throw new Error("Missing DTD element name. " + this.debugInfo());
  26954. }
  26955. if (attributeName == null) {
  26956. throw new Error("Missing DTD attribute name. " + this.debugInfo(elementName));
  26957. }
  26958. if (!attributeType) {
  26959. throw new Error("Missing DTD attribute type. " + this.debugInfo(elementName));
  26960. }
  26961. if (!defaultValueType) {
  26962. throw new Error("Missing DTD attribute default. " + this.debugInfo(elementName));
  26963. }
  26964. if (defaultValueType.indexOf('#') !== 0) {
  26965. defaultValueType = '#' + defaultValueType;
  26966. }
  26967. if (!defaultValueType.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/)) {
  26968. throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT. " + this.debugInfo(elementName));
  26969. }
  26970. if (defaultValue && !defaultValueType.match(/^(#FIXED|#DEFAULT)$/)) {
  26971. throw new Error("Default value only applies to #FIXED or #DEFAULT. " + this.debugInfo(elementName));
  26972. }
  26973. this.elementName = this.stringify.name(elementName);
  26974. this.type = NodeType.AttributeDeclaration;
  26975. this.attributeName = this.stringify.name(attributeName);
  26976. this.attributeType = this.stringify.dtdAttType(attributeType);
  26977. if (defaultValue) {
  26978. this.defaultValue = this.stringify.dtdAttDefault(defaultValue);
  26979. }
  26980. this.defaultValueType = defaultValueType;
  26981. }
  26982. XMLDTDAttList.prototype.toString = function(options) {
  26983. return this.options.writer.dtdAttList(this, this.options.writer.filterOptions(options));
  26984. };
  26985. return XMLDTDAttList;
  26986. })(XMLNode);
  26987. }).call(this);
  26988. },{"./NodeType":354,"./XMLNode":376}],366:[function(require,module,exports){
  26989. // Generated by CoffeeScript 1.12.7
  26990. (function() {
  26991. var NodeType, XMLDTDElement, XMLNode,
  26992. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  26993. hasProp = {}.hasOwnProperty;
  26994. XMLNode = require('./XMLNode');
  26995. NodeType = require('./NodeType');
  26996. module.exports = XMLDTDElement = (function(superClass) {
  26997. extend(XMLDTDElement, superClass);
  26998. function XMLDTDElement(parent, name, value) {
  26999. XMLDTDElement.__super__.constructor.call(this, parent);
  27000. if (name == null) {
  27001. throw new Error("Missing DTD element name. " + this.debugInfo());
  27002. }
  27003. if (!value) {
  27004. value = '(#PCDATA)';
  27005. }
  27006. if (Array.isArray(value)) {
  27007. value = '(' + value.join(',') + ')';
  27008. }
  27009. this.name = this.stringify.name(name);
  27010. this.type = NodeType.ElementDeclaration;
  27011. this.value = this.stringify.dtdElementValue(value);
  27012. }
  27013. XMLDTDElement.prototype.toString = function(options) {
  27014. return this.options.writer.dtdElement(this, this.options.writer.filterOptions(options));
  27015. };
  27016. return XMLDTDElement;
  27017. })(XMLNode);
  27018. }).call(this);
  27019. },{"./NodeType":354,"./XMLNode":376}],367:[function(require,module,exports){
  27020. // Generated by CoffeeScript 1.12.7
  27021. (function() {
  27022. var NodeType, XMLDTDEntity, XMLNode, isObject,
  27023. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  27024. hasProp = {}.hasOwnProperty;
  27025. isObject = require('./Utility').isObject;
  27026. XMLNode = require('./XMLNode');
  27027. NodeType = require('./NodeType');
  27028. module.exports = XMLDTDEntity = (function(superClass) {
  27029. extend(XMLDTDEntity, superClass);
  27030. function XMLDTDEntity(parent, pe, name, value) {
  27031. XMLDTDEntity.__super__.constructor.call(this, parent);
  27032. if (name == null) {
  27033. throw new Error("Missing DTD entity name. " + this.debugInfo(name));
  27034. }
  27035. if (value == null) {
  27036. throw new Error("Missing DTD entity value. " + this.debugInfo(name));
  27037. }
  27038. this.pe = !!pe;
  27039. this.name = this.stringify.name(name);
  27040. this.type = NodeType.EntityDeclaration;
  27041. if (!isObject(value)) {
  27042. this.value = this.stringify.dtdEntityValue(value);
  27043. this.internal = true;
  27044. } else {
  27045. if (!value.pubID && !value.sysID) {
  27046. throw new Error("Public and/or system identifiers are required for an external entity. " + this.debugInfo(name));
  27047. }
  27048. if (value.pubID && !value.sysID) {
  27049. throw new Error("System identifier is required for a public external entity. " + this.debugInfo(name));
  27050. }
  27051. this.internal = false;
  27052. if (value.pubID != null) {
  27053. this.pubID = this.stringify.dtdPubID(value.pubID);
  27054. }
  27055. if (value.sysID != null) {
  27056. this.sysID = this.stringify.dtdSysID(value.sysID);
  27057. }
  27058. if (value.nData != null) {
  27059. this.nData = this.stringify.dtdNData(value.nData);
  27060. }
  27061. if (this.pe && this.nData) {
  27062. throw new Error("Notation declaration is not allowed in a parameter entity. " + this.debugInfo(name));
  27063. }
  27064. }
  27065. }
  27066. Object.defineProperty(XMLDTDEntity.prototype, 'publicId', {
  27067. get: function() {
  27068. return this.pubID;
  27069. }
  27070. });
  27071. Object.defineProperty(XMLDTDEntity.prototype, 'systemId', {
  27072. get: function() {
  27073. return this.sysID;
  27074. }
  27075. });
  27076. Object.defineProperty(XMLDTDEntity.prototype, 'notationName', {
  27077. get: function() {
  27078. return this.nData || null;
  27079. }
  27080. });
  27081. Object.defineProperty(XMLDTDEntity.prototype, 'inputEncoding', {
  27082. get: function() {
  27083. return null;
  27084. }
  27085. });
  27086. Object.defineProperty(XMLDTDEntity.prototype, 'xmlEncoding', {
  27087. get: function() {
  27088. return null;
  27089. }
  27090. });
  27091. Object.defineProperty(XMLDTDEntity.prototype, 'xmlVersion', {
  27092. get: function() {
  27093. return null;
  27094. }
  27095. });
  27096. XMLDTDEntity.prototype.toString = function(options) {
  27097. return this.options.writer.dtdEntity(this, this.options.writer.filterOptions(options));
  27098. };
  27099. return XMLDTDEntity;
  27100. })(XMLNode);
  27101. }).call(this);
  27102. },{"./NodeType":354,"./Utility":355,"./XMLNode":376}],368:[function(require,module,exports){
  27103. // Generated by CoffeeScript 1.12.7
  27104. (function() {
  27105. var NodeType, XMLDTDNotation, XMLNode,
  27106. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  27107. hasProp = {}.hasOwnProperty;
  27108. XMLNode = require('./XMLNode');
  27109. NodeType = require('./NodeType');
  27110. module.exports = XMLDTDNotation = (function(superClass) {
  27111. extend(XMLDTDNotation, superClass);
  27112. function XMLDTDNotation(parent, name, value) {
  27113. XMLDTDNotation.__super__.constructor.call(this, parent);
  27114. if (name == null) {
  27115. throw new Error("Missing DTD notation name. " + this.debugInfo(name));
  27116. }
  27117. if (!value.pubID && !value.sysID) {
  27118. throw new Error("Public or system identifiers are required for an external entity. " + this.debugInfo(name));
  27119. }
  27120. this.name = this.stringify.name(name);
  27121. this.type = NodeType.NotationDeclaration;
  27122. if (value.pubID != null) {
  27123. this.pubID = this.stringify.dtdPubID(value.pubID);
  27124. }
  27125. if (value.sysID != null) {
  27126. this.sysID = this.stringify.dtdSysID(value.sysID);
  27127. }
  27128. }
  27129. Object.defineProperty(XMLDTDNotation.prototype, 'publicId', {
  27130. get: function() {
  27131. return this.pubID;
  27132. }
  27133. });
  27134. Object.defineProperty(XMLDTDNotation.prototype, 'systemId', {
  27135. get: function() {
  27136. return this.sysID;
  27137. }
  27138. });
  27139. XMLDTDNotation.prototype.toString = function(options) {
  27140. return this.options.writer.dtdNotation(this, this.options.writer.filterOptions(options));
  27141. };
  27142. return XMLDTDNotation;
  27143. })(XMLNode);
  27144. }).call(this);
  27145. },{"./NodeType":354,"./XMLNode":376}],369:[function(require,module,exports){
  27146. // Generated by CoffeeScript 1.12.7
  27147. (function() {
  27148. var NodeType, XMLDeclaration, XMLNode, isObject,
  27149. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  27150. hasProp = {}.hasOwnProperty;
  27151. isObject = require('./Utility').isObject;
  27152. XMLNode = require('./XMLNode');
  27153. NodeType = require('./NodeType');
  27154. module.exports = XMLDeclaration = (function(superClass) {
  27155. extend(XMLDeclaration, superClass);
  27156. function XMLDeclaration(parent, version, encoding, standalone) {
  27157. var ref;
  27158. XMLDeclaration.__super__.constructor.call(this, parent);
  27159. if (isObject(version)) {
  27160. ref = version, version = ref.version, encoding = ref.encoding, standalone = ref.standalone;
  27161. }
  27162. if (!version) {
  27163. version = '1.0';
  27164. }
  27165. this.type = NodeType.Declaration;
  27166. this.version = this.stringify.xmlVersion(version);
  27167. if (encoding != null) {
  27168. this.encoding = this.stringify.xmlEncoding(encoding);
  27169. }
  27170. if (standalone != null) {
  27171. this.standalone = this.stringify.xmlStandalone(standalone);
  27172. }
  27173. }
  27174. XMLDeclaration.prototype.toString = function(options) {
  27175. return this.options.writer.declaration(this, this.options.writer.filterOptions(options));
  27176. };
  27177. return XMLDeclaration;
  27178. })(XMLNode);
  27179. }).call(this);
  27180. },{"./NodeType":354,"./Utility":355,"./XMLNode":376}],370:[function(require,module,exports){
  27181. // Generated by CoffeeScript 1.12.7
  27182. (function() {
  27183. var NodeType, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDocType, XMLNamedNodeMap, XMLNode, isObject,
  27184. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  27185. hasProp = {}.hasOwnProperty;
  27186. isObject = require('./Utility').isObject;
  27187. XMLNode = require('./XMLNode');
  27188. NodeType = require('./NodeType');
  27189. XMLDTDAttList = require('./XMLDTDAttList');
  27190. XMLDTDEntity = require('./XMLDTDEntity');
  27191. XMLDTDElement = require('./XMLDTDElement');
  27192. XMLDTDNotation = require('./XMLDTDNotation');
  27193. XMLNamedNodeMap = require('./XMLNamedNodeMap');
  27194. module.exports = XMLDocType = (function(superClass) {
  27195. extend(XMLDocType, superClass);
  27196. function XMLDocType(parent, pubID, sysID) {
  27197. var child, i, len, ref, ref1, ref2;
  27198. XMLDocType.__super__.constructor.call(this, parent);
  27199. this.type = NodeType.DocType;
  27200. if (parent.children) {
  27201. ref = parent.children;
  27202. for (i = 0, len = ref.length; i < len; i++) {
  27203. child = ref[i];
  27204. if (child.type === NodeType.Element) {
  27205. this.name = child.name;
  27206. break;
  27207. }
  27208. }
  27209. }
  27210. this.documentObject = parent;
  27211. if (isObject(pubID)) {
  27212. ref1 = pubID, pubID = ref1.pubID, sysID = ref1.sysID;
  27213. }
  27214. if (sysID == null) {
  27215. ref2 = [pubID, sysID], sysID = ref2[0], pubID = ref2[1];
  27216. }
  27217. if (pubID != null) {
  27218. this.pubID = this.stringify.dtdPubID(pubID);
  27219. }
  27220. if (sysID != null) {
  27221. this.sysID = this.stringify.dtdSysID(sysID);
  27222. }
  27223. }
  27224. Object.defineProperty(XMLDocType.prototype, 'entities', {
  27225. get: function() {
  27226. var child, i, len, nodes, ref;
  27227. nodes = {};
  27228. ref = this.children;
  27229. for (i = 0, len = ref.length; i < len; i++) {
  27230. child = ref[i];
  27231. if ((child.type === NodeType.EntityDeclaration) && !child.pe) {
  27232. nodes[child.name] = child;
  27233. }
  27234. }
  27235. return new XMLNamedNodeMap(nodes);
  27236. }
  27237. });
  27238. Object.defineProperty(XMLDocType.prototype, 'notations', {
  27239. get: function() {
  27240. var child, i, len, nodes, ref;
  27241. nodes = {};
  27242. ref = this.children;
  27243. for (i = 0, len = ref.length; i < len; i++) {
  27244. child = ref[i];
  27245. if (child.type === NodeType.NotationDeclaration) {
  27246. nodes[child.name] = child;
  27247. }
  27248. }
  27249. return new XMLNamedNodeMap(nodes);
  27250. }
  27251. });
  27252. Object.defineProperty(XMLDocType.prototype, 'publicId', {
  27253. get: function() {
  27254. return this.pubID;
  27255. }
  27256. });
  27257. Object.defineProperty(XMLDocType.prototype, 'systemId', {
  27258. get: function() {
  27259. return this.sysID;
  27260. }
  27261. });
  27262. Object.defineProperty(XMLDocType.prototype, 'internalSubset', {
  27263. get: function() {
  27264. throw new Error("This DOM method is not implemented." + this.debugInfo());
  27265. }
  27266. });
  27267. XMLDocType.prototype.element = function(name, value) {
  27268. var child;
  27269. child = new XMLDTDElement(this, name, value);
  27270. this.children.push(child);
  27271. return this;
  27272. };
  27273. XMLDocType.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
  27274. var child;
  27275. child = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
  27276. this.children.push(child);
  27277. return this;
  27278. };
  27279. XMLDocType.prototype.entity = function(name, value) {
  27280. var child;
  27281. child = new XMLDTDEntity(this, false, name, value);
  27282. this.children.push(child);
  27283. return this;
  27284. };
  27285. XMLDocType.prototype.pEntity = function(name, value) {
  27286. var child;
  27287. child = new XMLDTDEntity(this, true, name, value);
  27288. this.children.push(child);
  27289. return this;
  27290. };
  27291. XMLDocType.prototype.notation = function(name, value) {
  27292. var child;
  27293. child = new XMLDTDNotation(this, name, value);
  27294. this.children.push(child);
  27295. return this;
  27296. };
  27297. XMLDocType.prototype.toString = function(options) {
  27298. return this.options.writer.docType(this, this.options.writer.filterOptions(options));
  27299. };
  27300. XMLDocType.prototype.ele = function(name, value) {
  27301. return this.element(name, value);
  27302. };
  27303. XMLDocType.prototype.att = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
  27304. return this.attList(elementName, attributeName, attributeType, defaultValueType, defaultValue);
  27305. };
  27306. XMLDocType.prototype.ent = function(name, value) {
  27307. return this.entity(name, value);
  27308. };
  27309. XMLDocType.prototype.pent = function(name, value) {
  27310. return this.pEntity(name, value);
  27311. };
  27312. XMLDocType.prototype.not = function(name, value) {
  27313. return this.notation(name, value);
  27314. };
  27315. XMLDocType.prototype.up = function() {
  27316. return this.root() || this.documentObject;
  27317. };
  27318. XMLDocType.prototype.isEqualNode = function(node) {
  27319. if (!XMLDocType.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) {
  27320. return false;
  27321. }
  27322. if (node.name !== this.name) {
  27323. return false;
  27324. }
  27325. if (node.publicId !== this.publicId) {
  27326. return false;
  27327. }
  27328. if (node.systemId !== this.systemId) {
  27329. return false;
  27330. }
  27331. return true;
  27332. };
  27333. return XMLDocType;
  27334. })(XMLNode);
  27335. }).call(this);
  27336. },{"./NodeType":354,"./Utility":355,"./XMLDTDAttList":365,"./XMLDTDElement":366,"./XMLDTDEntity":367,"./XMLDTDNotation":368,"./XMLNamedNodeMap":375,"./XMLNode":376}],371:[function(require,module,exports){
  27337. // Generated by CoffeeScript 1.12.7
  27338. (function() {
  27339. var NodeType, XMLDOMConfiguration, XMLDOMImplementation, XMLDocument, XMLNode, XMLStringWriter, XMLStringifier, isPlainObject,
  27340. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  27341. hasProp = {}.hasOwnProperty;
  27342. isPlainObject = require('./Utility').isPlainObject;
  27343. XMLDOMImplementation = require('./XMLDOMImplementation');
  27344. XMLDOMConfiguration = require('./XMLDOMConfiguration');
  27345. XMLNode = require('./XMLNode');
  27346. NodeType = require('./NodeType');
  27347. XMLStringifier = require('./XMLStringifier');
  27348. XMLStringWriter = require('./XMLStringWriter');
  27349. module.exports = XMLDocument = (function(superClass) {
  27350. extend(XMLDocument, superClass);
  27351. function XMLDocument(options) {
  27352. XMLDocument.__super__.constructor.call(this, null);
  27353. this.name = "#document";
  27354. this.type = NodeType.Document;
  27355. this.documentURI = null;
  27356. this.domConfig = new XMLDOMConfiguration();
  27357. options || (options = {});
  27358. if (!options.writer) {
  27359. options.writer = new XMLStringWriter();
  27360. }
  27361. this.options = options;
  27362. this.stringify = new XMLStringifier(options);
  27363. }
  27364. Object.defineProperty(XMLDocument.prototype, 'implementation', {
  27365. value: new XMLDOMImplementation()
  27366. });
  27367. Object.defineProperty(XMLDocument.prototype, 'doctype', {
  27368. get: function() {
  27369. var child, i, len, ref;
  27370. ref = this.children;
  27371. for (i = 0, len = ref.length; i < len; i++) {
  27372. child = ref[i];
  27373. if (child.type === NodeType.DocType) {
  27374. return child;
  27375. }
  27376. }
  27377. return null;
  27378. }
  27379. });
  27380. Object.defineProperty(XMLDocument.prototype, 'documentElement', {
  27381. get: function() {
  27382. return this.rootObject || null;
  27383. }
  27384. });
  27385. Object.defineProperty(XMLDocument.prototype, 'inputEncoding', {
  27386. get: function() {
  27387. return null;
  27388. }
  27389. });
  27390. Object.defineProperty(XMLDocument.prototype, 'strictErrorChecking', {
  27391. get: function() {
  27392. return false;
  27393. }
  27394. });
  27395. Object.defineProperty(XMLDocument.prototype, 'xmlEncoding', {
  27396. get: function() {
  27397. if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
  27398. return this.children[0].encoding;
  27399. } else {
  27400. return null;
  27401. }
  27402. }
  27403. });
  27404. Object.defineProperty(XMLDocument.prototype, 'xmlStandalone', {
  27405. get: function() {
  27406. if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
  27407. return this.children[0].standalone === 'yes';
  27408. } else {
  27409. return false;
  27410. }
  27411. }
  27412. });
  27413. Object.defineProperty(XMLDocument.prototype, 'xmlVersion', {
  27414. get: function() {
  27415. if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
  27416. return this.children[0].version;
  27417. } else {
  27418. return "1.0";
  27419. }
  27420. }
  27421. });
  27422. Object.defineProperty(XMLDocument.prototype, 'URL', {
  27423. get: function() {
  27424. return this.documentURI;
  27425. }
  27426. });
  27427. Object.defineProperty(XMLDocument.prototype, 'origin', {
  27428. get: function() {
  27429. return null;
  27430. }
  27431. });
  27432. Object.defineProperty(XMLDocument.prototype, 'compatMode', {
  27433. get: function() {
  27434. return null;
  27435. }
  27436. });
  27437. Object.defineProperty(XMLDocument.prototype, 'characterSet', {
  27438. get: function() {
  27439. return null;
  27440. }
  27441. });
  27442. Object.defineProperty(XMLDocument.prototype, 'contentType', {
  27443. get: function() {
  27444. return null;
  27445. }
  27446. });
  27447. XMLDocument.prototype.end = function(writer) {
  27448. var writerOptions;
  27449. writerOptions = {};
  27450. if (!writer) {
  27451. writer = this.options.writer;
  27452. } else if (isPlainObject(writer)) {
  27453. writerOptions = writer;
  27454. writer = this.options.writer;
  27455. }
  27456. return writer.document(this, writer.filterOptions(writerOptions));
  27457. };
  27458. XMLDocument.prototype.toString = function(options) {
  27459. return this.options.writer.document(this, this.options.writer.filterOptions(options));
  27460. };
  27461. XMLDocument.prototype.createElement = function(tagName) {
  27462. throw new Error("This DOM method is not implemented." + this.debugInfo());
  27463. };
  27464. XMLDocument.prototype.createDocumentFragment = function() {
  27465. throw new Error("This DOM method is not implemented." + this.debugInfo());
  27466. };
  27467. XMLDocument.prototype.createTextNode = function(data) {
  27468. throw new Error("This DOM method is not implemented." + this.debugInfo());
  27469. };
  27470. XMLDocument.prototype.createComment = function(data) {
  27471. throw new Error("This DOM method is not implemented." + this.debugInfo());
  27472. };
  27473. XMLDocument.prototype.createCDATASection = function(data) {
  27474. throw new Error("This DOM method is not implemented." + this.debugInfo());
  27475. };
  27476. XMLDocument.prototype.createProcessingInstruction = function(target, data) {
  27477. throw new Error("This DOM method is not implemented." + this.debugInfo());
  27478. };
  27479. XMLDocument.prototype.createAttribute = function(name) {
  27480. throw new Error("This DOM method is not implemented." + this.debugInfo());
  27481. };
  27482. XMLDocument.prototype.createEntityReference = function(name) {
  27483. throw new Error("This DOM method is not implemented." + this.debugInfo());
  27484. };
  27485. XMLDocument.prototype.getElementsByTagName = function(tagname) {
  27486. throw new Error("This DOM method is not implemented." + this.debugInfo());
  27487. };
  27488. XMLDocument.prototype.importNode = function(importedNode, deep) {
  27489. throw new Error("This DOM method is not implemented." + this.debugInfo());
  27490. };
  27491. XMLDocument.prototype.createElementNS = function(namespaceURI, qualifiedName) {
  27492. throw new Error("This DOM method is not implemented." + this.debugInfo());
  27493. };
  27494. XMLDocument.prototype.createAttributeNS = function(namespaceURI, qualifiedName) {
  27495. throw new Error("This DOM method is not implemented." + this.debugInfo());
  27496. };
  27497. XMLDocument.prototype.getElementsByTagNameNS = function(namespaceURI, localName) {
  27498. throw new Error("This DOM method is not implemented." + this.debugInfo());
  27499. };
  27500. XMLDocument.prototype.getElementById = function(elementId) {
  27501. throw new Error("This DOM method is not implemented." + this.debugInfo());
  27502. };
  27503. XMLDocument.prototype.adoptNode = function(source) {
  27504. throw new Error("This DOM method is not implemented." + this.debugInfo());
  27505. };
  27506. XMLDocument.prototype.normalizeDocument = function() {
  27507. throw new Error("This DOM method is not implemented." + this.debugInfo());
  27508. };
  27509. XMLDocument.prototype.renameNode = function(node, namespaceURI, qualifiedName) {
  27510. throw new Error("This DOM method is not implemented." + this.debugInfo());
  27511. };
  27512. XMLDocument.prototype.getElementsByClassName = function(classNames) {
  27513. throw new Error("This DOM method is not implemented." + this.debugInfo());
  27514. };
  27515. XMLDocument.prototype.createEvent = function(eventInterface) {
  27516. throw new Error("This DOM method is not implemented." + this.debugInfo());
  27517. };
  27518. XMLDocument.prototype.createRange = function() {
  27519. throw new Error("This DOM method is not implemented." + this.debugInfo());
  27520. };
  27521. XMLDocument.prototype.createNodeIterator = function(root, whatToShow, filter) {
  27522. throw new Error("This DOM method is not implemented." + this.debugInfo());
  27523. };
  27524. XMLDocument.prototype.createTreeWalker = function(root, whatToShow, filter) {
  27525. throw new Error("This DOM method is not implemented." + this.debugInfo());
  27526. };
  27527. return XMLDocument;
  27528. })(XMLNode);
  27529. }).call(this);
  27530. },{"./NodeType":354,"./Utility":355,"./XMLDOMConfiguration":361,"./XMLDOMImplementation":363,"./XMLNode":376,"./XMLStringWriter":381,"./XMLStringifier":382}],372:[function(require,module,exports){
  27531. // Generated by CoffeeScript 1.12.7
  27532. (function() {
  27533. var NodeType, WriterState, XMLAttribute, XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLDocument, XMLDocumentCB, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStringWriter, XMLStringifier, XMLText, getValue, isFunction, isObject, isPlainObject, ref,
  27534. hasProp = {}.hasOwnProperty;
  27535. ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction, isPlainObject = ref.isPlainObject, getValue = ref.getValue;
  27536. NodeType = require('./NodeType');
  27537. XMLDocument = require('./XMLDocument');
  27538. XMLElement = require('./XMLElement');
  27539. XMLCData = require('./XMLCData');
  27540. XMLComment = require('./XMLComment');
  27541. XMLRaw = require('./XMLRaw');
  27542. XMLText = require('./XMLText');
  27543. XMLProcessingInstruction = require('./XMLProcessingInstruction');
  27544. XMLDeclaration = require('./XMLDeclaration');
  27545. XMLDocType = require('./XMLDocType');
  27546. XMLDTDAttList = require('./XMLDTDAttList');
  27547. XMLDTDEntity = require('./XMLDTDEntity');
  27548. XMLDTDElement = require('./XMLDTDElement');
  27549. XMLDTDNotation = require('./XMLDTDNotation');
  27550. XMLAttribute = require('./XMLAttribute');
  27551. XMLStringifier = require('./XMLStringifier');
  27552. XMLStringWriter = require('./XMLStringWriter');
  27553. WriterState = require('./WriterState');
  27554. module.exports = XMLDocumentCB = (function() {
  27555. function XMLDocumentCB(options, onData, onEnd) {
  27556. var writerOptions;
  27557. this.name = "?xml";
  27558. this.type = NodeType.Document;
  27559. options || (options = {});
  27560. writerOptions = {};
  27561. if (!options.writer) {
  27562. options.writer = new XMLStringWriter();
  27563. } else if (isPlainObject(options.writer)) {
  27564. writerOptions = options.writer;
  27565. options.writer = new XMLStringWriter();
  27566. }
  27567. this.options = options;
  27568. this.writer = options.writer;
  27569. this.writerOptions = this.writer.filterOptions(writerOptions);
  27570. this.stringify = new XMLStringifier(options);
  27571. this.onDataCallback = onData || function() {};
  27572. this.onEndCallback = onEnd || function() {};
  27573. this.currentNode = null;
  27574. this.currentLevel = -1;
  27575. this.openTags = {};
  27576. this.documentStarted = false;
  27577. this.documentCompleted = false;
  27578. this.root = null;
  27579. }
  27580. XMLDocumentCB.prototype.createChildNode = function(node) {
  27581. var att, attName, attributes, child, i, len, ref1, ref2;
  27582. switch (node.type) {
  27583. case NodeType.CData:
  27584. this.cdata(node.value);
  27585. break;
  27586. case NodeType.Comment:
  27587. this.comment(node.value);
  27588. break;
  27589. case NodeType.Element:
  27590. attributes = {};
  27591. ref1 = node.attribs;
  27592. for (attName in ref1) {
  27593. if (!hasProp.call(ref1, attName)) continue;
  27594. att = ref1[attName];
  27595. attributes[attName] = att.value;
  27596. }
  27597. this.node(node.name, attributes);
  27598. break;
  27599. case NodeType.Dummy:
  27600. this.dummy();
  27601. break;
  27602. case NodeType.Raw:
  27603. this.raw(node.value);
  27604. break;
  27605. case NodeType.Text:
  27606. this.text(node.value);
  27607. break;
  27608. case NodeType.ProcessingInstruction:
  27609. this.instruction(node.target, node.value);
  27610. break;
  27611. default:
  27612. throw new Error("This XML node type is not supported in a JS object: " + node.constructor.name);
  27613. }
  27614. ref2 = node.children;
  27615. for (i = 0, len = ref2.length; i < len; i++) {
  27616. child = ref2[i];
  27617. this.createChildNode(child);
  27618. if (child.type === NodeType.Element) {
  27619. this.up();
  27620. }
  27621. }
  27622. return this;
  27623. };
  27624. XMLDocumentCB.prototype.dummy = function() {
  27625. return this;
  27626. };
  27627. XMLDocumentCB.prototype.node = function(name, attributes, text) {
  27628. var ref1;
  27629. if (name == null) {
  27630. throw new Error("Missing node name.");
  27631. }
  27632. if (this.root && this.currentLevel === -1) {
  27633. throw new Error("Document can only have one root node. " + this.debugInfo(name));
  27634. }
  27635. this.openCurrent();
  27636. name = getValue(name);
  27637. if (attributes == null) {
  27638. attributes = {};
  27639. }
  27640. attributes = getValue(attributes);
  27641. if (!isObject(attributes)) {
  27642. ref1 = [attributes, text], text = ref1[0], attributes = ref1[1];
  27643. }
  27644. this.currentNode = new XMLElement(this, name, attributes);
  27645. this.currentNode.children = false;
  27646. this.currentLevel++;
  27647. this.openTags[this.currentLevel] = this.currentNode;
  27648. if (text != null) {
  27649. this.text(text);
  27650. }
  27651. return this;
  27652. };
  27653. XMLDocumentCB.prototype.element = function(name, attributes, text) {
  27654. var child, i, len, oldValidationFlag, ref1, root;
  27655. if (this.currentNode && this.currentNode.type === NodeType.DocType) {
  27656. this.dtdElement.apply(this, arguments);
  27657. } else {
  27658. if (Array.isArray(name) || isObject(name) || isFunction(name)) {
  27659. oldValidationFlag = this.options.noValidation;
  27660. this.options.noValidation = true;
  27661. root = new XMLDocument(this.options).element('TEMP_ROOT');
  27662. root.element(name);
  27663. this.options.noValidation = oldValidationFlag;
  27664. ref1 = root.children;
  27665. for (i = 0, len = ref1.length; i < len; i++) {
  27666. child = ref1[i];
  27667. this.createChildNode(child);
  27668. if (child.type === NodeType.Element) {
  27669. this.up();
  27670. }
  27671. }
  27672. } else {
  27673. this.node(name, attributes, text);
  27674. }
  27675. }
  27676. return this;
  27677. };
  27678. XMLDocumentCB.prototype.attribute = function(name, value) {
  27679. var attName, attValue;
  27680. if (!this.currentNode || this.currentNode.children) {
  27681. throw new Error("att() can only be used immediately after an ele() call in callback mode. " + this.debugInfo(name));
  27682. }
  27683. if (name != null) {
  27684. name = getValue(name);
  27685. }
  27686. if (isObject(name)) {
  27687. for (attName in name) {
  27688. if (!hasProp.call(name, attName)) continue;
  27689. attValue = name[attName];
  27690. this.attribute(attName, attValue);
  27691. }
  27692. } else {
  27693. if (isFunction(value)) {
  27694. value = value.apply();
  27695. }
  27696. if (this.options.keepNullAttributes && (value == null)) {
  27697. this.currentNode.attribs[name] = new XMLAttribute(this, name, "");
  27698. } else if (value != null) {
  27699. this.currentNode.attribs[name] = new XMLAttribute(this, name, value);
  27700. }
  27701. }
  27702. return this;
  27703. };
  27704. XMLDocumentCB.prototype.text = function(value) {
  27705. var node;
  27706. this.openCurrent();
  27707. node = new XMLText(this, value);
  27708. this.onData(this.writer.text(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
  27709. return this;
  27710. };
  27711. XMLDocumentCB.prototype.cdata = function(value) {
  27712. var node;
  27713. this.openCurrent();
  27714. node = new XMLCData(this, value);
  27715. this.onData(this.writer.cdata(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
  27716. return this;
  27717. };
  27718. XMLDocumentCB.prototype.comment = function(value) {
  27719. var node;
  27720. this.openCurrent();
  27721. node = new XMLComment(this, value);
  27722. this.onData(this.writer.comment(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
  27723. return this;
  27724. };
  27725. XMLDocumentCB.prototype.raw = function(value) {
  27726. var node;
  27727. this.openCurrent();
  27728. node = new XMLRaw(this, value);
  27729. this.onData(this.writer.raw(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
  27730. return this;
  27731. };
  27732. XMLDocumentCB.prototype.instruction = function(target, value) {
  27733. var i, insTarget, insValue, len, node;
  27734. this.openCurrent();
  27735. if (target != null) {
  27736. target = getValue(target);
  27737. }
  27738. if (value != null) {
  27739. value = getValue(value);
  27740. }
  27741. if (Array.isArray(target)) {
  27742. for (i = 0, len = target.length; i < len; i++) {
  27743. insTarget = target[i];
  27744. this.instruction(insTarget);
  27745. }
  27746. } else if (isObject(target)) {
  27747. for (insTarget in target) {
  27748. if (!hasProp.call(target, insTarget)) continue;
  27749. insValue = target[insTarget];
  27750. this.instruction(insTarget, insValue);
  27751. }
  27752. } else {
  27753. if (isFunction(value)) {
  27754. value = value.apply();
  27755. }
  27756. node = new XMLProcessingInstruction(this, target, value);
  27757. this.onData(this.writer.processingInstruction(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
  27758. }
  27759. return this;
  27760. };
  27761. XMLDocumentCB.prototype.declaration = function(version, encoding, standalone) {
  27762. var node;
  27763. this.openCurrent();
  27764. if (this.documentStarted) {
  27765. throw new Error("declaration() must be the first node.");
  27766. }
  27767. node = new XMLDeclaration(this, version, encoding, standalone);
  27768. this.onData(this.writer.declaration(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
  27769. return this;
  27770. };
  27771. XMLDocumentCB.prototype.doctype = function(root, pubID, sysID) {
  27772. this.openCurrent();
  27773. if (root == null) {
  27774. throw new Error("Missing root node name.");
  27775. }
  27776. if (this.root) {
  27777. throw new Error("dtd() must come before the root node.");
  27778. }
  27779. this.currentNode = new XMLDocType(this, pubID, sysID);
  27780. this.currentNode.rootNodeName = root;
  27781. this.currentNode.children = false;
  27782. this.currentLevel++;
  27783. this.openTags[this.currentLevel] = this.currentNode;
  27784. return this;
  27785. };
  27786. XMLDocumentCB.prototype.dtdElement = function(name, value) {
  27787. var node;
  27788. this.openCurrent();
  27789. node = new XMLDTDElement(this, name, value);
  27790. this.onData(this.writer.dtdElement(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
  27791. return this;
  27792. };
  27793. XMLDocumentCB.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
  27794. var node;
  27795. this.openCurrent();
  27796. node = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
  27797. this.onData(this.writer.dtdAttList(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
  27798. return this;
  27799. };
  27800. XMLDocumentCB.prototype.entity = function(name, value) {
  27801. var node;
  27802. this.openCurrent();
  27803. node = new XMLDTDEntity(this, false, name, value);
  27804. this.onData(this.writer.dtdEntity(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
  27805. return this;
  27806. };
  27807. XMLDocumentCB.prototype.pEntity = function(name, value) {
  27808. var node;
  27809. this.openCurrent();
  27810. node = new XMLDTDEntity(this, true, name, value);
  27811. this.onData(this.writer.dtdEntity(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
  27812. return this;
  27813. };
  27814. XMLDocumentCB.prototype.notation = function(name, value) {
  27815. var node;
  27816. this.openCurrent();
  27817. node = new XMLDTDNotation(this, name, value);
  27818. this.onData(this.writer.dtdNotation(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
  27819. return this;
  27820. };
  27821. XMLDocumentCB.prototype.up = function() {
  27822. if (this.currentLevel < 0) {
  27823. throw new Error("The document node has no parent.");
  27824. }
  27825. if (this.currentNode) {
  27826. if (this.currentNode.children) {
  27827. this.closeNode(this.currentNode);
  27828. } else {
  27829. this.openNode(this.currentNode);
  27830. }
  27831. this.currentNode = null;
  27832. } else {
  27833. this.closeNode(this.openTags[this.currentLevel]);
  27834. }
  27835. delete this.openTags[this.currentLevel];
  27836. this.currentLevel--;
  27837. return this;
  27838. };
  27839. XMLDocumentCB.prototype.end = function() {
  27840. while (this.currentLevel >= 0) {
  27841. this.up();
  27842. }
  27843. return this.onEnd();
  27844. };
  27845. XMLDocumentCB.prototype.openCurrent = function() {
  27846. if (this.currentNode) {
  27847. this.currentNode.children = true;
  27848. return this.openNode(this.currentNode);
  27849. }
  27850. };
  27851. XMLDocumentCB.prototype.openNode = function(node) {
  27852. var att, chunk, name, ref1;
  27853. if (!node.isOpen) {
  27854. if (!this.root && this.currentLevel === 0 && node.type === NodeType.Element) {
  27855. this.root = node;
  27856. }
  27857. chunk = '';
  27858. if (node.type === NodeType.Element) {
  27859. this.writerOptions.state = WriterState.OpenTag;
  27860. chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '<' + node.name;
  27861. ref1 = node.attribs;
  27862. for (name in ref1) {
  27863. if (!hasProp.call(ref1, name)) continue;
  27864. att = ref1[name];
  27865. chunk += this.writer.attribute(att, this.writerOptions, this.currentLevel);
  27866. }
  27867. chunk += (node.children ? '>' : '/>') + this.writer.endline(node, this.writerOptions, this.currentLevel);
  27868. this.writerOptions.state = WriterState.InsideTag;
  27869. } else {
  27870. this.writerOptions.state = WriterState.OpenTag;
  27871. chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '<!DOCTYPE ' + node.rootNodeName;
  27872. if (node.pubID && node.sysID) {
  27873. chunk += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
  27874. } else if (node.sysID) {
  27875. chunk += ' SYSTEM "' + node.sysID + '"';
  27876. }
  27877. if (node.children) {
  27878. chunk += ' [';
  27879. this.writerOptions.state = WriterState.InsideTag;
  27880. } else {
  27881. this.writerOptions.state = WriterState.CloseTag;
  27882. chunk += '>';
  27883. }
  27884. chunk += this.writer.endline(node, this.writerOptions, this.currentLevel);
  27885. }
  27886. this.onData(chunk, this.currentLevel);
  27887. return node.isOpen = true;
  27888. }
  27889. };
  27890. XMLDocumentCB.prototype.closeNode = function(node) {
  27891. var chunk;
  27892. if (!node.isClosed) {
  27893. chunk = '';
  27894. this.writerOptions.state = WriterState.CloseTag;
  27895. if (node.type === NodeType.Element) {
  27896. chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '</' + node.name + '>' + this.writer.endline(node, this.writerOptions, this.currentLevel);
  27897. } else {
  27898. chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + ']>' + this.writer.endline(node, this.writerOptions, this.currentLevel);
  27899. }
  27900. this.writerOptions.state = WriterState.None;
  27901. this.onData(chunk, this.currentLevel);
  27902. return node.isClosed = true;
  27903. }
  27904. };
  27905. XMLDocumentCB.prototype.onData = function(chunk, level) {
  27906. this.documentStarted = true;
  27907. return this.onDataCallback(chunk, level + 1);
  27908. };
  27909. XMLDocumentCB.prototype.onEnd = function() {
  27910. this.documentCompleted = true;
  27911. return this.onEndCallback();
  27912. };
  27913. XMLDocumentCB.prototype.debugInfo = function(name) {
  27914. if (name == null) {
  27915. return "";
  27916. } else {
  27917. return "node: <" + name + ">";
  27918. }
  27919. };
  27920. XMLDocumentCB.prototype.ele = function() {
  27921. return this.element.apply(this, arguments);
  27922. };
  27923. XMLDocumentCB.prototype.nod = function(name, attributes, text) {
  27924. return this.node(name, attributes, text);
  27925. };
  27926. XMLDocumentCB.prototype.txt = function(value) {
  27927. return this.text(value);
  27928. };
  27929. XMLDocumentCB.prototype.dat = function(value) {
  27930. return this.cdata(value);
  27931. };
  27932. XMLDocumentCB.prototype.com = function(value) {
  27933. return this.comment(value);
  27934. };
  27935. XMLDocumentCB.prototype.ins = function(target, value) {
  27936. return this.instruction(target, value);
  27937. };
  27938. XMLDocumentCB.prototype.dec = function(version, encoding, standalone) {
  27939. return this.declaration(version, encoding, standalone);
  27940. };
  27941. XMLDocumentCB.prototype.dtd = function(root, pubID, sysID) {
  27942. return this.doctype(root, pubID, sysID);
  27943. };
  27944. XMLDocumentCB.prototype.e = function(name, attributes, text) {
  27945. return this.element(name, attributes, text);
  27946. };
  27947. XMLDocumentCB.prototype.n = function(name, attributes, text) {
  27948. return this.node(name, attributes, text);
  27949. };
  27950. XMLDocumentCB.prototype.t = function(value) {
  27951. return this.text(value);
  27952. };
  27953. XMLDocumentCB.prototype.d = function(value) {
  27954. return this.cdata(value);
  27955. };
  27956. XMLDocumentCB.prototype.c = function(value) {
  27957. return this.comment(value);
  27958. };
  27959. XMLDocumentCB.prototype.r = function(value) {
  27960. return this.raw(value);
  27961. };
  27962. XMLDocumentCB.prototype.i = function(target, value) {
  27963. return this.instruction(target, value);
  27964. };
  27965. XMLDocumentCB.prototype.att = function() {
  27966. if (this.currentNode && this.currentNode.type === NodeType.DocType) {
  27967. return this.attList.apply(this, arguments);
  27968. } else {
  27969. return this.attribute.apply(this, arguments);
  27970. }
  27971. };
  27972. XMLDocumentCB.prototype.a = function() {
  27973. if (this.currentNode && this.currentNode.type === NodeType.DocType) {
  27974. return this.attList.apply(this, arguments);
  27975. } else {
  27976. return this.attribute.apply(this, arguments);
  27977. }
  27978. };
  27979. XMLDocumentCB.prototype.ent = function(name, value) {
  27980. return this.entity(name, value);
  27981. };
  27982. XMLDocumentCB.prototype.pent = function(name, value) {
  27983. return this.pEntity(name, value);
  27984. };
  27985. XMLDocumentCB.prototype.not = function(name, value) {
  27986. return this.notation(name, value);
  27987. };
  27988. return XMLDocumentCB;
  27989. })();
  27990. }).call(this);
  27991. },{"./NodeType":354,"./Utility":355,"./WriterState":356,"./XMLAttribute":357,"./XMLCData":358,"./XMLComment":360,"./XMLDTDAttList":365,"./XMLDTDElement":366,"./XMLDTDEntity":367,"./XMLDTDNotation":368,"./XMLDeclaration":369,"./XMLDocType":370,"./XMLDocument":371,"./XMLElement":374,"./XMLProcessingInstruction":378,"./XMLRaw":379,"./XMLStringWriter":381,"./XMLStringifier":382,"./XMLText":383}],373:[function(require,module,exports){
  27992. // Generated by CoffeeScript 1.12.7
  27993. (function() {
  27994. var NodeType, XMLDummy, XMLNode,
  27995. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  27996. hasProp = {}.hasOwnProperty;
  27997. XMLNode = require('./XMLNode');
  27998. NodeType = require('./NodeType');
  27999. module.exports = XMLDummy = (function(superClass) {
  28000. extend(XMLDummy, superClass);
  28001. function XMLDummy(parent) {
  28002. XMLDummy.__super__.constructor.call(this, parent);
  28003. this.type = NodeType.Dummy;
  28004. }
  28005. XMLDummy.prototype.clone = function() {
  28006. return Object.create(this);
  28007. };
  28008. XMLDummy.prototype.toString = function(options) {
  28009. return '';
  28010. };
  28011. return XMLDummy;
  28012. })(XMLNode);
  28013. }).call(this);
  28014. },{"./NodeType":354,"./XMLNode":376}],374:[function(require,module,exports){
  28015. // Generated by CoffeeScript 1.12.7
  28016. (function() {
  28017. var NodeType, XMLAttribute, XMLElement, XMLNamedNodeMap, XMLNode, getValue, isFunction, isObject, ref,
  28018. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  28019. hasProp = {}.hasOwnProperty;
  28020. ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction, getValue = ref.getValue;
  28021. XMLNode = require('./XMLNode');
  28022. NodeType = require('./NodeType');
  28023. XMLAttribute = require('./XMLAttribute');
  28024. XMLNamedNodeMap = require('./XMLNamedNodeMap');
  28025. module.exports = XMLElement = (function(superClass) {
  28026. extend(XMLElement, superClass);
  28027. function XMLElement(parent, name, attributes) {
  28028. var child, j, len, ref1;
  28029. XMLElement.__super__.constructor.call(this, parent);
  28030. if (name == null) {
  28031. throw new Error("Missing element name. " + this.debugInfo());
  28032. }
  28033. this.name = this.stringify.name(name);
  28034. this.type = NodeType.Element;
  28035. this.attribs = {};
  28036. this.schemaTypeInfo = null;
  28037. if (attributes != null) {
  28038. this.attribute(attributes);
  28039. }
  28040. if (parent.type === NodeType.Document) {
  28041. this.isRoot = true;
  28042. this.documentObject = parent;
  28043. parent.rootObject = this;
  28044. if (parent.children) {
  28045. ref1 = parent.children;
  28046. for (j = 0, len = ref1.length; j < len; j++) {
  28047. child = ref1[j];
  28048. if (child.type === NodeType.DocType) {
  28049. child.name = this.name;
  28050. break;
  28051. }
  28052. }
  28053. }
  28054. }
  28055. }
  28056. Object.defineProperty(XMLElement.prototype, 'tagName', {
  28057. get: function() {
  28058. return this.name;
  28059. }
  28060. });
  28061. Object.defineProperty(XMLElement.prototype, 'namespaceURI', {
  28062. get: function() {
  28063. return '';
  28064. }
  28065. });
  28066. Object.defineProperty(XMLElement.prototype, 'prefix', {
  28067. get: function() {
  28068. return '';
  28069. }
  28070. });
  28071. Object.defineProperty(XMLElement.prototype, 'localName', {
  28072. get: function() {
  28073. return this.name;
  28074. }
  28075. });
  28076. Object.defineProperty(XMLElement.prototype, 'id', {
  28077. get: function() {
  28078. throw new Error("This DOM method is not implemented." + this.debugInfo());
  28079. }
  28080. });
  28081. Object.defineProperty(XMLElement.prototype, 'className', {
  28082. get: function() {
  28083. throw new Error("This DOM method is not implemented." + this.debugInfo());
  28084. }
  28085. });
  28086. Object.defineProperty(XMLElement.prototype, 'classList', {
  28087. get: function() {
  28088. throw new Error("This DOM method is not implemented." + this.debugInfo());
  28089. }
  28090. });
  28091. Object.defineProperty(XMLElement.prototype, 'attributes', {
  28092. get: function() {
  28093. if (!this.attributeMap || !this.attributeMap.nodes) {
  28094. this.attributeMap = new XMLNamedNodeMap(this.attribs);
  28095. }
  28096. return this.attributeMap;
  28097. }
  28098. });
  28099. XMLElement.prototype.clone = function() {
  28100. var att, attName, clonedSelf, ref1;
  28101. clonedSelf = Object.create(this);
  28102. if (clonedSelf.isRoot) {
  28103. clonedSelf.documentObject = null;
  28104. }
  28105. clonedSelf.attribs = {};
  28106. ref1 = this.attribs;
  28107. for (attName in ref1) {
  28108. if (!hasProp.call(ref1, attName)) continue;
  28109. att = ref1[attName];
  28110. clonedSelf.attribs[attName] = att.clone();
  28111. }
  28112. clonedSelf.children = [];
  28113. this.children.forEach(function(child) {
  28114. var clonedChild;
  28115. clonedChild = child.clone();
  28116. clonedChild.parent = clonedSelf;
  28117. return clonedSelf.children.push(clonedChild);
  28118. });
  28119. return clonedSelf;
  28120. };
  28121. XMLElement.prototype.attribute = function(name, value) {
  28122. var attName, attValue;
  28123. if (name != null) {
  28124. name = getValue(name);
  28125. }
  28126. if (isObject(name)) {
  28127. for (attName in name) {
  28128. if (!hasProp.call(name, attName)) continue;
  28129. attValue = name[attName];
  28130. this.attribute(attName, attValue);
  28131. }
  28132. } else {
  28133. if (isFunction(value)) {
  28134. value = value.apply();
  28135. }
  28136. if (this.options.keepNullAttributes && (value == null)) {
  28137. this.attribs[name] = new XMLAttribute(this, name, "");
  28138. } else if (value != null) {
  28139. this.attribs[name] = new XMLAttribute(this, name, value);
  28140. }
  28141. }
  28142. return this;
  28143. };
  28144. XMLElement.prototype.removeAttribute = function(name) {
  28145. var attName, j, len;
  28146. if (name == null) {
  28147. throw new Error("Missing attribute name. " + this.debugInfo());
  28148. }
  28149. name = getValue(name);
  28150. if (Array.isArray(name)) {
  28151. for (j = 0, len = name.length; j < len; j++) {
  28152. attName = name[j];
  28153. delete this.attribs[attName];
  28154. }
  28155. } else {
  28156. delete this.attribs[name];
  28157. }
  28158. return this;
  28159. };
  28160. XMLElement.prototype.toString = function(options) {
  28161. return this.options.writer.element(this, this.options.writer.filterOptions(options));
  28162. };
  28163. XMLElement.prototype.att = function(name, value) {
  28164. return this.attribute(name, value);
  28165. };
  28166. XMLElement.prototype.a = function(name, value) {
  28167. return this.attribute(name, value);
  28168. };
  28169. XMLElement.prototype.getAttribute = function(name) {
  28170. if (this.attribs.hasOwnProperty(name)) {
  28171. return this.attribs[name].value;
  28172. } else {
  28173. return null;
  28174. }
  28175. };
  28176. XMLElement.prototype.setAttribute = function(name, value) {
  28177. throw new Error("This DOM method is not implemented." + this.debugInfo());
  28178. };
  28179. XMLElement.prototype.getAttributeNode = function(name) {
  28180. if (this.attribs.hasOwnProperty(name)) {
  28181. return this.attribs[name];
  28182. } else {
  28183. return null;
  28184. }
  28185. };
  28186. XMLElement.prototype.setAttributeNode = function(newAttr) {
  28187. throw new Error("This DOM method is not implemented." + this.debugInfo());
  28188. };
  28189. XMLElement.prototype.removeAttributeNode = function(oldAttr) {
  28190. throw new Error("This DOM method is not implemented." + this.debugInfo());
  28191. };
  28192. XMLElement.prototype.getElementsByTagName = function(name) {
  28193. throw new Error("This DOM method is not implemented." + this.debugInfo());
  28194. };
  28195. XMLElement.prototype.getAttributeNS = function(namespaceURI, localName) {
  28196. throw new Error("This DOM method is not implemented." + this.debugInfo());
  28197. };
  28198. XMLElement.prototype.setAttributeNS = function(namespaceURI, qualifiedName, value) {
  28199. throw new Error("This DOM method is not implemented." + this.debugInfo());
  28200. };
  28201. XMLElement.prototype.removeAttributeNS = function(namespaceURI, localName) {
  28202. throw new Error("This DOM method is not implemented." + this.debugInfo());
  28203. };
  28204. XMLElement.prototype.getAttributeNodeNS = function(namespaceURI, localName) {
  28205. throw new Error("This DOM method is not implemented." + this.debugInfo());
  28206. };
  28207. XMLElement.prototype.setAttributeNodeNS = function(newAttr) {
  28208. throw new Error("This DOM method is not implemented." + this.debugInfo());
  28209. };
  28210. XMLElement.prototype.getElementsByTagNameNS = function(namespaceURI, localName) {
  28211. throw new Error("This DOM method is not implemented." + this.debugInfo());
  28212. };
  28213. XMLElement.prototype.hasAttribute = function(name) {
  28214. return this.attribs.hasOwnProperty(name);
  28215. };
  28216. XMLElement.prototype.hasAttributeNS = function(namespaceURI, localName) {
  28217. throw new Error("This DOM method is not implemented." + this.debugInfo());
  28218. };
  28219. XMLElement.prototype.setIdAttribute = function(name, isId) {
  28220. if (this.attribs.hasOwnProperty(name)) {
  28221. return this.attribs[name].isId;
  28222. } else {
  28223. return isId;
  28224. }
  28225. };
  28226. XMLElement.prototype.setIdAttributeNS = function(namespaceURI, localName, isId) {
  28227. throw new Error("This DOM method is not implemented." + this.debugInfo());
  28228. };
  28229. XMLElement.prototype.setIdAttributeNode = function(idAttr, isId) {
  28230. throw new Error("This DOM method is not implemented." + this.debugInfo());
  28231. };
  28232. XMLElement.prototype.getElementsByTagName = function(tagname) {
  28233. throw new Error("This DOM method is not implemented." + this.debugInfo());
  28234. };
  28235. XMLElement.prototype.getElementsByTagNameNS = function(namespaceURI, localName) {
  28236. throw new Error("This DOM method is not implemented." + this.debugInfo());
  28237. };
  28238. XMLElement.prototype.getElementsByClassName = function(classNames) {
  28239. throw new Error("This DOM method is not implemented." + this.debugInfo());
  28240. };
  28241. XMLElement.prototype.isEqualNode = function(node) {
  28242. var i, j, ref1;
  28243. if (!XMLElement.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) {
  28244. return false;
  28245. }
  28246. if (node.namespaceURI !== this.namespaceURI) {
  28247. return false;
  28248. }
  28249. if (node.prefix !== this.prefix) {
  28250. return false;
  28251. }
  28252. if (node.localName !== this.localName) {
  28253. return false;
  28254. }
  28255. if (node.attribs.length !== this.attribs.length) {
  28256. return false;
  28257. }
  28258. for (i = j = 0, ref1 = this.attribs.length - 1; 0 <= ref1 ? j <= ref1 : j >= ref1; i = 0 <= ref1 ? ++j : --j) {
  28259. if (!this.attribs[i].isEqualNode(node.attribs[i])) {
  28260. return false;
  28261. }
  28262. }
  28263. return true;
  28264. };
  28265. return XMLElement;
  28266. })(XMLNode);
  28267. }).call(this);
  28268. },{"./NodeType":354,"./Utility":355,"./XMLAttribute":357,"./XMLNamedNodeMap":375,"./XMLNode":376}],375:[function(require,module,exports){
  28269. // Generated by CoffeeScript 1.12.7
  28270. (function() {
  28271. var XMLNamedNodeMap;
  28272. module.exports = XMLNamedNodeMap = (function() {
  28273. function XMLNamedNodeMap(nodes) {
  28274. this.nodes = nodes;
  28275. }
  28276. Object.defineProperty(XMLNamedNodeMap.prototype, 'length', {
  28277. get: function() {
  28278. return Object.keys(this.nodes).length || 0;
  28279. }
  28280. });
  28281. XMLNamedNodeMap.prototype.clone = function() {
  28282. return this.nodes = null;
  28283. };
  28284. XMLNamedNodeMap.prototype.getNamedItem = function(name) {
  28285. return this.nodes[name];
  28286. };
  28287. XMLNamedNodeMap.prototype.setNamedItem = function(node) {
  28288. var oldNode;
  28289. oldNode = this.nodes[node.nodeName];
  28290. this.nodes[node.nodeName] = node;
  28291. return oldNode || null;
  28292. };
  28293. XMLNamedNodeMap.prototype.removeNamedItem = function(name) {
  28294. var oldNode;
  28295. oldNode = this.nodes[name];
  28296. delete this.nodes[name];
  28297. return oldNode || null;
  28298. };
  28299. XMLNamedNodeMap.prototype.item = function(index) {
  28300. return this.nodes[Object.keys(this.nodes)[index]] || null;
  28301. };
  28302. XMLNamedNodeMap.prototype.getNamedItemNS = function(namespaceURI, localName) {
  28303. throw new Error("This DOM method is not implemented.");
  28304. };
  28305. XMLNamedNodeMap.prototype.setNamedItemNS = function(node) {
  28306. throw new Error("This DOM method is not implemented.");
  28307. };
  28308. XMLNamedNodeMap.prototype.removeNamedItemNS = function(namespaceURI, localName) {
  28309. throw new Error("This DOM method is not implemented.");
  28310. };
  28311. return XMLNamedNodeMap;
  28312. })();
  28313. }).call(this);
  28314. },{}],376:[function(require,module,exports){
  28315. // Generated by CoffeeScript 1.12.7
  28316. (function() {
  28317. var DocumentPosition, NodeType, XMLCData, XMLComment, XMLDeclaration, XMLDocType, XMLDummy, XMLElement, XMLNamedNodeMap, XMLNode, XMLNodeList, XMLProcessingInstruction, XMLRaw, XMLText, getValue, isEmpty, isFunction, isObject, ref1,
  28318. hasProp = {}.hasOwnProperty;
  28319. ref1 = require('./Utility'), isObject = ref1.isObject, isFunction = ref1.isFunction, isEmpty = ref1.isEmpty, getValue = ref1.getValue;
  28320. XMLElement = null;
  28321. XMLCData = null;
  28322. XMLComment = null;
  28323. XMLDeclaration = null;
  28324. XMLDocType = null;
  28325. XMLRaw = null;
  28326. XMLText = null;
  28327. XMLProcessingInstruction = null;
  28328. XMLDummy = null;
  28329. NodeType = null;
  28330. XMLNodeList = null;
  28331. XMLNamedNodeMap = null;
  28332. DocumentPosition = null;
  28333. module.exports = XMLNode = (function() {
  28334. function XMLNode(parent1) {
  28335. this.parent = parent1;
  28336. if (this.parent) {
  28337. this.options = this.parent.options;
  28338. this.stringify = this.parent.stringify;
  28339. }
  28340. this.value = null;
  28341. this.children = [];
  28342. this.baseURI = null;
  28343. if (!XMLElement) {
  28344. XMLElement = require('./XMLElement');
  28345. XMLCData = require('./XMLCData');
  28346. XMLComment = require('./XMLComment');
  28347. XMLDeclaration = require('./XMLDeclaration');
  28348. XMLDocType = require('./XMLDocType');
  28349. XMLRaw = require('./XMLRaw');
  28350. XMLText = require('./XMLText');
  28351. XMLProcessingInstruction = require('./XMLProcessingInstruction');
  28352. XMLDummy = require('./XMLDummy');
  28353. NodeType = require('./NodeType');
  28354. XMLNodeList = require('./XMLNodeList');
  28355. XMLNamedNodeMap = require('./XMLNamedNodeMap');
  28356. DocumentPosition = require('./DocumentPosition');
  28357. }
  28358. }
  28359. Object.defineProperty(XMLNode.prototype, 'nodeName', {
  28360. get: function() {
  28361. return this.name;
  28362. }
  28363. });
  28364. Object.defineProperty(XMLNode.prototype, 'nodeType', {
  28365. get: function() {
  28366. return this.type;
  28367. }
  28368. });
  28369. Object.defineProperty(XMLNode.prototype, 'nodeValue', {
  28370. get: function() {
  28371. return this.value;
  28372. }
  28373. });
  28374. Object.defineProperty(XMLNode.prototype, 'parentNode', {
  28375. get: function() {
  28376. return this.parent;
  28377. }
  28378. });
  28379. Object.defineProperty(XMLNode.prototype, 'childNodes', {
  28380. get: function() {
  28381. if (!this.childNodeList || !this.childNodeList.nodes) {
  28382. this.childNodeList = new XMLNodeList(this.children);
  28383. }
  28384. return this.childNodeList;
  28385. }
  28386. });
  28387. Object.defineProperty(XMLNode.prototype, 'firstChild', {
  28388. get: function() {
  28389. return this.children[0] || null;
  28390. }
  28391. });
  28392. Object.defineProperty(XMLNode.prototype, 'lastChild', {
  28393. get: function() {
  28394. return this.children[this.children.length - 1] || null;
  28395. }
  28396. });
  28397. Object.defineProperty(XMLNode.prototype, 'previousSibling', {
  28398. get: function() {
  28399. var i;
  28400. i = this.parent.children.indexOf(this);
  28401. return this.parent.children[i - 1] || null;
  28402. }
  28403. });
  28404. Object.defineProperty(XMLNode.prototype, 'nextSibling', {
  28405. get: function() {
  28406. var i;
  28407. i = this.parent.children.indexOf(this);
  28408. return this.parent.children[i + 1] || null;
  28409. }
  28410. });
  28411. Object.defineProperty(XMLNode.prototype, 'ownerDocument', {
  28412. get: function() {
  28413. return this.document() || null;
  28414. }
  28415. });
  28416. Object.defineProperty(XMLNode.prototype, 'textContent', {
  28417. get: function() {
  28418. var child, j, len, ref2, str;
  28419. if (this.nodeType === NodeType.Element || this.nodeType === NodeType.DocumentFragment) {
  28420. str = '';
  28421. ref2 = this.children;
  28422. for (j = 0, len = ref2.length; j < len; j++) {
  28423. child = ref2[j];
  28424. if (child.textContent) {
  28425. str += child.textContent;
  28426. }
  28427. }
  28428. return str;
  28429. } else {
  28430. return null;
  28431. }
  28432. },
  28433. set: function(value) {
  28434. throw new Error("This DOM method is not implemented." + this.debugInfo());
  28435. }
  28436. });
  28437. XMLNode.prototype.setParent = function(parent) {
  28438. var child, j, len, ref2, results;
  28439. this.parent = parent;
  28440. if (parent) {
  28441. this.options = parent.options;
  28442. this.stringify = parent.stringify;
  28443. }
  28444. ref2 = this.children;
  28445. results = [];
  28446. for (j = 0, len = ref2.length; j < len; j++) {
  28447. child = ref2[j];
  28448. results.push(child.setParent(this));
  28449. }
  28450. return results;
  28451. };
  28452. XMLNode.prototype.element = function(name, attributes, text) {
  28453. var childNode, item, j, k, key, lastChild, len, len1, ref2, ref3, val;
  28454. lastChild = null;
  28455. if (attributes === null && (text == null)) {
  28456. ref2 = [{}, null], attributes = ref2[0], text = ref2[1];
  28457. }
  28458. if (attributes == null) {
  28459. attributes = {};
  28460. }
  28461. attributes = getValue(attributes);
  28462. if (!isObject(attributes)) {
  28463. ref3 = [attributes, text], text = ref3[0], attributes = ref3[1];
  28464. }
  28465. if (name != null) {
  28466. name = getValue(name);
  28467. }
  28468. if (Array.isArray(name)) {
  28469. for (j = 0, len = name.length; j < len; j++) {
  28470. item = name[j];
  28471. lastChild = this.element(item);
  28472. }
  28473. } else if (isFunction(name)) {
  28474. lastChild = this.element(name.apply());
  28475. } else if (isObject(name)) {
  28476. for (key in name) {
  28477. if (!hasProp.call(name, key)) continue;
  28478. val = name[key];
  28479. if (isFunction(val)) {
  28480. val = val.apply();
  28481. }
  28482. if (!this.options.ignoreDecorators && this.stringify.convertAttKey && key.indexOf(this.stringify.convertAttKey) === 0) {
  28483. lastChild = this.attribute(key.substr(this.stringify.convertAttKey.length), val);
  28484. } else if (!this.options.separateArrayItems && Array.isArray(val) && isEmpty(val)) {
  28485. lastChild = this.dummy();
  28486. } else if (isObject(val) && isEmpty(val)) {
  28487. lastChild = this.element(key);
  28488. } else if (!this.options.keepNullNodes && (val == null)) {
  28489. lastChild = this.dummy();
  28490. } else if (!this.options.separateArrayItems && Array.isArray(val)) {
  28491. for (k = 0, len1 = val.length; k < len1; k++) {
  28492. item = val[k];
  28493. childNode = {};
  28494. childNode[key] = item;
  28495. lastChild = this.element(childNode);
  28496. }
  28497. } else if (isObject(val)) {
  28498. if (!this.options.ignoreDecorators && this.stringify.convertTextKey && key.indexOf(this.stringify.convertTextKey) === 0) {
  28499. lastChild = this.element(val);
  28500. } else {
  28501. lastChild = this.element(key);
  28502. lastChild.element(val);
  28503. }
  28504. } else {
  28505. lastChild = this.element(key, val);
  28506. }
  28507. }
  28508. } else if (!this.options.keepNullNodes && text === null) {
  28509. lastChild = this.dummy();
  28510. } else {
  28511. if (!this.options.ignoreDecorators && this.stringify.convertTextKey && name.indexOf(this.stringify.convertTextKey) === 0) {
  28512. lastChild = this.text(text);
  28513. } else if (!this.options.ignoreDecorators && this.stringify.convertCDataKey && name.indexOf(this.stringify.convertCDataKey) === 0) {
  28514. lastChild = this.cdata(text);
  28515. } else if (!this.options.ignoreDecorators && this.stringify.convertCommentKey && name.indexOf(this.stringify.convertCommentKey) === 0) {
  28516. lastChild = this.comment(text);
  28517. } else if (!this.options.ignoreDecorators && this.stringify.convertRawKey && name.indexOf(this.stringify.convertRawKey) === 0) {
  28518. lastChild = this.raw(text);
  28519. } else if (!this.options.ignoreDecorators && this.stringify.convertPIKey && name.indexOf(this.stringify.convertPIKey) === 0) {
  28520. lastChild = this.instruction(name.substr(this.stringify.convertPIKey.length), text);
  28521. } else {
  28522. lastChild = this.node(name, attributes, text);
  28523. }
  28524. }
  28525. if (lastChild == null) {
  28526. throw new Error("Could not create any elements with: " + name + ". " + this.debugInfo());
  28527. }
  28528. return lastChild;
  28529. };
  28530. XMLNode.prototype.insertBefore = function(name, attributes, text) {
  28531. var child, i, newChild, refChild, removed;
  28532. if (name != null ? name.type : void 0) {
  28533. newChild = name;
  28534. refChild = attributes;
  28535. newChild.setParent(this);
  28536. if (refChild) {
  28537. i = children.indexOf(refChild);
  28538. removed = children.splice(i);
  28539. children.push(newChild);
  28540. Array.prototype.push.apply(children, removed);
  28541. } else {
  28542. children.push(newChild);
  28543. }
  28544. return newChild;
  28545. } else {
  28546. if (this.isRoot) {
  28547. throw new Error("Cannot insert elements at root level. " + this.debugInfo(name));
  28548. }
  28549. i = this.parent.children.indexOf(this);
  28550. removed = this.parent.children.splice(i);
  28551. child = this.parent.element(name, attributes, text);
  28552. Array.prototype.push.apply(this.parent.children, removed);
  28553. return child;
  28554. }
  28555. };
  28556. XMLNode.prototype.insertAfter = function(name, attributes, text) {
  28557. var child, i, removed;
  28558. if (this.isRoot) {
  28559. throw new Error("Cannot insert elements at root level. " + this.debugInfo(name));
  28560. }
  28561. i = this.parent.children.indexOf(this);
  28562. removed = this.parent.children.splice(i + 1);
  28563. child = this.parent.element(name, attributes, text);
  28564. Array.prototype.push.apply(this.parent.children, removed);
  28565. return child;
  28566. };
  28567. XMLNode.prototype.remove = function() {
  28568. var i, ref2;
  28569. if (this.isRoot) {
  28570. throw new Error("Cannot remove the root element. " + this.debugInfo());
  28571. }
  28572. i = this.parent.children.indexOf(this);
  28573. [].splice.apply(this.parent.children, [i, i - i + 1].concat(ref2 = [])), ref2;
  28574. return this.parent;
  28575. };
  28576. XMLNode.prototype.node = function(name, attributes, text) {
  28577. var child, ref2;
  28578. if (name != null) {
  28579. name = getValue(name);
  28580. }
  28581. attributes || (attributes = {});
  28582. attributes = getValue(attributes);
  28583. if (!isObject(attributes)) {
  28584. ref2 = [attributes, text], text = ref2[0], attributes = ref2[1];
  28585. }
  28586. child = new XMLElement(this, name, attributes);
  28587. if (text != null) {
  28588. child.text(text);
  28589. }
  28590. this.children.push(child);
  28591. return child;
  28592. };
  28593. XMLNode.prototype.text = function(value) {
  28594. var child;
  28595. if (isObject(value)) {
  28596. this.element(value);
  28597. }
  28598. child = new XMLText(this, value);
  28599. this.children.push(child);
  28600. return this;
  28601. };
  28602. XMLNode.prototype.cdata = function(value) {
  28603. var child;
  28604. child = new XMLCData(this, value);
  28605. this.children.push(child);
  28606. return this;
  28607. };
  28608. XMLNode.prototype.comment = function(value) {
  28609. var child;
  28610. child = new XMLComment(this, value);
  28611. this.children.push(child);
  28612. return this;
  28613. };
  28614. XMLNode.prototype.commentBefore = function(value) {
  28615. var child, i, removed;
  28616. i = this.parent.children.indexOf(this);
  28617. removed = this.parent.children.splice(i);
  28618. child = this.parent.comment(value);
  28619. Array.prototype.push.apply(this.parent.children, removed);
  28620. return this;
  28621. };
  28622. XMLNode.prototype.commentAfter = function(value) {
  28623. var child, i, removed;
  28624. i = this.parent.children.indexOf(this);
  28625. removed = this.parent.children.splice(i + 1);
  28626. child = this.parent.comment(value);
  28627. Array.prototype.push.apply(this.parent.children, removed);
  28628. return this;
  28629. };
  28630. XMLNode.prototype.raw = function(value) {
  28631. var child;
  28632. child = new XMLRaw(this, value);
  28633. this.children.push(child);
  28634. return this;
  28635. };
  28636. XMLNode.prototype.dummy = function() {
  28637. var child;
  28638. child = new XMLDummy(this);
  28639. return child;
  28640. };
  28641. XMLNode.prototype.instruction = function(target, value) {
  28642. var insTarget, insValue, instruction, j, len;
  28643. if (target != null) {
  28644. target = getValue(target);
  28645. }
  28646. if (value != null) {
  28647. value = getValue(value);
  28648. }
  28649. if (Array.isArray(target)) {
  28650. for (j = 0, len = target.length; j < len; j++) {
  28651. insTarget = target[j];
  28652. this.instruction(insTarget);
  28653. }
  28654. } else if (isObject(target)) {
  28655. for (insTarget in target) {
  28656. if (!hasProp.call(target, insTarget)) continue;
  28657. insValue = target[insTarget];
  28658. this.instruction(insTarget, insValue);
  28659. }
  28660. } else {
  28661. if (isFunction(value)) {
  28662. value = value.apply();
  28663. }
  28664. instruction = new XMLProcessingInstruction(this, target, value);
  28665. this.children.push(instruction);
  28666. }
  28667. return this;
  28668. };
  28669. XMLNode.prototype.instructionBefore = function(target, value) {
  28670. var child, i, removed;
  28671. i = this.parent.children.indexOf(this);
  28672. removed = this.parent.children.splice(i);
  28673. child = this.parent.instruction(target, value);
  28674. Array.prototype.push.apply(this.parent.children, removed);
  28675. return this;
  28676. };
  28677. XMLNode.prototype.instructionAfter = function(target, value) {
  28678. var child, i, removed;
  28679. i = this.parent.children.indexOf(this);
  28680. removed = this.parent.children.splice(i + 1);
  28681. child = this.parent.instruction(target, value);
  28682. Array.prototype.push.apply(this.parent.children, removed);
  28683. return this;
  28684. };
  28685. XMLNode.prototype.declaration = function(version, encoding, standalone) {
  28686. var doc, xmldec;
  28687. doc = this.document();
  28688. xmldec = new XMLDeclaration(doc, version, encoding, standalone);
  28689. if (doc.children.length === 0) {
  28690. doc.children.unshift(xmldec);
  28691. } else if (doc.children[0].type === NodeType.Declaration) {
  28692. doc.children[0] = xmldec;
  28693. } else {
  28694. doc.children.unshift(xmldec);
  28695. }
  28696. return doc.root() || doc;
  28697. };
  28698. XMLNode.prototype.dtd = function(pubID, sysID) {
  28699. var child, doc, doctype, i, j, k, len, len1, ref2, ref3;
  28700. doc = this.document();
  28701. doctype = new XMLDocType(doc, pubID, sysID);
  28702. ref2 = doc.children;
  28703. for (i = j = 0, len = ref2.length; j < len; i = ++j) {
  28704. child = ref2[i];
  28705. if (child.type === NodeType.DocType) {
  28706. doc.children[i] = doctype;
  28707. return doctype;
  28708. }
  28709. }
  28710. ref3 = doc.children;
  28711. for (i = k = 0, len1 = ref3.length; k < len1; i = ++k) {
  28712. child = ref3[i];
  28713. if (child.isRoot) {
  28714. doc.children.splice(i, 0, doctype);
  28715. return doctype;
  28716. }
  28717. }
  28718. doc.children.push(doctype);
  28719. return doctype;
  28720. };
  28721. XMLNode.prototype.up = function() {
  28722. if (this.isRoot) {
  28723. throw new Error("The root node has no parent. Use doc() if you need to get the document object.");
  28724. }
  28725. return this.parent;
  28726. };
  28727. XMLNode.prototype.root = function() {
  28728. var node;
  28729. node = this;
  28730. while (node) {
  28731. if (node.type === NodeType.Document) {
  28732. return node.rootObject;
  28733. } else if (node.isRoot) {
  28734. return node;
  28735. } else {
  28736. node = node.parent;
  28737. }
  28738. }
  28739. };
  28740. XMLNode.prototype.document = function() {
  28741. var node;
  28742. node = this;
  28743. while (node) {
  28744. if (node.type === NodeType.Document) {
  28745. return node;
  28746. } else {
  28747. node = node.parent;
  28748. }
  28749. }
  28750. };
  28751. XMLNode.prototype.end = function(options) {
  28752. return this.document().end(options);
  28753. };
  28754. XMLNode.prototype.prev = function() {
  28755. var i;
  28756. i = this.parent.children.indexOf(this);
  28757. if (i < 1) {
  28758. throw new Error("Already at the first node. " + this.debugInfo());
  28759. }
  28760. return this.parent.children[i - 1];
  28761. };
  28762. XMLNode.prototype.next = function() {
  28763. var i;
  28764. i = this.parent.children.indexOf(this);
  28765. if (i === -1 || i === this.parent.children.length - 1) {
  28766. throw new Error("Already at the last node. " + this.debugInfo());
  28767. }
  28768. return this.parent.children[i + 1];
  28769. };
  28770. XMLNode.prototype.importDocument = function(doc) {
  28771. var clonedRoot;
  28772. clonedRoot = doc.root().clone();
  28773. clonedRoot.parent = this;
  28774. clonedRoot.isRoot = false;
  28775. this.children.push(clonedRoot);
  28776. return this;
  28777. };
  28778. XMLNode.prototype.debugInfo = function(name) {
  28779. var ref2, ref3;
  28780. name = name || this.name;
  28781. if ((name == null) && !((ref2 = this.parent) != null ? ref2.name : void 0)) {
  28782. return "";
  28783. } else if (name == null) {
  28784. return "parent: <" + this.parent.name + ">";
  28785. } else if (!((ref3 = this.parent) != null ? ref3.name : void 0)) {
  28786. return "node: <" + name + ">";
  28787. } else {
  28788. return "node: <" + name + ">, parent: <" + this.parent.name + ">";
  28789. }
  28790. };
  28791. XMLNode.prototype.ele = function(name, attributes, text) {
  28792. return this.element(name, attributes, text);
  28793. };
  28794. XMLNode.prototype.nod = function(name, attributes, text) {
  28795. return this.node(name, attributes, text);
  28796. };
  28797. XMLNode.prototype.txt = function(value) {
  28798. return this.text(value);
  28799. };
  28800. XMLNode.prototype.dat = function(value) {
  28801. return this.cdata(value);
  28802. };
  28803. XMLNode.prototype.com = function(value) {
  28804. return this.comment(value);
  28805. };
  28806. XMLNode.prototype.ins = function(target, value) {
  28807. return this.instruction(target, value);
  28808. };
  28809. XMLNode.prototype.doc = function() {
  28810. return this.document();
  28811. };
  28812. XMLNode.prototype.dec = function(version, encoding, standalone) {
  28813. return this.declaration(version, encoding, standalone);
  28814. };
  28815. XMLNode.prototype.e = function(name, attributes, text) {
  28816. return this.element(name, attributes, text);
  28817. };
  28818. XMLNode.prototype.n = function(name, attributes, text) {
  28819. return this.node(name, attributes, text);
  28820. };
  28821. XMLNode.prototype.t = function(value) {
  28822. return this.text(value);
  28823. };
  28824. XMLNode.prototype.d = function(value) {
  28825. return this.cdata(value);
  28826. };
  28827. XMLNode.prototype.c = function(value) {
  28828. return this.comment(value);
  28829. };
  28830. XMLNode.prototype.r = function(value) {
  28831. return this.raw(value);
  28832. };
  28833. XMLNode.prototype.i = function(target, value) {
  28834. return this.instruction(target, value);
  28835. };
  28836. XMLNode.prototype.u = function() {
  28837. return this.up();
  28838. };
  28839. XMLNode.prototype.importXMLBuilder = function(doc) {
  28840. return this.importDocument(doc);
  28841. };
  28842. XMLNode.prototype.replaceChild = function(newChild, oldChild) {
  28843. throw new Error("This DOM method is not implemented." + this.debugInfo());
  28844. };
  28845. XMLNode.prototype.removeChild = function(oldChild) {
  28846. throw new Error("This DOM method is not implemented." + this.debugInfo());
  28847. };
  28848. XMLNode.prototype.appendChild = function(newChild) {
  28849. throw new Error("This DOM method is not implemented." + this.debugInfo());
  28850. };
  28851. XMLNode.prototype.hasChildNodes = function() {
  28852. return this.children.length !== 0;
  28853. };
  28854. XMLNode.prototype.cloneNode = function(deep) {
  28855. throw new Error("This DOM method is not implemented." + this.debugInfo());
  28856. };
  28857. XMLNode.prototype.normalize = function() {
  28858. throw new Error("This DOM method is not implemented." + this.debugInfo());
  28859. };
  28860. XMLNode.prototype.isSupported = function(feature, version) {
  28861. return true;
  28862. };
  28863. XMLNode.prototype.hasAttributes = function() {
  28864. return this.attribs.length !== 0;
  28865. };
  28866. XMLNode.prototype.compareDocumentPosition = function(other) {
  28867. var ref, res;
  28868. ref = this;
  28869. if (ref === other) {
  28870. return 0;
  28871. } else if (this.document() !== other.document()) {
  28872. res = DocumentPosition.Disconnected | DocumentPosition.ImplementationSpecific;
  28873. if (Math.random() < 0.5) {
  28874. res |= DocumentPosition.Preceding;
  28875. } else {
  28876. res |= DocumentPosition.Following;
  28877. }
  28878. return res;
  28879. } else if (ref.isAncestor(other)) {
  28880. return DocumentPosition.Contains | DocumentPosition.Preceding;
  28881. } else if (ref.isDescendant(other)) {
  28882. return DocumentPosition.Contains | DocumentPosition.Following;
  28883. } else if (ref.isPreceding(other)) {
  28884. return DocumentPosition.Preceding;
  28885. } else {
  28886. return DocumentPosition.Following;
  28887. }
  28888. };
  28889. XMLNode.prototype.isSameNode = function(other) {
  28890. throw new Error("This DOM method is not implemented." + this.debugInfo());
  28891. };
  28892. XMLNode.prototype.lookupPrefix = function(namespaceURI) {
  28893. throw new Error("This DOM method is not implemented." + this.debugInfo());
  28894. };
  28895. XMLNode.prototype.isDefaultNamespace = function(namespaceURI) {
  28896. throw new Error("This DOM method is not implemented." + this.debugInfo());
  28897. };
  28898. XMLNode.prototype.lookupNamespaceURI = function(prefix) {
  28899. throw new Error("This DOM method is not implemented." + this.debugInfo());
  28900. };
  28901. XMLNode.prototype.isEqualNode = function(node) {
  28902. var i, j, ref2;
  28903. if (node.nodeType !== this.nodeType) {
  28904. return false;
  28905. }
  28906. if (node.children.length !== this.children.length) {
  28907. return false;
  28908. }
  28909. for (i = j = 0, ref2 = this.children.length - 1; 0 <= ref2 ? j <= ref2 : j >= ref2; i = 0 <= ref2 ? ++j : --j) {
  28910. if (!this.children[i].isEqualNode(node.children[i])) {
  28911. return false;
  28912. }
  28913. }
  28914. return true;
  28915. };
  28916. XMLNode.prototype.getFeature = function(feature, version) {
  28917. throw new Error("This DOM method is not implemented." + this.debugInfo());
  28918. };
  28919. XMLNode.prototype.setUserData = function(key, data, handler) {
  28920. throw new Error("This DOM method is not implemented." + this.debugInfo());
  28921. };
  28922. XMLNode.prototype.getUserData = function(key) {
  28923. throw new Error("This DOM method is not implemented." + this.debugInfo());
  28924. };
  28925. XMLNode.prototype.contains = function(other) {
  28926. if (!other) {
  28927. return false;
  28928. }
  28929. return other === this || this.isDescendant(other);
  28930. };
  28931. XMLNode.prototype.isDescendant = function(node) {
  28932. var child, isDescendantChild, j, len, ref2;
  28933. ref2 = this.children;
  28934. for (j = 0, len = ref2.length; j < len; j++) {
  28935. child = ref2[j];
  28936. if (node === child) {
  28937. return true;
  28938. }
  28939. isDescendantChild = child.isDescendant(node);
  28940. if (isDescendantChild) {
  28941. return true;
  28942. }
  28943. }
  28944. return false;
  28945. };
  28946. XMLNode.prototype.isAncestor = function(node) {
  28947. return node.isDescendant(this);
  28948. };
  28949. XMLNode.prototype.isPreceding = function(node) {
  28950. var nodePos, thisPos;
  28951. nodePos = this.treePosition(node);
  28952. thisPos = this.treePosition(this);
  28953. if (nodePos === -1 || thisPos === -1) {
  28954. return false;
  28955. } else {
  28956. return nodePos < thisPos;
  28957. }
  28958. };
  28959. XMLNode.prototype.isFollowing = function(node) {
  28960. var nodePos, thisPos;
  28961. nodePos = this.treePosition(node);
  28962. thisPos = this.treePosition(this);
  28963. if (nodePos === -1 || thisPos === -1) {
  28964. return false;
  28965. } else {
  28966. return nodePos > thisPos;
  28967. }
  28968. };
  28969. XMLNode.prototype.treePosition = function(node) {
  28970. var found, pos;
  28971. pos = 0;
  28972. found = false;
  28973. this.foreachTreeNode(this.document(), function(childNode) {
  28974. pos++;
  28975. if (!found && childNode === node) {
  28976. return found = true;
  28977. }
  28978. });
  28979. if (found) {
  28980. return pos;
  28981. } else {
  28982. return -1;
  28983. }
  28984. };
  28985. XMLNode.prototype.foreachTreeNode = function(node, func) {
  28986. var child, j, len, ref2, res;
  28987. node || (node = this.document());
  28988. ref2 = node.children;
  28989. for (j = 0, len = ref2.length; j < len; j++) {
  28990. child = ref2[j];
  28991. if (res = func(child)) {
  28992. return res;
  28993. } else {
  28994. res = this.foreachTreeNode(child, func);
  28995. if (res) {
  28996. return res;
  28997. }
  28998. }
  28999. }
  29000. };
  29001. return XMLNode;
  29002. })();
  29003. }).call(this);
  29004. },{"./DocumentPosition":353,"./NodeType":354,"./Utility":355,"./XMLCData":358,"./XMLComment":360,"./XMLDeclaration":369,"./XMLDocType":370,"./XMLDummy":373,"./XMLElement":374,"./XMLNamedNodeMap":375,"./XMLNodeList":377,"./XMLProcessingInstruction":378,"./XMLRaw":379,"./XMLText":383}],377:[function(require,module,exports){
  29005. // Generated by CoffeeScript 1.12.7
  29006. (function() {
  29007. var XMLNodeList;
  29008. module.exports = XMLNodeList = (function() {
  29009. function XMLNodeList(nodes) {
  29010. this.nodes = nodes;
  29011. }
  29012. Object.defineProperty(XMLNodeList.prototype, 'length', {
  29013. get: function() {
  29014. return this.nodes.length || 0;
  29015. }
  29016. });
  29017. XMLNodeList.prototype.clone = function() {
  29018. return this.nodes = null;
  29019. };
  29020. XMLNodeList.prototype.item = function(index) {
  29021. return this.nodes[index] || null;
  29022. };
  29023. return XMLNodeList;
  29024. })();
  29025. }).call(this);
  29026. },{}],378:[function(require,module,exports){
  29027. // Generated by CoffeeScript 1.12.7
  29028. (function() {
  29029. var NodeType, XMLCharacterData, XMLProcessingInstruction,
  29030. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  29031. hasProp = {}.hasOwnProperty;
  29032. NodeType = require('./NodeType');
  29033. XMLCharacterData = require('./XMLCharacterData');
  29034. module.exports = XMLProcessingInstruction = (function(superClass) {
  29035. extend(XMLProcessingInstruction, superClass);
  29036. function XMLProcessingInstruction(parent, target, value) {
  29037. XMLProcessingInstruction.__super__.constructor.call(this, parent);
  29038. if (target == null) {
  29039. throw new Error("Missing instruction target. " + this.debugInfo());
  29040. }
  29041. this.type = NodeType.ProcessingInstruction;
  29042. this.target = this.stringify.insTarget(target);
  29043. this.name = this.target;
  29044. if (value) {
  29045. this.value = this.stringify.insValue(value);
  29046. }
  29047. }
  29048. XMLProcessingInstruction.prototype.clone = function() {
  29049. return Object.create(this);
  29050. };
  29051. XMLProcessingInstruction.prototype.toString = function(options) {
  29052. return this.options.writer.processingInstruction(this, this.options.writer.filterOptions(options));
  29053. };
  29054. XMLProcessingInstruction.prototype.isEqualNode = function(node) {
  29055. if (!XMLProcessingInstruction.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) {
  29056. return false;
  29057. }
  29058. if (node.target !== this.target) {
  29059. return false;
  29060. }
  29061. return true;
  29062. };
  29063. return XMLProcessingInstruction;
  29064. })(XMLCharacterData);
  29065. }).call(this);
  29066. },{"./NodeType":354,"./XMLCharacterData":359}],379:[function(require,module,exports){
  29067. // Generated by CoffeeScript 1.12.7
  29068. (function() {
  29069. var NodeType, XMLNode, XMLRaw,
  29070. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  29071. hasProp = {}.hasOwnProperty;
  29072. NodeType = require('./NodeType');
  29073. XMLNode = require('./XMLNode');
  29074. module.exports = XMLRaw = (function(superClass) {
  29075. extend(XMLRaw, superClass);
  29076. function XMLRaw(parent, text) {
  29077. XMLRaw.__super__.constructor.call(this, parent);
  29078. if (text == null) {
  29079. throw new Error("Missing raw text. " + this.debugInfo());
  29080. }
  29081. this.type = NodeType.Raw;
  29082. this.value = this.stringify.raw(text);
  29083. }
  29084. XMLRaw.prototype.clone = function() {
  29085. return Object.create(this);
  29086. };
  29087. XMLRaw.prototype.toString = function(options) {
  29088. return this.options.writer.raw(this, this.options.writer.filterOptions(options));
  29089. };
  29090. return XMLRaw;
  29091. })(XMLNode);
  29092. }).call(this);
  29093. },{"./NodeType":354,"./XMLNode":376}],380:[function(require,module,exports){
  29094. // Generated by CoffeeScript 1.12.7
  29095. (function() {
  29096. var NodeType, WriterState, XMLStreamWriter, XMLWriterBase,
  29097. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  29098. hasProp = {}.hasOwnProperty;
  29099. NodeType = require('./NodeType');
  29100. XMLWriterBase = require('./XMLWriterBase');
  29101. WriterState = require('./WriterState');
  29102. module.exports = XMLStreamWriter = (function(superClass) {
  29103. extend(XMLStreamWriter, superClass);
  29104. function XMLStreamWriter(stream, options) {
  29105. this.stream = stream;
  29106. XMLStreamWriter.__super__.constructor.call(this, options);
  29107. }
  29108. XMLStreamWriter.prototype.endline = function(node, options, level) {
  29109. if (node.isLastRootNode && options.state === WriterState.CloseTag) {
  29110. return '';
  29111. } else {
  29112. return XMLStreamWriter.__super__.endline.call(this, node, options, level);
  29113. }
  29114. };
  29115. XMLStreamWriter.prototype.document = function(doc, options) {
  29116. var child, i, j, k, len, len1, ref, ref1, results;
  29117. ref = doc.children;
  29118. for (i = j = 0, len = ref.length; j < len; i = ++j) {
  29119. child = ref[i];
  29120. child.isLastRootNode = i === doc.children.length - 1;
  29121. }
  29122. options = this.filterOptions(options);
  29123. ref1 = doc.children;
  29124. results = [];
  29125. for (k = 0, len1 = ref1.length; k < len1; k++) {
  29126. child = ref1[k];
  29127. results.push(this.writeChildNode(child, options, 0));
  29128. }
  29129. return results;
  29130. };
  29131. XMLStreamWriter.prototype.attribute = function(att, options, level) {
  29132. return this.stream.write(XMLStreamWriter.__super__.attribute.call(this, att, options, level));
  29133. };
  29134. XMLStreamWriter.prototype.cdata = function(node, options, level) {
  29135. return this.stream.write(XMLStreamWriter.__super__.cdata.call(this, node, options, level));
  29136. };
  29137. XMLStreamWriter.prototype.comment = function(node, options, level) {
  29138. return this.stream.write(XMLStreamWriter.__super__.comment.call(this, node, options, level));
  29139. };
  29140. XMLStreamWriter.prototype.declaration = function(node, options, level) {
  29141. return this.stream.write(XMLStreamWriter.__super__.declaration.call(this, node, options, level));
  29142. };
  29143. XMLStreamWriter.prototype.docType = function(node, options, level) {
  29144. var child, j, len, ref;
  29145. level || (level = 0);
  29146. this.openNode(node, options, level);
  29147. options.state = WriterState.OpenTag;
  29148. this.stream.write(this.indent(node, options, level));
  29149. this.stream.write('<!DOCTYPE ' + node.root().name);
  29150. if (node.pubID && node.sysID) {
  29151. this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"');
  29152. } else if (node.sysID) {
  29153. this.stream.write(' SYSTEM "' + node.sysID + '"');
  29154. }
  29155. if (node.children.length > 0) {
  29156. this.stream.write(' [');
  29157. this.stream.write(this.endline(node, options, level));
  29158. options.state = WriterState.InsideTag;
  29159. ref = node.children;
  29160. for (j = 0, len = ref.length; j < len; j++) {
  29161. child = ref[j];
  29162. this.writeChildNode(child, options, level + 1);
  29163. }
  29164. options.state = WriterState.CloseTag;
  29165. this.stream.write(']');
  29166. }
  29167. options.state = WriterState.CloseTag;
  29168. this.stream.write(options.spaceBeforeSlash + '>');
  29169. this.stream.write(this.endline(node, options, level));
  29170. options.state = WriterState.None;
  29171. return this.closeNode(node, options, level);
  29172. };
  29173. XMLStreamWriter.prototype.element = function(node, options, level) {
  29174. var att, child, childNodeCount, firstChildNode, j, len, name, prettySuppressed, ref, ref1;
  29175. level || (level = 0);
  29176. this.openNode(node, options, level);
  29177. options.state = WriterState.OpenTag;
  29178. this.stream.write(this.indent(node, options, level) + '<' + node.name);
  29179. ref = node.attribs;
  29180. for (name in ref) {
  29181. if (!hasProp.call(ref, name)) continue;
  29182. att = ref[name];
  29183. this.attribute(att, options, level);
  29184. }
  29185. childNodeCount = node.children.length;
  29186. firstChildNode = childNodeCount === 0 ? null : node.children[0];
  29187. if (childNodeCount === 0 || node.children.every(function(e) {
  29188. return (e.type === NodeType.Text || e.type === NodeType.Raw) && e.value === '';
  29189. })) {
  29190. if (options.allowEmpty) {
  29191. this.stream.write('>');
  29192. options.state = WriterState.CloseTag;
  29193. this.stream.write('</' + node.name + '>');
  29194. } else {
  29195. options.state = WriterState.CloseTag;
  29196. this.stream.write(options.spaceBeforeSlash + '/>');
  29197. }
  29198. } else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw) && (firstChildNode.value != null)) {
  29199. this.stream.write('>');
  29200. options.state = WriterState.InsideTag;
  29201. options.suppressPrettyCount++;
  29202. prettySuppressed = true;
  29203. this.writeChildNode(firstChildNode, options, level + 1);
  29204. options.suppressPrettyCount--;
  29205. prettySuppressed = false;
  29206. options.state = WriterState.CloseTag;
  29207. this.stream.write('</' + node.name + '>');
  29208. } else {
  29209. this.stream.write('>' + this.endline(node, options, level));
  29210. options.state = WriterState.InsideTag;
  29211. ref1 = node.children;
  29212. for (j = 0, len = ref1.length; j < len; j++) {
  29213. child = ref1[j];
  29214. this.writeChildNode(child, options, level + 1);
  29215. }
  29216. options.state = WriterState.CloseTag;
  29217. this.stream.write(this.indent(node, options, level) + '</' + node.name + '>');
  29218. }
  29219. this.stream.write(this.endline(node, options, level));
  29220. options.state = WriterState.None;
  29221. return this.closeNode(node, options, level);
  29222. };
  29223. XMLStreamWriter.prototype.processingInstruction = function(node, options, level) {
  29224. return this.stream.write(XMLStreamWriter.__super__.processingInstruction.call(this, node, options, level));
  29225. };
  29226. XMLStreamWriter.prototype.raw = function(node, options, level) {
  29227. return this.stream.write(XMLStreamWriter.__super__.raw.call(this, node, options, level));
  29228. };
  29229. XMLStreamWriter.prototype.text = function(node, options, level) {
  29230. return this.stream.write(XMLStreamWriter.__super__.text.call(this, node, options, level));
  29231. };
  29232. XMLStreamWriter.prototype.dtdAttList = function(node, options, level) {
  29233. return this.stream.write(XMLStreamWriter.__super__.dtdAttList.call(this, node, options, level));
  29234. };
  29235. XMLStreamWriter.prototype.dtdElement = function(node, options, level) {
  29236. return this.stream.write(XMLStreamWriter.__super__.dtdElement.call(this, node, options, level));
  29237. };
  29238. XMLStreamWriter.prototype.dtdEntity = function(node, options, level) {
  29239. return this.stream.write(XMLStreamWriter.__super__.dtdEntity.call(this, node, options, level));
  29240. };
  29241. XMLStreamWriter.prototype.dtdNotation = function(node, options, level) {
  29242. return this.stream.write(XMLStreamWriter.__super__.dtdNotation.call(this, node, options, level));
  29243. };
  29244. return XMLStreamWriter;
  29245. })(XMLWriterBase);
  29246. }).call(this);
  29247. },{"./NodeType":354,"./WriterState":356,"./XMLWriterBase":384}],381:[function(require,module,exports){
  29248. // Generated by CoffeeScript 1.12.7
  29249. (function() {
  29250. var XMLStringWriter, XMLWriterBase,
  29251. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  29252. hasProp = {}.hasOwnProperty;
  29253. XMLWriterBase = require('./XMLWriterBase');
  29254. module.exports = XMLStringWriter = (function(superClass) {
  29255. extend(XMLStringWriter, superClass);
  29256. function XMLStringWriter(options) {
  29257. XMLStringWriter.__super__.constructor.call(this, options);
  29258. }
  29259. XMLStringWriter.prototype.document = function(doc, options) {
  29260. var child, i, len, r, ref;
  29261. options = this.filterOptions(options);
  29262. r = '';
  29263. ref = doc.children;
  29264. for (i = 0, len = ref.length; i < len; i++) {
  29265. child = ref[i];
  29266. r += this.writeChildNode(child, options, 0);
  29267. }
  29268. if (options.pretty && r.slice(-options.newline.length) === options.newline) {
  29269. r = r.slice(0, -options.newline.length);
  29270. }
  29271. return r;
  29272. };
  29273. return XMLStringWriter;
  29274. })(XMLWriterBase);
  29275. }).call(this);
  29276. },{"./XMLWriterBase":384}],382:[function(require,module,exports){
  29277. // Generated by CoffeeScript 1.12.7
  29278. (function() {
  29279. var XMLStringifier,
  29280. bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  29281. hasProp = {}.hasOwnProperty;
  29282. module.exports = XMLStringifier = (function() {
  29283. function XMLStringifier(options) {
  29284. this.assertLegalName = bind(this.assertLegalName, this);
  29285. this.assertLegalChar = bind(this.assertLegalChar, this);
  29286. var key, ref, value;
  29287. options || (options = {});
  29288. this.options = options;
  29289. if (!this.options.version) {
  29290. this.options.version = '1.0';
  29291. }
  29292. ref = options.stringify || {};
  29293. for (key in ref) {
  29294. if (!hasProp.call(ref, key)) continue;
  29295. value = ref[key];
  29296. this[key] = value;
  29297. }
  29298. }
  29299. XMLStringifier.prototype.name = function(val) {
  29300. if (this.options.noValidation) {
  29301. return val;
  29302. }
  29303. return this.assertLegalName('' + val || '');
  29304. };
  29305. XMLStringifier.prototype.text = function(val) {
  29306. if (this.options.noValidation) {
  29307. return val;
  29308. }
  29309. return this.assertLegalChar(this.textEscape('' + val || ''));
  29310. };
  29311. XMLStringifier.prototype.cdata = function(val) {
  29312. if (this.options.noValidation) {
  29313. return val;
  29314. }
  29315. val = '' + val || '';
  29316. val = val.replace(']]>', ']]]]><![CDATA[>');
  29317. return this.assertLegalChar(val);
  29318. };
  29319. XMLStringifier.prototype.comment = function(val) {
  29320. if (this.options.noValidation) {
  29321. return val;
  29322. }
  29323. val = '' + val || '';
  29324. if (val.match(/--/)) {
  29325. throw new Error("Comment text cannot contain double-hypen: " + val);
  29326. }
  29327. return this.assertLegalChar(val);
  29328. };
  29329. XMLStringifier.prototype.raw = function(val) {
  29330. if (this.options.noValidation) {
  29331. return val;
  29332. }
  29333. return '' + val || '';
  29334. };
  29335. XMLStringifier.prototype.attValue = function(val) {
  29336. if (this.options.noValidation) {
  29337. return val;
  29338. }
  29339. return this.assertLegalChar(this.attEscape(val = '' + val || ''));
  29340. };
  29341. XMLStringifier.prototype.insTarget = function(val) {
  29342. if (this.options.noValidation) {
  29343. return val;
  29344. }
  29345. return this.assertLegalChar('' + val || '');
  29346. };
  29347. XMLStringifier.prototype.insValue = function(val) {
  29348. if (this.options.noValidation) {
  29349. return val;
  29350. }
  29351. val = '' + val || '';
  29352. if (val.match(/\?>/)) {
  29353. throw new Error("Invalid processing instruction value: " + val);
  29354. }
  29355. return this.assertLegalChar(val);
  29356. };
  29357. XMLStringifier.prototype.xmlVersion = function(val) {
  29358. if (this.options.noValidation) {
  29359. return val;
  29360. }
  29361. val = '' + val || '';
  29362. if (!val.match(/1\.[0-9]+/)) {
  29363. throw new Error("Invalid version number: " + val);
  29364. }
  29365. return val;
  29366. };
  29367. XMLStringifier.prototype.xmlEncoding = function(val) {
  29368. if (this.options.noValidation) {
  29369. return val;
  29370. }
  29371. val = '' + val || '';
  29372. if (!val.match(/^[A-Za-z](?:[A-Za-z0-9._-])*$/)) {
  29373. throw new Error("Invalid encoding: " + val);
  29374. }
  29375. return this.assertLegalChar(val);
  29376. };
  29377. XMLStringifier.prototype.xmlStandalone = function(val) {
  29378. if (this.options.noValidation) {
  29379. return val;
  29380. }
  29381. if (val) {
  29382. return "yes";
  29383. } else {
  29384. return "no";
  29385. }
  29386. };
  29387. XMLStringifier.prototype.dtdPubID = function(val) {
  29388. if (this.options.noValidation) {
  29389. return val;
  29390. }
  29391. return this.assertLegalChar('' + val || '');
  29392. };
  29393. XMLStringifier.prototype.dtdSysID = function(val) {
  29394. if (this.options.noValidation) {
  29395. return val;
  29396. }
  29397. return this.assertLegalChar('' + val || '');
  29398. };
  29399. XMLStringifier.prototype.dtdElementValue = function(val) {
  29400. if (this.options.noValidation) {
  29401. return val;
  29402. }
  29403. return this.assertLegalChar('' + val || '');
  29404. };
  29405. XMLStringifier.prototype.dtdAttType = function(val) {
  29406. if (this.options.noValidation) {
  29407. return val;
  29408. }
  29409. return this.assertLegalChar('' + val || '');
  29410. };
  29411. XMLStringifier.prototype.dtdAttDefault = function(val) {
  29412. if (this.options.noValidation) {
  29413. return val;
  29414. }
  29415. return this.assertLegalChar('' + val || '');
  29416. };
  29417. XMLStringifier.prototype.dtdEntityValue = function(val) {
  29418. if (this.options.noValidation) {
  29419. return val;
  29420. }
  29421. return this.assertLegalChar('' + val || '');
  29422. };
  29423. XMLStringifier.prototype.dtdNData = function(val) {
  29424. if (this.options.noValidation) {
  29425. return val;
  29426. }
  29427. return this.assertLegalChar('' + val || '');
  29428. };
  29429. XMLStringifier.prototype.convertAttKey = '@';
  29430. XMLStringifier.prototype.convertPIKey = '?';
  29431. XMLStringifier.prototype.convertTextKey = '#text';
  29432. XMLStringifier.prototype.convertCDataKey = '#cdata';
  29433. XMLStringifier.prototype.convertCommentKey = '#comment';
  29434. XMLStringifier.prototype.convertRawKey = '#raw';
  29435. XMLStringifier.prototype.assertLegalChar = function(str) {
  29436. var regex, res;
  29437. if (this.options.noValidation) {
  29438. return str;
  29439. }
  29440. regex = '';
  29441. if (this.options.version === '1.0') {
  29442. regex = /[\0-\x08\x0B\f\x0E-\x1F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
  29443. if (res = str.match(regex)) {
  29444. throw new Error("Invalid character in string: " + str + " at index " + res.index);
  29445. }
  29446. } else if (this.options.version === '1.1') {
  29447. regex = /[\0\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
  29448. if (res = str.match(regex)) {
  29449. throw new Error("Invalid character in string: " + str + " at index " + res.index);
  29450. }
  29451. }
  29452. return str;
  29453. };
  29454. XMLStringifier.prototype.assertLegalName = function(str) {
  29455. var regex;
  29456. if (this.options.noValidation) {
  29457. return str;
  29458. }
  29459. this.assertLegalChar(str);
  29460. regex = /^([:A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])([\x2D\.0-:A-Z_a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*$/;
  29461. if (!str.match(regex)) {
  29462. throw new Error("Invalid character in name");
  29463. }
  29464. return str;
  29465. };
  29466. XMLStringifier.prototype.textEscape = function(str) {
  29467. var ampregex;
  29468. if (this.options.noValidation) {
  29469. return str;
  29470. }
  29471. ampregex = this.options.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g;
  29472. return str.replace(ampregex, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\r/g, '&#xD;');
  29473. };
  29474. XMLStringifier.prototype.attEscape = function(str) {
  29475. var ampregex;
  29476. if (this.options.noValidation) {
  29477. return str;
  29478. }
  29479. ampregex = this.options.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g;
  29480. return str.replace(ampregex, '&amp;').replace(/</g, '&lt;').replace(/"/g, '&quot;').replace(/\t/g, '&#x9;').replace(/\n/g, '&#xA;').replace(/\r/g, '&#xD;');
  29481. };
  29482. return XMLStringifier;
  29483. })();
  29484. }).call(this);
  29485. },{}],383:[function(require,module,exports){
  29486. // Generated by CoffeeScript 1.12.7
  29487. (function() {
  29488. var NodeType, XMLCharacterData, XMLText,
  29489. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  29490. hasProp = {}.hasOwnProperty;
  29491. NodeType = require('./NodeType');
  29492. XMLCharacterData = require('./XMLCharacterData');
  29493. module.exports = XMLText = (function(superClass) {
  29494. extend(XMLText, superClass);
  29495. function XMLText(parent, text) {
  29496. XMLText.__super__.constructor.call(this, parent);
  29497. if (text == null) {
  29498. throw new Error("Missing element text. " + this.debugInfo());
  29499. }
  29500. this.name = "#text";
  29501. this.type = NodeType.Text;
  29502. this.value = this.stringify.text(text);
  29503. }
  29504. Object.defineProperty(XMLText.prototype, 'isElementContentWhitespace', {
  29505. get: function() {
  29506. throw new Error("This DOM method is not implemented." + this.debugInfo());
  29507. }
  29508. });
  29509. Object.defineProperty(XMLText.prototype, 'wholeText', {
  29510. get: function() {
  29511. var next, prev, str;
  29512. str = '';
  29513. prev = this.previousSibling;
  29514. while (prev) {
  29515. str = prev.data + str;
  29516. prev = prev.previousSibling;
  29517. }
  29518. str += this.data;
  29519. next = this.nextSibling;
  29520. while (next) {
  29521. str = str + next.data;
  29522. next = next.nextSibling;
  29523. }
  29524. return str;
  29525. }
  29526. });
  29527. XMLText.prototype.clone = function() {
  29528. return Object.create(this);
  29529. };
  29530. XMLText.prototype.toString = function(options) {
  29531. return this.options.writer.text(this, this.options.writer.filterOptions(options));
  29532. };
  29533. XMLText.prototype.splitText = function(offset) {
  29534. throw new Error("This DOM method is not implemented." + this.debugInfo());
  29535. };
  29536. XMLText.prototype.replaceWholeText = function(content) {
  29537. throw new Error("This DOM method is not implemented." + this.debugInfo());
  29538. };
  29539. return XMLText;
  29540. })(XMLCharacterData);
  29541. }).call(this);
  29542. },{"./NodeType":354,"./XMLCharacterData":359}],384:[function(require,module,exports){
  29543. // Generated by CoffeeScript 1.12.7
  29544. (function() {
  29545. var NodeType, WriterState, XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLDummy, XMLElement, XMLProcessingInstruction, XMLRaw, XMLText, XMLWriterBase, assign,
  29546. hasProp = {}.hasOwnProperty;
  29547. assign = require('./Utility').assign;
  29548. NodeType = require('./NodeType');
  29549. XMLDeclaration = require('./XMLDeclaration');
  29550. XMLDocType = require('./XMLDocType');
  29551. XMLCData = require('./XMLCData');
  29552. XMLComment = require('./XMLComment');
  29553. XMLElement = require('./XMLElement');
  29554. XMLRaw = require('./XMLRaw');
  29555. XMLText = require('./XMLText');
  29556. XMLProcessingInstruction = require('./XMLProcessingInstruction');
  29557. XMLDummy = require('./XMLDummy');
  29558. XMLDTDAttList = require('./XMLDTDAttList');
  29559. XMLDTDElement = require('./XMLDTDElement');
  29560. XMLDTDEntity = require('./XMLDTDEntity');
  29561. XMLDTDNotation = require('./XMLDTDNotation');
  29562. WriterState = require('./WriterState');
  29563. module.exports = XMLWriterBase = (function() {
  29564. function XMLWriterBase(options) {
  29565. var key, ref, value;
  29566. options || (options = {});
  29567. this.options = options;
  29568. ref = options.writer || {};
  29569. for (key in ref) {
  29570. if (!hasProp.call(ref, key)) continue;
  29571. value = ref[key];
  29572. this["_" + key] = this[key];
  29573. this[key] = value;
  29574. }
  29575. }
  29576. XMLWriterBase.prototype.filterOptions = function(options) {
  29577. var filteredOptions, ref, ref1, ref2, ref3, ref4, ref5, ref6;
  29578. options || (options = {});
  29579. options = assign({}, this.options, options);
  29580. filteredOptions = {
  29581. writer: this
  29582. };
  29583. filteredOptions.pretty = options.pretty || false;
  29584. filteredOptions.allowEmpty = options.allowEmpty || false;
  29585. filteredOptions.indent = (ref = options.indent) != null ? ref : ' ';
  29586. filteredOptions.newline = (ref1 = options.newline) != null ? ref1 : '\n';
  29587. filteredOptions.offset = (ref2 = options.offset) != null ? ref2 : 0;
  29588. filteredOptions.dontPrettyTextNodes = (ref3 = (ref4 = options.dontPrettyTextNodes) != null ? ref4 : options.dontprettytextnodes) != null ? ref3 : 0;
  29589. filteredOptions.spaceBeforeSlash = (ref5 = (ref6 = options.spaceBeforeSlash) != null ? ref6 : options.spacebeforeslash) != null ? ref5 : '';
  29590. if (filteredOptions.spaceBeforeSlash === true) {
  29591. filteredOptions.spaceBeforeSlash = ' ';
  29592. }
  29593. filteredOptions.suppressPrettyCount = 0;
  29594. filteredOptions.user = {};
  29595. filteredOptions.state = WriterState.None;
  29596. return filteredOptions;
  29597. };
  29598. XMLWriterBase.prototype.indent = function(node, options, level) {
  29599. var indentLevel;
  29600. if (!options.pretty || options.suppressPrettyCount) {
  29601. return '';
  29602. } else if (options.pretty) {
  29603. indentLevel = (level || 0) + options.offset + 1;
  29604. if (indentLevel > 0) {
  29605. return new Array(indentLevel).join(options.indent);
  29606. }
  29607. }
  29608. return '';
  29609. };
  29610. XMLWriterBase.prototype.endline = function(node, options, level) {
  29611. if (!options.pretty || options.suppressPrettyCount) {
  29612. return '';
  29613. } else {
  29614. return options.newline;
  29615. }
  29616. };
  29617. XMLWriterBase.prototype.attribute = function(att, options, level) {
  29618. var r;
  29619. this.openAttribute(att, options, level);
  29620. r = ' ' + att.name + '="' + att.value + '"';
  29621. this.closeAttribute(att, options, level);
  29622. return r;
  29623. };
  29624. XMLWriterBase.prototype.cdata = function(node, options, level) {
  29625. var r;
  29626. this.openNode(node, options, level);
  29627. options.state = WriterState.OpenTag;
  29628. r = this.indent(node, options, level) + '<![CDATA[';
  29629. options.state = WriterState.InsideTag;
  29630. r += node.value;
  29631. options.state = WriterState.CloseTag;
  29632. r += ']]>' + this.endline(node, options, level);
  29633. options.state = WriterState.None;
  29634. this.closeNode(node, options, level);
  29635. return r;
  29636. };
  29637. XMLWriterBase.prototype.comment = function(node, options, level) {
  29638. var r;
  29639. this.openNode(node, options, level);
  29640. options.state = WriterState.OpenTag;
  29641. r = this.indent(node, options, level) + '<!-- ';
  29642. options.state = WriterState.InsideTag;
  29643. r += node.value;
  29644. options.state = WriterState.CloseTag;
  29645. r += ' -->' + this.endline(node, options, level);
  29646. options.state = WriterState.None;
  29647. this.closeNode(node, options, level);
  29648. return r;
  29649. };
  29650. XMLWriterBase.prototype.declaration = function(node, options, level) {
  29651. var r;
  29652. this.openNode(node, options, level);
  29653. options.state = WriterState.OpenTag;
  29654. r = this.indent(node, options, level) + '<?xml';
  29655. options.state = WriterState.InsideTag;
  29656. r += ' version="' + node.version + '"';
  29657. if (node.encoding != null) {
  29658. r += ' encoding="' + node.encoding + '"';
  29659. }
  29660. if (node.standalone != null) {
  29661. r += ' standalone="' + node.standalone + '"';
  29662. }
  29663. options.state = WriterState.CloseTag;
  29664. r += options.spaceBeforeSlash + '?>';
  29665. r += this.endline(node, options, level);
  29666. options.state = WriterState.None;
  29667. this.closeNode(node, options, level);
  29668. return r;
  29669. };
  29670. XMLWriterBase.prototype.docType = function(node, options, level) {
  29671. var child, i, len, r, ref;
  29672. level || (level = 0);
  29673. this.openNode(node, options, level);
  29674. options.state = WriterState.OpenTag;
  29675. r = this.indent(node, options, level);
  29676. r += '<!DOCTYPE ' + node.root().name;
  29677. if (node.pubID && node.sysID) {
  29678. r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
  29679. } else if (node.sysID) {
  29680. r += ' SYSTEM "' + node.sysID + '"';
  29681. }
  29682. if (node.children.length > 0) {
  29683. r += ' [';
  29684. r += this.endline(node, options, level);
  29685. options.state = WriterState.InsideTag;
  29686. ref = node.children;
  29687. for (i = 0, len = ref.length; i < len; i++) {
  29688. child = ref[i];
  29689. r += this.writeChildNode(child, options, level + 1);
  29690. }
  29691. options.state = WriterState.CloseTag;
  29692. r += ']';
  29693. }
  29694. options.state = WriterState.CloseTag;
  29695. r += options.spaceBeforeSlash + '>';
  29696. r += this.endline(node, options, level);
  29697. options.state = WriterState.None;
  29698. this.closeNode(node, options, level);
  29699. return r;
  29700. };
  29701. XMLWriterBase.prototype.element = function(node, options, level) {
  29702. var att, child, childNodeCount, firstChildNode, i, j, len, len1, name, prettySuppressed, r, ref, ref1, ref2;
  29703. level || (level = 0);
  29704. prettySuppressed = false;
  29705. r = '';
  29706. this.openNode(node, options, level);
  29707. options.state = WriterState.OpenTag;
  29708. r += this.indent(node, options, level) + '<' + node.name;
  29709. ref = node.attribs;
  29710. for (name in ref) {
  29711. if (!hasProp.call(ref, name)) continue;
  29712. att = ref[name];
  29713. r += this.attribute(att, options, level);
  29714. }
  29715. childNodeCount = node.children.length;
  29716. firstChildNode = childNodeCount === 0 ? null : node.children[0];
  29717. if (childNodeCount === 0 || node.children.every(function(e) {
  29718. return (e.type === NodeType.Text || e.type === NodeType.Raw) && e.value === '';
  29719. })) {
  29720. if (options.allowEmpty) {
  29721. r += '>';
  29722. options.state = WriterState.CloseTag;
  29723. r += '</' + node.name + '>' + this.endline(node, options, level);
  29724. } else {
  29725. options.state = WriterState.CloseTag;
  29726. r += options.spaceBeforeSlash + '/>' + this.endline(node, options, level);
  29727. }
  29728. } else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw) && (firstChildNode.value != null)) {
  29729. r += '>';
  29730. options.state = WriterState.InsideTag;
  29731. options.suppressPrettyCount++;
  29732. prettySuppressed = true;
  29733. r += this.writeChildNode(firstChildNode, options, level + 1);
  29734. options.suppressPrettyCount--;
  29735. prettySuppressed = false;
  29736. options.state = WriterState.CloseTag;
  29737. r += '</' + node.name + '>' + this.endline(node, options, level);
  29738. } else {
  29739. if (options.dontPrettyTextNodes) {
  29740. ref1 = node.children;
  29741. for (i = 0, len = ref1.length; i < len; i++) {
  29742. child = ref1[i];
  29743. if ((child.type === NodeType.Text || child.type === NodeType.Raw) && (child.value != null)) {
  29744. options.suppressPrettyCount++;
  29745. prettySuppressed = true;
  29746. break;
  29747. }
  29748. }
  29749. }
  29750. r += '>' + this.endline(node, options, level);
  29751. options.state = WriterState.InsideTag;
  29752. ref2 = node.children;
  29753. for (j = 0, len1 = ref2.length; j < len1; j++) {
  29754. child = ref2[j];
  29755. r += this.writeChildNode(child, options, level + 1);
  29756. }
  29757. options.state = WriterState.CloseTag;
  29758. r += this.indent(node, options, level) + '</' + node.name + '>';
  29759. if (prettySuppressed) {
  29760. options.suppressPrettyCount--;
  29761. }
  29762. r += this.endline(node, options, level);
  29763. options.state = WriterState.None;
  29764. }
  29765. this.closeNode(node, options, level);
  29766. return r;
  29767. };
  29768. XMLWriterBase.prototype.writeChildNode = function(node, options, level) {
  29769. switch (node.type) {
  29770. case NodeType.CData:
  29771. return this.cdata(node, options, level);
  29772. case NodeType.Comment:
  29773. return this.comment(node, options, level);
  29774. case NodeType.Element:
  29775. return this.element(node, options, level);
  29776. case NodeType.Raw:
  29777. return this.raw(node, options, level);
  29778. case NodeType.Text:
  29779. return this.text(node, options, level);
  29780. case NodeType.ProcessingInstruction:
  29781. return this.processingInstruction(node, options, level);
  29782. case NodeType.Dummy:
  29783. return '';
  29784. case NodeType.Declaration:
  29785. return this.declaration(node, options, level);
  29786. case NodeType.DocType:
  29787. return this.docType(node, options, level);
  29788. case NodeType.AttributeDeclaration:
  29789. return this.dtdAttList(node, options, level);
  29790. case NodeType.ElementDeclaration:
  29791. return this.dtdElement(node, options, level);
  29792. case NodeType.EntityDeclaration:
  29793. return this.dtdEntity(node, options, level);
  29794. case NodeType.NotationDeclaration:
  29795. return this.dtdNotation(node, options, level);
  29796. default:
  29797. throw new Error("Unknown XML node type: " + node.constructor.name);
  29798. }
  29799. };
  29800. XMLWriterBase.prototype.processingInstruction = function(node, options, level) {
  29801. var r;
  29802. this.openNode(node, options, level);
  29803. options.state = WriterState.OpenTag;
  29804. r = this.indent(node, options, level) + '<?';
  29805. options.state = WriterState.InsideTag;
  29806. r += node.target;
  29807. if (node.value) {
  29808. r += ' ' + node.value;
  29809. }
  29810. options.state = WriterState.CloseTag;
  29811. r += options.spaceBeforeSlash + '?>';
  29812. r += this.endline(node, options, level);
  29813. options.state = WriterState.None;
  29814. this.closeNode(node, options, level);
  29815. return r;
  29816. };
  29817. XMLWriterBase.prototype.raw = function(node, options, level) {
  29818. var r;
  29819. this.openNode(node, options, level);
  29820. options.state = WriterState.OpenTag;
  29821. r = this.indent(node, options, level);
  29822. options.state = WriterState.InsideTag;
  29823. r += node.value;
  29824. options.state = WriterState.CloseTag;
  29825. r += this.endline(node, options, level);
  29826. options.state = WriterState.None;
  29827. this.closeNode(node, options, level);
  29828. return r;
  29829. };
  29830. XMLWriterBase.prototype.text = function(node, options, level) {
  29831. var r;
  29832. this.openNode(node, options, level);
  29833. options.state = WriterState.OpenTag;
  29834. r = this.indent(node, options, level);
  29835. options.state = WriterState.InsideTag;
  29836. r += node.value;
  29837. options.state = WriterState.CloseTag;
  29838. r += this.endline(node, options, level);
  29839. options.state = WriterState.None;
  29840. this.closeNode(node, options, level);
  29841. return r;
  29842. };
  29843. XMLWriterBase.prototype.dtdAttList = function(node, options, level) {
  29844. var r;
  29845. this.openNode(node, options, level);
  29846. options.state = WriterState.OpenTag;
  29847. r = this.indent(node, options, level) + '<!ATTLIST';
  29848. options.state = WriterState.InsideTag;
  29849. r += ' ' + node.elementName + ' ' + node.attributeName + ' ' + node.attributeType;
  29850. if (node.defaultValueType !== '#DEFAULT') {
  29851. r += ' ' + node.defaultValueType;
  29852. }
  29853. if (node.defaultValue) {
  29854. r += ' "' + node.defaultValue + '"';
  29855. }
  29856. options.state = WriterState.CloseTag;
  29857. r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
  29858. options.state = WriterState.None;
  29859. this.closeNode(node, options, level);
  29860. return r;
  29861. };
  29862. XMLWriterBase.prototype.dtdElement = function(node, options, level) {
  29863. var r;
  29864. this.openNode(node, options, level);
  29865. options.state = WriterState.OpenTag;
  29866. r = this.indent(node, options, level) + '<!ELEMENT';
  29867. options.state = WriterState.InsideTag;
  29868. r += ' ' + node.name + ' ' + node.value;
  29869. options.state = WriterState.CloseTag;
  29870. r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
  29871. options.state = WriterState.None;
  29872. this.closeNode(node, options, level);
  29873. return r;
  29874. };
  29875. XMLWriterBase.prototype.dtdEntity = function(node, options, level) {
  29876. var r;
  29877. this.openNode(node, options, level);
  29878. options.state = WriterState.OpenTag;
  29879. r = this.indent(node, options, level) + '<!ENTITY';
  29880. options.state = WriterState.InsideTag;
  29881. if (node.pe) {
  29882. r += ' %';
  29883. }
  29884. r += ' ' + node.name;
  29885. if (node.value) {
  29886. r += ' "' + node.value + '"';
  29887. } else {
  29888. if (node.pubID && node.sysID) {
  29889. r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
  29890. } else if (node.sysID) {
  29891. r += ' SYSTEM "' + node.sysID + '"';
  29892. }
  29893. if (node.nData) {
  29894. r += ' NDATA ' + node.nData;
  29895. }
  29896. }
  29897. options.state = WriterState.CloseTag;
  29898. r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
  29899. options.state = WriterState.None;
  29900. this.closeNode(node, options, level);
  29901. return r;
  29902. };
  29903. XMLWriterBase.prototype.dtdNotation = function(node, options, level) {
  29904. var r;
  29905. this.openNode(node, options, level);
  29906. options.state = WriterState.OpenTag;
  29907. r = this.indent(node, options, level) + '<!NOTATION';
  29908. options.state = WriterState.InsideTag;
  29909. r += ' ' + node.name;
  29910. if (node.pubID && node.sysID) {
  29911. r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
  29912. } else if (node.pubID) {
  29913. r += ' PUBLIC "' + node.pubID + '"';
  29914. } else if (node.sysID) {
  29915. r += ' SYSTEM "' + node.sysID + '"';
  29916. }
  29917. options.state = WriterState.CloseTag;
  29918. r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
  29919. options.state = WriterState.None;
  29920. this.closeNode(node, options, level);
  29921. return r;
  29922. };
  29923. XMLWriterBase.prototype.openNode = function(node, options, level) {};
  29924. XMLWriterBase.prototype.closeNode = function(node, options, level) {};
  29925. XMLWriterBase.prototype.openAttribute = function(att, options, level) {};
  29926. XMLWriterBase.prototype.closeAttribute = function(att, options, level) {};
  29927. return XMLWriterBase;
  29928. })();
  29929. }).call(this);
  29930. },{"./NodeType":354,"./Utility":355,"./WriterState":356,"./XMLCData":358,"./XMLComment":360,"./XMLDTDAttList":365,"./XMLDTDElement":366,"./XMLDTDEntity":367,"./XMLDTDNotation":368,"./XMLDeclaration":369,"./XMLDocType":370,"./XMLDummy":373,"./XMLElement":374,"./XMLProcessingInstruction":378,"./XMLRaw":379,"./XMLText":383}],385:[function(require,module,exports){
  29931. // Generated by CoffeeScript 1.12.7
  29932. (function() {
  29933. var NodeType, WriterState, XMLDOMImplementation, XMLDocument, XMLDocumentCB, XMLStreamWriter, XMLStringWriter, assign, isFunction, ref;
  29934. ref = require('./Utility'), assign = ref.assign, isFunction = ref.isFunction;
  29935. XMLDOMImplementation = require('./XMLDOMImplementation');
  29936. XMLDocument = require('./XMLDocument');
  29937. XMLDocumentCB = require('./XMLDocumentCB');
  29938. XMLStringWriter = require('./XMLStringWriter');
  29939. XMLStreamWriter = require('./XMLStreamWriter');
  29940. NodeType = require('./NodeType');
  29941. WriterState = require('./WriterState');
  29942. module.exports.create = function(name, xmldec, doctype, options) {
  29943. var doc, root;
  29944. if (name == null) {
  29945. throw new Error("Root element needs a name.");
  29946. }
  29947. options = assign({}, xmldec, doctype, options);
  29948. doc = new XMLDocument(options);
  29949. root = doc.element(name);
  29950. if (!options.headless) {
  29951. doc.declaration(options);
  29952. if ((options.pubID != null) || (options.sysID != null)) {
  29953. doc.dtd(options);
  29954. }
  29955. }
  29956. return root;
  29957. };
  29958. module.exports.begin = function(options, onData, onEnd) {
  29959. var ref1;
  29960. if (isFunction(options)) {
  29961. ref1 = [options, onData], onData = ref1[0], onEnd = ref1[1];
  29962. options = {};
  29963. }
  29964. if (onData) {
  29965. return new XMLDocumentCB(options, onData, onEnd);
  29966. } else {
  29967. return new XMLDocument(options);
  29968. }
  29969. };
  29970. module.exports.stringWriter = function(options) {
  29971. return new XMLStringWriter(options);
  29972. };
  29973. module.exports.streamWriter = function(stream, options) {
  29974. return new XMLStreamWriter(stream, options);
  29975. };
  29976. module.exports.implementation = new XMLDOMImplementation();
  29977. module.exports.nodeType = NodeType;
  29978. module.exports.writerState = WriterState;
  29979. }).call(this);
  29980. },{"./NodeType":354,"./Utility":355,"./WriterState":356,"./XMLDOMImplementation":363,"./XMLDocument":371,"./XMLDocumentCB":372,"./XMLStreamWriter":380,"./XMLStringWriter":381}],386:[function(require,module,exports){
  29981. module.exports = extend
  29982. var hasOwnProperty = Object.prototype.hasOwnProperty;
  29983. function extend() {
  29984. var target = {}
  29985. for (var i = 0; i < arguments.length; i++) {
  29986. var source = arguments[i]
  29987. for (var key in source) {
  29988. if (hasOwnProperty.call(source, key)) {
  29989. target[key] = source[key]
  29990. }
  29991. }
  29992. }
  29993. return target
  29994. }
  29995. },{}],387:[function(require,module,exports){
  29996. "use strict";
  29997. require("core-js/modules/es.array.concat");
  29998. require("core-js/modules/es.array.fill");
  29999. require("core-js/modules/es.array.join");
  30000. require("core-js/modules/es.array.slice");
  30001. require("core-js/modules/es.object.to-string");
  30002. require("core-js/modules/es.regexp.to-string");
  30003. var Buffer = require('buffer').Buffer;
  30004. var sha = require('./sha');
  30005. var md5 = require('./md5');
  30006. var algorithms = {
  30007. sha1: sha,
  30008. md5: md5
  30009. };
  30010. var blocksize = 64;
  30011. var zeroBuffer = Buffer.alloc(blocksize);
  30012. zeroBuffer.fill(0);
  30013. function hmac(fn, key, data) {
  30014. if (!Buffer.isBuffer(key)) key = Buffer.from(key);
  30015. if (!Buffer.isBuffer(data)) data = Buffer.from(data);
  30016. if (key.length > blocksize) {
  30017. key = fn(key);
  30018. } else if (key.length < blocksize) {
  30019. key = Buffer.concat([key, zeroBuffer], blocksize);
  30020. }
  30021. var ipad = Buffer.alloc(blocksize),
  30022. opad = Buffer.alloc(blocksize);
  30023. for (var i = 0; i < blocksize; i++) {
  30024. ipad[i] = key[i] ^ 0x36;
  30025. opad[i] = key[i] ^ 0x5C;
  30026. }
  30027. var hash = fn(Buffer.concat([ipad, data]));
  30028. return fn(Buffer.concat([opad, hash]));
  30029. }
  30030. function hash(alg, key) {
  30031. alg = alg || 'sha1';
  30032. var fn = algorithms[alg];
  30033. var bufs = [];
  30034. var length = 0;
  30035. if (!fn) error('algorithm:', alg, 'is not yet supported');
  30036. return {
  30037. update: function update(data) {
  30038. if (!Buffer.isBuffer(data)) data = Buffer.from(data);
  30039. bufs.push(data);
  30040. length += data.length;
  30041. return this;
  30042. },
  30043. digest: function digest(enc) {
  30044. var buf = Buffer.concat(bufs);
  30045. var r = key ? hmac(fn, key, buf) : fn(buf);
  30046. bufs = null;
  30047. return enc ? r.toString(enc) : r;
  30048. }
  30049. };
  30050. }
  30051. function error() {
  30052. var m = [].slice.call(arguments).join(' ');
  30053. throw new Error([m, 'we accept pull requests', 'http://github.com/dominictarr/crypto-browserify'].join('\n'));
  30054. }
  30055. exports.createHash = function (alg) {
  30056. return hash(alg);
  30057. };
  30058. exports.createHmac = function (alg, key) {
  30059. return hash(alg, key);
  30060. };
  30061. exports.createCredentials = function () {
  30062. error('sorry,createCredentials is not implemented yet');
  30063. };
  30064. exports.createCipher = function () {
  30065. error('sorry,createCipher is not implemented yet');
  30066. };
  30067. exports.createCipheriv = function () {
  30068. error('sorry,createCipheriv is not implemented yet');
  30069. };
  30070. exports.createDecipher = function () {
  30071. error('sorry,createDecipher is not implemented yet');
  30072. };
  30073. exports.createDecipheriv = function () {
  30074. error('sorry,createDecipheriv is not implemented yet');
  30075. };
  30076. exports.createSign = function () {
  30077. error('sorry,createSign is not implemented yet');
  30078. };
  30079. exports.createVerify = function () {
  30080. error('sorry,createVerify is not implemented yet');
  30081. };
  30082. exports.createDiffieHellman = function () {
  30083. error('sorry,createDiffieHellman is not implemented yet');
  30084. };
  30085. exports.pbkdf2 = function () {
  30086. error('sorry,pbkdf2 is not implemented yet');
  30087. };
  30088. },{"./md5":389,"./sha":390,"buffer":98,"core-js/modules/es.array.concat":234,"core-js/modules/es.array.fill":235,"core-js/modules/es.array.join":243,"core-js/modules/es.array.slice":246,"core-js/modules/es.object.to-string":254,"core-js/modules/es.regexp.to-string":257}],388:[function(require,module,exports){
  30089. "use strict";
  30090. require("core-js/modules/es.array.concat");
  30091. require("core-js/modules/es.array.fill");
  30092. var Buffer = require('buffer').Buffer;
  30093. var intSize = 4;
  30094. var zeroBuffer = Buffer.alloc(intSize);
  30095. zeroBuffer.fill(0);
  30096. var chrsz = 8;
  30097. function toArray(buf, bigEndian) {
  30098. if (buf.length % intSize !== 0) {
  30099. var len = buf.length + (intSize - buf.length % intSize);
  30100. buf = Buffer.concat([buf, zeroBuffer], len);
  30101. }
  30102. var arr = [];
  30103. var fn = bigEndian ? buf.readInt32BE : buf.readInt32LE;
  30104. for (var i = 0; i < buf.length; i += intSize) {
  30105. arr.push(fn.call(buf, i));
  30106. }
  30107. return arr;
  30108. }
  30109. function toBuffer(arr, size, bigEndian) {
  30110. var buf = Buffer.alloc(size);
  30111. var fn = bigEndian ? buf.writeInt32BE : buf.writeInt32LE;
  30112. for (var i = 0; i < arr.length; i++) {
  30113. fn.call(buf, arr[i], i * 4, true);
  30114. }
  30115. return buf;
  30116. }
  30117. function hash(buf, fn, hashSize, bigEndian) {
  30118. if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf);
  30119. var arr = fn(toArray(buf, bigEndian), buf.length * chrsz);
  30120. return toBuffer(arr, hashSize, bigEndian);
  30121. }
  30122. module.exports = {
  30123. hash: hash
  30124. };
  30125. },{"buffer":98,"core-js/modules/es.array.concat":234,"core-js/modules/es.array.fill":235}],389:[function(require,module,exports){
  30126. "use strict";
  30127. /*
  30128. * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
  30129. * Digest Algorithm, as defined in RFC 1321.
  30130. * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
  30131. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  30132. * Distributed under the BSD License
  30133. * See http://pajhome.org.uk/crypt/md5 for more info.
  30134. */
  30135. var helpers = require('./helpers');
  30136. /*
  30137. * Perform a simple self-test to see if the VM is working
  30138. */
  30139. function md5_vm_test() {
  30140. return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
  30141. }
  30142. /*
  30143. * Calculate the MD5 of an array of little-endian words, and a bit length
  30144. */
  30145. function core_md5(x, len) {
  30146. /* append padding */
  30147. x[len >> 5] |= 0x80 << len % 32;
  30148. x[(len + 64 >>> 9 << 4) + 14] = len;
  30149. var a = 1732584193;
  30150. var b = -271733879;
  30151. var c = -1732584194;
  30152. var d = 271733878;
  30153. for (var i = 0; i < x.length; i += 16) {
  30154. var olda = a;
  30155. var oldb = b;
  30156. var oldc = c;
  30157. var oldd = d;
  30158. a = md5_ff(a, b, c, d, x[i + 0], 7, -680876936);
  30159. d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586);
  30160. c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819);
  30161. b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330);
  30162. a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897);
  30163. d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426);
  30164. c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341);
  30165. b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983);
  30166. a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416);
  30167. d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417);
  30168. c = md5_ff(c, d, a, b, x[i + 10], 17, -42063);
  30169. b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162);
  30170. a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682);
  30171. d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101);
  30172. c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290);
  30173. b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329);
  30174. a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510);
  30175. d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632);
  30176. c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713);
  30177. b = md5_gg(b, c, d, a, x[i + 0], 20, -373897302);
  30178. a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691);
  30179. d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083);
  30180. c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335);
  30181. b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848);
  30182. a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438);
  30183. d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690);
  30184. c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961);
  30185. b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501);
  30186. a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467);
  30187. d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784);
  30188. c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473);
  30189. b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734);
  30190. a = md5_hh(a, b, c, d, x[i + 5], 4, -378558);
  30191. d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463);
  30192. c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562);
  30193. b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556);
  30194. a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060);
  30195. d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353);
  30196. c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632);
  30197. b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640);
  30198. a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174);
  30199. d = md5_hh(d, a, b, c, x[i + 0], 11, -358537222);
  30200. c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979);
  30201. b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189);
  30202. a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487);
  30203. d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835);
  30204. c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520);
  30205. b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651);
  30206. a = md5_ii(a, b, c, d, x[i + 0], 6, -198630844);
  30207. d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415);
  30208. c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905);
  30209. b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055);
  30210. a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571);
  30211. d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606);
  30212. c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523);
  30213. b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799);
  30214. a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359);
  30215. d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744);
  30216. c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380);
  30217. b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649);
  30218. a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070);
  30219. d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379);
  30220. c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259);
  30221. b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551);
  30222. a = safe_add(a, olda);
  30223. b = safe_add(b, oldb);
  30224. c = safe_add(c, oldc);
  30225. d = safe_add(d, oldd);
  30226. }
  30227. return Array(a, b, c, d);
  30228. }
  30229. /*
  30230. * These functions implement the four basic operations the algorithm uses.
  30231. */
  30232. function md5_cmn(q, a, b, x, s, t) {
  30233. return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b);
  30234. }
  30235. function md5_ff(a, b, c, d, x, s, t) {
  30236. return md5_cmn(b & c | ~b & d, a, b, x, s, t);
  30237. }
  30238. function md5_gg(a, b, c, d, x, s, t) {
  30239. return md5_cmn(b & d | c & ~d, a, b, x, s, t);
  30240. }
  30241. function md5_hh(a, b, c, d, x, s, t) {
  30242. return md5_cmn(b ^ c ^ d, a, b, x, s, t);
  30243. }
  30244. function md5_ii(a, b, c, d, x, s, t) {
  30245. return md5_cmn(c ^ (b | ~d), a, b, x, s, t);
  30246. }
  30247. /*
  30248. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  30249. * to work around bugs in some JS interpreters.
  30250. */
  30251. function safe_add(x, y) {
  30252. var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  30253. var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  30254. return msw << 16 | lsw & 0xFFFF;
  30255. }
  30256. /*
  30257. * Bitwise rotate a 32-bit number to the left.
  30258. */
  30259. function bit_rol(num, cnt) {
  30260. return num << cnt | num >>> 32 - cnt;
  30261. }
  30262. module.exports = function md5(buf) {
  30263. return helpers.hash(buf, core_md5, 16);
  30264. };
  30265. },{"./helpers":388}],390:[function(require,module,exports){
  30266. "use strict";
  30267. /*
  30268. * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
  30269. * in FIPS PUB 180-1
  30270. * Version 2.1a Copyright Paul Johnston 2000 - 2002.
  30271. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  30272. * Distributed under the BSD License
  30273. * See http://pajhome.org.uk/crypt/md5 for details.
  30274. */
  30275. var helpers = require('./helpers');
  30276. /*
  30277. * Calculate the SHA-1 of an array of big-endian words, and a bit length
  30278. */
  30279. function core_sha1(x, len) {
  30280. /* append padding */
  30281. x[len >> 5] |= 0x80 << 24 - len % 32;
  30282. x[(len + 64 >> 9 << 4) + 15] = len;
  30283. var w = Array(80);
  30284. var a = 1732584193;
  30285. var b = -271733879;
  30286. var c = -1732584194;
  30287. var d = 271733878;
  30288. var e = -1009589776;
  30289. for (var i = 0; i < x.length; i += 16) {
  30290. var olda = a;
  30291. var oldb = b;
  30292. var oldc = c;
  30293. var oldd = d;
  30294. var olde = e;
  30295. for (var j = 0; j < 80; j++) {
  30296. if (j < 16) w[j] = x[i + j];else w[j] = rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);
  30297. var t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)), safe_add(safe_add(e, w[j]), sha1_kt(j)));
  30298. e = d;
  30299. d = c;
  30300. c = rol(b, 30);
  30301. b = a;
  30302. a = t;
  30303. }
  30304. a = safe_add(a, olda);
  30305. b = safe_add(b, oldb);
  30306. c = safe_add(c, oldc);
  30307. d = safe_add(d, oldd);
  30308. e = safe_add(e, olde);
  30309. }
  30310. return Array(a, b, c, d, e);
  30311. }
  30312. /*
  30313. * Perform the appropriate triplet combination function for the current
  30314. * iteration
  30315. */
  30316. function sha1_ft(t, b, c, d) {
  30317. if (t < 20) return b & c | ~b & d;
  30318. if (t < 40) return b ^ c ^ d;
  30319. if (t < 60) return b & c | b & d | c & d;
  30320. return b ^ c ^ d;
  30321. }
  30322. /*
  30323. * Determine the appropriate additive constant for the current iteration
  30324. */
  30325. function sha1_kt(t) {
  30326. return t < 20 ? 1518500249 : t < 40 ? 1859775393 : t < 60 ? -1894007588 : -899497514;
  30327. }
  30328. /*
  30329. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  30330. * to work around bugs in some JS interpreters.
  30331. */
  30332. function safe_add(x, y) {
  30333. var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  30334. var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  30335. return msw << 16 | lsw & 0xFFFF;
  30336. }
  30337. /*
  30338. * Bitwise rotate a 32-bit number to the left.
  30339. */
  30340. function rol(num, cnt) {
  30341. return num << cnt | num >>> 32 - cnt;
  30342. }
  30343. module.exports = function sha1(buf) {
  30344. return helpers.hash(buf, core_sha1, 20, true);
  30345. };
  30346. },{"./helpers":388}],391:[function(require,module,exports){
  30347. "use strict";
  30348. module.exports = function () {
  30349. return function () {};
  30350. };
  30351. },{}],392:[function(require,module,exports){
  30352. (function (Buffer){
  30353. "use strict";
  30354. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  30355. var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
  30356. var _require = require('stream'),
  30357. Stream = _require.Stream;
  30358. var _require2 = require('../lib/common/utils/isArray'),
  30359. isArray = _require2.isArray;
  30360. module.exports.string = function isString(obj) {
  30361. return typeof obj === 'string';
  30362. };
  30363. module.exports.array = isArray;
  30364. module.exports.buffer = Buffer.isBuffer;
  30365. function isStream(obj) {
  30366. return obj instanceof Stream;
  30367. }
  30368. module.exports.writableStream = function isWritableStream(obj) {
  30369. return isStream(obj) && typeof obj._write === 'function' && (0, _typeof2.default)(obj._writableState) === 'object';
  30370. };
  30371. }).call(this,{"isBuffer":require("../node_modules/is-buffer/index.js")})
  30372. },{"../lib/common/utils/isArray":59,"../node_modules/is-buffer/index.js":308,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/helpers/typeof":72,"stream":340}],393:[function(require,module,exports){
  30373. "use strict";
  30374. var immediate = require('immediate');
  30375. var process = module.exports = {};
  30376. process.nextTick = immediate;
  30377. process.title = 'browser';
  30378. process.browser = true;
  30379. process.env = {};
  30380. process.argv = [];
  30381. process.version = ''; // empty string to avoid regexp issues
  30382. process.versions = {};
  30383. function noop() {}
  30384. process.on = noop;
  30385. process.addListener = noop;
  30386. process.once = noop;
  30387. process.off = noop;
  30388. process.removeListener = noop;
  30389. process.removeAllListeners = noop;
  30390. process.emit = noop;
  30391. process.prependListener = noop;
  30392. process.prependOnceListener = noop;
  30393. process.listeners = function (name) {
  30394. return [];
  30395. };
  30396. process.binding = function (name) {
  30397. throw new Error('process.binding is not supported');
  30398. };
  30399. process.cwd = function () {
  30400. return '/';
  30401. };
  30402. process.chdir = function (dir) {
  30403. throw new Error('process.chdir is not supported');
  30404. };
  30405. process.umask = function () {
  30406. return 0;
  30407. };
  30408. },{"immediate":301}],394:[function(require,module,exports){
  30409. // Copyright Joyent, Inc. and other Node contributors.
  30410. //
  30411. // Permission is hereby granted, free of charge, to any person obtaining a
  30412. // copy of this software and associated documentation files (the
  30413. // "Software"), to deal in the Software without restriction, including
  30414. // without limitation the rights to use, copy, modify, merge, publish,
  30415. // distribute, sublicense, and/or sell copies of the Software, and to permit
  30416. // persons to whom the Software is furnished to do so, subject to the
  30417. // following conditions:
  30418. //
  30419. // The above copyright notice and this permission notice shall be included
  30420. // in all copies or substantial portions of the Software.
  30421. //
  30422. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  30423. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  30424. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  30425. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  30426. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  30427. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  30428. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  30429. 'use strict';
  30430. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  30431. require("core-js/modules/es.array.concat");
  30432. require("core-js/modules/es.array.index-of");
  30433. require("core-js/modules/es.array.join");
  30434. require("core-js/modules/es.array.last-index-of");
  30435. require("core-js/modules/es.array.slice");
  30436. require("core-js/modules/es.array.splice");
  30437. require("core-js/modules/es.object.keys");
  30438. require("core-js/modules/es.regexp.exec");
  30439. require("core-js/modules/es.string.match");
  30440. require("core-js/modules/es.string.replace");
  30441. require("core-js/modules/es.string.search");
  30442. require("core-js/modules/es.string.split");
  30443. require("core-js/modules/es.string.trim");
  30444. var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
  30445. var punycode = require('punycode');
  30446. var util = require('./util');
  30447. exports.parse = urlParse;
  30448. exports.resolve = urlResolve;
  30449. exports.resolveObject = urlResolveObject;
  30450. exports.format = urlFormat;
  30451. exports.Url = Url;
  30452. function Url() {
  30453. this.protocol = null;
  30454. this.slashes = null;
  30455. this.auth = null;
  30456. this.host = null;
  30457. this.port = null;
  30458. this.hostname = null;
  30459. this.hash = null;
  30460. this.search = null;
  30461. this.query = null;
  30462. this.pathname = null;
  30463. this.path = null;
  30464. this.href = null;
  30465. } // Reference: RFC 3986, RFC 1808, RFC 2396
  30466. // define these here so at least they only have to be
  30467. // compiled once on the first module load.
  30468. var protocolPattern = /^([a-z0-9.+-]+:)/i,
  30469. portPattern = /:[0-9]*$/,
  30470. // Special case for a simple path URL
  30471. simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
  30472. // RFC 2396: characters reserved for delimiting URLs.
  30473. // We actually just auto-escape these.
  30474. delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
  30475. // RFC 2396: characters not allowed for various reasons.
  30476. unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims),
  30477. // Allowed by RFCs, but cause of XSS attacks. Always escape these.
  30478. autoEscape = ['\''].concat(unwise),
  30479. // Characters that are never ever allowed in a hostname.
  30480. // Note that any invalid chars are also handled, but these
  30481. // are the ones that are *expected* to be seen, so we fast-path
  30482. // them.
  30483. nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),
  30484. hostEndingChars = ['/', '?', '#'],
  30485. hostnameMaxLen = 255,
  30486. hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,
  30487. hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
  30488. // protocols that can allow "unsafe" and "unwise" chars.
  30489. unsafeProtocol = {
  30490. 'javascript': true,
  30491. 'javascript:': true
  30492. },
  30493. // protocols that never have a hostname.
  30494. hostlessProtocol = {
  30495. 'javascript': true,
  30496. 'javascript:': true
  30497. },
  30498. // protocols that always contain a // bit.
  30499. slashedProtocol = {
  30500. 'http': true,
  30501. 'https': true,
  30502. 'ftp': true,
  30503. 'gopher': true,
  30504. 'file': true,
  30505. 'http:': true,
  30506. 'https:': true,
  30507. 'ftp:': true,
  30508. 'gopher:': true,
  30509. 'file:': true
  30510. },
  30511. querystring = require('querystring');
  30512. function urlParse(url, parseQueryString, slashesDenoteHost) {
  30513. if (url && util.isObject(url) && url instanceof Url) return url;
  30514. var u = new Url();
  30515. u.parse(url, parseQueryString, slashesDenoteHost);
  30516. return u;
  30517. }
  30518. Url.prototype.parse = function (url, parseQueryString, slashesDenoteHost) {
  30519. if (!util.isString(url)) {
  30520. throw new TypeError("Parameter 'url' must be a string, not " + (0, _typeof2.default)(url));
  30521. } // Copy chrome, IE, opera backslash-handling behavior.
  30522. // Back slashes before the query string get converted to forward slashes
  30523. // See: https://code.google.com/p/chromium/issues/detail?id=25916
  30524. var queryIndex = url.indexOf('?'),
  30525. splitter = queryIndex !== -1 && queryIndex < url.indexOf('#') ? '?' : '#',
  30526. uSplit = url.split(splitter),
  30527. slashRegex = /\\/g;
  30528. uSplit[0] = uSplit[0].replace(slashRegex, '/');
  30529. url = uSplit.join(splitter);
  30530. var rest = url; // trim before proceeding.
  30531. // This is to support parse stuff like " http://foo.com \n"
  30532. rest = rest.trim();
  30533. if (!slashesDenoteHost && url.split('#').length === 1) {
  30534. // Try fast path regexp
  30535. var simplePath = simplePathPattern.exec(rest);
  30536. if (simplePath) {
  30537. this.path = rest;
  30538. this.href = rest;
  30539. this.pathname = simplePath[1];
  30540. if (simplePath[2]) {
  30541. this.search = simplePath[2];
  30542. if (parseQueryString) {
  30543. this.query = querystring.parse(this.search.substr(1));
  30544. } else {
  30545. this.query = this.search.substr(1);
  30546. }
  30547. } else if (parseQueryString) {
  30548. this.search = '';
  30549. this.query = {};
  30550. }
  30551. return this;
  30552. }
  30553. }
  30554. var proto = protocolPattern.exec(rest);
  30555. if (proto) {
  30556. proto = proto[0];
  30557. var lowerProto = proto.toLowerCase();
  30558. this.protocol = lowerProto;
  30559. rest = rest.substr(proto.length);
  30560. } // figure out if it's got a host
  30561. // user@server is *always* interpreted as a hostname, and url
  30562. // resolution will treat //foo/bar as host=foo,path=bar because that's
  30563. // how the browser resolves relative URLs.
  30564. if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
  30565. var slashes = rest.substr(0, 2) === '//';
  30566. if (slashes && !(proto && hostlessProtocol[proto])) {
  30567. rest = rest.substr(2);
  30568. this.slashes = true;
  30569. }
  30570. }
  30571. if (!hostlessProtocol[proto] && (slashes || proto && !slashedProtocol[proto])) {
  30572. // there's a hostname.
  30573. // the first instance of /, ?, ;, or # ends the host.
  30574. //
  30575. // If there is an @ in the hostname, then non-host chars *are* allowed
  30576. // to the left of the last @ sign, unless some host-ending character
  30577. // comes *before* the @-sign.
  30578. // URLs are obnoxious.
  30579. //
  30580. // ex:
  30581. // http://a@b@c/ => user:a@b host:c
  30582. // http://a@b?@c => user:a host:c path:/?@c
  30583. // v0.12 TODO(isaacs): This is not quite how Chrome does things.
  30584. // Review our test case against browsers more comprehensively.
  30585. // find the first instance of any hostEndingChars
  30586. var hostEnd = -1;
  30587. for (var i = 0; i < hostEndingChars.length; i++) {
  30588. var hec = rest.indexOf(hostEndingChars[i]);
  30589. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) hostEnd = hec;
  30590. } // at this point, either we have an explicit point where the
  30591. // auth portion cannot go past, or the last @ char is the decider.
  30592. var auth, atSign;
  30593. if (hostEnd === -1) {
  30594. // atSign can be anywhere.
  30595. atSign = rest.lastIndexOf('@');
  30596. } else {
  30597. // atSign must be in auth portion.
  30598. // http://a@b/c@d => host:b auth:a path:/c@d
  30599. atSign = rest.lastIndexOf('@', hostEnd);
  30600. } // Now we have a portion which is definitely the auth.
  30601. // Pull that off.
  30602. if (atSign !== -1) {
  30603. auth = rest.slice(0, atSign);
  30604. rest = rest.slice(atSign + 1);
  30605. this.auth = decodeURIComponent(auth);
  30606. } // the host is the remaining to the left of the first non-host char
  30607. hostEnd = -1;
  30608. for (var i = 0; i < nonHostChars.length; i++) {
  30609. var hec = rest.indexOf(nonHostChars[i]);
  30610. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) hostEnd = hec;
  30611. } // if we still have not hit it, then the entire thing is a host.
  30612. if (hostEnd === -1) hostEnd = rest.length;
  30613. this.host = rest.slice(0, hostEnd);
  30614. rest = rest.slice(hostEnd); // pull out port.
  30615. this.parseHost(); // we've indicated that there is a hostname,
  30616. // so even if it's empty, it has to be present.
  30617. this.hostname = this.hostname || ''; // if hostname begins with [ and ends with ]
  30618. // assume that it's an IPv6 address.
  30619. var ipv6Hostname = this.hostname[0] === '[' && this.hostname[this.hostname.length - 1] === ']'; // validate a little.
  30620. if (!ipv6Hostname) {
  30621. var hostparts = this.hostname.split('.');
  30622. for (var i = 0, l = hostparts.length; i < l; i++) {
  30623. var part = hostparts[i];
  30624. if (!part) continue;
  30625. if (!part.match(hostnamePartPattern)) {
  30626. var newpart = '';
  30627. for (var j = 0, k = part.length; j < k; j++) {
  30628. if (part.charCodeAt(j) > 127) {
  30629. // we replace non-ASCII char with a temporary placeholder
  30630. // we need this to make sure size of hostname is not
  30631. // broken by replacing non-ASCII by nothing
  30632. newpart += 'x';
  30633. } else {
  30634. newpart += part[j];
  30635. }
  30636. } // we test again with ASCII char only
  30637. if (!newpart.match(hostnamePartPattern)) {
  30638. var validParts = hostparts.slice(0, i);
  30639. var notHost = hostparts.slice(i + 1);
  30640. var bit = part.match(hostnamePartStart);
  30641. if (bit) {
  30642. validParts.push(bit[1]);
  30643. notHost.unshift(bit[2]);
  30644. }
  30645. if (notHost.length) {
  30646. rest = '/' + notHost.join('.') + rest;
  30647. }
  30648. this.hostname = validParts.join('.');
  30649. break;
  30650. }
  30651. }
  30652. }
  30653. }
  30654. if (this.hostname.length > hostnameMaxLen) {
  30655. this.hostname = '';
  30656. } else {
  30657. // hostnames are always lower case.
  30658. this.hostname = this.hostname.toLowerCase();
  30659. }
  30660. if (!ipv6Hostname) {
  30661. // IDNA Support: Returns a punycoded representation of "domain".
  30662. // It only converts parts of the domain name that
  30663. // have non-ASCII characters, i.e. it doesn't matter if
  30664. // you call it with a domain that already is ASCII-only.
  30665. this.hostname = punycode.toASCII(this.hostname);
  30666. }
  30667. var p = this.port ? ':' + this.port : '';
  30668. var h = this.hostname || '';
  30669. this.host = h + p;
  30670. this.href += this.host; // strip [ and ] from the hostname
  30671. // the host field still retains them, though
  30672. if (ipv6Hostname) {
  30673. this.hostname = this.hostname.substr(1, this.hostname.length - 2);
  30674. if (rest[0] !== '/') {
  30675. rest = '/' + rest;
  30676. }
  30677. }
  30678. } // now rest is set to the post-host stuff.
  30679. // chop off any delim chars.
  30680. if (!unsafeProtocol[lowerProto]) {
  30681. // First, make 100% sure that any "autoEscape" chars get
  30682. // escaped, even if encodeURIComponent doesn't think they
  30683. // need to be.
  30684. for (var i = 0, l = autoEscape.length; i < l; i++) {
  30685. var ae = autoEscape[i];
  30686. if (rest.indexOf(ae) === -1) continue;
  30687. var esc = encodeURIComponent(ae);
  30688. if (esc === ae) {
  30689. esc = escape(ae);
  30690. }
  30691. rest = rest.split(ae).join(esc);
  30692. }
  30693. } // chop off from the tail first.
  30694. var hash = rest.indexOf('#');
  30695. if (hash !== -1) {
  30696. // got a fragment string.
  30697. this.hash = rest.substr(hash);
  30698. rest = rest.slice(0, hash);
  30699. }
  30700. var qm = rest.indexOf('?');
  30701. if (qm !== -1) {
  30702. this.search = rest.substr(qm);
  30703. this.query = rest.substr(qm + 1);
  30704. if (parseQueryString) {
  30705. this.query = querystring.parse(this.query);
  30706. }
  30707. rest = rest.slice(0, qm);
  30708. } else if (parseQueryString) {
  30709. // no query string, but parseQueryString still requested
  30710. this.search = '';
  30711. this.query = {};
  30712. }
  30713. if (rest) this.pathname = rest;
  30714. if (slashedProtocol[lowerProto] && this.hostname && !this.pathname) {
  30715. this.pathname = '/';
  30716. } //to support http.request
  30717. if (this.pathname || this.search) {
  30718. var p = this.pathname || '';
  30719. var s = this.search || '';
  30720. this.path = p + s;
  30721. } // finally, reconstruct the href based on what has been validated.
  30722. this.href = this.format();
  30723. return this;
  30724. }; // format a parsed object into a url string
  30725. function urlFormat(obj) {
  30726. // ensure it's an object, and not a string url.
  30727. // If it's an obj, this is a no-op.
  30728. // this way, you can call url_format() on strings
  30729. // to clean up potentially wonky urls.
  30730. if (util.isString(obj)) obj = urlParse(obj);
  30731. if (!(obj instanceof Url)) return Url.prototype.format.call(obj);
  30732. return obj.format();
  30733. }
  30734. Url.prototype.format = function () {
  30735. var auth = this.auth || '';
  30736. if (auth) {
  30737. auth = encodeURIComponent(auth);
  30738. auth = auth.replace(/%3A/i, ':');
  30739. auth += '@';
  30740. }
  30741. var protocol = this.protocol || '',
  30742. pathname = this.pathname || '',
  30743. hash = this.hash || '',
  30744. host = false,
  30745. query = '';
  30746. if (this.host) {
  30747. host = auth + this.host;
  30748. } else if (this.hostname) {
  30749. host = auth + (this.hostname.indexOf(':') === -1 ? this.hostname : '[' + this.hostname + ']');
  30750. if (this.port) {
  30751. host += ':' + this.port;
  30752. }
  30753. }
  30754. if (this.query && util.isObject(this.query) && Object.keys(this.query).length) {
  30755. query = querystring.stringify(this.query);
  30756. }
  30757. var search = this.search || query && '?' + query || '';
  30758. if (protocol && protocol.substr(-1) !== ':') protocol += ':'; // only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
  30759. // unless they had them to begin with.
  30760. if (this.slashes || (!protocol || slashedProtocol[protocol]) && host !== false) {
  30761. host = '//' + (host || '');
  30762. if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;
  30763. } else if (!host) {
  30764. host = '';
  30765. }
  30766. if (hash && hash.charAt(0) !== '#') hash = '#' + hash;
  30767. if (search && search.charAt(0) !== '?') search = '?' + search;
  30768. pathname = pathname.replace(/[?#]/g, function (match) {
  30769. return encodeURIComponent(match);
  30770. });
  30771. search = search.replace('#', '%23');
  30772. return protocol + host + pathname + search + hash;
  30773. };
  30774. function urlResolve(source, relative) {
  30775. return urlParse(source, false, true).resolve(relative);
  30776. }
  30777. Url.prototype.resolve = function (relative) {
  30778. return this.resolveObject(urlParse(relative, false, true)).format();
  30779. };
  30780. function urlResolveObject(source, relative) {
  30781. if (!source) return relative;
  30782. return urlParse(source, false, true).resolveObject(relative);
  30783. }
  30784. Url.prototype.resolveObject = function (relative) {
  30785. if (util.isString(relative)) {
  30786. var rel = new Url();
  30787. rel.parse(relative, false, true);
  30788. relative = rel;
  30789. }
  30790. var result = new Url();
  30791. var tkeys = Object.keys(this);
  30792. for (var tk = 0; tk < tkeys.length; tk++) {
  30793. var tkey = tkeys[tk];
  30794. result[tkey] = this[tkey];
  30795. } // hash is always overridden, no matter what.
  30796. // even href="" will remove it.
  30797. result.hash = relative.hash; // if the relative url is empty, then there's nothing left to do here.
  30798. if (relative.href === '') {
  30799. result.href = result.format();
  30800. return result;
  30801. } // hrefs like //foo/bar always cut to the protocol.
  30802. if (relative.slashes && !relative.protocol) {
  30803. // take everything except the protocol from relative
  30804. var rkeys = Object.keys(relative);
  30805. for (var rk = 0; rk < rkeys.length; rk++) {
  30806. var rkey = rkeys[rk];
  30807. if (rkey !== 'protocol') result[rkey] = relative[rkey];
  30808. } //urlParse appends trailing / to urls like http://www.example.com
  30809. if (slashedProtocol[result.protocol] && result.hostname && !result.pathname) {
  30810. result.path = result.pathname = '/';
  30811. }
  30812. result.href = result.format();
  30813. return result;
  30814. }
  30815. if (relative.protocol && relative.protocol !== result.protocol) {
  30816. // if it's a known url protocol, then changing
  30817. // the protocol does weird things
  30818. // first, if it's not file:, then we MUST have a host,
  30819. // and if there was a path
  30820. // to begin with, then we MUST have a path.
  30821. // if it is file:, then the host is dropped,
  30822. // because that's known to be hostless.
  30823. // anything else is assumed to be absolute.
  30824. if (!slashedProtocol[relative.protocol]) {
  30825. var keys = Object.keys(relative);
  30826. for (var v = 0; v < keys.length; v++) {
  30827. var k = keys[v];
  30828. result[k] = relative[k];
  30829. }
  30830. result.href = result.format();
  30831. return result;
  30832. }
  30833. result.protocol = relative.protocol;
  30834. if (!relative.host && !hostlessProtocol[relative.protocol]) {
  30835. var relPath = (relative.pathname || '').split('/');
  30836. while (relPath.length && !(relative.host = relPath.shift())) {
  30837. ;
  30838. }
  30839. if (!relative.host) relative.host = '';
  30840. if (!relative.hostname) relative.hostname = '';
  30841. if (relPath[0] !== '') relPath.unshift('');
  30842. if (relPath.length < 2) relPath.unshift('');
  30843. result.pathname = relPath.join('/');
  30844. } else {
  30845. result.pathname = relative.pathname;
  30846. }
  30847. result.search = relative.search;
  30848. result.query = relative.query;
  30849. result.host = relative.host || '';
  30850. result.auth = relative.auth;
  30851. result.hostname = relative.hostname || relative.host;
  30852. result.port = relative.port; // to support http.request
  30853. if (result.pathname || result.search) {
  30854. var p = result.pathname || '';
  30855. var s = result.search || '';
  30856. result.path = p + s;
  30857. }
  30858. result.slashes = result.slashes || relative.slashes;
  30859. result.href = result.format();
  30860. return result;
  30861. }
  30862. var isSourceAbs = result.pathname && result.pathname.charAt(0) === '/',
  30863. isRelAbs = relative.host || relative.pathname && relative.pathname.charAt(0) === '/',
  30864. mustEndAbs = isRelAbs || isSourceAbs || result.host && relative.pathname,
  30865. removeAllDots = mustEndAbs,
  30866. srcPath = result.pathname && result.pathname.split('/') || [],
  30867. relPath = relative.pathname && relative.pathname.split('/') || [],
  30868. psychotic = result.protocol && !slashedProtocol[result.protocol]; // if the url is a non-slashed url, then relative
  30869. // links like ../.. should be able
  30870. // to crawl up to the hostname, as well. This is strange.
  30871. // result.protocol has already been set by now.
  30872. // Later on, put the first path part into the host field.
  30873. if (psychotic) {
  30874. result.hostname = '';
  30875. result.port = null;
  30876. if (result.host) {
  30877. if (srcPath[0] === '') srcPath[0] = result.host;else srcPath.unshift(result.host);
  30878. }
  30879. result.host = '';
  30880. if (relative.protocol) {
  30881. relative.hostname = null;
  30882. relative.port = null;
  30883. if (relative.host) {
  30884. if (relPath[0] === '') relPath[0] = relative.host;else relPath.unshift(relative.host);
  30885. }
  30886. relative.host = null;
  30887. }
  30888. mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
  30889. }
  30890. if (isRelAbs) {
  30891. // it's absolute.
  30892. result.host = relative.host || relative.host === '' ? relative.host : result.host;
  30893. result.hostname = relative.hostname || relative.hostname === '' ? relative.hostname : result.hostname;
  30894. result.search = relative.search;
  30895. result.query = relative.query;
  30896. srcPath = relPath; // fall through to the dot-handling below.
  30897. } else if (relPath.length) {
  30898. // it's relative
  30899. // throw away the existing file, and take the new path instead.
  30900. if (!srcPath) srcPath = [];
  30901. srcPath.pop();
  30902. srcPath = srcPath.concat(relPath);
  30903. result.search = relative.search;
  30904. result.query = relative.query;
  30905. } else if (!util.isNullOrUndefined(relative.search)) {
  30906. // just pull out the search.
  30907. // like href='?foo'.
  30908. // Put this after the other two cases because it simplifies the booleans
  30909. if (psychotic) {
  30910. result.hostname = result.host = srcPath.shift(); //occationaly the auth can get stuck only in host
  30911. //this especially happens in cases like
  30912. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  30913. var authInHost = result.host && result.host.indexOf('@') > 0 ? result.host.split('@') : false;
  30914. if (authInHost) {
  30915. result.auth = authInHost.shift();
  30916. result.host = result.hostname = authInHost.shift();
  30917. }
  30918. }
  30919. result.search = relative.search;
  30920. result.query = relative.query; //to support http.request
  30921. if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
  30922. result.path = (result.pathname ? result.pathname : '') + (result.search ? result.search : '');
  30923. }
  30924. result.href = result.format();
  30925. return result;
  30926. }
  30927. if (!srcPath.length) {
  30928. // no path at all. easy.
  30929. // we've already handled the other stuff above.
  30930. result.pathname = null; //to support http.request
  30931. if (result.search) {
  30932. result.path = '/' + result.search;
  30933. } else {
  30934. result.path = null;
  30935. }
  30936. result.href = result.format();
  30937. return result;
  30938. } // if a url ENDs in . or .., then it must get a trailing slash.
  30939. // however, if it ends in anything else non-slashy,
  30940. // then it must NOT get a trailing slash.
  30941. var last = srcPath.slice(-1)[0];
  30942. var hasTrailingSlash = (result.host || relative.host || srcPath.length > 1) && (last === '.' || last === '..') || last === ''; // strip single dots, resolve double dots to parent dir
  30943. // if the path tries to go above the root, `up` ends up > 0
  30944. var up = 0;
  30945. for (var i = srcPath.length; i >= 0; i--) {
  30946. last = srcPath[i];
  30947. if (last === '.') {
  30948. srcPath.splice(i, 1);
  30949. } else if (last === '..') {
  30950. srcPath.splice(i, 1);
  30951. up++;
  30952. } else if (up) {
  30953. srcPath.splice(i, 1);
  30954. up--;
  30955. }
  30956. } // if the path is allowed to go above the root, restore leading ..s
  30957. if (!mustEndAbs && !removeAllDots) {
  30958. for (; up--; up) {
  30959. srcPath.unshift('..');
  30960. }
  30961. }
  30962. if (mustEndAbs && srcPath[0] !== '' && (!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
  30963. srcPath.unshift('');
  30964. }
  30965. if (hasTrailingSlash && srcPath.join('/').substr(-1) !== '/') {
  30966. srcPath.push('');
  30967. }
  30968. var isAbsolute = srcPath[0] === '' || srcPath[0] && srcPath[0].charAt(0) === '/'; // put the host back
  30969. if (psychotic) {
  30970. result.hostname = result.host = isAbsolute ? '' : srcPath.length ? srcPath.shift() : ''; //occationaly the auth can get stuck only in host
  30971. //this especially happens in cases like
  30972. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  30973. var authInHost = result.host && result.host.indexOf('@') > 0 ? result.host.split('@') : false;
  30974. if (authInHost) {
  30975. result.auth = authInHost.shift();
  30976. result.host = result.hostname = authInHost.shift();
  30977. }
  30978. }
  30979. mustEndAbs = mustEndAbs || result.host && srcPath.length;
  30980. if (mustEndAbs && !isAbsolute) {
  30981. srcPath.unshift('');
  30982. }
  30983. if (!srcPath.length) {
  30984. result.pathname = null;
  30985. result.path = null;
  30986. } else {
  30987. result.pathname = srcPath.join('/');
  30988. } //to support request.http
  30989. if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
  30990. result.path = (result.pathname ? result.pathname : '') + (result.search ? result.search : '');
  30991. }
  30992. result.auth = relative.auth || result.auth;
  30993. result.slashes = result.slashes || relative.slashes;
  30994. result.href = result.format();
  30995. return result;
  30996. };
  30997. Url.prototype.parseHost = function () {
  30998. var host = this.host;
  30999. var port = portPattern.exec(host);
  31000. if (port) {
  31001. port = port[0];
  31002. if (port !== ':') {
  31003. this.port = port.substr(1);
  31004. }
  31005. host = host.substr(0, host.length - port.length);
  31006. }
  31007. if (host) this.hostname = host;
  31008. };
  31009. },{"./util":395,"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/helpers/typeof":72,"core-js/modules/es.array.concat":234,"core-js/modules/es.array.index-of":241,"core-js/modules/es.array.join":243,"core-js/modules/es.array.last-index-of":244,"core-js/modules/es.array.slice":246,"core-js/modules/es.array.splice":248,"core-js/modules/es.object.keys":253,"core-js/modules/es.regexp.exec":256,"core-js/modules/es.string.match":260,"core-js/modules/es.string.replace":261,"core-js/modules/es.string.search":262,"core-js/modules/es.string.split":263,"core-js/modules/es.string.trim":265,"punycode":320,"querystring":323}],395:[function(require,module,exports){
  31010. 'use strict';
  31011. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  31012. var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
  31013. module.exports = {
  31014. isString: function isString(arg) {
  31015. return typeof arg === 'string';
  31016. },
  31017. isObject: function isObject(arg) {
  31018. return (0, _typeof2.default)(arg) === 'object' && arg !== null;
  31019. },
  31020. isNull: function isNull(arg) {
  31021. return arg === null;
  31022. },
  31023. isNullOrUndefined: function isNullOrUndefined(arg) {
  31024. return arg == null;
  31025. }
  31026. };
  31027. },{"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/helpers/typeof":72}],396:[function(require,module,exports){
  31028. "use strict";
  31029. require("core-js/modules/es.number.constructor");
  31030. // copy from https://github.com/node-modules/utility for browser
  31031. exports.encodeURIComponent = function (text) {
  31032. try {
  31033. return encodeURIComponent(text);
  31034. } catch (e) {
  31035. return text;
  31036. }
  31037. };
  31038. exports.escape = require('escape-html');
  31039. exports.timestamp = function timestamp(t) {
  31040. if (t) {
  31041. var v = t;
  31042. if (typeof v === 'string') {
  31043. v = Number(v);
  31044. }
  31045. if (String(t).length === 10) {
  31046. v *= 1000;
  31047. }
  31048. return new Date(v);
  31049. }
  31050. return Math.round(Date.now() / 1000);
  31051. };
  31052. },{"core-js/modules/es.number.constructor":250,"escape-html":296}],397:[function(require,module,exports){
  31053. (function (process,Buffer){
  31054. 'use strict';
  31055. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  31056. require("core-js/modules/es.array.concat");
  31057. require("core-js/modules/es.array.index-of");
  31058. require("core-js/modules/es.array.join");
  31059. require("core-js/modules/es.function.name");
  31060. require("core-js/modules/es.object.to-string");
  31061. require("core-js/modules/es.promise");
  31062. var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
  31063. var util = require('util');
  31064. var urlutil = require('url');
  31065. var http = require('http');
  31066. var https = require('https');
  31067. var debug = require('debug')('urllib');
  31068. var ms = require('humanize-ms');
  31069. var _Promise;
  31070. var REQUEST_ID = 0;
  31071. var MAX_VALUE = Math.pow(2, 31) - 10;
  31072. var PROTO_RE = /^https?:\/\//i;
  31073. function getAgent(agent, defaultAgent) {
  31074. return agent === undefined ? defaultAgent : agent;
  31075. }
  31076. function makeCallback(resolve, reject) {
  31077. return function (err, data, res) {
  31078. if (err) {
  31079. return reject(err);
  31080. }
  31081. resolve({
  31082. data: data,
  31083. status: res.statusCode,
  31084. headers: res.headers,
  31085. res: res
  31086. });
  31087. };
  31088. } // exports.TIMEOUT = ms('5s');
  31089. exports.TIMEOUTS = [ms('300s'), ms('300s')];
  31090. var TEXT_DATA_TYPES = ['json', 'text'];
  31091. exports.request = function request(url, args, callback) {
  31092. // request(url, callback)
  31093. if (arguments.length === 2 && typeof args === 'function') {
  31094. callback = args;
  31095. args = null;
  31096. }
  31097. if (typeof callback === 'function') {
  31098. return exports.requestWithCallback(url, args, callback);
  31099. }
  31100. return new Promise(function (resolve, reject) {
  31101. exports.requestWithCallback(url, args, makeCallback(resolve, reject));
  31102. });
  31103. };
  31104. exports.requestWithCallback = function requestWithCallback(url, args, callback) {
  31105. // requestWithCallback(url, callback)
  31106. if (!url || typeof url !== 'string' && (0, _typeof2.default)(url) !== 'object') {
  31107. var msg = util.format('expect request url to be a string or a http request options, but got %j', url);
  31108. throw new Error(msg);
  31109. }
  31110. if (arguments.length === 2 && typeof args === 'function') {
  31111. callback = args;
  31112. args = null;
  31113. }
  31114. args = args || {};
  31115. if (REQUEST_ID >= MAX_VALUE) {
  31116. REQUEST_ID = 0;
  31117. }
  31118. var reqId = ++REQUEST_ID;
  31119. args.requestUrls = args.requestUrls || [];
  31120. var reqMeta = {
  31121. requestId: reqId,
  31122. url: url,
  31123. args: args,
  31124. ctx: args.ctx
  31125. };
  31126. if (args.emitter) {
  31127. args.emitter.emit('request', reqMeta);
  31128. }
  31129. args.timeout = args.timeout || exports.TIMEOUTS;
  31130. args.maxRedirects = args.maxRedirects || 10;
  31131. args.streaming = args.streaming || args.customResponse;
  31132. var requestStartTime = Date.now();
  31133. var parsedUrl;
  31134. if (typeof url === 'string') {
  31135. if (!PROTO_RE.test(url)) {
  31136. // Support `request('www.server.com')`
  31137. url = 'http://' + url;
  31138. }
  31139. parsedUrl = urlutil.parse(url);
  31140. } else {
  31141. parsedUrl = url;
  31142. }
  31143. var method = (args.type || args.method || parsedUrl.method || 'GET').toUpperCase();
  31144. var port = parsedUrl.port || 80;
  31145. var httplib = http;
  31146. var agent = getAgent(args.agent, exports.agent);
  31147. var fixJSONCtlChars = args.fixJSONCtlChars;
  31148. if (parsedUrl.protocol === 'https:') {
  31149. httplib = https;
  31150. agent = getAgent(args.httpsAgent, exports.httpsAgent);
  31151. if (!parsedUrl.port) {
  31152. port = 443;
  31153. }
  31154. } // request through proxy tunnel
  31155. // var proxyTunnelAgent = detectProxyAgent(parsedUrl, args);
  31156. // if (proxyTunnelAgent) {
  31157. // agent = proxyTunnelAgent;
  31158. // }
  31159. var options = {
  31160. host: parsedUrl.hostname || parsedUrl.host || 'localhost',
  31161. path: parsedUrl.path || '/',
  31162. method: method,
  31163. port: port,
  31164. agent: agent,
  31165. headers: args.headers || {},
  31166. // default is dns.lookup
  31167. // https://github.com/nodejs/node/blob/master/lib/net.js#L986
  31168. // custom dnslookup require node >= 4.0.0
  31169. // https://github.com/nodejs/node/blob/archived-io.js-v0.12/lib/net.js#L952
  31170. lookup: args.lookup
  31171. };
  31172. if (Array.isArray(args.timeout)) {
  31173. options.requestTimeout = args.timeout[args.timeout.length - 1];
  31174. } else if (typeof args.timeout !== 'undefined') {
  31175. options.requestTimeout = args.timeout;
  31176. }
  31177. var sslNames = ['pfx', 'key', 'passphrase', 'cert', 'ca', 'ciphers', 'rejectUnauthorized', 'secureProtocol', 'secureOptions'];
  31178. for (var i = 0; i < sslNames.length; i++) {
  31179. var name = sslNames[i];
  31180. if (args.hasOwnProperty(name)) {
  31181. options[name] = args[name];
  31182. }
  31183. } // don't check ssl
  31184. if (options.rejectUnauthorized === false && !options.hasOwnProperty('secureOptions')) {
  31185. options.secureOptions = require('constants').SSL_OP_NO_TLSv1_2;
  31186. }
  31187. var auth = args.auth || parsedUrl.auth;
  31188. if (auth) {
  31189. options.auth = auth;
  31190. }
  31191. var body = args.content || args.data;
  31192. var dataAsQueryString = method === 'GET' || method === 'HEAD' || args.dataAsQueryString;
  31193. if (!args.content) {
  31194. if (body && !(typeof body === 'string' || Buffer.isBuffer(body))) {
  31195. if (dataAsQueryString) {
  31196. // read: GET, HEAD, use query string
  31197. body = args.nestedQuerystring ? qs.stringify(body) : querystring.stringify(body);
  31198. } else {
  31199. var contentType = options.headers['Content-Type'] || options.headers['content-type']; // auto add application/x-www-form-urlencoded when using urlencode form request
  31200. if (!contentType) {
  31201. if (args.contentType === 'json') {
  31202. contentType = 'application/json';
  31203. } else {
  31204. contentType = 'application/x-www-form-urlencoded';
  31205. }
  31206. options.headers['Content-Type'] = contentType;
  31207. }
  31208. if (parseContentType(contentType).type === 'application/json') {
  31209. body = JSON.stringify(body);
  31210. } else {
  31211. // 'application/x-www-form-urlencoded'
  31212. body = args.nestedQuerystring ? qs.stringify(body) : querystring.stringify(body);
  31213. }
  31214. }
  31215. }
  31216. } // if it's a GET or HEAD request, data should be sent as query string
  31217. if (dataAsQueryString && body) {
  31218. options.path += (parsedUrl.query ? '&' : '?') + body;
  31219. body = null;
  31220. }
  31221. var requestSize = 0;
  31222. if (body) {
  31223. var length = body.length;
  31224. if (!Buffer.isBuffer(body)) {
  31225. length = Buffer.byteLength(body);
  31226. }
  31227. requestSize = options.headers['Content-Length'] = length;
  31228. }
  31229. if (args.dataType === 'json') {
  31230. options.headers.Accept = 'application/json';
  31231. }
  31232. if (typeof args.beforeRequest === 'function') {
  31233. // you can use this hook to change every thing.
  31234. args.beforeRequest(options);
  31235. }
  31236. var connectTimer = null;
  31237. var responseTimer = null;
  31238. var __err = null;
  31239. var connected = false; // socket connected or not
  31240. var keepAliveSocket = false; // request with keepalive socket
  31241. var responseSize = 0;
  31242. var statusCode = -1;
  31243. var responseAborted = false;
  31244. var remoteAddress = '';
  31245. var remotePort = '';
  31246. var timing = null;
  31247. if (args.timing) {
  31248. timing = {
  31249. // socket assigned
  31250. queuing: 0,
  31251. // dns lookup time
  31252. dnslookup: 0,
  31253. // socket connected
  31254. connected: 0,
  31255. // request sent
  31256. requestSent: 0,
  31257. // Time to first byte (TTFB)
  31258. waiting: 0,
  31259. contentDownload: 0
  31260. };
  31261. }
  31262. function cancelConnectTimer() {
  31263. if (connectTimer) {
  31264. clearTimeout(connectTimer);
  31265. connectTimer = null;
  31266. }
  31267. }
  31268. function cancelResponseTimer() {
  31269. if (responseTimer) {
  31270. clearTimeout(responseTimer);
  31271. responseTimer = null;
  31272. }
  31273. }
  31274. function done(err, data, res) {
  31275. cancelResponseTimer();
  31276. if (!callback) {
  31277. console.warn('[urllib:warn] [%s] [%s] [worker:%s] %s %s callback twice!!!', Date(), reqId, process.pid, options.method, url); // https://github.com/node-modules/urllib/pull/30
  31278. if (err) {
  31279. console.warn('[urllib:warn] [%s] [%s] [worker:%s] %s: %s\nstack: %s', Date(), reqId, process.pid, err.name, err.message, err.stack);
  31280. }
  31281. return;
  31282. }
  31283. var cb = callback;
  31284. callback = null;
  31285. var headers = {};
  31286. if (res) {
  31287. statusCode = res.statusCode;
  31288. headers = res.headers;
  31289. } // handle digest auth
  31290. if (statusCode === 401 && headers['www-authenticate'] && (!args.headers || !args.headers.Authorization) && args.digestAuth) {
  31291. var authenticate = headers['www-authenticate'];
  31292. if (authenticate.indexOf('Digest ') >= 0) {
  31293. debug('Request#%d %s: got digest auth header WWW-Authenticate: %s', reqId, url, authenticate);
  31294. args.headers = args.headers || {};
  31295. args.headers.Authorization = digestAuthHeader(options.method, options.path, authenticate, args.digestAuth);
  31296. debug('Request#%d %s: auth with digest header: %s', reqId, url, args.headers.Authorization);
  31297. if (res.headers['set-cookie']) {
  31298. args.headers.Cookie = res.headers['set-cookie'].join(';');
  31299. }
  31300. return exports.requestWithCallback(url, args, cb);
  31301. }
  31302. }
  31303. var requestUseTime = Date.now() - requestStartTime;
  31304. if (timing) {
  31305. timing.contentDownload = requestUseTime;
  31306. }
  31307. debug('[%sms] done, %s bytes HTTP %s %s %s %s, keepAliveSocket: %s, timing: %j', requestUseTime, responseSize, statusCode, options.method, options.host, options.path, keepAliveSocket, timing);
  31308. var response = {
  31309. status: statusCode,
  31310. statusCode: statusCode,
  31311. headers: headers,
  31312. size: responseSize,
  31313. aborted: responseAborted,
  31314. rt: requestUseTime,
  31315. keepAliveSocket: keepAliveSocket,
  31316. data: data,
  31317. requestUrls: args.requestUrls,
  31318. timing: timing,
  31319. remoteAddress: remoteAddress,
  31320. remotePort: remotePort
  31321. };
  31322. if (err) {
  31323. var agentStatus = '';
  31324. if (agent && typeof agent.getCurrentStatus === 'function') {
  31325. // add current agent status to error message for logging and debug
  31326. agentStatus = ', agent status: ' + JSON.stringify(agent.getCurrentStatus());
  31327. }
  31328. err.message += ', ' + options.method + ' ' + url + ' ' + statusCode + ' (connected: ' + connected + ', keepalive socket: ' + keepAliveSocket + agentStatus + ')' + '\nheaders: ' + JSON.stringify(headers);
  31329. err.data = data;
  31330. err.path = options.path;
  31331. err.status = statusCode;
  31332. err.headers = headers;
  31333. err.res = response;
  31334. }
  31335. cb(err, data, args.streaming ? res : response);
  31336. if (args.emitter) {
  31337. // keep to use the same reqMeta object on request event before
  31338. reqMeta.url = url;
  31339. reqMeta.socket = req && req.connection;
  31340. reqMeta.options = options;
  31341. reqMeta.size = requestSize;
  31342. args.emitter.emit('response', {
  31343. requestId: reqId,
  31344. error: err,
  31345. ctx: args.ctx,
  31346. req: reqMeta,
  31347. res: response
  31348. });
  31349. }
  31350. }
  31351. function handleRedirect(res) {
  31352. var err = null;
  31353. if (args.followRedirect && statuses.redirect[res.statusCode]) {
  31354. // handle redirect
  31355. args._followRedirectCount = (args._followRedirectCount || 0) + 1;
  31356. var location = res.headers.location;
  31357. if (!location) {
  31358. err = new Error('Got statusCode ' + res.statusCode + ' but cannot resolve next location from headers');
  31359. err.name = 'FollowRedirectError';
  31360. } else if (args._followRedirectCount > args.maxRedirects) {
  31361. err = new Error('Exceeded maxRedirects. Probably stuck in a redirect loop ' + url);
  31362. err.name = 'MaxRedirectError';
  31363. } else {
  31364. var newUrl = args.formatRedirectUrl ? args.formatRedirectUrl(url, location) : urlutil.resolve(url, location);
  31365. debug('Request#%d %s: `redirected` from %s to %s', reqId, options.path, url, newUrl); // make sure timer stop
  31366. cancelResponseTimer(); // should clean up headers.Host on `location: http://other-domain/url`
  31367. if (args.headers && args.headers.Host && PROTO_RE.test(location)) {
  31368. args.headers.Host = null;
  31369. } // avoid done will be execute in the future change.
  31370. var cb = callback;
  31371. callback = null;
  31372. exports.requestWithCallback(newUrl, args, cb);
  31373. return {
  31374. redirect: true,
  31375. error: null
  31376. };
  31377. }
  31378. }
  31379. return {
  31380. redirect: false,
  31381. error: err
  31382. };
  31383. }
  31384. if (args.gzip) {
  31385. if (!options.headers['Accept-Encoding'] && !options.headers['accept-encoding']) {
  31386. options.headers['Accept-Encoding'] = 'gzip';
  31387. }
  31388. }
  31389. function decodeContent(res, body, cb) {
  31390. var encoding = res.headers['content-encoding']; // if (body.length === 0) {
  31391. // return cb(null, body, encoding);
  31392. // }
  31393. // if (!encoding || encoding.toLowerCase() !== 'gzip') {
  31394. return cb(null, body, encoding); // }
  31395. // debug('gunzip %d length body', body.length);
  31396. // zlib.gunzip(body, cb);
  31397. }
  31398. var writeStream = args.writeStream;
  31399. debug('Request#%d %s %s with headers %j, options.path: %s', reqId, method, url, options.headers, options.path);
  31400. args.requestUrls.push(url);
  31401. function onResponse(res) {
  31402. if (timing) {
  31403. timing.waiting = Date.now() - requestStartTime;
  31404. }
  31405. debug('Request#%d %s `req response` event emit: status %d, headers: %j', reqId, url, res.statusCode, res.headers);
  31406. if (args.streaming) {
  31407. var result = handleRedirect(res);
  31408. if (result.redirect) {
  31409. res.resume();
  31410. return;
  31411. }
  31412. if (result.error) {
  31413. res.resume();
  31414. return done(result.error, null, res);
  31415. }
  31416. return done(null, null, res);
  31417. }
  31418. res.on('close', function () {
  31419. debug('Request#%d %s: `res close` event emit, total size %d', reqId, url, responseSize);
  31420. });
  31421. res.on('error', function () {
  31422. debug('Request#%d %s: `res error` event emit, total size %d', reqId, url, responseSize);
  31423. });
  31424. res.on('aborted', function () {
  31425. responseAborted = true;
  31426. debug('Request#%d %s: `res aborted` event emit, total size %d', reqId, url, responseSize);
  31427. });
  31428. if (writeStream) {
  31429. // If there's a writable stream to recieve the response data, just pipe the
  31430. // response stream to that writable stream and call the callback when it has
  31431. // finished writing.
  31432. //
  31433. // NOTE that when the response stream `res` emits an 'end' event it just
  31434. // means that it has finished piping data to another stream. In the
  31435. // meanwhile that writable stream may still writing data to the disk until
  31436. // it emits a 'close' event.
  31437. //
  31438. // That means that we should not apply callback until the 'close' of the
  31439. // writable stream is emited.
  31440. //
  31441. // See also:
  31442. // - https://github.com/TBEDP/urllib/commit/959ac3365821e0e028c231a5e8efca6af410eabb
  31443. // - http://nodejs.org/api/stream.html#stream_event_end
  31444. // - http://nodejs.org/api/stream.html#stream_event_close_1
  31445. var result = handleRedirect(res);
  31446. if (result.redirect) {
  31447. res.resume();
  31448. return;
  31449. }
  31450. if (result.error) {
  31451. res.resume(); // end ths stream first
  31452. writeStream.end();
  31453. return done(result.error, null, res);
  31454. } // you can set consumeWriteStream false that only wait response end
  31455. if (args.consumeWriteStream === false) {
  31456. res.on('end', done.bind(null, null, null, res));
  31457. } else {
  31458. // node 0.10, 0.12: only emit res aborted, writeStream close not fired
  31459. if (isNode010 || isNode012) {
  31460. first([[writeStream, 'close'], [res, 'aborted']], function (_, stream, event) {
  31461. debug('Request#%d %s: writeStream or res %s event emitted', reqId, url, event);
  31462. done(__err || null, null, res);
  31463. });
  31464. } else {
  31465. writeStream.on('close', function () {
  31466. debug('Request#%d %s: writeStream close event emitted', reqId, url);
  31467. done(__err || null, null, res);
  31468. });
  31469. }
  31470. }
  31471. return res.pipe(writeStream);
  31472. } // Otherwise, just concat those buffers.
  31473. //
  31474. // NOTE that the `chunk` is not a String but a Buffer. It means that if
  31475. // you simply concat two chunk with `+` you're actually converting both
  31476. // Buffers into Strings before concating them. It'll cause problems when
  31477. // dealing with multi-byte characters.
  31478. //
  31479. // The solution is to store each chunk in an array and concat them with
  31480. // 'buffer-concat' when all chunks is recieved.
  31481. //
  31482. // See also:
  31483. // http://cnodejs.org/topic/4faf65852e8fb5bc65113403
  31484. var chunks = [];
  31485. res.on('data', function (chunk) {
  31486. debug('Request#%d %s: `res data` event emit, size %d', reqId, url, chunk.length);
  31487. responseSize += chunk.length;
  31488. chunks.push(chunk);
  31489. });
  31490. res.on('end', function () {
  31491. var body = Buffer.concat(chunks, responseSize);
  31492. debug('Request#%d %s: `res end` event emit, total size %d, _dumped: %s', reqId, url, responseSize, res._dumped);
  31493. if (__err) {
  31494. // req.abort() after `res data` event emit.
  31495. return done(__err, body, res);
  31496. }
  31497. var result = handleRedirect(res);
  31498. if (result.error) {
  31499. return done(result.error, body, res);
  31500. }
  31501. if (result.redirect) {
  31502. return;
  31503. }
  31504. decodeContent(res, body, function (err, data, encoding) {
  31505. if (err) {
  31506. return done(err, body, res);
  31507. } // if body not decode, dont touch it
  31508. if (!encoding && TEXT_DATA_TYPES.indexOf(args.dataType) >= 0) {
  31509. // try to decode charset
  31510. try {
  31511. data = decodeBodyByCharset(data, res);
  31512. } catch (e) {
  31513. debug('decodeBodyByCharset error: %s', e); // if error, dont touch it
  31514. return done(null, data, res);
  31515. }
  31516. if (args.dataType === 'json') {
  31517. if (responseSize === 0) {
  31518. data = null;
  31519. } else {
  31520. var r = parseJSON(data, fixJSONCtlChars);
  31521. if (r.error) {
  31522. err = r.error;
  31523. } else {
  31524. data = r.data;
  31525. }
  31526. }
  31527. }
  31528. }
  31529. if (responseAborted) {
  31530. // err = new Error('Remote socket was terminated before `response.end()` was called');
  31531. // err.name = 'RemoteSocketClosedError';
  31532. debug('Request#%d %s: Remote socket was terminated before `response.end()` was called', reqId, url);
  31533. }
  31534. done(err, data, res);
  31535. });
  31536. });
  31537. }
  31538. var connectTimeout, responseTimeout;
  31539. if (Array.isArray(args.timeout)) {
  31540. connectTimeout = ms(args.timeout[0]);
  31541. responseTimeout = ms(args.timeout[1]);
  31542. } else {
  31543. // set both timeout equal
  31544. connectTimeout = responseTimeout = ms(args.timeout);
  31545. }
  31546. debug('ConnectTimeout: %d, ResponseTimeout: %d', connectTimeout, responseTimeout);
  31547. function startConnectTimer() {
  31548. debug('Connect timer ticking, timeout: %d', connectTimeout);
  31549. connectTimer = setTimeout(function () {
  31550. connectTimer = null;
  31551. if (statusCode === -1) {
  31552. statusCode = -2;
  31553. }
  31554. var msg = 'Connect timeout for ' + connectTimeout + 'ms';
  31555. var errorName = 'ConnectionTimeoutError';
  31556. if (!req.socket) {
  31557. errorName = 'SocketAssignTimeoutError';
  31558. msg += ', working sockets is full';
  31559. }
  31560. __err = new Error(msg);
  31561. __err.name = errorName;
  31562. __err.requestId = reqId;
  31563. debug('ConnectTimeout: Request#%d %s %s: %s, connected: %s', reqId, url, __err.name, msg, connected);
  31564. abortRequest();
  31565. }, connectTimeout);
  31566. }
  31567. function startResposneTimer() {
  31568. debug('Response timer ticking, timeout: %d', responseTimeout);
  31569. responseTimer = setTimeout(function () {
  31570. responseTimer = null;
  31571. var msg = 'Response timeout for ' + responseTimeout + 'ms';
  31572. var errorName = 'ResponseTimeoutError';
  31573. __err = new Error(msg);
  31574. __err.name = errorName;
  31575. __err.requestId = reqId;
  31576. debug('ResponseTimeout: Request#%d %s %s: %s, connected: %s', reqId, url, __err.name, msg, connected);
  31577. abortRequest();
  31578. }, responseTimeout);
  31579. }
  31580. var req; // request headers checker will throw error
  31581. options.mode = args.mode ? args.mode : '';
  31582. try {
  31583. req = httplib.request(options, onResponse);
  31584. } catch (err) {
  31585. return done(err);
  31586. } // environment detection: browser or nodejs
  31587. if (typeof window === 'undefined') {
  31588. // start connect timer just after `request` return, and just in nodejs environment
  31589. startConnectTimer();
  31590. } else {
  31591. req.on('requestTimeout', function () {
  31592. if (statusCode === -1) {
  31593. statusCode = -2;
  31594. }
  31595. var msg = 'Connect timeout for ' + connectTimeout + 'ms';
  31596. var errorName = 'ConnectionTimeoutError';
  31597. __err = new Error(msg);
  31598. __err.name = errorName;
  31599. __err.requestId = reqId;
  31600. abortRequest();
  31601. });
  31602. }
  31603. function abortRequest() {
  31604. debug('Request#%d %s abort, connected: %s', reqId, url, connected); // it wont case error event when req haven't been assigned a socket yet.
  31605. if (!req.socket) {
  31606. __err.noSocket = true;
  31607. done(__err);
  31608. }
  31609. req.abort();
  31610. }
  31611. if (timing) {
  31612. // request sent
  31613. req.on('finish', function () {
  31614. timing.requestSent = Date.now() - requestStartTime;
  31615. });
  31616. }
  31617. req.once('socket', function (socket) {
  31618. if (timing) {
  31619. // socket queuing time
  31620. timing.queuing = Date.now() - requestStartTime;
  31621. } // https://github.com/nodejs/node/blob/master/lib/net.js#L377
  31622. // https://github.com/nodejs/node/blob/v0.10.40-release/lib/net.js#L352
  31623. // should use socket.socket on 0.10.x
  31624. if (isNode010 && socket.socket) {
  31625. socket = socket.socket;
  31626. }
  31627. var readyState = socket.readyState;
  31628. if (readyState === 'opening') {
  31629. socket.once('lookup', function (err, ip, addressType) {
  31630. debug('Request#%d %s lookup: %s, %s, %s', reqId, url, err, ip, addressType);
  31631. if (timing) {
  31632. timing.dnslookup = Date.now() - requestStartTime;
  31633. }
  31634. if (ip) {
  31635. remoteAddress = ip;
  31636. }
  31637. });
  31638. socket.once('connect', function () {
  31639. if (timing) {
  31640. // socket connected
  31641. timing.connected = Date.now() - requestStartTime;
  31642. } // cancel socket timer at first and start tick for TTFB
  31643. cancelConnectTimer();
  31644. startResposneTimer();
  31645. debug('Request#%d %s new socket connected', reqId, url);
  31646. connected = true;
  31647. if (!remoteAddress) {
  31648. remoteAddress = socket.remoteAddress;
  31649. }
  31650. remotePort = socket.remotePort;
  31651. });
  31652. return;
  31653. }
  31654. debug('Request#%d %s reuse socket connected, readyState: %s', reqId, url, readyState);
  31655. connected = true;
  31656. keepAliveSocket = true;
  31657. if (!remoteAddress) {
  31658. remoteAddress = socket.remoteAddress;
  31659. }
  31660. remotePort = socket.remotePort; // reuse socket, timer should be canceled.
  31661. cancelConnectTimer();
  31662. startResposneTimer();
  31663. });
  31664. req.on('error', function (err) {
  31665. //TypeError for browser fetch api, Error for browser xmlhttprequest api
  31666. if (err.name === 'Error' || err.name === 'TypeError') {
  31667. err.name = connected ? 'ResponseError' : 'RequestError';
  31668. }
  31669. err.message += ' (req "error")';
  31670. debug('Request#%d %s `req error` event emit, %s: %s', reqId, url, err.name, err.message);
  31671. done(__err || err);
  31672. });
  31673. if (writeStream) {
  31674. writeStream.once('error', function (err) {
  31675. err.message += ' (writeStream "error")';
  31676. __err = err;
  31677. debug('Request#%d %s `writeStream error` event emit, %s: %s', reqId, url, err.name, err.message);
  31678. abortRequest();
  31679. });
  31680. }
  31681. if (args.stream) {
  31682. args.stream.pipe(req);
  31683. args.stream.once('error', function (err) {
  31684. err.message += ' (stream "error")';
  31685. __err = err;
  31686. debug('Request#%d %s `readStream error` event emit, %s: %s', reqId, url, err.name, err.message);
  31687. abortRequest();
  31688. });
  31689. } else {
  31690. req.end(body);
  31691. }
  31692. req.requestId = reqId;
  31693. return req;
  31694. };
  31695. }).call(this,require('_process'),require("buffer").Buffer)
  31696. },{"@babel/runtime/helpers/interopRequireDefault":71,"@babel/runtime/helpers/typeof":72,"_process":393,"buffer":98,"constants":100,"core-js/modules/es.array.concat":234,"core-js/modules/es.array.index-of":241,"core-js/modules/es.array.join":243,"core-js/modules/es.function.name":249,"core-js/modules/es.object.to-string":254,"core-js/modules/es.promise":255,"debug":391,"http":79,"https":298,"humanize-ms":299,"url":394,"util":346}]},{},[1])(1)
  31697. });